Skip to content

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.

Nothing copied yet.
Group
Outside
Inside A
Inside B
Drag the background to select · hold Space to pan
bit Blow

Try 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() and DuplicateSelectionAsync(); CanPaste says whether there is anything to paste, and OnPaste reports the BlowFragment that 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-2 and so on - rewires edges and parents to the copies, offsets everything by PasteOffset (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: Deletable and OnBeforeDelete apply, and OnNodesDelete reports it.
  • Duplicate with own ids uses the pure helpers, which need no canvas: BlowClipboard.Copy(nodes, edges) takes the fragment, and BlowClipboard.Paste(fragment, options) makes the copies with a BlowPasteOptions - the Offset, the ExistingIds to avoid, an IdFactory that receives the original id and an attempt number, and Select. The page then adds them with AddNodes and AddEdges.
  • SelectionOnDrag makes a drag on the background draw a selection box, and PanActivationKey (Space, the default) is held to pan instead.
An unhandled error has occurred. Reload 🗙