Editor
The Editor object stores all the state of a slate editor. It can be extended by plugins to add helpers and implement new behaviors.
Note: This method is imported directly from Slate and is not part of the Editor object.
Creates a new, empty Editor object.
Get the ancestor above a location in the document.
Options: {at?: Location, match?: NodeMatch, mode?: 'highest' | 'lowest', voids?: boolean}
Get the point after a location.
Options: {distance?: number, unit?: 'offset' | 'character' | 'word' | 'line' | 'block', voids?: boolean}
Get the point before a location.
Options: {distance?: number, unit?: 'offset' | 'character' | 'word' | 'line' | 'block', voids?: boolean}
Get the start and end points of a location.
Get the end point of a location.
Get the first node at a location.
Get the fragment at a location.
Get the last node at a location.
Get the leaf text node at a location.
Options: {depth?: number, edge?: 'start' | 'end'}
Iterate through all of the levels at a location.
Options: {at?: Location, match?: NodeMatch, reverse?: boolean, voids?: boolean}
Get the marks that would be added to text at the current selection.
Get the matching node in the branch of the document after a location.
Options: {at?: Location, match?: NodeMatch, mode?: 'all' | 'highest' | 'lowest', voids?: boolean}
Get the node at a location.
Options: depth?: number, edge?: 'start' | 'end'
Iterate through all of the nodes in the Editor.
Options: {at?: Location | Span, match?: NodeMatch, mode?: 'all' | 'highest' | 'lowest', universal?: boolean, reverse?: boolean, voids?: boolean}
options.mode:
- 'all' (default): all matching nodes
- 'highest': in a hierarchy of nodes, only return the highest level matching nodes
- 'lowest': in a hierarchy of nodes, only return the lowest level matching nodes
Get the parent node of a location.
Options: {depth?: number, edge?: 'start' | 'end'}
Get the path of a location.
Options: {depth?: number, edge?: 'start' | 'end'}
Create a mutable ref for a Path object, which will stay in sync as new operations are applied to the editor.
Options: {affinity?: 'backward' | 'forward' | null}
Get the set of currently tracked path refs of the editor.
Get the start or end point of a location.
Options: {edge?: 'start' | 'end'}
Create a mutable ref for a Point object, which will stay in sync as new operations are applied to the editor.
Options: {affinity?: 'backward' | 'forward' | null}
Get the set of currently tracked point refs of the editor.
Iterate through all of the positions in the document where a Point can be placed.
By default it will move forward by individual offsets at a time, but you can pass the unit: 'character' option to moved forward one character, word, or line at at time.
Note: By default void nodes are treated as a single point and iteration will not happen inside their content unless you pass in true for the voids option, then iteration will occur.
Options: {at?: Location, unit?: 'offset' | 'character' | 'word' | 'line' | 'block', reverse?: boolean, voids?: boolean}
Get the matching node in the branch of the document before a location.
Options: {at?: Location, match?: NodeMatch, mode?: 'all' | 'highest' | 'lowest', voids?: boolean}
Get a range of a location.
Create a mutable ref for a Range object, which will stay in sync as new operations are applied to the editor.
Options: {affinity?: 'backward' | 'forward' | 'outward' | 'inward' | null}
Get the set of currently tracked range refs of the editor.
Get the start point of a location.
Get the text string content of a location.
Note: by default the text of void nodes is considered to be an empty string, regardless of content, unless you pass in true for the voids option
Options: : {voids?: boolean}
Match a void node in the current branch of the editor.
Options: {at?: Location, mode?: 'highest' | 'lowest', voids?: boolean}
Add a custom property to the leaf text nodes in the current selection.
If the selection is currently collapsed, the marks will be added to the editor.marks property instead, and applied when text is inserted next.
Delete content in the editor backward from the current selection.
Options: {unit?: 'character' | 'word' | 'line' | 'block'}
Delete content in the editor forward from the current selection.
Options: {unit?: 'character' | 'word' | 'line' | 'block'}
Delete the content in the current selection.
Insert a block break at the current selection.
Insert a fragment at the current selection.
If the selection is currently expanded, it will be deleted first.
Insert a node at the current selection.
If the selection is currently expanded, it will be deleted first.
Insert text at the current selection.
If the selection is currently expanded, it will be deleted first.
Remove a custom property from all of the leaf text nodes in the current selection.
If the selection is currently collapsed, the removal will be stored on editor.marks and applied to the text inserted next.
Convert a range into a non-hanging one.
Options: {voids?: boolean}
Check if a node has block children.
Check if a node has inline and text children.
Check if a node has text children.
Check if a value is a block Element object.
Check if a value is an Editor object.
Check if a point is the end point of a location.
Check if a point is an edge of a location.
Check if an element is empty, accounting for void nodes.
Check if a value is an inline Element object.
Check if the editor is currently normalizing after each operation.
Check if a point is the start point of a location.
Check if a value is a void Element object.
Normalize any dirty objects in the editor.
Options: {force?: boolean}
Call a function, deferring normalization until after it completes.
Replace these methods to modify the original behavior of the editor when building Plugins. When modifying behavior, call the original method when appropriate. For example, a plugin that marks image nodes as "void":
Check if a value is an inline Element object.
Check if a value is a void Element object.
Normalize a Node according to the schema.
Called when there is a change in the editor.
Add a custom property to the leaf text nodes in the currentk selection. If the selection is currently collapsed, the marks will be added to the editor.marks property instead, and applied when text is inserted next.
Remove a custom property from the leaf text nodes in the current selection.
Returns the fragment at the current selection. Used when cutting or copying, as an example, to get the fragment at the current selection.
When a user presses backspace or delete, it invokes the method based on the selection. For example, if the selection is expanded over some text and the user presses the backspace key, deleteFragment will be called but if the selecttion is collapsed, deleteBackward will be called.
Delete content in the editor backward from the current selection.
Delete content in the editor forward from the current selection.
Delete the content of the current selection.
Insert a fragment at the current selection. If the selection is currently expanded, delete it first.
Insert a block break at the current selection. If the selection is currently expanded, delete it first.
Insert a node at the current selection. If the selection is currently expanded, delete it first.
Insert text at the current selection. If the selection is currently expanded, delete it first.
Apply an operation in the editor.