Skip to content
GitHubDiscord

prosekit/svelte

editor: Editor


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

view: EditorView

mark: Writable<Mark>


Options for defineSvelteMarkView.

name: string

The name of the mark type.

as?: MarkViewDOMSpec

contentAs?: MarkViewDOMSpec

component: SvelteMarkViewComponent

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

destroy?: () => void


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

view: EditorView

getPos: () => number | undefined

setAttrs: (attrs: Attrs) => void

node: Writable<ProseMirrorNode>

selected: Writable<boolean>

decorations: Writable<readonly Decoration[]>

innerDecorations: Writable<DecorationSource>


Options for defineSvelteNodeView.

name: string

The name of the node type.

as?: NodeViewDOMSpec

contentAs?: NodeViewDOMSpec

component: SvelteNodeViewComponent

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

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

selectNode?: () => void

deselectNode?: () => void

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

stopEvent?: (event: Event) => boolean

destroy?: () => void

onUpdate?: () => void


editor?: Editor<E>

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


editor?: Editor<any>

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.

type SvelteMarkViewComponent = Component<SvelteMarkViewProps>


type SvelteNodeViewComponent = Component<SvelteNodeViewProps>

const ProseKit: typeof SvelteComponent

The root component for a ProseKit editor.

function defineSvelteMarkView(options: SvelteMarkViewOptions): Extension

Defines a mark view using a Svelte component.


function defineSvelteNodeView(options: SvelteNodeViewOptions): Extension

Defines a node view using a Svelte component.


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

Calls the given handler whenever the editor document changes.


function useEditorDerivedValue<E, Derived>(derive: (editor: Editor<E>) => Derived, options?: UseEditorDerivedOptions<E>): Readable<Derived>

Runs a function to derive a value from the editor instance after editor state changes.

This is useful when you need to render something based on the editor state, for example, whether the selected text is wrapped in an italic mark.

It returns a Svelte store that stores the derived value and updates whenever the editor state changes.


function useEditor<E>(options?: object): Readable<Editor<E>>

Retrieves the editor instance from the nearest ProseKit component.


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

Add an extension to the editor.


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


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

Calls the given handler whenever the editor state changes.