add useEditor
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
export * from '@tiptap/core'
|
export * from '@tiptap/core'
|
||||||
export { Editor } from './Editor'
|
export { Editor } from './Editor'
|
||||||
export * from './EditorContent'
|
export * from './EditorContent'
|
||||||
|
export * from './useEditor'
|
||||||
export * from './VueRenderer'
|
export * from './VueRenderer'
|
||||||
export * from './VueNodeViewRenderer'
|
export * from './VueNodeViewRenderer'
|
||||||
|
|||||||
17
packages/vue-3/src/useEditor.ts
Normal file
17
packages/vue-3/src/useEditor.ts
Normal 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
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user