Skip to content

cut command

This command cuts out content and places it into the given position.

See also: focus

Parameters

range: { from: number; to: number }

The start and end positions of the content to cut.

targetPos: number

The position to insert the content at, measured in the document before cutting. The command adjusts this position after removing the source range.

Use the cut command

const from = editor.state.selection.from
const to = editor.state.selection.to

const endPos = editor.state.doc.nodeSize - 2

// Cut out content from range and put it at the end of the document
editor.commands.cut({ from, to }, endPos)