Files
tiptap/packages/vue-3/src/useEditor.ts
2021-03-17 21:21:57 +01:00

18 lines
378 B
TypeScript

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