mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-30 21:27:51 +08:00
18 lines
369 B
TypeScript
18 lines
369 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()
|
||
|
|
||
|
onMounted(() => {
|
||
|
editor.value = new Editor(options)
|
||
|
})
|
||
|
|
||
|
onBeforeUnmount(() => {
|
||
|
editor.value.destroy()
|
||
|
})
|
||
|
|
||
|
return editor
|
||
|
}
|