getNodePath method

List<int>? getNodePath(
  1. String nodeId
)

Gets the hierarchical path of a node in the document

Implementation

List<int>? getNodePath(String nodeId) {
  // Fast path: check if it's a top-level node
  for (var i = 0; i < _content.nodes.length; i++) {
    if (_content.nodes[i].id == nodeId) {
      return [i];
    }
  }

  // Search in nested structures
  for (var i = 0; i < _content.nodes.length; i++) {
    final found = _findNodePathRecursive(_content.nodes[i], nodeId, [i]);
    if (found != null) return found;
  }
  return null;
}