Skip to content

prosekit/core

Priority

ProseKit extension priority.

Enumeration Members

Enumeration MemberValue
default2
high3
highest4
low1
lowest0

Editor<E>

Extended by

Type Parameters

E extends Extension = any

Accessors

commands

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

All CommandActions defined by the editor.

Returns

ToCommandAction<{ [KeyType in string | number | symbol]: UnionToIntersection<ExtractTyping<E>["Commands"]>[KeyType] }>

focused

get focused(): boolean

Whether the editor is focused.

Returns

boolean

marks

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

All MarkActions defined by the editor.

Returns

ToMarkAction<SimplifyDeeper<{ [KeyType in string | number | symbol]: UnionToIntersection<ExtractTyping<E>["Marks"]>[KeyType] }>>

mounted

get mounted(): boolean

Whether the editor is mounted.

Returns

boolean

nodes

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

All NodeActions defined by the editor.

Returns

ToNodeAction<SimplifyDeeper<{ [KeyType in string | number | symbol]: UnionToIntersection<ExtractTyping<E>["Nodes"]>[KeyType] }>>

schema

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

The editor schema.

Returns

Schema<ExtractNodeNames<E>, ExtractMarkNames<E>>

state

get state(): EditorState

The editor's current state.

Returns

EditorState

view

get view(): EditorView

The editor view.

Returns

EditorView

Methods

blur()

blur(): void

Blur the editor.

Returns

void

focus()

focus(): void

Focus the editor.

Returns

void

mount()

mount(place): void

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

Parameters

place: undefined | null | HTMLElement

Returns

void

unmount()

unmount(): void

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

Returns

void

updateState()

updateState(state): void

Update the editor's state.

Parameters

state: EditorState

Returns

void

Remarks

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

use()

use(extension): VoidFunction

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

Parameters

extension: Extension<ExtensionTyping<any, any, any>>

Returns

VoidFunction


AddMarkOptions

Properties

attrs?

optional attrs: null | Attrs

The attributes of the mark to add.

from?

optional from: number

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

to?

optional to: number

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

type

type: string | MarkType

The type of the mark to add.


BaseNodeViewOptions

Some basic props for custom node views.

Extended by

Properties

as?

optional as: string | HTMLElement | (node) => HTMLElement

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

contentAs?

optional contentAs: string | HTMLElement | (node) => HTMLElement

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

deselectNode()?

optional deselectNode: () => void

Returns

void

destroy()?

optional destroy: () => void

Returns

void

ignoreMutation()?

optional ignoreMutation: (mutation) => boolean

Parameters

mutation: MutationRecord

Returns

boolean

onUpdate()?

optional onUpdate: () => void

Returns

void

selectNode()?

optional selectNode: () => void

Returns

void

setSelection()?

optional setSelection: (anchor, head, root) => void

Parameters

anchor: number

head: number

root: Document | ShadowRoot

Returns

void

stopEvent()?

optional stopEvent: (event) => boolean

Parameters

event: Event

Returns

boolean

update()?

optional update: (node, decorations, innerDecorations) => boolean

Parameters

node: Node

decorations: readonly Decoration[]

innerDecorations: DecorationSource

Returns

boolean


CommandAction()<Args>

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 canApply method to check if the command can be applied.

Type Parameters

Args extends any[] = any[]

CommandAction(...args): boolean

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 canApply method to check if the command can be applied.

Parameters

• ...args: Args

Returns

boolean

Methods

canApply()

canApply(...args): boolean

Parameters

• ...args: Args

Returns

boolean


DOMDocumentOptions

Properties

document?

optional document: Document


DOMParserOptions

Extends

Properties

DOMParser?

optional DOMParser: typeof DOMParser


DOMSerializerOptions

Properties

DOMSerializer?

optional DOMSerializer: typeof DOMSerializer


DefaultStateOptions

Properties

defaultDoc?

optional defaultDoc: NodeJSON

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

defaultHTML?

optional defaultHTML: string | HTMLElement

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

defaultSelection?

optional defaultSelection: SelectionJSON

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


EditorOptions<E>

Type Parameters

E extends Extension

Properties

defaultDoc?

optional defaultDoc: NodeJSON

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

