prosekit/core
Priority
ProseKit extension priority.
Enumeration Members
Enumeration Member | Value |
---|---|
default | 2 |
high | 3 |
highest | 4 |
low | 1 |
lowest | 0 |
Editor<E>
Extended by
Type Parameters
• E extends Extension
= any
Accessors
commands
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.
Returns
ToCommandAction
<{ [KeyType in string | number | symbol]: UnionToIntersection<ExtractTyping<E>["Commands"] extends undefined ? never : 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"] extends undefined ? never : ExtractTyping<E>["Marks"]>[KeyType] }>>
All MarkActions defined by the editor.
Returns
ToMarkAction
<SimplifyDeeper
<{ [KeyType in string | number | symbol]: UnionToIntersection<ExtractTyping<E>["Marks"] extends undefined ? never : 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"] extends undefined ? never : ExtractTyping<E>["Nodes"]>[KeyType] }>>
All NodeActions defined by the editor.
Returns
ToNodeAction
<SimplifyDeeper
<{ [KeyType in string | number | symbol]: UnionToIntersection<ExtractTyping<E>["Nodes"] extends undefined ? never : 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
view
get
view():EditorView
The editor view.
Returns
Methods
blur()
blur():
void
Blur the editor.
Returns
void
canExec()
canExec(
command
):boolean
Check if the given command can be executed. Return true
if the command can be executed, otherwise false
.
Parameters
• command: Command
Returns
boolean
exec()
exec(
command
):boolean
Execute the given command. Return true
if the command was successfully executed, otherwise false
.
Parameters
• command: Command
Returns
boolean
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
setContent()
setContent(
content
,selection
?):void
Update the editor's document and selection.
Parameters
• content: string
| Node
| NodeJSON
| HTMLElement
The new document to set. It can be one of the following:
- A ProseMirror node instance
- A ProseMirror node JSON object
- An HTML string
- An HTML element instance
• selection?: Selection
| "start"
| SelectionJSON
| "end"
Optional. Specifies the new selection. It can be one of the following:
- A ProseMirror selection instance
- A ProseMirror selection JSON object
- The string "start" (to set selection at the beginning, default value)
- The string "end" (to set selection at the end)
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 canExec
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 canExec
method to check if the command can be applied.
Parameters
• ...args: Args
Returns
boolean
Methods
canApply()
canApply(...
args
):boolean
An alias for canExec
.
Parameters
• ...args: Args
Returns
boolean
Deprecated
Use canExec
instead.
canExec()
canExec(...
args
):boolean
Check if the current command can be executed. Return true
if the command can be executed, otherwise false
.
Parameters
• ...args: Args
Returns
boolean
DefaultStateOptions
Properties
defaultContent?
optional
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?
optional
defaultDoc:NodeJSON
A JSON object representing the starting document to use when creating the editor.
Deprecated
Use defaultContent
instead.
defaultHTML?
optional
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?
optional
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
Properties
document?
optional
document:Document
DOMParserOptions
Extends
Properties
DOMParser?
optional
DOMParser: typeofDOMParser
DOMSerializerOptions
Properties
DOMSerializer?
optional
DOMSerializer: typeofDOMSerializer
EditorOptions<E>
Type Parameters
• E extends Extension
Properties
defaultContent?
optional
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?
optional
defaultDoc:NodeJSON
A JSON object representing the starting document to use when creating the editor.
Deprecated
Use defaultContent
instead.
defaultHTML?
optional
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?
optional
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
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.
FindParentNodeResult
Properties
depth
depth:
number
The depth of the node.
node
node:
Node
The closest parent node that satisfies the predicate.
pos
pos:
number
The position directly before the node.
start
start:
number
The position at the start of the node.
HistoryOptions
Options for defineHistory.
Properties
depth?
optional
depth:number
The amount of history events that are collected before the oldest events are discarded.
Default
200
newGroupDelay?
optional
newGroupDelay:number
The delay in milliseconds between changes after which a new group should be started.
Default
250
InsertDefaultBlockOptions
Properties
pos?
optional
pos:number
The position to insert the node at. By default it will insert after the current selection.
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
AttrSpec
<AttrType
>
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
) =>AttrType
Parses the attribute value from the DOM.
Parameters
• node: HTMLElement
Returns
AttrType
toDOM()?
optional
toDOM: (value
) =>undefined
|null
| [string
,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.
Parameters
• value: AttrType
The value of the attribute of current ProseMirror node.
Returns
undefined
| null
| [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
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
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
AttrSpec
<AttrType
>
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
) =>AttrType
Parses the attribute value from the DOM.
Parameters
• node: HTMLElement
Returns
AttrType
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
undefined
toDOM()?
optional
toDOM: (value
) =>undefined
|null
| [string
,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.
Parameters
• value: AttrType
The value of the attribute of current ProseMirror node.
Returns
undefined
| null
| [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:object
[]
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
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
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
The optional attributes to set on the mark.
enterInlineAtoms?
optional
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?
optional
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
type:
string
|MarkType
The mark type to toggle.
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.
ToggleWrapOptions
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
Optional attributes to apply to the node.
nodeType?
optional
nodeType:NodeType
Deprecated
Use nodeSpec
instead.
type
type:
string
|NodeType
The node type to wrap the selected textblock with.
AnyAttrs
AnyAttrs:
Attrs
An object holding the attributes of a node.
AttrSpec<AttrType>
AttrSpec<
AttrType
>:object
Type Parameters
• AttrType = any
Type declaration
Name | Type | Description |
---|---|---|
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. |
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 ` |
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
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
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
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
[]
Deprecated
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
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
collectChildren()
collectChildren(
parent
):ProseMirrorNode
[]
Collects all children of a node or a fragment, and returns them as an array.
Parameters
Returns
collectNodes()
collectNodes(
content
):ProseMirrorNode
[]
Collects all nodes from a given content.
Parameters
• content: NodeContent
Returns
Deprecated
Use collectChildren
instead.
createEditor()
createEditor<
E
>(options
):Editor
<E
>
Type Parameters
• E extends Extension
<ExtensionTyping
<any
, any
, any
>>
Parameters
• options: EditorOptions
<E
>
Returns
Editor
<E
>
defineBaseCommands()
defineBaseCommands():
BaseCommandsExtension
Add some base commands
Returns
BaseCommandsExtension
defineBaseKeymap()
defineBaseKeymap(
options
?):BaseKeymapExtension
Defines some basic key bindings.
Parameters
• options?
• options.priority?: Priority
The priority of the keymap.
Default
Priority.low
Returns
BaseKeymapExtension
defineClickHandler()
defineClickHandler(
handler
):PlainExtension
See https://prosemirror.net/docs/ref/#view.EditorProps.handleClick
Parameters
• handler: ClickHandler
Returns
PlainExtension
defineClickOnHandler()
defineClickOnHandler(
handler
):PlainExtension
See https://prosemirror.net/docs/ref/#view.EditorProps.handleClickOn
Parameters
• handler: ClickOnHandler
Returns
PlainExtension
defineCommands()
defineCommands<
T
>(commands
):Extension
<object
>
Type Parameters
• T extends Record
<string
, CommandCreator
> = Record
<string
, CommandCreator
>
Parameters
• commands: T
Returns
Extension
<object
>
Name | Type |
---|---|
Commands | { [K in keyof T]: Parameters<T[K]> } |
defineDefaultState()
defineDefaultState(
options
):PlainExtension
Define a default state for the editor.
Parameters
• options: DefaultStateOptions
Returns
PlainExtension
defineDoc()
defineDoc():
DocExtension
Returns
DocExtension
defineDocChangeHandler()
defineDocChangeHandler(
handler
):PlainExtension
Registers a event handler that is called when the editor document is changed.
Parameters
• handler: DocChangeHandler
Returns
PlainExtension
defineDOMEventHandler()
defineDOMEventHandler<
Event
>(event
,handler
):PlainExtension
Register a new event handler for the given event type.
Type Parameters
• Event extends keyof DOMEventMap
= string
Parameters
• event: Event
• handler: DOMEventHandler
<Event
>
Returns
PlainExtension
defineDoubleClickHandler()
defineDoubleClickHandler(
handler
):PlainExtension
See https://prosemirror.net/docs/ref/#view.EditorProps.handleDoubleClick
Parameters
• handler: DoubleClickHandler
Returns
PlainExtension
defineDoubleClickOnHandler()
defineDoubleClickOnHandler(
handler
):PlainExtension
See https://prosemirror.net/docs/ref/#view.EditorProps.handleDoubleClickOn
Parameters
• handler: DoubleClickOnHandler
Returns
PlainExtension
defineDropHandler()
defineDropHandler(
handler
):PlainExtension
See https://prosemirror.net/docs/ref/#view.EditorProps.handleDrop
Parameters
• handler: DropHandler
Returns
PlainExtension
defineFocusChangeHandler()
defineFocusChangeHandler(
handler
):PlainExtension
Registers a event handler that is called when the editor gains or loses focus.
Parameters
• handler: FocusChangeHandler
Returns
PlainExtension
defineHistory()
defineHistory(
options
):HistoryExtension
Add undo/redo history to the editor.
Parameters
• options: HistoryOptions
= {}
Returns
HistoryExtension
defineKeyDownHandler()
defineKeyDownHandler(
handler
):PlainExtension
See https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyDown
Parameters
• handler: KeyDownHandler
Returns
PlainExtension
defineKeymap()
defineKeymap(
keymap
):PlainExtension
Parameters
• keymap: Keymap
Returns
PlainExtension
defineKeyPressHandler()
defineKeyPressHandler(
handler
):PlainExtension
See https://prosemirror.net/docs/ref/#view.EditorProps.handleKeyPress
Parameters
• handler: KeyPressHandler
Returns
PlainExtension
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
>
Name | Type |
---|---|
Marks | { [K in MarkType]: AttrType } |
defineMarkSpec()
defineMarkSpec<
Mark
,Attrs
>(options
):Extension
<object
>
Type Parameters
• Mark extends string
Parameters
• options: MarkSpecOptions
<Mark
, Attrs
>
Returns
Extension
<object
>
Name | Type |
---|---|
Marks | { [K in Mark]: Attrs } |
defineMountHandler()
defineMountHandler(
handler
):PlainExtension
Registers a event handler that is called when the editor view is mounted.
Parameters
• handler: MountHandler
Returns
PlainExtension
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
>
Name | Type |
---|---|
Nodes | { [K in NodeType]: { [K in AttrName]: AttrType } } |
defineNodeSpec()
defineNodeSpec<
Node
,Attrs
>(options
):Extension
<object
>
Defines a node type.
Type Parameters
• Node extends string
Parameters
• options: NodeSpecOptions
<Node
, Attrs
>
Returns
Extension
<object
>
Name | Type |
---|---|
Nodes | { [K in Node]: Attrs } |
defineNodeView()
defineNodeView(
options
):Extension
Parameters
• options: NodeViewOptions
Returns
defineParagraph()
defineParagraph():
ParagraphExtension
Defines a paragraph node spec as the highest priority, because it should be the default block node for most cases.
Returns
ParagraphExtension
definePasteHandler()
definePasteHandler(
handler
):PlainExtension
See https://prosemirror.net/docs/ref/#view.EditorProps.handlePaste
Parameters
• handler: PasteHandler
Returns
PlainExtension
definePlugin()
definePlugin(
plugin
):PlainExtension
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
PlainExtension
defineScrollToSelectionHandler()
defineScrollToSelectionHandler(
handler
):PlainExtension
See https://prosemirror.net/docs/ref/#view.EditorProps.handleScrollToSelection
Parameters
• handler: ScrollToSelectionHandler
Returns
PlainExtension
defineText()
defineText():
TextExtension
Returns
TextExtension
defineTextInputHandler()
defineTextInputHandler(
handler
):PlainExtension
See https://prosemirror.net/docs/ref/#view.EditorProps.handleTextInput
Parameters
• handler: TextInputHandler
Returns
PlainExtension
defineTripleClickHandler()
defineTripleClickHandler(
handler
):PlainExtension
See https://prosemirror.net/docs/ref/#view.EditorProps.handleTripleClick
Parameters
• handler: TripleClickHandler
Returns
PlainExtension
defineTripleClickOnHandler()
defineTripleClickOnHandler(
handler
):PlainExtension
See https://prosemirror.net/docs/ref/#view.EditorProps.handleTripleClickOn
Parameters
• handler: TripleClickOnHandler
Returns
PlainExtension
defineUnmountHandler()
defineUnmountHandler(
handler
):PlainExtension
Registers a event handler that is called when the editor view is unmounted.
Parameters
• handler: UnmountHandler
Returns
PlainExtension
defineUpdateHandler()
defineUpdateHandler(
handler
):PlainExtension
Registers a event handler that is called when the editor state is updated.
Parameters
• handler: UpdateHandler
Returns
PlainExtension
elementFromJSON()
elementFromJSON(
json
,options
):HTMLElement
Parse a ProseMirror document JSON object to a HTML element.
Parameters
• json: NodeJSON
• options: JSONParserOptions
& DOMSerializerOptions
& DOMDocumentOptions
Returns
elementFromNode()
elementFromNode(
node
,options
?):HTMLElement
Serialize a ProseMirror node to a HTML element.
Parameters
• node: Node
• options?: DOMSerializerOptions
& DOMDocumentOptions
Returns
expandMark()
expandMark(
options
):Command
Expands the selection to include the entire mark at the current position.
Parameters
• options: ExpandMarkOptions
Returns
findParentNode()
findParentNode(
predicate
,$pos
):FindParentNodeResult
|undefined
Find the closest parent node that satisfies the predicate.
Parameters
• predicate
The predicate to test the parent node.
• $pos: ResolvedPos
The position to start searching from.
Returns
FindParentNodeResult
| undefined
findParentNodeOfType()
findParentNodeOfType(
type
,$pos
):FindParentNodeResult
|undefined
Finds the closest parent node that matches the given node type.
Parameters
• type: string
| NodeType
The type of the node to find.
• $pos: ResolvedPos
The position to start searching from.
Returns
FindParentNodeResult
| undefined
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
insertDefaultBlock()
insertDefaultBlock(
options
?):Command
Returns a command that inserts a default block after current selection or at the given position.
Parameters
• options?: InsertDefaultBlockOptions
Returns
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
isAllSelection()
isAllSelection(
sel
):sel is AllSelection
Checks if the given object is a AllSelection
instance.
Parameters
• sel: Selection
Returns
sel is AllSelection
isFragment()
isFragment(
fragment
):fragment is Fragment
Checks if the given object is a Fragment
instance.
Parameters
• fragment: unknown
Returns
fragment is Fragment
isMark()
isMark(
mark
):mark is Mark
Checks if the given object is a Mark
instance.
Parameters
• mark: unknown
Returns
mark is Mark
isNodeSelection()
isNodeSelection(
sel
):sel is NodeSelection
Checks if the given object is a NodeSelection
instance.
Parameters
• sel: Selection
Returns
sel is NodeSelection
isProseMirrorNode()
isProseMirrorNode(
node
):node is Node
Checks if the given object is a ProseMirrorNode
instance.
Parameters
• node: unknown
Returns
node is Node
isSelection()
isSelection(
sel
):sel is Selection
Checks if the given object is a Selection
instance.
Parameters
• sel: unknown
Returns
sel is Selection
isSlice()
isSlice(
slice
):slice is Slice
Checks if the given object is a Slice
instance.
Parameters
• slice: unknown
Returns
slice is Slice
isTextSelection()
isTextSelection(
sel
):sel is TextSelection
Checks if the given object is a TextSelection
instance.
Parameters
• sel: Selection
Returns
sel is TextSelection
jsonFromHTML()
jsonFromHTML(
html
,options
):NodeJSON
Parse a HTML string to a ProseMirror document JSON object.
Parameters
• html: string
• options: DOMDocumentOptions
& DOMParserOptions
& JSONParserOptions
Returns
jsonFromNode()
jsonFromNode(
node
):NodeJSON
Return a JSON object representing this node.
Parameters
• node: Node
Returns
jsonFromState()
jsonFromState(
state
):StateJSON
Return a JSON object representing this state.
Parameters
• state: EditorState
Returns
nodeFromElement()
nodeFromElement(
element
,options
):ProseMirrorNode
Parse a HTML element to a ProseMirror node.
Parameters
• element: Node
• options: DOMParserOptions
& JSONParserOptions
Returns
nodeFromHTML()
nodeFromHTML(
html
,options
):ProseMirrorNode
Parse a HTML string to a ProseMirror node.
Parameters
• html: string
• options: DOMParserOptions
& JSONParserOptions
& DOMDocumentOptions
Returns
nodeFromJSON()
nodeFromJSON(
json
,options
):ProseMirrorNode
Parse a JSON object to a ProseMirror node.
Parameters
• json: NodeJSON
• options: JSONParserOptions
Returns
removeMark()
removeMark(
options
):Command
Returns a command that removes the given mark.
Parameters
• options: RemoveMarkOptions
Returns
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
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
setNodeAttrs()
setNodeAttrs(
options
):Command
Returns a command that set the attributes of the current node.
Parameters
• options: SetNodeAttrsOptions
Returns
setSelectionAround()
setSelectionAround(
tr
,pos
):void
Parameters
• tr: Transaction
• pos: number
Returns
void
stateFromJSON()
stateFromJSON(
json
,options
):EditorState
Parse a JSON object to a ProseMirror state.
Parameters
• json: StateJSON
• options: JSONParserOptions
Returns
toggleMark()
toggleMark(
options
):Command
Returns a command that toggles the given mark with the given attributes.
Parameters
• options: ToggleMarkOptions
Returns
toggleNode()
toggleNode(
options
):Command
Returns a command that set the selected textblocks to the given node type with the given attributes.
Parameters
• options: ToggleNodeOptions
Returns
toggleWrap()
toggleWrap(
options
):Command
Toggle between wrapping an inactive node with the provided node type, and lifting it up into it's parent.
Parameters
• options: ToggleWrapOptions
Returns
union()
union(exts)
union<
E
>(...exts
):Union
<E
>
Merges multiple extensions into one. You can pass multiple extensions as arguments or a single array containing multiple extensions.
Type Parameters
• E extends readonly Extension
<ExtensionTyping
<any
, any
, any
>>[]
Parameters
• ...exts: E
Returns
Union
<E
>
Throws
If no extensions are provided.
Examples
function defineFancyNodes() {
return union(
defineFancyParagraph(),
defineFancyHeading(),
)
}
function defineFancyNodes() {
return union([
defineFancyParagraph(),
defineFancyHeading(),
])
}
union(exts)
union<
E
>(exts
):Union
<E
>
Type Parameters
• E extends readonly Extension
<ExtensionTyping
<any
, any
, any
>>[]
Parameters
• exts: E
Returns
Union
<E
>
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
unsetMark()
unsetMark(
options
?):Command
Returns a command that removes all marks.
Parameters
• options?: UnsetMarkOptions
Returns
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
import { Priority, withPriority } from 'prosekit/core'
const extension = withPriority(defineMyExtension(), Priority.high)
wrap()
wrap(
options
):Command
Returns a command that wraps the selected textblock with the given node type.
Parameters
• options: WrapOptions