Type Editor / @type-editor/model / replace / replace
Function: replace()
ts
function replace($from, $to, slice): Node;Defined in: packages/model/src/replace.ts:43
Replace a range of content between two resolved positions with a slice. This is the main entry point for performing document replacements.
Parameters
| Parameter | Type | Description |
|---|---|---|
$from | ResolvedPos | The resolved position where the replacement starts. |
$to | ResolvedPos | The resolved position where the replacement ends. |
slice | Slice | The slice to insert between the positions. |
Returns
The root node with the replacement applied.
Throws
If the slice's open depth is invalid or inconsistent with the positions.