defaultHTML?

optional defaultHTML: string | HTMLElement

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

defaultSelection?

optional defaultSelection: SelectionJSON

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

extension

extension: E

The extension to use when creating the editor.


ExpandMarkOptions

Properties

type

type: string | MarkType

The type of the mark to expand.


Extension<T>

Type Parameters

T extends ExtensionTyping<any, any, any> = ExtensionTyping<any, any, any>

Properties

_type?

optional _type: T

extension

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

priority?

optional priority: Priority

schema

schema: null | Schema<any, any>

The schema that this extension represents.


HistoryOptions

Options for defineHistory.

Properties

depth?

optional depth: number

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

Default
ts
200

newGroupDelay?

optional newGroupDelay: number

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

Default
ts
250

InsertNodeOptions

Properties

attrs?

optional attrs: Attrs

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

node?

optional node: Node

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

pos?

optional pos: number

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

type?

optional type: string | NodeType

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


JSONParserOptions

Properties

schema

schema: Schema<any, any>


Keymap

Indexable

[key: string]: Command


MarkAction()<Attrs>

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.

Type Parameters

Attrs extends AnyAttrs = AnyAttrs

MarkAction(attrs, ...children): Node[]

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.

Parameters

attrs: null | Attrs

• ...children: NodeChild[]

Returns

Node[]

MarkAction(...children): Node[]

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.

Parameters

• ...children: NodeChild[]

Returns

Node[]

Properties

isActive()

