tiptap/packages/vue-3/src/useEditor.ts
Ben Asher e97630c639
Require file extensions for imports and exports (#4001)
* Require .js endings

* add extension alias for cypress to resolve ts files with js endings
2023-06-30 21:03:49 +02:00

19 lines
396 B
TypeScript

import { EditorOptions } from '@tiptap/core'
import { onBeforeUnmount, onMounted, shallowRef } from 'vue'
import { Editor } from './Editor.js'
export const useEditor = (options: Partial<EditorOptions> = {}) => {
const editor = shallowRef<Editor>()
onMounted(() => {
editor.value = new Editor(options)
})
onBeforeUnmount(() => {
editor.value?.destroy()
})
return editor
}