prosekit/svelte
ProseKitProps
editor
Type:
Editor<any>
SvelteNodeViewOptions
Options for defineSvelteNodeView.
as
The wrapping DOM element for the node view. Defaults to
div
for block nodes andspan
for inline nodes.Type:
string | HTMLElement | ((node: Node) => HTMLElement)
component
The Svelte component to render the node.
Type:
SvelteNodeViewComponent
contentAs
The wrapping DOM element for the node view's content. Defaults to
div
for block nodes andspan
for inline nodes.Type:
string | HTMLElement | ((node: Node) => HTMLElement)
deselectNode
Type:
() => void
destroy
Type:
() => void
ignoreMutation
Type:
(mutation: MutationRecord) => boolean
name
The name of the node type.
Type:
string
onUpdate
Type:
() => void
selectNode
Type:
() => void
setSelection
Type:
(anchor: number, head: number, root: Document | ShadowRoot) => void
stopEvent
Type:
(event: Event) => boolean
update
Type:
(node: Node, decorations: readonly Decoration[], innerDecorations: DecorationSource) => boolean
SvelteNodeViewProps
contentRef
Type:
(node: null | HTMLElement) => void
decorations
Type:
Writable<readonly Decoration[]>
getPos
Type:
() => undefined | number
innerDecorations
Type:
Writable<DecorationSource>
node
Type:
Writable<Node>
selected
Type:
Writable<boolean>
setAttrs
Type:
(attrs: Attrs) => void
view
Type:
EditorView
UseExtensionOptions
editor
The editor to add the extension to. If not provided, it will use the editor from the nearest
ProseKit
component.Type:
Editor<any>
priority
Optional priority to add the extension with.
Type:
Priority
SvelteNodeViewComponent
Type: ComponentType<SvelteComponent<SvelteNodeViewProps>>
ProseKit
The root component for a ProseKit editor.
Type: typeof SvelteComponent
defineSvelteNodeView
function defineSvelteNodeView(options: SvelteNodeViewOptions): Extension
Defines a node view using a Svelte component.
useDocChange
function useDocChange(handler: (doc: Node) => void, options?: UseExtensionOptions): void
Calls the given handler whenever the editor document changes.
useEditor
function useEditor<E extends Extension<ExtensionTyping<any, any, any>>>(options?: { update?: boolean }): Readable<Editor<E>>
Retrieves the editor instance from the nearest ProseKit component.
useExtension
function useExtension<T extends Extension<ExtensionTyping<any, any, any>>>(extension: Readable<null | T>, options?: UseExtensionOptions): void
Add an extension to the editor.
useKeymap
function useKeymap(keymapStore: Readable<Keymap>, options?: UseExtensionOptions): void
useStateUpdate
function useStateUpdate(handler: (state: EditorState) => void, options?: UseExtensionOptions): void
Calls the given handler whenever the editor state changes.