don’t use __vue__

This commit is contained in:
Philipp Kühn
2021-03-05 11:01:26 +01:00
parent a073d75dff
commit e9e3418a0f
6 changed files with 63 additions and 33 deletions

View File

@@ -1,4 +1,5 @@
import Vue from 'vue'
import Vue, { PropType } from 'vue'
import { Editor } from './Editor'
export const EditorContent = Vue.extend({
name: 'EditorContent',
@@ -6,17 +7,30 @@ export const EditorContent = Vue.extend({
props: {
editor: {
default: null,
type: Object,
type: Object as PropType<Editor>,
},
},
watch: {
editor: {
immediate: true,
handler(editor) {
handler(editor: Editor) {
if (editor && editor.options.element) {
this.$nextTick(() => {
this.$el.appendChild(editor.options.element.firstChild)
const element = this.$el
if (!element || !editor.options.element.firstChild) {
return
}
element.appendChild(editor.options.element.firstChild)
editor.contentComponent = this
editor.setOptions({
element,
})
editor.createNodeViews()
})
}
@@ -29,8 +43,26 @@ export const EditorContent = Vue.extend({
},
beforeDestroy() {
this.editor.setOptions({
element: this.$el,
const { editor } = this
if (!editor.isDestroyed) {
editor.view.setProps({
nodeViews: {},
})
}
editor.contentComponent = null
if (!editor.options.element.firstChild) {
return
}
const newElement = document.createElement('div')
newElement.appendChild(editor.options.element.firstChild)
editor.setOptions({
element: newElement,
})
},
})