tiptap/packages/vue-2/src/EditorContent.ts

37 lines
626 B
TypeScript
Raw Normal View History

2021-02-28 06:56:08 +08:00
import Vue from 'vue'
2021-03-01 06:24:26 +08:00
export const EditorContent = Vue.extend({
2021-02-28 06:56:08 +08:00
name: 'EditorContent',
props: {
editor: {
default: null,
type: Object,
},
},
watch: {
editor: {
immediate: true,
handler(editor) {
if (editor && editor.options.element) {
this.$nextTick(() => {
this.$el.appendChild(editor.options.element.firstChild)
editor.createNodeViews()
})
}
},
},
},
render(createElement) {
return createElement('div')
},
beforeDestroy() {
this.editor.setOptions({
element: this.$el,
})
},
})