add registerPlugin method

This commit is contained in:
Philipp Kühn
2020-04-10 21:43:23 +02:00
parent 00a6143e89
commit 2111b04a01

View File

@@ -1,4 +1,4 @@
import { EditorState, TextSelection } from 'prosemirror-state'
import { EditorState, Plugin } from 'prosemirror-state'
import { EditorView} from 'prosemirror-view'
import { Schema, DOMParser, DOMSerializer } from 'prosemirror-model'
import { undoInputRule } from 'prosemirror-inputrules'
@@ -104,6 +104,18 @@ export class Editor extends EventEmitter {
return this.proxy
}
public registerPlugin(plugin: Plugin) {
if (!plugin) {
return
}
const state = this.state.reconfigure({
plugins: [plugin, ...this.state.plugins],
})
this.view.updateState(state)
}
public command(name: string, ...args: any) {
return this.commands[name](...args)
}