Skip to content

prosekit/core

Priority

ProseKit extension priority.

default = 2

high = 3

highest = 4

low = 1

lowest = 0

Editor

get commands(): ToCommandAction<{[KeyType in string | number | symbol]: UnionToIntersection<ExtractTyping<E>["Commands"] extends undefined ? never : ExtractTyping<E>["Commands"]>[KeyType]}>

All CommandActions defined by the editor.

get focused(): boolean

Whether the editor is focused.

get marks(): ToMarkAction<SimplifyDeeper<{[KeyType in string | number | symbol]: UnionToIntersection<ExtractTyping<E>["Marks"] extends undefined ? never : ExtractTyping<E>["Marks"]>[KeyType]}>>

All MarkActions defined by the editor.

get mounted(): boolean

Whether the editor is mounted.

get nodes(): ToNodeAction<SimplifyDeeper<{[KeyType in string | number | symbol]: UnionToIntersection<ExtractTyping<E>["Nodes"] extends undefined ? never : ExtractTyping<E>["Nodes"]>[KeyType]}>>

All NodeActions defined by the editor.

get schema(): Schema<ExtractNodeNames<E>, ExtractMarkNames<E>>

The editor schema.

get state(): EditorState

The editor's current state.

get view(): EditorView

The editor view.

blur

Blur the editor.

ts
const blur: () => void

canExec

Check if the given command can be executed. Return true if the command can be executed, otherwise false.

ts
const canExec: (command: Command) => boolean

exec

Execute the given command. Return true if the command was successfully executed, otherwise false.

ts
const exec: (command: Command) => boolean

focus

Focus the editor.

ts
const focus: () => void

mount

Mount the editor to the given HTML element. Pass null or undefined to unmount the editor.

ts
const mount: (place: undefined | null | HTMLElement) => void

setContent

Update the editor's document and selection.

ts
const setContent: (content: string | Node | NodeJSON | HTMLElement, selection?: Selection | "start" | SelectionJSON | "end") => void

unmount

Unmount the editor. This is equivalent to mount(null).

ts
const unmount: () => void

updateState

Update the editor's state.

Remarks

This is an advanced method. Use it only if you have a specific reason to directly manipulate the editor's state.

ts
const updateState: (state: EditorState) => void

use

Register an extension to the editor. Return a function to unregister the extension.

ts
const use: (extension: Extension) => VoidFunction

AddMarkOptions

attrs?: null | Attrs

The attributes of the mark to add.

from?: number

The start position of the document. By default it will be the start position of current selection.

to?: number

The end position of the document. By default it will be the end position of current selection.

type: string | MarkType

The type of the mark to add.

BaseNodeViewOptions

Some basic props for custom node views.

Deprecated

  • This is no longer needed. Use CoreNodeViewUserOptions from @prosemirror-adapter/core instead.

as?: string | HTMLElement | ((node: Node) => HTMLElement)

The wrapping DOM element for the node view. Defaults to div for block nodes and span for inline nodes.

contentAs?: string | HTMLElement | ((node: Node) => HTMLElement)

The wrapping DOM element for the node view's content. Defaults to div for block nodes and span for inline nodes.

deselectNode?: () => void

destroy?: () => void

ignoreMutation?: (mutation: ViewMutationRecord) => boolean

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

CommandAction

A function to apply a command to the editor. It will return true if the command was applied, and false otherwise.

It also has a canExec method to check if the command can be applied.

canApply

An alias for canExec.

Deprecated

Use canExec instead.

ts
const canApply: (...args: Args) => boolean

canExec

Check if the current command can be executed. Return true if the command can be executed, otherwise false.

ts
const canExec: (...args: Args) => boolean

DefaultStateOptions

defaultContent?: string | NodeJSON | HTMLElement

The starting document to use when creating the editor. It can be a ProseMirror node JSON object, a HTML string, or a HTML element instance.

defaultDoc?: NodeJSON

A JSON object representing the starting document to use when creating the editor.

Deprecated

Use defaultContent instead.

defaultHTML?: string | HTMLElement

A HTML element or a HTML string representing the starting document to use when creating the editor.

