Copy & Paste
Copy, cut, paste and duplicate a selection with the keyboard or from code. Ids stay unique across repeated pastes, edges are rewired to the copies, an edge leaving the selection stays behind, and a copied child lands inside its copied parent. The same work is available without a canvas through BlowClipboard.
Drag the background to select · hold Space to pan
Press Tab to move between the nodes and edges of the diagram.
Press Enter or Space to select it, Shift with Enter to add it to the selection, the arrow keys to move the selected nodes, Delete to remove them and Escape to clear the selection. Press C to start a connection from it.
Press Enter or Space to select it, Delete to remove it and Escape to clear the selection. Press C to move its end to another node.
bit BlowTry it
- Drag across the background to select with a box (hold Space while dragging to pan instead), or click a node and Shift+click more.
- Select Inside A and Inside B, then press Ctrl/Cmd+C and Ctrl/Cmd+V, or use Copy and Paste: the copies come with the edge between them but not the one out to Outside, and stay selected so you can drag them away. Paste again for another copy; the status lists the new ids.
- Select the Group and copy it: its children come along and land inside the copied group.
- Ctrl/Cmd+X or Cut copies and deletes; Ctrl/Cmd+D or Duplicate copies and pastes in one go and leaves what you copied before on the clipboard.
- Pick a Paste offset and paste: on top, the copy hides its original, which is why the default shifts it.
- Duplicate with own ids copies the selection below itself with ids of the page's own making, such as
in-v1.
How it works
ClipboardShortcutsEnabled(off by default, so a flow does not take those keys from the page around it) binds Ctrl/Cmd+C, X, V and D. While focus is in a text field the keys copy text as usual.- The buttons call
Copy(),CutAsync(),PasteAsync()andDuplicateSelectionAsync();CanPastesays whether there is anything to paste, andOnPastereports theBlowFragmentthat was added. The clipboard is the canvas's own, in memory: a browser does not let a component read the system clipboard, which would carry no graph anyway. - Copying takes the selected nodes and every edge between two of them, selected or not. A paste mints fresh ids -
{id}-copy, then{id}-copy-2and so on - rewires edges and parents to the copies, offsets everything byPasteOffset(24, 24 by default) and makes the copies the selection. A child copied without its parent becomes a root where it was on screen. Copy()with nothing selected hands back what the clipboard already holds, so the page checks for a selection before reporting a copy. Cut deletes with the usual rules:DeletableandOnBeforeDeleteapply, andOnNodesDeletereports it.- Duplicate with own ids uses the pure helpers, which need no canvas:
BlowClipboard.Copy(nodes, edges)takes the fragment, andBlowClipboard.Paste(fragment, options)makes the copies with aBlowPasteOptions- theOffset, theExistingIdsto avoid, anIdFactorythat receives the original id and an attempt number, andSelect. The page then adds them withAddNodesandAddEdges. SelectionOnDragmakes a drag on the background draw a selection box, andPanActivationKey(Space, the default) is held to pan instead.