From 2111b04a011778e2e54f4a57cd40f8924a813601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Fri, 10 Apr 2020 21:43:23 +0200 Subject: [PATCH] add registerPlugin method --- packages/core/src/Editor.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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) }