fix using registerPlugin and unregisterPlugin for vue-3

This commit is contained in:
Philipp Kühn 2021-03-31 12:11:55 +02:00
parent 2b0a0dad0f
commit d06f5c0c73
2 changed files with 18 additions and 1 deletions

View File

@ -25,6 +25,7 @@
"@tiptap/core": "^2.0.0-beta.1"
},
"dependencies": {
"prosemirror-state": "^1.3.4",
"prosemirror-view": "^1.18.2",
"vue": "^3.0.0"
}

View File

@ -1,3 +1,4 @@
import { EditorState, Plugin, PluginKey } from 'prosemirror-state'
import { Editor as CoreEditor, EditorOptions } from '@tiptap/core'
import {
markRaw,
@ -7,7 +8,6 @@ import {
ComponentPublicInstance,
reactive,
} from 'vue'
import { EditorState } from 'prosemirror-state'
import { VueRenderer } from './VueRenderer'
function useDebouncedRef<T>(value: T) {
@ -60,4 +60,20 @@ export class Editor extends CoreEditor {
? this.reactiveState.value
: this.view.state
}
/**
* Register a ProseMirror plugin.
*/
public registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): void {
super.registerPlugin(plugin, handlePlugins)
this.reactiveState.value = this.view.state
}
/**
* Unregister a ProseMirror plugin.
*/
public unregisterPlugin(nameOrPluginKey: string | PluginKey): void {
super.unregisterPlugin(nameOrPluginKey)
this.reactiveState.value = this.view.state
}
}