Skip to main content

INTERNAL_$expandSelectionToWholeDocument

function

When `selection` covers the whole document, widen it to the root's own element points, so the range describes the top-level blocks themselves rather than only the text inside them. A delete over that range then removes the blocks outright and leaves the editor on a fresh empty paragraph, instead of gutting them and leaving an empty heading, quote or list behind that keeps its type and styles the next character typed (#5835). It also keeps a cut honest: what lands on the clipboard is what leaves the document, so Cmd+X then Cmd+V restores the blocks rather than their bare text. Widening rather than deleting-then-repairing is what makes this safe for every block type. The range simply contains the blocks, so nothing has to decide whether a heading, a nested list, a code block or a third-party node should dissolve, and no node is destroyed that the user did not select. A no-op for anything else: a range that stops short of either end is an ordinary edit inside the blocks it touches, and a select-all scoped to a named slot never covers the root.

function INTERNAL_$expandSelectionToWholeDocument(selection: RangeSelection): void

Import

import { INTERNAL_$expandSelectionToWholeDocument } from '@modular/sdk/editor';