feat: Add extension storage (#2069)

This commit is contained in:
Philipp Kühn
2021-10-22 08:52:54 +02:00
committed by GitHub
parent 6987505fda
commit 7ffabf251c
26 changed files with 555 additions and 105 deletions

View File

@@ -39,6 +39,8 @@ export type ContentComponent = ComponentInternalInstance & {
export class Editor extends CoreEditor {
private reactiveState: Ref<EditorState>
private reactiveExtensionStorage: Ref<Record<string, any>>
public vueRenderers = reactive<Map<string, VueRenderer>>(new Map())
public contentComponent: ContentComponent | null = null
@@ -47,9 +49,11 @@ export class Editor extends CoreEditor {
super(options)
this.reactiveState = useDebouncedRef(this.view.state)
this.reactiveExtensionStorage = useDebouncedRef(this.extensionStorage)
this.on('transaction', () => {
this.reactiveState.value = this.view.state
this.reactiveExtensionStorage.value = this.extensionStorage
})
return markRaw(this)
@@ -61,6 +65,12 @@ export class Editor extends CoreEditor {
: this.view.state
}
get storage() {
return this.reactiveExtensionStorage
? this.reactiveExtensionStorage.value
: super.storage
}
/**
* Register a ProseMirror plugin.
*/