isNodeSelected method
Returns true if a node is selected (partially or fully).
positionIndex maps nodeId → document-order position (0..n-1). When
provided it is used instead of the broken lexicographic UUID comparison.
Implementation
bool isNodeSelected(String nodeId, {Map<String, int>? positionIndex}) {
if (!hasSelection) return false;
final base = _isAnchorBeforeFocus(positionIndex) ? anchor! : focus!;
final extent = _isAnchorBeforeFocus(positionIndex) ? focus! : anchor!;
final nodeIsBase = base.nodeId == nodeId;
final nodeIsExtent = extent.nodeId == nodeId;
final nodeBetween = _isNodeBetween(nodeId, base.nodeId, extent.nodeId, positionIndex);
return nodeIsBase || nodeIsExtent || nodeBetween;
}