refactoring
This commit is contained in:
@@ -17,7 +17,7 @@ export const NodeViewWrapper = defineComponent({
|
|||||||
whiteSpace: 'normal',
|
whiteSpace: 'normal',
|
||||||
},
|
},
|
||||||
'data-node-view-wrapper': '',
|
'data-node-view-wrapper': '',
|
||||||
// @ts-ignore
|
// @ts-ignore (https://github.com/vuejs/vue-next/issues/3031)
|
||||||
onDragStart: this.onDragStart,
|
onDragStart: this.onDragStart,
|
||||||
},
|
},
|
||||||
this.$slots.default?.(),
|
this.$slots.default?.(),
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
import {
|
import { Node, NodeViewRenderer, NodeViewRendererProps } from '@tiptap/core'
|
||||||
Node,
|
|
||||||
NodeViewRenderer,
|
|
||||||
NodeViewRendererProps,
|
|
||||||
} from '@tiptap/core'
|
|
||||||
import {
|
import {
|
||||||
ref,
|
ref,
|
||||||
provide,
|
provide,
|
||||||
@@ -103,6 +99,10 @@ class VueNodeView implements NodeView {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get dom() {
|
get dom() {
|
||||||
|
if (!this.renderer.element.hasAttribute('data-node-view-wrapper')) {
|
||||||
|
throw Error('Please use the NodeViewWrapper component for your node view.')
|
||||||
|
}
|
||||||
|
|
||||||
return this.renderer.element
|
return this.renderer.element
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,6 +31,11 @@ export class VueRenderer {
|
|||||||
|
|
||||||
if (this.editor.contentComponent) {
|
if (this.editor.contentComponent) {
|
||||||
this.editor.contentComponent.update()
|
this.editor.contentComponent.update()
|
||||||
|
|
||||||
|
if (this.teleportElement.children.length !== 1) {
|
||||||
|
throw Error('VueRenderer doesn’t support multiple child elements.')
|
||||||
|
}
|
||||||
|
|
||||||
this.element = this.teleportElement.firstElementChild as Element
|
this.element = this.teleportElement.firstElementChild as Element
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user