Skip to content

Type Editor


Type Editor / @type-editor/viewdesc / util/replace-nodes / replaceNodes

Function: replaceNodes()

ts
function replaceNodes(nodes, from, to, view, replacement?): ViewDesc[];

Defined in: util/replace-nodes.ts:22

Replace range from-to in an array of view descs with replacement (may be undefined to just delete). This goes very much against the grain of the rest of this code, which tends to create nodes with the right shape in one go, rather than messing with them after creation, but is necessary in the composition hack.

Parameters

ParameterTypeDescription
nodesreadonly ViewDesc[]The array of view descriptions
fromnumberStart position of the range to replace
tonumberEnd position of the range to replace
viewPmEditorViewThe editor view
replacement?ViewDescOptional replacement view description

Returns

ViewDesc[]

A new array with the replacement applied