GraphEditorCanvas
The editing analog of GraphCanvas. Same elements[] shape on the input — swap viewer ↔ editor without reshaping your data. React Flow under the hood; the canvas owns theme-token sync, mini-map, keyboard, and undo/redo so consumers focus on their domain model.
Installation#
Import the stylesheet once at your app entry (Next.js: app/layout.tsx; Vite: main.tsx; etc.). The component intentionally does not import it itself — Next.js rejects library-internal global CSS, and explicit imports let you control load order against your own theme.
import '@ship-it-ui/graph-editor/styles.css';Toolbar#
Pass any React node into the toolbar slot. When toolbar is omitted and you supply onNodeAdd, the editor renders a built-in keyboard-accessible "+ Add" button.
Custom nodes#
Pass renderNode to override the visual. <GraphNodeShell> is re-exported for consumers who want the canonical 52×52 square + selection ring without re-rolling it. Combine with <InlineEdit> for rename-in-place.
Keyboard#
The canvas root is role="application" and owns its keyboard semantics — Tab into it once, then:
Props#
GraphEditorCanvas.Accessibility#
- Canvas root is
role="application"with the suppliedaria-label(defaultGraph editor). OneTabbrings focus to the canvas; keyboard handlers take over from there. Delete/Backspaceremoves selected nodes and edges, firingonNodeDelete/onEdgeDeletefor each. Arrow keys nudge selected nodes (Shift = 32px) and fireonNodeMove.Escapeclears the selection and firesonClearSelection.⌘Z/Ctrl+Zundoes;⌘⇧Z/Ctrl+Shift+Zredoes.historySize=0disables the stack entirely if your consumer manages undo externally.- When
toolbaris omitted andonNodeAddis provided, the canvas renders a real<button aria-label="Add node">in the top-left — keyboard-only users can add a node without a pointer.
Engine#
<GraphEditorCanvas> uses React Flow (@xyflow/react) under the hood. The viewer (<GraphCanvas>) uses Cytoscape.js. They share the elements[] shape via a round-trip-tested adapter (toFlowElements / toCytoscapeElements), and they share token resolution via @ship-it-ui/graph-tokens. Consumers who import only the viewer don't pay for React Flow; consumers who import only the editor don't pay for Cytoscape.