deleteNodesAtPath method

void deleteNodesAtPath(
  1. Path path, [
  2. int length = 1
])

Deletes the Nodes at the given Path.

The length indicates the number of consecutive deletions, including the node of the current path.

Implementation

void deleteNodesAtPath(Path path, [int length = 1]) {
  if (path.isEmpty) return;
  final nodes = <Node>[];
  final parent = path.parent;
  for (var i = 0; i < length; i++) {
    final node = document.nodeAtPath(parent + [path.last + i]);
    if (node == null) {
      break;
    }
    nodes.add(node);
  }
  add(DeleteOperation(path, nodes));
}