Editor Transforms
API reference for editor transformation operations in Slate.
Editor transforms are methods that modify the editor state. They are grouped into several categories: node operations, text operations, selection operations, DOM operations, and history operations.
editor.tf
insertFragment
Insert a fragment of nodes at the specified location or current selection.
Parameters
The nodes to insert.
Options for the insertion:
.
batchDirty: Whether to batch dirty operations
.
hanging: Whether the insertion is hanging
.
at: Location where to perform insertion
.
voids: Whether to allow insertion in void nodes
insertNode
Atomically insert a node at the specified location or current selection.
Parameters
The node to insert.
Options for the insertion:
.
batchDirty: Whether to batch dirty operations
.
hanging: Whether insertion is hanging
.
nextBlock: Insert after current block
.
removeEmpty: Remove current block if empty
.
select: Select inserted nodes
insertNodes
Atomically inserts multiple nodes at the specified location or current selection.
Parameters
A single node or array of nodes to insert.
Options for insertion:
replaceNodes
Replace nodes at a location with new nodes.
Parameters
The replacement nodes.
Options for the replacement:
setNodes
Set properties of nodes at the specified location.
Parameters
The properties to set.
Options for setting properties:
unsetNodes
Unset properties of nodes at the specified location.
Parameters
The properties to unset.
Options for unsetting properties:
wrapNodes
Wrap nodes at the specified location in an element container.
Parameters
The wrapping element.
Options for wrapping:
unwrapNodes
Unwrap nodes at the specified location.
Parameters
Options for unwrapping:
mergeNodes
Merge a node with the previous node at the same depth.
Parameters
Options for merging:
moveNodes
Move nodes from one location to another.
Parameters
Options for moving:
liftNodes
Lift nodes upwards in the document tree.
Parameters
Options for lifting nodes.
Text Operations
insertText
Insert text at the specified location or current selection.
Parameters
The text to insert.
Options for text insertion:
deleteText
Delete text in the document.
Parameters
Options for deletion:
Selection Operations
select
Set the selection to a new value.
Parameters
The target location.
Options for selection:
setSelection
Set new properties on an active selection.
Parameters
The selection properties to set.
DOM Operations
focus
Focus the editor.
Parameters
Options for focusing:
History Operations
withoutNormalizing
Call a function, deferring normalization until after it completes.
Parameters
The function to execute.
withMerging
Apply changes that will be merged into the previous history.
Parameters
The function containing the changes.
withNewBatch
Apply changes starting a new batch in the history.
Parameters
The function containing the changes.
addMark
Add a custom property to the leaf text nodes in the current selection.
Parameters
The mark key to add.
The value to set for the mark.
addMarks
Add multiple marks to the leaf text nodes in the current selection.
Parameters
The marks to add.
Options for adding marks:
removeMark
Remove a custom property from leaf text nodes in the current selection.
Parameters
The mark key to remove.
removeMarks
Remove marks from text nodes.
Parameters
The mark keys to remove.
Options for removing marks:
toggleMark
Toggle a mark on the leaf text nodes in the current selection.
Parameters
The mark key to toggle.
The value to set when adding the mark.
Options for toggling:
deleteBackward
Delete content backward from the current selection.
Parameters
Options for deletion:
deleteForward
Delete content forward from the current selection.
Parameters
Options for deletion:
deleteFragment
Delete the content of the current selection.
Parameters
Options for deletion:
duplicateNodes
Duplicate nodes at a location.
Parameters
Options for duplication:
insertBreak
Insert a block break at the current selection.
insertSoftBreak
Insert a soft break at the current selection.
normalize
Normalize any dirty objects in the editor.
Parameters
Options for normalization:
redo
Redo to the next saved state.
undo
Undo to the previous saved state.
collapseSelection
Collapse the selection to a single point.
Parameters
Options for collapsing:
moveSelection
Move the selection in a direction.
Parameters
Options for moving:
setPoint
Set new properties on one of the selection's points.
Parameters
The point properties to set.
Options for setting point:
blur
Blur the editor.
deselect
Unset the selection.
withoutSaving
Apply changes without saving to history.
Parameters
The function containing the changes.
withoutMerging
Apply changes without merging into previous history.
Parameters
The function containing the changes.
History Operations
HistoryEditor
The HistoryEditor
interface extends the base Editor
interface to handle history operations.
Parameters
The history of operations.
Undo the last operation.
Redo the last undone operation.