mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-12-21 07:18:05 +08:00
8c6751f0c6
* chore: add precommit hook for eslint fixes, fix linting issues * chore: add eslint import sort plugin
19 lines
393 B
TypeScript
19 lines
393 B
TypeScript
import { EditorOptions } from '@tiptap/core'
|
|
import { onBeforeUnmount, onMounted, shallowRef } from 'vue'
|
|
|
|
import { Editor } from './Editor'
|
|
|
|
export const useEditor = (options: Partial<EditorOptions> = {}) => {
|
|
const editor = shallowRef<Editor>()
|
|
|
|
onMounted(() => {
|
|
editor.value = new Editor(options)
|
|
})
|
|
|
|
onBeforeUnmount(() => {
|
|
editor.value?.destroy()
|
|
})
|
|
|
|
return editor
|
|
}
|