diff --git a/packages/core/src/Editor.ts b/packages/core/src/Editor.ts index 48360b2a..5b061938 100644 --- a/packages/core/src/Editor.ts +++ b/packages/core/src/Editor.ts @@ -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) }