refactoring

This commit is contained in:
Philipp Kühn
2021-03-05 09:46:47 +01:00
parent 21d9bf6c51
commit 328d5a459d
3 changed files with 11 additions and 6 deletions

View File

@@ -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?.(),

View File

@@ -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
} }

View File

@@ -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 doesnt support multiple child elements.')
}
this.element = this.teleportElement.firstElementChild as Element this.element = this.teleportElement.firstElementChild as Element
} }
} }