prosekit/pm/commands
Re-exports from prosemirror-commands
Variables
Section titled “Variables”baseKeymap
Section titled “baseKeymap”-
const baseKeymap:
object
-
Depending on the detected platform, this will hold
pcBasekeymap
ormacBaseKeymap
.
createParagraphNear
Section titled “createParagraphNear”-
const createParagraphNear:
Command
-
If a block node is selected, create an empty paragraph before (if it is its parent’s first child) or after it.
deleteSelection
Section titled “deleteSelection”-
const deleteSelection:
Command
-
Delete the selection, if there is one.
exitCode
Section titled “exitCode”-
When the selection is in a node with a truthy
code
property in its spec, create a default block after the code block, and move the cursor there.
joinBackward
Section titled “joinBackward”-
const joinBackward:
Command
-
If the selection is empty and at the start of a textblock, try to reduce the distance between that block and the one before it—if there’s a block directly before it that can be joined, join them. If not, try to move the selected block closer to the next one in the document structure by lifting it out of its parent or moving it into a parent of the previous block. Will use the view for accurate (bidi-aware) start-of-textblock detection if given.
joinDown
Section titled “joinDown”-
Join the selected block, or the closest ancestor of the selection that can be joined, with the sibling after it.
joinForward
Section titled “joinForward”-
const joinForward:
Command
-
If the selection is empty and the cursor is at the end of a textblock, try to reduce or remove the boundary between that block and the one after it, either by joining them or by moving the other block closer to this one in the tree structure. Will use the view for accurate start-of-textblock detection if given.
joinTextblockBackward
Section titled “joinTextblockBackward”-
const joinTextblockBackward:
Command
-
A more limited form of
joinBackward
that only tries to join the current textblock to the one before it, if the cursor is at the start of a textblock.
joinTextblockForward
Section titled “joinTextblockForward”-
const joinTextblockForward:
Command
-
A more limited form of
joinForward
that only tries to join the current textblock to the one after it, if the cursor is at the end of a textblock.
joinUp
Section titled “joinUp”-
Join the selected block or, if there is a text selection, the closest ancestor block of the selection that can be joined, with the sibling above it.
-
Lift the selected block, or the closest ancestor block of the selection that can be lifted, out of its parent node.
liftEmptyBlock
Section titled “liftEmptyBlock”-
const liftEmptyBlock:
Command
-
If the cursor is in an empty textblock that can be lifted, lift the block.
macBaseKeymap
Section titled “macBaseKeymap”-
const macBaseKeymap:
object
-
A copy of
pcBaseKeymap
that also binds Ctrl-h like Backspace, Ctrl-d like Delete, Alt-Backspace like Ctrl-Backspace, and Ctrl-Alt-Backspace, Alt-Delete, and Alt-d like Ctrl-Delete.
newlineInCode
Section titled “newlineInCode”-
const newlineInCode:
Command
-
If the selection is in a node whose type has a truthy
code
property in its spec, replace the selection with a newline character.
pcBaseKeymap
Section titled “pcBaseKeymap”-
const pcBaseKeymap:
object
-
A basic keymap containing bindings not specific to any schema. Binds the following keys (when multiple commands are listed, they are chained with
chainCommands
):- Enter to
newlineInCode
,createParagraphNear
,liftEmptyBlock
,splitBlock
- Mod-Enter to
exitCode
- Backspace and Mod-Backspace to
deleteSelection
,joinBackward
,selectNodeBackward
- Delete and Mod-Delete to
deleteSelection
,joinForward
,selectNodeForward
- Mod-Delete to
deleteSelection
,joinForward
,selectNodeForward
- Mod-a to
selectAll
- Enter to
selectAll
Section titled “selectAll”selectNodeBackward
Section titled “selectNodeBackward”-
const selectNodeBackward:
Command
-
When the selection is empty and at the start of a textblock, select the node before that textblock, if possible. This is intended to be bound to keys like backspace, after
joinBackward
or other deleting commands, as a fall-back behavior when the schema doesn’t allow deletion at the selected point.
selectNodeForward
Section titled “selectNodeForward”-
const selectNodeForward:
Command
-
When the selection is empty and at the end of a textblock, select the node coming after that textblock, if possible. This is intended to be bound to keys like delete, after
joinForward
and similar deleting commands, to provide a fall-back behavior when the schema doesn’t allow deletion at the selected point.
selectParentNode
Section titled “selectParentNode”-
const selectParentNode:
Command
-
Move the selection to the node wrapping the current selection, if any. (Will not select the document node.)
selectTextblockEnd
Section titled “selectTextblockEnd”-
const selectTextblockEnd:
Command
-
Moves the cursor to the end of current text block.
selectTextblockStart
Section titled “selectTextblockStart”-
const selectTextblockStart:
Command
-
Moves the cursor to the start of current text block.
splitBlock
Section titled “splitBlock”-
const splitBlock:
Command
-
Split the parent block of the selection. If the selection is a text selection, also delete its content.
splitBlockKeepMarks
Section titled “splitBlockKeepMarks”-
const splitBlockKeepMarks:
Command
-
Acts like
splitBlock
, but without resetting the set of active marks at the cursor.
Functions
Section titled “Functions”autoJoin()
Section titled “autoJoin()”-
function autoJoin(
command
:Command
,isJoinable
: readonlystring
[] | (before
:ProseMirrorNode
,after
:ProseMirrorNode
) =>boolean
):Command
-
Wrap a command so that, when it produces a transform that causes two joinable nodes to end up next to each other, those are joined. Nodes are considered joinable when they are of the same type and when the
isJoinable
predicate returns true for them or, if an array of strings was passed, if their node type name is in that array.
chainCommands()
Section titled “chainCommands()”-
function chainCommands(…
commands
: readonlyCommand
[]):Command
-
Combine a number of command functions into a single function (which calls them one by one until one returns true).
setBlockType()
Section titled “setBlockType()”-
function setBlockType(
nodeType
:NodeType
,attrs?
:null
|Attrs
):Command
-
Returns a command that tries to set the selected textblocks to the given node type with the given attributes.
splitBlockAs()
Section titled “splitBlockAs()”-
function splitBlockAs(
splitNode?
: (node
:ProseMirrorNode
,atEnd
:boolean
,$from
:ResolvedPos
) =>null
| {attrs?
:Attrs
;type
:NodeType
; }):Command
-
Create a variant of
splitBlock
that uses a custom function to determine the type of the newly split off block.
toggleMark()
Section titled “toggleMark()”-
function toggleMark(
markType
:MarkType
,attrs?
:null
|Attrs
,options?
:object
):Command
-
Create a command function that toggles the given mark with the given attributes. Will return
false
when the current selection doesn’t support that mark. This will remove the mark if any marks of that type exist in the selection, or add it otherwise. If the selection is empty, this applies to the stored marks instead of a range of the document.