diff --git a/src/composables/useEditor.ts b/src/composables/useEditor.ts index e9d3fe439bd..0f0d9d7079c 100644 --- a/src/composables/useEditor.ts +++ b/src/composables/useEditor.ts @@ -4,16 +4,17 @@ */ import { Editor } from '@tiptap/core' -import { inject, type InjectionKey, provide } from 'vue' +import { type InjectionKey } from 'vue' + +let globalEditor: Editor | undefined export const editorKey = Symbol('tiptap:editor') as InjectionKey export const provideEditor = (editor: Editor) => { - provide(editorKey, editor) + globalEditor = editor } export const useEditor = () => { - const editor = inject(editorKey) - if (!editor) { + if (!globalEditor) { throw new Error('Failed to inject Editor') } - return { editor: editor as Editor } + return { editor: globalEditor! } }