$selectAll function

void $selectAll()

Selects the whole document.

The ends are resolved to the first and last leaf rather than to the root's child indices, so that a subsequent edit has real text nodes to work with instead of having to materialize them.

Implementation

void $selectAll() {
  final root = $getRoot();
  final first = _firstPointIn(root) ?? Point(root.key, 0, PointType.element);
  final last = _lastPointIn(root) ?? Point(root.key, 0, PointType.element);
  $setSelection(
    RangeSelection(
      Point(first.key, first.offset, first.type),
      Point(last.key, last.offset, last.type),
    ),
  );
}