Deprecated

Use defaultContent instead.

defaultSelection?: SelectionJSON

A JSON object representing the starting selection to use when creating the editor. It's only used when defaultContent is also provided.

DOMDocumentOptions

document?: Document

DOMParserOptions

DOMParser?: typeof DOMParser

DOMSerializerOptions

DOMSerializer?: typeof DOMSerializer

EditorOptions

defaultContent?: string | NodeJSON | HTMLElement

The starting document to use when creating the editor. It can be a ProseMirror node JSON object, a HTML string, or a HTML element instance.

defaultDoc?: NodeJSON

A JSON object representing the starting document to use when creating the editor.

Deprecated

Use defaultContent instead.

defaultHTML?: string | HTMLElement

A HTML element or a HTML string representing the starting document to use when creating the editor.

Deprecated

Use defaultContent instead.

defaultSelection?: SelectionJSON

A JSON object representing the starting selection to use when creating the editor. It's only used when defaultContent is also provided.

extension: E

The extension to use when creating the editor.

ExpandMarkOptions

type: string | MarkType

The type of the mark to expand.

Extension

_type?: T

extension: Extension | Extension[]

priority?: Priority

schema: null | Schema

The schema that this extension represents.

FindParentNodeResult

depth: number

The depth of the node.

node: Node

The closest parent node that satisfies the predicate.

pos: number

The position directly before the node.

start: number

The position at the start of the node.

HistoryOptions

Options for defineHistory.

depth?: number

The amount of history events that are collected before the oldest events are discarded.

Default: 200

newGroupDelay?: number

The delay in milliseconds between changes after which a new group should be started.

Default: 250

InsertDefaultBlockOptions

pos?: number

The position to insert the node at. By default it will insert after the current selection.

InsertNodeOptions

attrs?: Attrs

When type is provided, the attributes of the node to insert.

node?: Node

The node to insert. Either this or type must be provided.

pos?: number

The position to insert the node at. By default it will be the anchor position of current selection.

type?: string | NodeType

The type of the node to insert. Either this or node must be provided.

JSONParserOptions

schema: Schema

Keymap

MarkAction

A function for creating a mark with optional attributes and any number of children.

It also has a isActive method for checking if the mark is active in the current editor selection.

isActive: (attrs?: Attrs) => boolean

Checks if the mark is active in the current editor selection. If the optional attrs parameter is provided, it will check if the mark is active with the given attributes.

MarkAttrOptions

attr: AttrName

The name of the attribute.

default?: AttrType

The default value for this attribute, to use when no explicit value is provided. Attributes that have no default must be provided whenever a node or mark of a type that has them is created.

parseDOM?: (node: HTMLElement) => AttrType

Parses the attribute value from the DOM.

toDOM?: (value: AttrType) => undefined | null | [key: string, value: string]

Returns the attribute key and value to be set on the HTML element.

If the returned key is "style", the value is a string of CSS properties and will be prepended to the existing style attribute on the DOM node.

type: MarkName

The name of the mark type.

validate?: string | ((value: unknown) => void)

A function or type name used to validate values of this attribute. This will be used when deserializing the attribute from JSON, and when running Node.check. When a function, it should raise an exception if the value isn't of the expected type or shape. When a string, it should be a |-separated string of primitive types ("number", "string", "boolean", "null", and "undefined"), and the library will raise an error when the value is not one of those types.

MarkSpecOptions

attrs?: {[K in string | number | symbol]: AttrSpec<Attrs[K]>}

The attributes that marks of this type get.

name: MarkName

The name of the mark type.

MarkViewOptions

constructor: MarkViewConstructor

name: string

NodeAction

A function for creating a node with optional attributes and any number of children.

It also has a isActive method for checking if the node is active in the current editor selection.

isActive: (attrs?: Attrs) => boolean

Checks if the node is active in the current editor selection. If the optional attrs parameter is provided, it will check if the node is active with the given attributes.

NodeAttrOptions

attr: AttrName

The name of the attribute.

default?: AttrType

The default value for this attribute, to use when no explicit value is provided. Attributes that have no default must be provided whenever a node or mark of a type that has them is created.