isActive: (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.

Parameters

attrs?: Attrs

Returns

boolean


MarkAttrOptions<MarkName, AttrName, AttrType>

Extends

Type Parameters

MarkName extends string = string

AttrName extends string = string

AttrType = any

Properties

attr

attr: AttrName

The name of the attribute.

default?

optional 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.

Inherited from

AttrSpec.default

parseDOM()?

optional parseDOM: (node) => any

Parses the attribute value from the DOM.

Parameters

node: HTMLElement

Returns

any

toDOM()?

optional toDOM: (value) => null | void | [string, string]

Returns the attribute key and value to be set on the DOM node.

Parameters

value: any

Returns

null | void | [string, string]

type

type: MarkName

The name of the mark type.

validate?

optional validate: string | (value) => 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.

Inherited from

AttrSpec.validate


MarkSpecOptions<MarkName, Attrs>

Extends

Type Parameters

MarkName extends string = string

Attrs extends AnyAttrs = AnyAttrs

Properties

attrs?

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

The attributes that marks of this type get.

Overrides

MarkSpec.attrs

name

name: MarkName

The name of the mark type.


NodeAction()<Attrs>

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.

Type Parameters

Attrs extends AnyAttrs = AnyAttrs

NodeAction(attrs, ...children): Node

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.

Parameters

attrs: null | Attrs

• ...children: NodeChild[]

Returns

Node

NodeAction(...children): Node

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.

Parameters

• ...children: NodeChild[]

Returns

Node

Properties

isActive()

isActive: (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.

Parameters

attrs?: Attrs

Returns

boolean


NodeAttrOptions<NodeName, AttrName, AttrType>

Extends

Type Parameters

NodeName extends string = string

AttrName extends string = string

AttrType = any

Properties

attr

attr: AttrName

The name of the attribute.

default?

optional 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.

Inherited from

AttrSpec.default

parseDOM()?

optional parseDOM: (node) => any

Parses the attribute value from the DOM.

Parameters

node: HTMLElement

Returns

any

splittable?

optional 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
ts
undefined

toDOM()?

optional toDOM: (value) => null | void | [string, string]

Returns the attribute key and value to be set on the DOM node.

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

Parameters

value: any

Returns

null | void | [string, string]

type

type: NodeName

The name of the node type.

validate?

optional validate: string | (value) => 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.

Inherited from

AttrSpec.validate


NodeJSON

A JSON representation of the prosemirror node.

Properties

attrs?

optional attrs: Record<string, any>

content?

optional content: NodeJSON[]

marks?

optional marks: any[]

text?

optional text: string

type

type: string


NodeSpecOptions<NodeName, Attrs>

Extends

Type Parameters

NodeName extends string = string

Attrs extends AnyAttrs = AnyAttrs

Properties

attrs?

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

The attributes that nodes of this type get.

Overrides

NodeSpec.attrs

name

name: NodeName

The name of the node type.

topNode?

optional 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

Properties

constructor

constructor: NodeViewConstructor

name

name: string


RemoveMarkOptions

Properties

attrs?

optional attrs: null | Attrs

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

from?

optional from: number

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

to?

optional to: number

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

type

type: string | MarkType

The type of the mark to remove.


RemoveNodeOptions

Properties

pos?

optional pos: number

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

type

type: string | NodeType

The type of the node to remove.


SelectionJSON

A JSON representation of the prosemirror selection.

Properties

anchor

anchor: number

head: number

type

type: string


SetBlockTypeOptions

Properties

attrs?

optional attrs: null | Attrs

from?

optional from: number

to?

optional to: number

type

type: string | NodeType


SetNodeAttrsOptions

Properties

attrs

attrs: Attrs

The attributes to set.

pos?

optional pos: number

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

type

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.

Properties

doc

doc: NodeJSON

The main ProseMirror doc.

selection

selection: SelectionJSON

The current selection.


StepJSON

A JSON representation of the prosemirror step.

Indexable

[x: string]: unknown

Properties

stepType

stepType: string

The type of the step.


ToggleMarkOptions

Properties

attrs?

optional attrs: null | Attrs

type

type: string | MarkType


ToggleNodeOptions

Properties

attrs?

optional attrs: null | Attrs

The attributes of the node to toggle.

type

type: string | NodeType

The type of the node to toggle.


UnsetBlockTypeOptions

Properties

from?

optional from: number

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

to?

optional to: number

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


UnsetMarkOptions

Properties

from?

optional from: number

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

to?

optional to: number

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


WrapOptions

Properties

attrs?

optional attrs: null | Attrs

nodeType

nodeType: NodeType


AnyAttrs

AnyAttrs: Attrs

An object holding the attributes of a node.


AttrSpec<AttrType>

AttrSpec<AttrType>: object

Type Parameters

AttrType = any

Type declaration

NameTypeDescription
defaultAttrTypeThe 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.
validatestring | (value) => voidA 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 `

ClickHandler()

ClickHandler: (view, pos, event) => boolean | void

Parameters

view: EditorView

pos: number

event: MouseEvent

Returns

boolean | void


ClickOnHandler()

ClickOnHandler: (view, pos, node, nodePos, event, direct) => boolean | void

Parameters

view: EditorView

pos: number

node: Node

nodePos: number

event: MouseEvent

direct: boolean

Returns

boolean | void


DOMEventHandler()<Event>

DOMEventHandler<Event>: (view, event) => boolean | void

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 Parameters

Event extends keyof DOMEventMap = string

Parameters

view: EditorView

event: DOMEventMap[Event]

Returns

boolean | void


DocChangeHandler()

DocChangeHandler: (view, prevState) => void

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

Parameters

view: EditorView

The editor view.

prevState: EditorState

The previous editor state.

Returns

void


DoubleClickHandler()

DoubleClickHandler: (view, pos, event) => boolean | void

Parameters

view: EditorView

pos: number

event: MouseEvent

Returns

boolean | void


DoubleClickOnHandler()

DoubleClickOnHandler: (view, pos, node, nodePos, event, direct) => boolean | void

Parameters

view: EditorView

pos: number

node: Node

nodePos: number

event: MouseEvent

direct: boolean

Returns

boolean | void


DropHandler()

DropHandler: (view, event, slice, moved) => boolean | void

Parameters

view: EditorView

event: DragEvent

slice: Slice

moved: boolean

Returns

boolean | void


ExtractCommandActions<E>

ExtractCommandActions<E>: ToCommandAction<ExtractCommands<E>>

Extracts the CommandActions from an extension type.

Type Parameters

E extends Extension


ExtractCommandAppliers<E>

ExtractCommandAppliers<E>: ExtractCommandActions<E>

Type Parameters

E extends Extension

Deprecated

Use ExtractCommandActions instead.


ExtractCommandCreators<E>

ExtractCommandCreators<E>: ToCommandCreators<ExtractCommands<E>>

Type Parameters

E extends Extension


ExtractMarkActions<E>

ExtractMarkActions<E>: ToMarkAction<ExtractMarks<E>>

Extracts the MarkActions from an extension type.

Type Parameters

E extends Extension


ExtractMarks<E>

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

Type Parameters

E extends Extension


ExtractNodeActions<E>

ExtractNodeActions<E>: ToNodeAction<ExtractNodes<E>>

Extracts the NodeActions from an extension type.

Type Parameters

E extends Extension


ExtractNodes<E>

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

Type Parameters

E extends Extension


FocusChangeHandler()

FocusChangeHandler: (hasFocus) => void

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

Parameters

hasFocus: boolean

Whether the editor has focus.

Returns

void


KeyDownHandler()

KeyDownHandler: (view, event) => boolean | void

Parameters

view: EditorView

event: KeyboardEvent

Returns

boolean | void


KeyPressHandler()

KeyPressHandler: (view, event) => boolean | void

Parameters

view: EditorView

event: KeyboardEvent

Returns

boolean | void


MarkBuilder

MarkBuilder: MarkAction

Deprecated

Use type MarkAction instead.


MountHandler()

MountHandler: (view) => void

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

Parameters

view: EditorView

The editor view.

Returns

void


NodeBuilder

NodeBuilder: NodeAction

Deprecated

Use type NodeAction instead.


NodeChild

NodeChild: ProseMirrorNode | string | NodeChild[]

Available children parameters for NodeAction and MarkAction.


NodeContent

NodeContent: ProseMirrorNode | ProseMirrorFragment | NodeContent[]


PasteHandler()

PasteHandler: (view, event, slice) => boolean | void

Parameters

view: EditorView

event: ClipboardEvent

slice: Slice

Returns

boolean | void


ScrollToSelectionHandler()

ScrollToSelectionHandler: (view) => boolean

Parameters

view: EditorView

Returns

boolean


TextInputHandler()

TextInputHandler: (view, from, to, text) => boolean | void

Parameters

view: EditorView

from: number

to: number

text: string

Returns

boolean | void


TripleClickHandler()

TripleClickHandler: (view, pos, event) => boolean | void

Parameters

view: EditorView

pos: number

event: MouseEvent

Returns

boolean | void


TripleClickOnHandler()

TripleClickOnHandler: (view, pos, node, nodePos, event, direct) => boolean | void

Parameters

view: EditorView

pos: number

node: Node

nodePos: number

event: MouseEvent

direct: boolean

Returns

boolean | void


UnmountHandler()

UnmountHandler: () => void

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

Returns

void


UpdateHandler()

UpdateHandler: (view, prevState) => void

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

Parameters

view: EditorView

The editor view.

prevState: EditorState

The previous editor state.

Returns

void


addMark()

addMark(options): Command

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

Parameters

options: AddMarkOptions

Returns

Command


canUseRegexLookbehind()

canUseRegexLookbehind(): boolean

Returns

boolean


clsx()

clsx(...args): string

A utility for constructing className strings conditionally.

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

Parameters

• ...args: (undefined | null | string | boolean)[]

Returns

string


collectNodes()

collectNodes(content): ProseMirrorNode[]

Collects all nodes from a given content.

Parameters

content: NodeContent

Returns

ProseMirrorNode[]


createEditor()

createEditor<E>(options): Editor<E>

Type Parameters

E extends Extension<ExtensionTyping<any, any, any>>

Parameters

options: EditorOptions<E>

Returns

Editor<E>


defineBaseCommands()

defineBaseCommands(): Extension<object>

Add some base commands

Returns

Extension<object>

NameType
Commandsobject
Commands.addMark[AddMarkOptions]
Commands.insertNode[InsertNodeOptions]
Commands.insertText[object]
Commands.removeMark[RemoveMarkOptions]
Commands.removeNode[RemoveNodeOptions]
Commands.selectAll[]
Commands.setBlockType[SetBlockTypeOptions]
Commands.setNodeAttrs[SetNodeAttrsOptions]
Commands.unsetBlockType[UnsetBlockTypeOptions]
Commands.unsetMark[UnsetMarkOptions]
Commands.wrap[WrapOptions]
Marksnever
Nodesnever

defineBaseKeymap()

defineBaseKeymap(options?): Extension<ExtensionTyping<any, any, any>>

Defines some basic key bindings.

Parameters

options?

options.priority?: Priority

The priority of the keymap.

Default

ts
Priority.low

Returns

Extension<ExtensionTyping<any, any, any>>


defineClickHandler()

defineClickHandler(handler): Extension<ExtensionTyping<any, any, any>>

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

Parameters

handler: ClickHandler

Returns

Extension<ExtensionTyping<any, any, any>>


defineClickOnHandler()

defineClickOnHandler(handler): Extension<ExtensionTyping<any, any, any>>

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

Parameters

handler: ClickOnHandler

Returns

Extension<ExtensionTyping<any, any, any>>


defineCommands()

defineCommands<T>(commands): Extension<object>

Type Parameters

T extends Record<string, CommandCreator> = Record<string, CommandCreator>

Parameters

commands: T

Returns

Extension<object>

NameType
Commands{ [K in keyof T]: Parameters<T[K]> }
Marksnever
Nodesnever

defineDOMEventHandler()

defineDOMEventHandler<Event>(event, handler): Extension<ExtensionTyping<any, any, any>>

Register a new event handler for the given event type.

Type Parameters

Event extends keyof DOMEventMap = string

Parameters

event: Event

handler: DOMEventHandler<Event>

Returns

Extension<ExtensionTyping<any, any, any>>


defineDefaultState()

defineDefaultState(__namedParameters): Extension

Parameters

__namedParameters: DefaultStateOptions

Returns

Extension


defineDoc()

defineDoc(): Extension<object>

Returns

Extension<object>

NameType
Commandsnever
Marksnever
Nodesobject
Nodes.docAttrs

defineDocChangeHandler()

defineDocChangeHandler(handler): Extension<ExtensionTyping<any, any, any>>

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

Parameters

handler: DocChangeHandler

Returns

Extension<ExtensionTyping<any, any, any>>


defineDoubleClickHandler()

defineDoubleClickHandler(handler): Extension<ExtensionTyping<any, any, any>>

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

Parameters

handler: DoubleClickHandler

Returns

Extension<ExtensionTyping<any, any, any>>


defineDoubleClickOnHandler()

defineDoubleClickOnHandler(handler): Extension<ExtensionTyping<any, any, any>>

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

Parameters

handler: DoubleClickOnHandler

Returns

Extension<ExtensionTyping<any, any, any>>


defineDropHandler()

defineDropHandler(handler): Extension<ExtensionTyping<any, any, any>>

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

Parameters

handler: DropHandler

Returns

Extension<ExtensionTyping<any, any, any>>


defineFocusChangeHandler()

defineFocusChangeHandler(handler): Extension<ExtensionTyping<any, any, any>>

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

Parameters

handler: FocusChangeHandler

Returns

Extension<ExtensionTyping<any, any, any>>


defineHistory()

defineHistory(__namedParameters): Extension<object>

Add undo/redo history to the editor.

Parameters

__namedParameters: HistoryOptions = {}

Returns

Extension<object>

NameType
Commandsobject
Commands.redo[]
Commands.undo[]
Marksnever
Nodesnever

defineKeyDownHandler()

defineKeyDownHandler(handler): Extension<ExtensionTyping<any, any, any>>

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

Parameters

handler: KeyDownHandler

Returns

Extension<ExtensionTyping<any, any, any>>


defineKeyPressHandler()

defineKeyPressHandler(handler): Extension<ExtensionTyping<any, any, any>>

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

Parameters

handler: KeyPressHandler

Returns

Extension<ExtensionTyping<any, any, any>>


defineKeymap()

defineKeymap(keymap): Extension

Parameters

keymap: Keymap

Returns

Extension


defineMarkAttr()

defineMarkAttr<MarkType, AttrName, AttrType>(options): Extension<object>

Type Parameters

MarkType extends string = string

AttrName extends string = string

AttrType = any

Parameters

options: MarkAttrOptions<MarkType, AttrName, AttrType>

Returns

Extension<object>

NameType
Commandsnever
Marks{ [K in MarkType]: AttrType }
Nodesnever

defineMarkSpec()

defineMarkSpec<Mark, Attrs>(options): Extension<object>

Type Parameters

Mark extends string

Attrs extends Attrs = Attrs

Parameters

options: MarkSpecOptions<Mark, Attrs>

Returns

Extension<object>

NameType
Commandsnever
Marks{ [K in Mark]: Attrs }
Nodesnever

defineMountHandler()

defineMountHandler(handler): Extension<ExtensionTyping<any, any, any>>

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

Parameters

handler: MountHandler

Returns

Extension<ExtensionTyping<any, any, any>>


defineNodeAttr()

defineNodeAttr<NodeType, AttrName, AttrType>(options): Extension<object>

Defines an attribute for a node type.

Type Parameters

NodeType extends string = string

AttrName extends string = string

AttrType = any

Parameters

options: NodeAttrOptions<NodeType, AttrName, AttrType>

Returns

Extension<object>

NameType
Commandsnever
Marksnever
Nodes{ [K in NodeType]: { [K in AttrName]: AttrType } }

defineNodeSpec()

defineNodeSpec<Node, Attrs>(options): Extension<object>

Defines a node type.

Type Parameters

Node extends string

Attrs extends Attrs = Attrs

Parameters

options: NodeSpecOptions<Node, Attrs>

Returns

Extension<object>

NameType
Commandsnever
Marksnever
Nodes{ [K in Node]: Attrs }

defineNodeView()

defineNodeView(options): Extension

Parameters

options: NodeViewOptions

Returns

Extension


defineParagraph()

defineParagraph(): Extension<object>

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

Returns

Extension<object>

NameType
Commandsnever
Marksnever
Nodesobject
Nodes.paragraphAttrs

definePasteHandler()

definePasteHandler(handler): Extension<ExtensionTyping<any, any, any>>

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

Parameters

handler: PasteHandler

Returns

Extension<ExtensionTyping<any, any, any>>


definePlugin()

definePlugin(plugin): Extension

Adds a ProseMirror plugin to the editor.

Parameters

plugin: Plugin<any> | Plugin<any>[] | (context) => Plugin<any> | Plugin<any>[]

The ProseMirror plugin to add, or an array of plugins, or a function that returns one or multiple plugins.

Returns

Extension


defineScrollToSelectionHandler()

defineScrollToSelectionHandler(handler): Extension<ExtensionTyping<any, any, any>>

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

Parameters

handler: ScrollToSelectionHandler

Returns

Extension<ExtensionTyping<any, any, any>>


defineText()

defineText(): Extension<object>

Returns

Extension<object>

NameType
Commandsnever
Marksnever
Nodesobject
Nodes.textAttrs

defineTextInputHandler()

defineTextInputHandler(handler): Extension<ExtensionTyping<any, any, any>>

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

Parameters

handler: TextInputHandler

Returns

Extension<ExtensionTyping<any, any, any>>


defineTripleClickHandler()

defineTripleClickHandler(handler): Extension<ExtensionTyping<any, any, any>>

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

Parameters

handler: TripleClickHandler

Returns

Extension<ExtensionTyping<any, any, any>>


defineTripleClickOnHandler()

defineTripleClickOnHandler(handler): Extension<ExtensionTyping<any, any, any>>

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

Parameters

handler: TripleClickOnHandler

Returns

Extension<ExtensionTyping<any, any, any>>


defineUnmountHandler()

defineUnmountHandler(handler): Extension<ExtensionTyping<any, any, any>>

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

Parameters

handler: UnmountHandler

Returns

Extension<ExtensionTyping<any, any, any>>


defineUpdateHandler()

defineUpdateHandler(handler): Extension<ExtensionTyping<any, any, any>>

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

Parameters

handler: UpdateHandler

Returns

Extension<ExtensionTyping<any, any, any>>


elementFromJSON()

elementFromJSON(json, options): HTMLElement

Parse a ProseMirror document JSON object to a HTML element.

Parameters

json: NodeJSON

options: JSONParserOptions & DOMSerializerOptions & DOMDocumentOptions

Returns

HTMLElement


elementFromNode()

elementFromNode(node, options?): HTMLElement

Serialize a ProseMirror node to a HTML element.

Parameters

node: Node

options?: DOMSerializerOptions & DOMDocumentOptions

Returns

HTMLElement


expandMark()

expandMark(options): Command

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

Parameters

options: ExpandMarkOptions

Returns

Command


htmlFromJSON()

htmlFromJSON(json, options): string

Parse a ProseMirror document JSON object to a HTML string.

Parameters

json: NodeJSON

options: JSONParserOptions & DOMSerializerOptions & DOMDocumentOptions

Returns

string


htmlFromNode()

htmlFromNode(node, options?): string

Serialize a ProseMirror node to a HTML string

Parameters

node: Node

options?: DOMSerializerOptions & DOMDocumentOptions

Returns

string


insertNode()

insertNode(options): Command

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

Parameters

options: InsertNodeOptions

Returns

Command


jsonFromHTML()

jsonFromHTML(html, options): NodeJSON

Parse a HTML string to a ProseMirror document JSON object.

Parameters

html: string

options: DOMDocumentOptions & DOMParserOptions & JSONParserOptions

Returns

NodeJSON


jsonFromNode()

jsonFromNode(node): NodeJSON

Return a JSON object representing this node.

Parameters

node: Node

Returns

NodeJSON


jsonFromState()

jsonFromState(state): StateJSON

Return a JSON object representing this state.

Parameters

state: EditorState

Returns

StateJSON


nodeFromElement()

nodeFromElement(element, options): ProseMirrorNode

Parse a HTML element to a ProseMirror node.

Parameters

element: Node

options: DOMParserOptions & JSONParserOptions

Returns

ProseMirrorNode


nodeFromHTML()

nodeFromHTML(html, options): ProseMirrorNode

Parse a HTML string to a ProseMirror node.

Parameters

html: string

options: DOMParserOptions & JSONParserOptions & DOMDocumentOptions

Returns

ProseMirrorNode


nodeFromJSON()

nodeFromJSON(json, options): ProseMirrorNode

Parse a JSON object to a ProseMirror node.

Parameters

json: NodeJSON

options: JSONParserOptions

Returns

ProseMirrorNode


removeMark()

removeMark(options): Command

Returns a command that removes the given mark.

Parameters

options: RemoveMarkOptions

Returns

Command


removeNode()

removeNode(options): Command

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

Parameters

options: RemoveNodeOptions

Returns

Command


setBlockType()

setBlockType(options): Command

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

Parameters

options: SetBlockTypeOptions

Returns

Command


setNodeAttrs()

setNodeAttrs(options): Command

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

Parameters

options: SetNodeAttrsOptions

Returns

Command


stateFromJSON()

stateFromJSON(json, options): EditorState

Parse a JSON object to a ProseMirror state.

Parameters

json: StateJSON

options: JSONParserOptions

Returns

EditorState


toggleMark()

toggleMark(__namedParameters): Command

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

Parameters

__namedParameters: ToggleMarkOptions

Returns

Command


toggleNode()

toggleNode(__namedParameters): Command

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

Parameters

__namedParameters: ToggleNodeOptions

Returns

Command


union()

union<E>(extension): UnionExtension<E>

Merge multiple extensions into one.

Type Parameters

E extends Extension<ExtensionTyping<any, any, any>> | readonly Extension<ExtensionTyping<any, any, any>>[]

Parameters

extension: E

Returns

UnionExtension<E>

Throws

If no extensions are provided.

Example

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

unsetBlockType()

unsetBlockType(options?): Command

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

Parameters

options?: UnsetBlockTypeOptions

Returns

Command


unsetMark()

unsetMark(options?): Command

Returns a command that removes all marks.

Parameters

options?: UnsetMarkOptions

Returns

Command


withPriority()

withPriority<T>(extension, priority): T

Return an new extension with the given priority.

Type Parameters

T extends Extension<ExtensionTyping<any, any, any>>

Parameters

extension: T

priority: Priority

Returns

T

Example

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

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

wrap()

wrap(__namedParameters): Command

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

Parameters

__namedParameters: WrapOptions

Returns

Command