mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-21 07:46:24 +00:00
proper constructor for SvelteNodeView (#4709)
Signed-off-by: Vyacheslav Tumanov <me@slavatumanov.me>
This commit is contained in:
parent
9b0cfe55db
commit
20b4854dcc
@ -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))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user