parseDOM?: (node: HTMLElement) => AttrType

Parses the attribute value from the DOM.

splittable?: boolean

Whether the attribute should be kept when the node is split. Set it to true if you want to inherit the attribute from the previous node when splitting the node by pressing Enter.

Default: undefined

toDOM?: (value: AttrType) => undefined | null | [key: string, value: string]

Returns the attribute key and value to be set on the HTML element.

If the returned key is "style", the value is a string of CSS properties and will be prepended to the existing style attribute on the DOM node.

type: NodeName

The name of the node type.

validate?: string | ((value: unknown) => void)

A function or type name used to validate values of this attribute. This will be used when deserializing the attribute from JSON, and when running Node.check. When a function, it should raise an exception if the value isn't of the expected type or shape. When a string, it should be a |-separated string of primitive types ("number", "string", "boolean", "null", and "undefined"), and the library will raise an error when the value is not one of those types.

NodeJSON

A JSON representation of the prosemirror node.

attrs?: Record<string, any>

content?: NodeJSON[]

marks?: { attrs?: Record<string, any>; type: string }[]

text?: string

type: string

NodeSpecOptions

attrs?: {[key in string | number | symbol]: AttrSpec<Attrs[key]>}

The attributes that nodes of this type get.

name: NodeName

The name of the node type.

topNode?: boolean

Whether this is the top-level node type. Only one node type can be the top-level node type in a schema.

NodeViewOptions

constructor: NodeViewConstructor

name: string

RemoveMarkOptions

attrs?: null | Attrs

If attrs is given, remove precisely the mark with the given attrs. Otherwise, remove all marks of the given type.

from?: number

The start position of the document. By default it will be the start position of current selection.

to?: number

The end position of the document. By default it will be the end position of current selection.

type: string | MarkType

The type of the mark to remove.

RemoveNodeOptions

pos?: number

The document position to start searching node. By default it will be the anchor position of current selection.

type: string | NodeType

The type of the node to remove.

SelectionJSON

A JSON representation of the prosemirror selection.

anchor: number

head: number

type: string

SetBlockTypeOptions

attrs?: null | Attrs

from?: number

to?: number

type: string | NodeType

SetNodeAttrsOptions

attrs: Attrs

The attributes to set.

pos?: number

The position of the node. Defaults to the position of the wrapping node containing the current selection.

type: string | NodeType | string[] | NodeType[]

The type of node to set the attributes of.

If current node is not of this type, the command will do nothing.

StateJSON

A JSON representation of the prosemirror state.

doc: NodeJSON

The main ProseMirror doc.

selection: SelectionJSON

The current selection.

StepJSON

A JSON representation of the prosemirror step.

stepType: string

The type of the step.

ToggleMarkOptions

attrs?: null | Attrs

The optional attributes to set on the mark.

enterInlineAtoms?: boolean

Whether the command should act on the content of inline nodes marked as atoms that are completely covered by a selection range.

Default: true

removeWhenPresent?: boolean

Controls whether, when part of the selected range has the mark already and part doesn't, the mark is removed (true) or added (false).

Default: false

type: string | MarkType

The mark type to toggle.

ToggleNodeOptions

attrs?: null | Attrs

The attributes of the node to toggle.

type: string | NodeType

The type of the node to toggle.

ToggleWrapOptions

attrs?: null | Attrs

The attributes of the node to toggle.

type: string | NodeType

The type of the node to toggle.

UnsetBlockTypeOptions

from?: number

The start position of the document. By default it will be the start position of current selection.

to?: number

The end position of the document. By default it will be the end position of current selection.

UnsetMarkOptions

from?: number

The start position of the document. By default it will be the start position of current selection.

to?: number

The end position of the document. By default it will be the end position of current selection.

WrapOptions

attrs?: null | Attrs

Optional attributes to apply to the node.

nodeType?: NodeType

Deprecated

Use nodeSpec instead.

type: string | NodeType

The node type to wrap the selected textblock with.

AnyAttrs

An object holding the attributes of a node.

Type: Attrs

AttrSpec

