duplicate method
Copies the element id and places the copy right after it, in the same
container, with fresh ids all the way down, and selects the copy. This
is Ctrl+D (Cmd+D).
Fresh ids, because two nodes answering to one id would be one selection, one edit target and one entry in a collaborator's document.
Implementation
void duplicate(String id) {
final DVPageNode? parent = _dvStudioParentOf(_document.root, id);
if (parent == null) {
throw ArgumentError.value(id, 'id', 'is the page or not on it');
}
final DVPageNode original = _editor.find(id)!;
final DVPageNode copy = _dvStudioFresh(original);
final int index =
parent.children.indexWhere((DVPageNode n) => n.id == id) + 1;
insert(copy, parent: parent.id, index: index);
}