Operation objects define the low-level instructions that Slate editors use to apply changes to their internal state. Representing all changes as operations is what allows Slate editors to easily implement history, collaboration, and other features.
// insert a new `Node`typeInsertNodeOperation= { type:'insert_node' path:Path node:Node}// merge two `Node` objectstypeMergeNodeOperation= { type:'merge_node' path:Path position:number properties:Partial<Node>}// move `Node` from one path to anothertypeMoveNodeOperation= { type:'move_node' path:Path newPath:Path}// Remove a `Node`typeRemoveNodeOperation= { type:'remove_node' path:Path node:Node}// Set properties of a `Node`typeSetNodeOperation= { type:'set_node' path:Path properties:Partial<Node> newProperties:Partial<Node>}// Split a node into two separate `Node` objectstypeSplitNodeOperation= { type:'split_node' path:Path position:number properties:Partial<Node>}exporttypeNodeOperation=|InsertNodeOperation|MergeNodeOperation|MoveNodeOperation|RemoveNodeOperation|SetNodeOperation|SplitNodeOperation
Text Operations
Text operations operate on Text objects only.
Note: Text objects are Node objects so you can use Node operations on Text objects.
// insert text into an existing `Text` nodetypeInsertTextOperation= { type:'insert_text' path:Path offset:number text:string}// remove text from an existing `Text` nodetypeRemoveTextOperation= { type:'remove_text' path:Path offset:number text:string}exporttypeTextOperation=InsertTextOperation|RemoveTextOperation