proper constructor for SvelteNodeView (#4709)

Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
Vyacheslav Tumanov 2024-02-20 00:13:54 +05:00 committed by GitHub
parent 9b0cfe55db
commit 20b4854dcc
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -19,7 +19,8 @@ import {
NodeView, NodeView,
type NodeViewProps, type NodeViewProps,
type NodeViewRenderer, type NodeViewRenderer,
type NodeViewRendererOptions type NodeViewRendererOptions,
type NodeViewRendererProps
} from '@tiptap/core' } from '@tiptap/core'
import type { Node as ProseMirrorNode } from '@tiptap/pm/model' import type { Node as ProseMirrorNode } from '@tiptap/pm/model'
import type { ComponentType, SvelteComponent } from 'svelte' import type { ComponentType, SvelteComponent } from 'svelte'
@ -43,13 +44,18 @@ export type SvelteNodeViewComponent = typeof SvelteComponent | ComponentType
* https://tiptap.dev/guide/node-views/react/ * https://tiptap.dev/guide/node-views/react/
*/ */
class SvelteNodeView extends NodeView<SvelteNodeViewComponent, Editor, SvelteNodeViewRendererOptions> { class SvelteNodeView extends NodeView<SvelteNodeViewComponent, Editor, SvelteNodeViewRendererOptions> {
renderer!: SvelteRenderer private readonly renderer!: SvelteRenderer
contentDOMElement!: HTMLElement | null private contentDOMElement!: HTMLElement | null
isEditable!: boolean private isEditable!: boolean
override mount (): void { constructor (
component: SvelteNodeViewComponent,
prop: NodeViewRendererProps,
options?: Partial<SvelteNodeViewRendererOptions>
) {
super(component, prop, options)
const props: SvelteNodeViewProps = { const props: SvelteNodeViewProps = {
editor: this.editor, editor: this.editor,
node: this.node, node: this.node,
@ -83,7 +89,6 @@ class SvelteNodeView extends NodeView<SvelteNodeViewComponent, Editor, SvelteNod
}) })
this.renderer = new SvelteRenderer(this.component, { element: target, props, context }) this.renderer = new SvelteRenderer(this.component, { element: target, props, context })
this.editor.on('update', this.handleEditorUpdate.bind(this)) this.editor.on('update', this.handleEditorUpdate.bind(this))
} }