Skip to content

Type Editor


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

ParameterTypeDescription
$fromResolvedPosThe resolved position where the replacement starts.
$toResolvedPosThe resolved position where the replacement ends.
sliceSliceThe slice to insert between the positions.

Returns

Node

The root node with the replacement applied.

Throws

If the slice's open depth is invalid or inconsistent with the positions.