mirror of
https://github.com/ueberdosis/tiptap.git
synced 2024-11-24 11:49:02 +08:00
add useEditor
This commit is contained in:
parent
64b8f5c514
commit
6d66571128
@ -1,5 +1,6 @@
|
||||
export * from '@tiptap/core'
|
||||
export { Editor } from './Editor'
|
||||
export * from './EditorContent'
|
||||
export * from './useEditor'
|
||||
export * from './VueRenderer'
|
||||
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
|
||||
}
|
Loading…
Reference in New Issue
Block a user