mirror of
https://github.com/ueberdosis/tiptap.git
synced 2025-01-03 16:28:53 +08:00
e97630c639
* Require .js endings * add extension alias for cypress to resolve ts files with js endings
19 lines
396 B
TypeScript
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
|
|
}
|