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

editorView.focus()

items.forEach(({command, dom}) => {

if (dom.contains(e.target))

command(editorView.state, editorView.dispatch, editorView)

})

})

}

update() {

this.items.forEach(({command, dom}) => {

let active = command(this.editorView.state, null, this.editorView)

dom.style.display = active ? "" : "none"

})

}

destroy() { this.dom.remove() }

}

嵌入代码编辑器嵌入代码编辑器,使某个节点的文档内(例如代码块,数学公式或图像)显示为专门用于此类内容的自定义编辑器控件非常实用。节点视图是ProseMirror功能,可实现此功能。将此节点视图和键映射连接到编辑器中可以得到如下内容:

推荐阅读