$isAtNodeEnd function

bool $isAtNodeEnd(
  1. Point point
)

Whether point addresses the very end of the node it sits in.

The end of a text node is past its last code unit; the end of an element is past its last child. Says nothing about the document — a point at the end of the first of three paragraphs is at a node end.

Implementation

bool $isAtNodeEnd(Point point) {
  final node = point.getNode();
  if (point.type == PointType.text) {
    if (node is! TextNode) {
      throw LexicalStateError(
        'isAtNodeEnd: a text point must address a text node, '
        'and ${point.key} is ${node?.type ?? 'gone'}.',
      );
    }
    return point.offset == node.getTextContentSize();
  }
  if (node is! ElementNode) {
    throw LexicalStateError(
      'isAtNodeEnd: an element point must address an element, '
      'and ${point.key} is ${node?.type ?? 'gone'}.',
    );
  }
  return point.offset == node.childrenSize;
}