用于在Web上构建富文本编辑器的工具包——prosemirror( 四 )

用于在Web上构建富文本编辑器的工具包——prosemirror

自定义菜单prosemirror允许自定义菜单,这样更加可控,灵活性更强

用于在Web上构建富文本编辑器的工具包——prosemirror

class MenuView {

constructor(items, editorView) {

this.items = items

this.editorView = editorView

this.dom = document.createElement("div")

this.dom.className = "menubar"

items.forEach(({dom}) => this.dom.appendChild(dom))

this.update()

this.dom.addEventListener("mousedown", e => {

e.preventDefault()

推荐阅读