From b08e77b1fe7dedf591328beb89238c811aa3b0c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philipp=20Ku=CC=88hn?= Date: Fri, 10 Apr 2020 22:55:14 +0200 Subject: [PATCH] add unregisterPlugin --- packages/core/src/Editor.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/core/src/Editor.ts b/packages/core/src/Editor.ts index 3a094673..19e6b327 100644 --- a/packages/core/src/Editor.ts +++ b/packages/core/src/Editor.ts @@ -117,6 +117,19 @@ export class Editor extends EventEmitter { this.view.updateState(state) } + public unregisterPlugin(name: string) { + if (!name) { + return + } + + const state = this.state.reconfigure({ + // @ts-ignore + plugins: this.state.plugins.filter(plugin => !plugin.key.startsWith(`${name}$`)), + }) + + this.view.updateState(state) + } + public command(name: string, ...args: any) { return this.commands[name](...args) }