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

ts
const blur: () => void

canExec

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

exec

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

focus

ts
const focus: () => void

mount

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

setContent

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

unmount

ts
const unmount: () => void

updateState

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

use

ts
const use: (extension: Extension<ExtensionTyping<any, any, any>>) => VoidFunction

AddMarkOptions

attrs

The attributes of the mark to add.

Type: null | Attrs

from

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

Type: number

to

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

Type: number

type

The type of the mark to add.

Type: string | MarkType

BaseNodeViewOptions

Some basic props for custom node views.

as

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

Type: string | HTMLElement | ((node: Node) => HTMLElement)

contentAs

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

Type: string | HTMLElement | ((node: Node) => HTMLElement)

deselectNode

Type: () => void

destroy

Type: () => void

ignoreMutation

Type: (mutation: MutationRecord) => boolean

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

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

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

canExec

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

DefaultStateOptions

defaultContent

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.

Type: string | NodeJSON | HTMLElement

defaultDoc

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

Type: NodeJSON

Deprecated

Use defaultContent instead.

defaultHTML

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

Type: string | HTMLElement

Deprecated

Use defaultContent instead.

defaultSelection

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

Type: SelectionJSON

DOMDocumentOptions

document

Type: Document

DOMParserOptions

DOMParser

Type: typeof DOMParser

DOMSerializerOptions

DOMSerializer

Type: typeof DOMSerializer

EditorOptions

defaultContent

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.

Type: string | NodeJSON | HTMLElement

defaultDoc

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

Type: NodeJSON

Deprecated

Use defaultContent instead.

defaultHTML

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

Type: string | HTMLElement

Deprecated

Use defaultContent instead.

defaultSelection

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

Type: SelectionJSON

extension

The extension to use when creating the editor.

Type: E

ExpandMarkOptions

type

The type of the mark to expand.

Type: string | MarkType

Extension

_type

Type: T

extension

Type: Extension<ExtensionTyping<any, any, any>> | Extension<ExtensionTyping<any, any, any>>[]

priority

Type: Priority

schema

The schema that this extension represents.

Type: null | Schema<any, any>

FindParentNodeResult

depth

The depth of the node.

Type: number

node

The closest parent node that satisfies the predicate.

Type: Node

pos

The position directly before the node.

Type: number

start

The position at the start of the node.

Type: number

HistoryOptions

Options for defineHistory.

depth

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

Type: number

Default: 200

newGroupDelay

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

Type: number

Default: 250

InsertDefaultBlockOptions

pos

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

Type: number

InsertNodeOptions

attrs

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

Type: Attrs

node

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

Type: Node

pos

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

Type: number

type

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

Type: string | NodeType

JSONParserOptions

schema

Type: Schema<any, any>

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

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.

Type: (attrs?: Attrs) => boolean

MarkAttrOptions

attr

The name of the attribute.

Type: AttrName

default

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.

Type: AttrType

parseDOM

Parses the attribute value from the DOM.

Type: (node: HTMLElement) => AttrType

toDOM

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: (value: AttrType) => undefined | null | [key: string, value: string]

type

The name of the mark type.

Type: MarkName

validate

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.

Type: string | ((value: unknown) => void)

MarkSpecOptions

attrs

The attributes that marks of this type get.

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

name

The name of the mark type.

Type: MarkName

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

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.

Type: (attrs?: Attrs) => boolean

NodeAttrOptions

attr

The name of the attribute.

Type: AttrName

default

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.

Type: AttrType

parseDOM

Parses the attribute value from the DOM.

Type: (node: HTMLElement) => AttrType

splittable

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.

Type: boolean

Default: undefined

toDOM

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: (value: AttrType) => undefined | null | [key: string, value: string]

type

The name of the node type.

Type: NodeName

validate

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.

Type: string | ((value: unknown) => void)

NodeJSON

A JSON representation of the prosemirror node.

attrs

Type: Record<string, any>

content

Type: NodeJSON[]

marks

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

text

Type: string

type

Type: string

NodeSpecOptions

attrs

The attributes that nodes of this type get.

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

name

The name of the node type.

Type: NodeName

topNode

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

Type: boolean

NodeViewOptions

constructor

Type: NodeViewConstructor

name

Type: string

RemoveMarkOptions

attrs

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

Type: null | Attrs

from

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

Type: number

to

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

Type: number

type

The type of the mark to remove.

Type: string | MarkType

RemoveNodeOptions

pos

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

Type: number

type

The type of the node to remove.

Type: string | NodeType

SelectionJSON

A JSON representation of the prosemirror selection.

anchor

Type: number

head

Type: number

type

Type: string

SetBlockTypeOptions

attrs

Type: null | Attrs

from

Type: number

to

Type: number

type

Type: string | NodeType

SetNodeAttrsOptions

attrs

The attributes to set.

Type: Attrs

pos

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

Type: number

type

The type of node to set the attributes of.

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

Type: string | NodeType | string[] | NodeType[]

StateJSON

A JSON representation of the prosemirror state.

doc

The main ProseMirror doc.

Type: NodeJSON

selection

The current selection.

Type: SelectionJSON

StepJSON

A JSON representation of the prosemirror step.

stepType

The type of the step.

Type: string

ToggleMarkOptions

attrs

The optional attributes to set on the mark.

Type: null | Attrs

enterInlineAtoms

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

Type: boolean

Default: true

removeWhenPresent

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

Type: boolean

Default: false

type

The mark type to toggle.

Type: string | MarkType

ToggleNodeOptions

attrs

The attributes of the node to toggle.

Type: null | Attrs

type

The type of the node to toggle.

Type: string | NodeType

ToggleWrapOptions

attrs

The attributes of the node to toggle.

Type: null | Attrs

type

The type of the node to toggle.

Type: string | NodeType

UnsetBlockTypeOptions

from

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

Type: number

to

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

Type: number

UnsetMarkOptions

from

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

Type: number

to

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

Type: number

WrapOptions

attrs

Optional attributes to apply to the node.

Type: null | Attrs

nodeType

Type: NodeType

Deprecated

Use nodeSpec instead.

type

The node type to wrap the selected textblock with.

Type: string | NodeType

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<ExtensionTyping<any, any, any>>>(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} }>

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<any> | Plugin<any>[] | ((context: { schema: Schema<any, any> }) => Plugin<any> | Plugin<any>[])): 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<ExtensionTyping<any, any, any>>[]>(...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<ExtensionTyping<any, any, any>>[]>(exts: E): Union<E>

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<ExtensionTyping<any, any, any>>>(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.