mirror of
https://github.com/ianstormtaylor/slate.git
synced 2025-08-18 21:21:21 +02:00
Clarifies when to use Editor.insertNode vs. Transforms.insertNodes (#4731)
This commit is contained in:
@@ -44,10 +44,20 @@ Options: `{at?: Location, hanging?: boolean, voids?: boolean}`
|
||||
|
||||
#### `Transforms.insertNodes(editor: Editor, nodes: Node | Node[], options?)`
|
||||
|
||||
Insert `nodes` at the specified location in the document. If no location is specified, insert at the current selection. If there is no selection, insert at the end of the document.
|
||||
Atomically inserts `nodes` at the specified location in the document. If no location is specified, inserts at the current selection. If there is no selection, inserts at the end of the document.
|
||||
|
||||
Options supported: `NodeOptions & {hanging?: boolean, select?: boolean}`.
|
||||
|
||||
For example, to insert at the very end, without replacing the current selection and regardless of block nesting, use
|
||||
|
||||
```javascript
|
||||
Transforms.insertNodes(
|
||||
editor,
|
||||
{ type: targetType, children: [{ text: '' }] },
|
||||
{ at: [editor.children.length] }
|
||||
)
|
||||
```
|
||||
|
||||
#### `Transforms.removeNodes(editor: Editor, options?)`
|
||||
|
||||
Remove nodes at the specified location in the document. If no location is specified, remove the nodes in the selection.
|
||||
|
Reference in New Issue
Block a user