add useEditor

This commit is contained in:
Philipp Kühn 2021-02-28 23:47:34 +01:00
parent 64b8f5c514
commit 6d66571128
2 changed files with 18 additions and 0 deletions

View File

@ -1,5 +1,6 @@
export * from '@tiptap/core'
export { Editor } from './Editor'
export * from './EditorContent'
export * from './useEditor'
export * from './VueRenderer'
export * from './VueNodeViewRenderer'

View File

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