paste method
void
paste()
Ctrl+V: a copy of what was copied, after the selection -- or into it, when the selection holds children -- or at the end of the page.
Implementation
void paste() {
final DVPageNode? held = _clipboard;
if (held == null) return;
final DVPageNode copy = _dvStudioFresh(held);
final String? at = _selectedId;
final DVPageNode? selected = at == null ? null : _editor.find(at);
if (selected == null || selected.id == _document.root.id) {
insert(copy, parent: _document.root.id);
return;
}
if (selected.type == 'box') {
insert(copy, parent: selected.id);
return;
}
final DVPageNode parent = _dvStudioParentOf(_document.root, selected.id)!;
final int index =
parent.children.indexWhere((DVPageNode n) => n.id == selected.id) + 1;
insert(copy, parent: parent.id, index: index);
}