Skip to content

prosekit/svelte

ProseKitProps

editor: Editor

SvelteMarkViewOptions

Options for defineSvelteMarkView.

as?: MarkViewDOMSpec

component: SvelteMarkViewComponent

contentAs?: MarkViewDOMSpec

destroy?: () => void

ignoreMutation?: (mutation: ViewMutationRecord) => boolean | void

name: string

The name of the mark type.

SvelteMarkViewProps

contentRef: (element: null | HTMLElement) => void

mark: Writable<Mark>

view: EditorView

SvelteNodeViewOptions

Options for defineSvelteNodeView.

as?: NodeViewDOMSpec

component: SvelteNodeViewComponent

contentAs?: NodeViewDOMSpec

deselectNode?: () => void

destroy?: () => void

ignoreMutation?: (mutation: ViewMutationRecord) => boolean | void

name: string

The name of the node type.

onUpdate?: () => void

selectNode?: () => void

setSelection?: (anchor: number, head: number, root: Document | ShadowRoot) => void

stopEvent?: (event: Event) => boolean

update?: (node: Node, decorations: readonly Decoration[], innerDecorations: DecorationSource) => boolean | void

SvelteNodeViewProps

contentRef: (element: null | HTMLElement) => void

decorations: Writable<readonly Decoration[]>

getPos: () => undefined | number

innerDecorations: Writable<DecorationSource>

node: Writable<Node>

selected: Writable<boolean>

setAttrs: (attrs: Attrs) => void

view: EditorView

UseExtensionOptions

editor?: Editor

The editor to add the extension to. If not provided, it will use the editor from the nearest ProseKit component.

priority?: Priority

Optional priority to add the extension with.

SvelteMarkViewComponent

Type: Component<SvelteMarkViewProps>

SvelteNodeViewComponent

Type: Component<SvelteNodeViewProps>

ProseKit

The root component for a ProseKit editor.

Type: typeof SvelteComponent

defineSvelteMarkView

ts
function defineSvelteMarkView(options: SvelteMarkViewOptions): Extension

Defines a mark view using a Svelte component.

defineSvelteNodeView

ts
function defineSvelteNodeView(options: SvelteNodeViewOptions): Extension

Defines a node view using a Svelte component.

useDocChange

ts
function useDocChange(handler: (doc: Node) => void, options?: UseExtensionOptions): void

Calls the given handler whenever the editor document changes.

useEditor

ts
function useEditor<E extends Extension>(options?: { update?: boolean }): Readable<Editor<E>>

Retrieves the editor instance from the nearest ProseKit component.

useExtension

ts
function useExtension<T extends Extension>(extension: Readable<null | T>, options?: UseExtensionOptions): void

Add an extension to the editor.

useKeymap

ts
function useKeymap(keymapStore: Readable<Keymap>, options?: UseExtensionOptions): void

useStateUpdate

ts
function useStateUpdate(handler: (state: EditorState) => void, options?: UseExtensionOptions): void

Calls the given handler whenever the editor state changes.