Editable Node
Nodes can host real form controls. Typing in a field - Backspace and Delete included - edits the text and leaves the graph alone, because the canvas ignores its keys while focus is in an editable element; a drag handle keeps the fields usable by leaving the rest of the node undraggable.
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
- Click into a label field and type, using Backspace and Delete freely: the text changes and the node stays.
- Write in a notes box: a textarea is just as safe.
- Drag a node by its grip (⠿ and its id) to move it. Pressing or dragging in the fields never moves it.
- To delete a node, click its grip - that selects the node and takes focus out of the fields - then press Delete or Backspace.
How it works
- Graph keys - Delete, Backspace, the arrows, Ctrl+A - are ignored while focus is in a text input, textarea, select or contenteditable element, so a field inside a node is safe to type in. Escape still abandons a gesture in progress.
- Pressing a field still selects its node; it is the focus in the field that keeps Delete from removing it.
UseCustomDragHandle = truestops the node's body from starting a drag, and theBlowDragHandlegrip starts one instead - so placing the caret or selecting text never moves the node.- The label field writes to
node.Labelon every keystroke, andLabelis also the node's accessible name. The notes live in a dictionary on the page, keyed by node id. - The other way to hand a field its presses back is the
nodragclass (the canvas'sNoDragClass) on the field itself, which leaves the rest of the body draggable; the Custom Node example does that.