Type: { default?: AttrType; validate?: string | ((value: unknown) => void) }

ClickHandler

Type: (view: EditorView, pos: number, event: MouseEvent) => boolean | void

ClickOnHandler

Type: (view: EditorView, pos: number, node: Node, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void

DocChangeHandler

A function that is called when the editor document is changed.

Type: (view: EditorView, prevState: EditorState) => void

DOMEventHandler

A function to handle the events fired on the editable DOM element. Returns true to indicate that it handled the given event. you are responsible for calling preventDefault yourself (or not, if you want to allow the default behavior).

Type: (view: EditorView, event: DOMEventMap[Event]) => boolean | void

DoubleClickHandler

Type: (view: EditorView, pos: number, event: MouseEvent) => boolean | void

DoubleClickOnHandler

Type: (view: EditorView, pos: number, node: Node, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void

DropHandler

Type: (view: EditorView, event: DragEvent, slice: Slice, moved: boolean) => boolean | void

ExtractCommandActions

Extracts the CommandActions from an extension type.

Type: ToCommandAction<ExtractCommands<E>>

ExtractCommandAppliers

Deprecated

Use ExtractCommandActions instead.

Type: ExtractCommandActions<E>

ExtractCommandCreators

Type: ToCommandCreators<ExtractCommands<E>>

ExtractMarkActions

Extracts the MarkActions from an extension type.

Type: ToMarkAction<ExtractMarks<E>>

ExtractMarks

Type: SimplifyDeeper<SimplifyUnion<ExtractTyping<E>["Marks"]>>

ExtractNodeActions

Extracts the NodeActions from an extension type.

Type: ToNodeAction<ExtractNodes<E>>

ExtractNodes

Type: SimplifyDeeper<SimplifyUnion<ExtractTyping<E>["Nodes"]>>

FocusChangeHandler

A function that is called when the editor gains or loses focus.

Type: (hasFocus: boolean) => void

KeyDownHandler

Type: (view: EditorView, event: KeyboardEvent) => boolean | void

KeyPressHandler

Type: (view: EditorView, event: KeyboardEvent) => boolean | void

MarkBuilder

Deprecated

Use type MarkAction instead.

Type: MarkAction

MountHandler

A function that is called when the editor view is mounted.

Type: (view: EditorView) => void

NodeBuilder

Deprecated

Use type NodeAction instead.

Type: NodeAction

NodeChild

Available children parameters for NodeAction and MarkAction.

Type: ProseMirrorNode | string | NodeChild[]

NodeContent

Deprecated

Type: ProseMirrorNode | ProseMirrorFragment | NodeContent[]

PasteHandler

Type: (view: EditorView, event: ClipboardEvent, slice: Slice) => boolean | void

ScrollToSelectionHandler

Type: (view: EditorView) => boolean

TextInputHandler

Type: (view: EditorView, from: number, to: number, text: string) => boolean | void

TripleClickHandler

Type: (view: EditorView, pos: number, event: MouseEvent) => boolean | void

TripleClickOnHandler

Type: (view: EditorView, pos: number, node: Node, nodePos: number, event: MouseEvent, direct: boolean) => boolean | void

UnmountHandler

A function that is called when the editor view is unmounted.

Type: () => void

UpdateHandler

A function that is called when the editor state is updated.

Type: (view: EditorView, prevState: EditorState) => void

addMark

ts
function addMark(options: AddMarkOptions): Command

Returns a command that adds the given mark with the given attributes.

canUseRegexLookbehind

ts
function canUseRegexLookbehind(): boolean

clsx

A utility for constructing className strings conditionally.

It is a re-export of clsx/lite with stricter types.

ts
function clsx(...args: (undefined | null | string | boolean)[]): string

collectChildren

ts
function collectChildren(parent: Node | Fragment): ProseMirrorNode[]

Collects all children of a node or a fragment, and returns them as an array.

collectNodes

ts
function collectNodes(content: NodeContent): ProseMirrorNode[]

Collects all nodes from a given content.

Deprecated

Use collectChildren instead.

createEditor

ts
function createEditor<E extends Extension>(options: EditorOptions<E>): Editor<E>

defineBaseCommands

ts
function defineBaseCommands(): BaseCommandsExtension

Add some base commands

defineBaseKeymap

ts
function defineBaseKeymap(options?: { priority?: Priority }): BaseKeymapExtension

Defines some basic key bindings.

defineClickHandler

ts
function defineClickHandler(handler: ClickHandler): PlainExtension

See https://prosemirror.net/docs/ref/#view.EditorProps.handleClick

defineClickOnHandler

ts
function defineClickOnHandler(handler: ClickOnHandler): PlainExtension

See https://prosemirror.net/docs/ref/#view.EditorProps.handleClickOn

defineCommands

ts
function defineCommands<T extends Record<string, CommandCreator>>(commands: T): Extension<{ Commands: {[K in keyof T]: Parameters<T[K]>} }>

defineDefaultState

ts
function defineDefaultState(options: DefaultStateOptions): PlainExtension

Define a default state for the editor.

defineDoc

ts
function defineDoc(): DocExtension

defineDocChangeHandler

ts
function defineDocChangeHandler(handler: DocChangeHandler): PlainExtension

Registers a event handler that is called when the editor document is changed.

defineDOMEventHandler

ts
function defineDOMEventHandler<Event extends keyof DOMEventMap>(event: Event, handler: DOMEventHandler<Event>): PlainExtension

Register a new event handler for the given event type.

defineDoubleClickHandler

ts
function defineDoubleClickHandler(handler: DoubleClickHandler): PlainExtension

See https://prosemirror.net/docs/ref/#view.EditorProps.handleDoubleClick

defineDoubleClickOnHandler

ts
function defineDoubleClickOnHandler(handler: DoubleClickOnHandler): PlainExtension

See https://prosemirror.net/docs/ref/#view.EditorProps.handleDoubleClickOn

defineDropHandler

ts
function defineDropHandler(handler: DropHandler): PlainExtension

See https://prosemirror.net/docs/ref/#view.EditorProps.handleDrop

defineFocusChangeHandler

ts
function defineFocusChangeHandler(handler: FocusChangeHandler): PlainExtension

Registers a event handler that is called when the editor gains or loses focus.

defineHistory

ts
function defineHistory(options?: HistoryOptions): HistoryExtension

Add undo/redo history to the editor.

defineKeyDownHandler

ts
function defineKeyDownHandler(handler: KeyDownHandler): PlainExtension

See https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyDown

defineKeymap

ts
function defineKeymap(keymap: Keymap): PlainExtension

defineKeyPressHandler

ts
function defineKeyPressHandler(handler: KeyPressHandler): PlainExtension

See https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyPress

defineMarkAttr

ts
function defineMarkAttr<MarkType extends string, AttrName extends string, AttrType>(options: MarkAttrOptions<MarkType, AttrName, AttrType>): Extension<{ Marks: {[K in MarkType]: AttrType} }>

defineMarkSpec

ts
function defineMarkSpec<Mark extends string, Attrs extends Attrs>(options: MarkSpecOptions<Mark, Attrs>): Extension<{ Marks: {[K in Mark]: Attrs} }>

defineMarkView

ts
function defineMarkView(options: MarkViewOptions): Extension

defineMountHandler

ts
function defineMountHandler(handler: MountHandler): PlainExtension

Registers a event handler that is called when the editor view is mounted.

defineNodeAttr

ts
function defineNodeAttr<NodeType extends string, AttrName extends string, AttrType>(options: NodeAttrOptions<NodeType, AttrName, AttrType>): Extension<{ Nodes: {[K in NodeType]: {[K in AttrName]: AttrType}} }>

Defines an attribute for a node type.

defineNodeSpec

ts
function defineNodeSpec<Node extends string, Attrs extends Attrs>(options: NodeSpecOptions<Node, Attrs>): Extension<{ Nodes: {[K in Node]: Attrs} }>

Defines a node type.

defineNodeView

ts
function defineNodeView(options: NodeViewOptions): Extension

defineParagraph

ts
function defineParagraph(): ParagraphExtension

Defines a paragraph node spec as the highest priority, because it should be the default block node for most cases.

definePasteHandler

ts
function definePasteHandler(handler: PasteHandler): PlainExtension

See https://prosemirror.net/docs/ref/#view.EditorProps.handlePaste

definePlugin

ts
function definePlugin(plugin: Plugin | Plugin[] | ((context: { schema: Schema }) => Plugin | Plugin[])): PlainExtension

Adds a ProseMirror plugin to the editor.

defineScrollToSelectionHandler

ts
function defineScrollToSelectionHandler(handler: ScrollToSelectionHandler): PlainExtension

See https://prosemirror.net/docs/ref/#view.EditorProps.handleScrollToSelection

defineText

ts
function defineText(): TextExtension

defineTextInputHandler

ts
function defineTextInputHandler(handler: TextInputHandler): PlainExtension

See https://prosemirror.net/docs/ref/#view.EditorProps.handleTextInput

defineTripleClickHandler

ts
function defineTripleClickHandler(handler: TripleClickHandler): PlainExtension

See https://prosemirror.net/docs/ref/#view.EditorProps.handleTripleClick

defineTripleClickOnHandler

ts
function defineTripleClickOnHandler(handler: TripleClickOnHandler): PlainExtension

See https://prosemirror.net/docs/ref/#view.EditorProps.handleTripleClickOn

defineUnmountHandler

ts
function defineUnmountHandler(handler: UnmountHandler): PlainExtension

Registers a event handler that is called when the editor view is unmounted.

defineUpdateHandler

ts
function defineUpdateHandler(handler: UpdateHandler): PlainExtension

Registers a event handler that is called when the editor state is updated.

elementFromJSON

ts
function elementFromJSON(json: NodeJSON, options: JSONParserOptions & DOMSerializerOptions & DOMDocumentOptions): HTMLElement

Parse a ProseMirror document JSON object to a HTML element.

elementFromNode

ts
function elementFromNode(node: Node, options?: DOMSerializerOptions & DOMDocumentOptions): HTMLElement

Serialize a ProseMirror node to a HTML element.

expandMark

ts
function expandMark(options: ExpandMarkOptions): Command

Expands the selection to include the entire mark at the current position.

findParentNode

ts
function findParentNode(predicate: (node: Node) => boolean, $pos: ResolvedPos): FindParentNodeResult | undefined

Find the closest parent node that satisfies the predicate.

findParentNodeOfType

ts
function findParentNodeOfType(type: string | NodeType, $pos: ResolvedPos): FindParentNodeResult | undefined

Finds the closest parent node that matches the given node type.

htmlFromJSON

ts
function htmlFromJSON(json: NodeJSON, options: JSONParserOptions & DOMSerializerOptions & DOMDocumentOptions): string

Parse a ProseMirror document JSON object to a HTML string.

htmlFromNode

ts
function htmlFromNode(node: Node, options?: DOMSerializerOptions & DOMDocumentOptions): string

Serialize a ProseMirror node to a HTML string

insertDefaultBlock

ts
function insertDefaultBlock(options?: InsertDefaultBlockOptions): Command

Returns a command that inserts a default block after current selection or at the given position.

insertNode

ts
function insertNode(options: InsertNodeOptions): Command

Returns a command that inserts the given node at the current selection or at the given position.

isAllSelection

ts
function isAllSelection(sel: Selection): sel is AllSelection

Checks if the given object is a AllSelection instance.

isFragment

ts
function isFragment(fragment: unknown): fragment is Fragment

Checks if the given object is a Fragment instance.

isMark

ts
function isMark(mark: unknown): mark is Mark

Checks if the given object is a Mark instance.

isNodeSelection

ts
function isNodeSelection(sel: Selection): sel is NodeSelection

Checks if the given object is a NodeSelection instance.

isProseMirrorNode

ts
function isProseMirrorNode(node: unknown): node is Node

Checks if the given object is a ProseMirrorNode instance.

isSelection

ts
function isSelection(sel: unknown): sel is Selection

Checks if the given object is a Selection instance.

isSlice

ts
function isSlice(slice: unknown): slice is Slice

Checks if the given object is a Slice instance.

isTextSelection

ts
function isTextSelection(sel: Selection): sel is TextSelection

Checks if the given object is a TextSelection instance.

jsonFromHTML

ts
function jsonFromHTML(html: string, options: DOMDocumentOptions & DOMParserOptions & JSONParserOptions): NodeJSON

Parse a HTML string to a ProseMirror document JSON object.

jsonFromNode

ts
function jsonFromNode(node: Node): NodeJSON

Return a JSON object representing this node.

jsonFromState

ts
function jsonFromState(state: EditorState): StateJSON

Return a JSON object representing this state.

nodeFromElement

ts
function nodeFromElement(element: Node, options: DOMParserOptions & JSONParserOptions): ProseMirrorNode

Parse a HTML element to a ProseMirror node.

nodeFromHTML

ts
function nodeFromHTML(html: string, options: DOMParserOptions & JSONParserOptions & DOMDocumentOptions): ProseMirrorNode

Parse a HTML string to a ProseMirror node.

nodeFromJSON

ts
function nodeFromJSON(json: NodeJSON, options: JSONParserOptions): ProseMirrorNode

Parse a JSON object to a ProseMirror node.

removeMark

ts
function removeMark(options: RemoveMarkOptions): Command

Returns a command that removes the given mark.

removeNode

ts
function removeNode(options: RemoveNodeOptions): Command

Returns a command to remove the nearest ancestor node of a specific type from the current position.

setBlockType

ts
function setBlockType(options: SetBlockTypeOptions): Command

Returns a command that tries to set the selected textblocks to the given node type with the given attributes.

setNodeAttrs

ts
function setNodeAttrs(options: SetNodeAttrsOptions): Command

Returns a command that set the attributes of the current node.

setSelectionAround

ts
function setSelectionAround(tr: Transaction, pos: number): void

stateFromJSON

ts
function stateFromJSON(json: StateJSON, options: JSONParserOptions): EditorState

Parse a JSON object to a ProseMirror state.

toggleMark

ts
function toggleMark(options: ToggleMarkOptions): Command

Returns a command that toggles the given mark with the given attributes.

toggleNode

ts
function toggleNode(options: ToggleNodeOptions): Command

Returns a command that set the selected textblocks to the given node type with the given attributes.

toggleWrap

ts
function toggleWrap(options: ToggleWrapOptions): Command

Toggle between wrapping an inactive node with the provided node type, and lifting it up into it's parent.

union

ts
function union<const E extends readonly Extension[]>(...exts: E): Union<E>

Merges multiple extensions into one. You can pass multiple extensions as arguments or a single array containing multiple extensions.

Throws

If no extensions are provided.

Example

ts
function defineFancyNodes() {
  return union(
    defineFancyParagraph(),
    defineFancyHeading(),
  )
}

Example

ts
function defineFancyNodes() {
  return union([
    defineFancyParagraph(),
    defineFancyHeading(),
  ])
}
ts
function union<const E extends readonly Extension[]>(exts: E): Union<E>

Merges multiple extensions into one. You can pass multiple extensions as arguments or a single array containing multiple extensions.

Throws

If no extensions are provided.

Example

ts
function defineFancyNodes() {
  return union(
    defineFancyParagraph(),
    defineFancyHeading(),
  )
}

Example

ts
function defineFancyNodes() {
  return union([
    defineFancyParagraph(),
    defineFancyHeading(),
  ])
}

unsetBlockType

ts
function unsetBlockType(options?: UnsetBlockTypeOptions): Command

Returns a command that set the type of all textblocks between the given range to the default type (usually paragraph).

unsetMark

ts
function unsetMark(options?: UnsetMarkOptions): Command

Returns a command that removes all marks.

withPriority

ts
function withPriority<T extends Extension>(extension: T, priority: Priority): T

Return an new extension with the given priority.

Example

ts
import { Priority, withPriority } from 'prosekit/core'

const extension = withPriority(defineMyExtension(), Priority.high)

wrap

ts
function wrap(options: WrapOptions): Command

Returns a command that wraps the selected textblock with the given node type.