Engine API
Shared data, behavior and controller APIs. The installed preset fills the visual slots; pass only the widgets you want to replace.
Start with Widget Structure to understand composition and customization. Use this reference for exact props, builder arguments and controller members.
Props
| Prop | Type | Description |
|---|---|---|
| data | FlowDiagramData | The graph: { nodes, edges }. |
| custom | FlowDiagramCustom<TConfig> | Builder for every visual part. FlowDiagram fills all of them; pass only the ones you replace. |
| config? | TConfig | Your theme object. Builders read it as context.config. |
| nodeOptions? | Record<string, NodeOptions> | Per-type interaction metadata: handles, editability, groups and zoom breakpoints. Render through custom.node. |
| getHandles? | GetHandlesFn<TConfig> | Declare connection points. Inline handles are placed as widgets and measured by the engine. |
| getEdgePath? | GetEdgePathFn<TConfig> | Compute edge geometry used for drawing and hit testing. |
| getContextMenuItems? | GetContextMenuItemsFn<TConfig> | Return application commands. The engine wires their gestures before calling custom.menuItem. |
| getControlsOptions? | GetControlsOptionsFn<TConfig> | Control action timings; the installed preset derives them from config.controls. |
| getMinimapOptions? | GetMinimapOptionsFn<TConfig> | Minimap geometry and panning; the installed preset derives them from config.minimap. |
| highlightConnected? | boolean | Rebuild visual slots on graph-wide hover and selection changes for dimming unrelated elements. |
| layout? | LayoutAlgorithm | LayoutConfig | An algorithm, or { algorithm, options, runOn, fitView }. |
| viewport? | { initial?: Viewport; fitView?: boolean | FitViewOptions; minZoom?: number; maxZoom?: number; extent?: CoordinateExtent } | Initial viewport, fit on mount, zoom limits and pan extent. |
| interaction? | | InteractionPreset | (DeepPartial<FlowInteraction> & { preset?: InteractionPreset }) | A preset name, or groups merged over a preset. See Interaction below. |
| can? | (gesture: Gesture, target: GestureTarget) => boolean | One permission check per gesture and target. Wins over per-item flags. |
| on? | FlowEvents | Event callbacks. before* hooks return false to veto or a value to patch. |
| controller? | FlowDiagramController | Your own FlowDiagramController, to drive the graph from outside. |
| key? | unknown | Widget key. |
Events: on
| Event | Type | Description |
|---|---|---|
| nodesChange? | (changes: NodeChange<FlowNode>[]) => void | Every node change, after it is applied. |
| edgesChange? | (changes: EdgeChange<FlowEdge>[]) => void | Every edge change, after it is applied. |
| connect? | (connection: Connection) => void | A new connection was made. |
| nodeClick? | (event: MouseEvent, node: FlowNode) => void | A node was clicked. |
| nodeDoubleClick? | (event: MouseEvent, node: FlowNode) => void | A node was double-clicked. |
| dragStart? | (event: MouseEvent, node: FlowNode, nodes: FlowNode[]) => void | A node drag started. nodes holds every node that moves. |
| drag? | (event: MouseEvent, node: FlowNode, nodes: FlowNode[]) => void | Each frame of a node drag. |
| dragEnd? | (event: MouseEvent, node: FlowNode, nodes: FlowNode[]) => void | A node drag ended. |
| edgeClick? | (event: MouseEvent, edge: FlowEdge) => void | An edge was clicked. |
| edgeDoubleClick? | (event: MouseEvent, edge: FlowEdge) => void | An edge was double-clicked. |
| paneClick? | (event: MouseEvent) => void | The empty pane was clicked. |
| paneDoubleClick? | (event: MouseEvent) => void | The empty pane was double-clicked. |
| selectionChange? | (selection: { nodes: FlowNode[]; edges: FlowEdge[] }) => void | The selected nodes or edges changed. |
| delete? | (deleted: { nodes: FlowNode[]; edges: FlowEdge[] }) => void | Nodes and edges were deleted. |
| beforeDelete? | (deleted: { nodes: FlowNode[]; edges: FlowEdge[] }) => | boolean | { nodes: FlowNode[]; edges: FlowEdge[] } | Promise<boolean | { nodes: FlowNode[]; edges: FlowEdge[] }> | Return false to keep everything, or the subset to delete. |
| reconnect? | (oldEdge: FlowEdge, newConnection: Connection) => void | An edge end moved to another handle. |
| resizeStart? | (event: MouseEvent, node: FlowNode) => void | A resize started. |
| resize? | (event: MouseEvent, node: FlowNode, params: ResizeParams) => void | Each frame of a resize. |
| resizeEnd? | (event: MouseEvent, node: FlowNode, params: ResizeParams) => void | A resize ended. |
| init? | (controller: FlowDiagramController) => void | The controller is ready. |
| error? | (code: "layout", message: string) => void | Something failed, such as a layout. |
| viewportChange? | (change: { phase: "start" | "move" | "end"; viewport: Viewport }) => void | Pan or zoom, with phase start, move or end. |
| connectStart? | (state: ConnectionState) => void | A connection drag started. |
| connectEnd? | (result: { state: ConnectionState; dropPosition: XYPosition }) => void | A connection drag ended. dropPosition is in flow coordinates. |
| beforeConnect? | (connection: Connection) => false | Connection | void | Return false to refuse, or a patched connection. |
| reshapeStart? | (args: EdgeHandleCustomArgs) => void | A waypoint drag started. |
| reshape? | (args: EdgeHandleCustomArgs) => void | Each frame of a waypoint drag. |
| reshapeEnd? | (args: EdgeHandleCustomArgs) => void | A waypoint drag ended. |
| editStart? | (args: { node: FlowNode }) => void | Inline text editing started. |
| editEnd? | (args: { node: FlowNode; committed: boolean }) => void | Inline text editing ended. committed is false after Esc. |
| historyChange? | (state: { canUndo: boolean; canRedo: boolean }) => void | canUndo or canRedo changed. |
| contextMenu? | (args: ContextMenuCustomArgs) => void | A context menu opened. |
can: (gesture: "pan" | "zoom" | "select" | "drag" | "connect" | "reconnect" | "resize" | "reshape" | "edit" | "delete" | "copy" | "contextMenu",
target: { kind: "node" | "edge" | "pane" | "selection"; id?: string }) => booleanInteraction
Values per preset. Mod is ⌘ on macOS and Ctrl elsewhere.
interaction: "viewer" // a preset
interaction: { preset: "whiteboard", drag: { overlap: "push" } } // preset + overrides
interaction: { keys: { duplicate: null } } // editor + one changepane
| Property | Type | editor | viewer | whiteboard | Description |
|---|---|---|---|---|---|
| drag | "pan" | "select" | "pan" | "pan" | "select" | What dragging the empty pane does. |
| scroll | "zoom" | "pan" | "zoom" | "zoom" | "zoom" | What the wheel does without a modifier. |
| scrollSpeed | number | 0.5 | 0.5 | 0.5 | Pan speed when the wheel pans. |
| pinch | boolean | true | true | true | Pinch and trackpad zoom. |
| doubleClick | "zoom" | "none" | "zoom" | "zoom" | "zoom" | Double-click on the pane zooms in, or does nothing. |
| autoPan | boolean | { speed: number } | { speed: 15 } | { speed: 15 } | { speed: 15 } | Pan while dragging near the border. Speed in px per frame. |
| panKey | KeyCode | "Space" | "Space" | "Space" | Hold to pan with a drag when drag selects. |
| selectKey | KeyCode | "Shift" | "Shift" | "Shift" | Hold to box-select with a drag when drag pans. |
select
| Property | Type | editor | viewer | whiteboard | Description |
|---|---|---|---|---|---|
| enabled | boolean | true | true | true | Click selection of nodes and edges. |
| box | boolean | true | false | true | Drag a selection box: with selectKey held, or plainly when pane.drag is select. false frees both. |
| mode | SelectionMode | "full" | "full" | "full" | full: the box must contain a node. partial: touching is enough. |
| toggleKey | KeyCode | "Mod" | "Mod" | "Mod" | Hold to add or remove from the selection. |
| elevate | boolean | true | true | true | Raise selected and dragged nodes above the rest. |
| edgeHitWidth | number | 20 | 20 | 20 | Invisible stroke width that hits edges, in px. |
drag
| Property | Type | editor | viewer | whiteboard | Description |
|---|---|---|---|---|---|
| enabled | boolean | true | false | true | Node dragging. |
| threshold | number | 1 | 1 | 1 | Pixels a press moves before it becomes a drag. |
| snap.grid | false | [number, number] | false | false | false | Snap positions to this grid, or false. |
| snap.guides | boolean | false | false | true | Snap to other nodes and draw alignment guides. |
| snap.radius | number | 5 | 5 | 5 | Distance in px at which guides snap. |
| overlap | "allow" | "push" | "reject" | "allow" | "allow" | "allow" | On drop: allow keeps overlaps, push moves the dropped nodes clear, reject cancels the drag. |
| dropIntoGroup | boolean | true | false | true | Dropping a node on a group makes it a child. Dropping it outside detaches it. |
connect
| Property | Type | editor | viewer | whiteboard | Description |
|---|---|---|---|---|---|
| enabled | boolean | true | false | true | Dragging from a handle creates an edge. |
| mode | ConnectionMode | "strict" | "strict" | "strict" | strict: source to target only. loose: any handle to any handle. |
| radius | number | 20 | 20 | 20 | Snap distance to a handle, in px. |
| onClick | boolean | true | false | true | Click one handle, then another, to connect. |
| reconnect | boolean | true | false | true | Drag an edge end onto another handle. |
| reconnectRadius | number | 10 | 10 | 10 | Grab radius at edge ends, in px. |
| lineType | string | "default" | "default" | "default" | Path type of the line while connecting. |
| validate | (connection: Connection) => boolean | — | — | — | Return false to refuse a connection. |
edit
| Property | Type | editor | viewer | whiteboard | Description |
|---|---|---|---|---|---|
| text | boolean | false | false | true | Double-click a node to edit its label. |
| waypoints | boolean | false | false | false | On a selected edge, drag a midpoint grip to add a bend. Double-click a bend to remove it. |
| resize | boolean | NodeResizeOptions | false | false | true | Resize controls on selected nodes. Options set size limits. |
history
| Property | Type | editor | viewer | whiteboard | Description |
|---|---|---|---|---|---|
| enabled | boolean | true | false | true | Undo and redo, one step per gesture. |
| limit | number | 100 | 100 | 100 | Undo steps kept. |
clipboard
| Property | Type | editor | viewer | whiteboard | Description |
|---|---|---|---|---|---|
| enabled | boolean | true | false | true | Copy, paste and duplicate. |
| offset | XYPosition | { x: 20, y: 20 } | { x: 20, y: 20 } | { x: 20, y: 20 } | Shift applied to each duplicated copy. |
| system | boolean | false | false | false | Also write to the system clipboard. |
contextMenu
| Property | Type | editor | viewer | whiteboard | Description |
|---|---|---|---|---|---|
| enabled | boolean | true | false | true | Right-click and long-press open custom.contextMenu. |
| longPress | number | 500 | 500 | 500 | Touch hold time in ms. |
keys
| Property | Type | editor | viewer | whiteboard | Description |
|---|---|---|---|---|---|
| delete | KeyCode | ["Backspace", "Delete"] | null | ["Backspace", "Delete"] | Delete the selection. |
| undo | KeyCode | "Mod+z" | null | "Mod+z" | Undo. |
| redo | KeyCode | ["Mod+Shift+z", "Mod+y"] | null | ["Mod+Shift+z", "Mod+y"] | Redo. |
| copy | KeyCode | "Mod+c" | null | "Mod+c" | Copy the selection. |
| paste | KeyCode | "Mod+v" | null | "Mod+v" | Paste at the pointer. |
| duplicate | KeyCode | "Mod+d" | null | "Mod+d" | Duplicate the selection. |
| selectAll | KeyCode | "Mod+a" | null | "Mod+a" | Select every node. |
| fitView | KeyCode | "Shift+1" | "Shift+1" | "Shift+1" | Fit the graph in view. |
| zoomIn | KeyCode | ["+", "="] | ["+", "="] | ["+", "="] | Zoom in. |
| zoomOut | KeyCode | "-" | "-" | "-" | Zoom out. |
| nudge | KeyCode | ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"] | null | ["ArrowLeft", "ArrowRight", "ArrowUp", "ArrowDown"] | Move the selection by 1 px, or 10 px with Shift. |
| escape | KeyCode | "Escape" | "Escape" | "Escape" | Clear the selection, or cancel a connection or edit. |
general
| Property | Type | editor | viewer | whiteboard | Description |
|---|---|---|---|---|---|
| touch | boolean | true | true | true | Touch input: drag, two-finger pan and pinch, long-press. |
Custom parts
| Slot | Signature | Description |
|---|---|---|
| layout | (args: LayoutCustomArgs, context) => Widget | Arranges the viewport and screen-space overlays; override it to add extra UI. |
| viewport | (args: ViewportCustomArgs, context) => Widget | Arranges cached nodes and edges in paint order, then flow-space overlays. |
| nodeBox | (args: NodeBoxCustomArgs, context) => Widget | Places the pre-built node, connection handles, resize controls and toolbar. |
| edgeBox | (args: EdgeBoxCustomArgs, context) => Widget | Arranges the pre-built edge, label and editing handles. |
| controls | (args: ControlsCustomArgs, context) => Widget | Arranges zoom, fit and lock child widgets with their actions already attached. |
| controlButton | (args: ControlButtonCustomArgs, context) => Widget | One control button's appearance. Click and hover behavior are attached by the engine. |
| minimap | (args: MinimapCustomArgs, context) => Widget | Arranges background, node, mask and viewport widgets; the engine owns panning. |
| minimapNode | (args: MinimapNodeCustomArgs, context) => Widget | One node in minimap coordinates. |
| minimapBackground | (args: MinimapBackgroundCustomArgs, context) => Widget | Minimap background widget. |
| minimapMask | (args: MinimapMaskCustomArgs, context) => Widget | Mask around the visible portion of the minimap. |
| minimapViewport | (args: MinimapViewportCustomArgs, context) => Widget | Current viewport outline in minimap coordinates. |
| contextMenu | (target: ContextMenuCustomArgs & { items: Widget[] }, context) => Widget | Menu for a right-click or long-press. Return SizedBox.shrink() for no menu. |
| menuItem | (args: MenuItemCustomArgs, context) => Widget | One menu item's appearance. Selection, disabled state and menu dismissal are wired by the engine. |
| guides | (args: GuidesCustomArgs, context) => Widget | Alignment guide lines while snapping. |
| edgeHandle | (args: EdgeHandleCustomArgs, context) => Widget | Waypoint pins and midpoint grips on an editable edge. |
| node | (args: NodeBodyCustomArgs, context) => Widget | Node body. Receives a built label and inline handle widgets; the engine attaches node gestures. |
| nodeLabel | (args: NodeCustomArgs, context) => Widget | Node label widget, including the preset's editable text. |
| nodeToolbar | (args: NodeToolbarCustomArgs, context) => Widget | Screen-space toolbar for a selected node. |
| edge | (args: EdgeCustomArgs, context) => Widget | Edge visual. The engine retains hit testing, selection and hover. |
| edgeLabel | (args: EdgeLabelCustomArgs, context) => Widget | Label drawn at the edge's label point. |
| handle | (args: HandleCustomArgs, context) => Widget | A connection handle. |
| connectionLine | (args: ConnectionLineCustomArgs, context) => Widget | The line drawn while connecting. |
| background | (args: BackgroundCustomArgs, context) => Widget | Pane backdrop. Return SizedBox.shrink() for none. |
| selectionBox | (args: SelectionBoxCustomArgs, context) => Widget | The rectangle drawn while box-selecting. |
| nodesSelectionRect | (args: NodesSelectionRectCustomArgs, context) => Widget | Bounds drawn around a multi-selection. |
| resizeControl | (args: ResizeControlCustomArgs, context) => Widget | Resize lines and corner handles. |
| reconnectHandle | (args: ReconnectHandleCustomArgs, context) => Widget | Grab area at an edge end. Invisible by default. |
Builder args
| Slot | Arg | Type | Description |
|---|---|---|---|
| layout | background | Widget | |
| viewport | Widget | Current x, y and zoom. | |
| selectionBox | Widget | ||
| toolbars | Widget | ||
| controls | Widget | ||
| minimap | Widget | ||
| contextMenu | Widget | ||
| viewport | edges | Widget[] | |
| nodes | Widget[] | ||
| connectionLine | Widget | ||
| nodesSelectionRect | Widget | ||
| guides | Widget | ||
| items | Widget[] | Interleaved nodes/edges in controller paint order, preserving group-edge elevation. | |
| nodeBox | node | Widget | The node. |
| handles | Widget[] | ||
| resizeControls | Widget[] | ||
| toolbar | Widget | The pre-built screen-space toolbar, also supplied to layout.toolbars for unscaled placement. | |
| args | NodeCustomArgs | ||
| placements | NodeAttachmentPlacement[] | Placement rules measured against the node body's laid-out size. | |
| edgeBox | edge | Widget | The edge. |
| label | Widget | edge.label. | |
| reconnectHandles | Widget[] | ||
| edgeHandles | Widget[] | ||
| args | EdgeCustomArgs | ||
| controls | zoomIn | Widget | |
| zoomOut | Widget | ||
| fitView | Widget | ||
| interactive | Widget | ||
| controlButton | kind | ControlKind | waypoint for a bend, midpoint for an insert grip. |
| isHovered | boolean | Under the pointer. | |
| isDisabled | boolean | ||
| isInteractive | boolean | ||
| minimap | width | number | Pane width. |
| height | number | Pane height. | |
| background | Widget | ||
| nodes | Widget[] | ||
| mask | Widget | ||
| viewport | Widget | Current x, y and zoom. | |
| minimapNode | node | FlowNode | The node. |
| rect | Rect | ||
| isSelected | boolean | Selected now. | |
| minimapBackground | width | number | Pane width. |
| height | number | Pane height. | |
| minimapMask | width | number | Pane width. |
| height | number | Pane height. | |
| rect | Rect | ||
| minimapViewport | rect | Rect | |
| contextMenu | target | GestureTarget["kind"] | What was clicked: node, edge, pane or selection. |
| ids | string[] | Ids the menu acts on. | |
| position | XYPosition | Pointer in flow coordinates. | |
| screenPosition | XYPosition | Pointer in pane pixels. | |
| items | Widget[] | ||
| label | string | edge.label. | |
| index | number | Waypoint or segment index. | |
| isHovered | boolean | Under the pointer. | |
| isDisabled | boolean | ||
| isSeparator | boolean | ||
| guides | lines | Guide[] | Overlay-local coordinates; controller.guides uses flow coordinates. |
| edgeHandle | edge | FlowEdge | The edge. |
| kind | "waypoint" | "midpoint" | waypoint for a bend, midpoint for an insert grip. | |
| index | number | Waypoint or segment index. | |
| isActive | boolean | Being dragged. | |
| node | node | FlowNode | The node. |
| isSelected | boolean | Selected now. | |
| isDragging | boolean | Being dragged. | |
| isHovered | boolean | Under the pointer. | |
| isDraggable | boolean | Drag is allowed. | |
| isSelectable | boolean | Selection is allowed. | |
| isConnectable | boolean | Connecting is allowed. | |
| positionAbsolute | XYPosition | Top-left in flow coordinates, after parents. | |
| zIndex | number | Paint order. | |
| isConnectionTarget | boolean | A connection is being dragged over this node (any of its handles is the candidate). | |
| isResizable | boolean | Resize controls apply. | |
| isResizing | boolean | A resize is in progress. | |
| isEditing | boolean | Inline text editing is active. | |
| isDropTarget | boolean | A dragged node would drop into this group. | |
| isOverlapping | boolean | Overlaps another node. | |
| isCollapsed | boolean | node.collapsed. The nodes it hides are not drawn. | |
| hiddenChildCount | number | How many nodes this collapse hides right now. | |
| isNeighbour | boolean | Connected to the hovered or selected node. | |
| label | Widget | edge.label. | |
| handles | { id: string | null; type: HandleType; handle: Widget }[] | Interaction-ready inline handles. Place each handle once in the node's widget tree. | |
| nodeLabel | node | FlowNode | The node. |
| isSelected | boolean | Selected now. | |
| isDragging | boolean | Being dragged. | |
| isHovered | boolean | Under the pointer. | |
| isDraggable | boolean | Drag is allowed. | |
| isSelectable | boolean | Selection is allowed. | |
| isConnectable | boolean | Connecting is allowed. | |
| positionAbsolute | XYPosition | Top-left in flow coordinates, after parents. | |
| zIndex | number | Paint order. | |
| isConnectionTarget | boolean | A connection is being dragged over this node (any of its handles is the candidate). | |
| isResizable | boolean | Resize controls apply. | |
| isResizing | boolean | A resize is in progress. | |
| isEditing | boolean | Inline text editing is active. | |
| isDropTarget | boolean | A dragged node would drop into this group. | |
| isOverlapping | boolean | Overlaps another node. | |
| isCollapsed | boolean | node.collapsed. The nodes it hides are not drawn. | |
| hiddenChildCount | number | How many nodes this collapse hides right now. | |
| isNeighbour | boolean | Connected to the hovered or selected node. | |
| nodeToolbar | node | FlowNode | The node. |
| isSelected | boolean | Selected now. | |
| edge | edge | FlowEdge | The edge. |
| path | EdgePathResult | Geometry in the edge widget's local coordinates (top-left is `origin`). | |
| origin | XYPosition | Top-left of the edge widget in flow coordinates. | |
| size | Dimensions | Size of the widget. | |
| endpoints | EdgeEndpoints | Resolved source and target points and sides. | |
| isSelected | boolean | Selected now. | |
| isHovered | boolean | Under the pointer. | |
| isAnimated | boolean | edge.animated, resolved. | |
| sourceNode | FlowNode | Node at the source end. | |
| targetNode | FlowNode | Node at the target end. | |
| markerStart | EdgeMarker | null | Resolved start marker. | |
| markerEnd | EdgeMarker | null | Resolved end marker. | |
| interactionWidth | number | Hit stroke width. | |
| isReconnecting | boolean | One endpoint of this edge is being dragged to a new handle. | |
| waypoints | XYPosition[] | Bend points in flow coordinates. | |
| activeHandle | { kind: "waypoint" | "midpoint"; index: number } | null | The waypoint or midpoint being dragged. | |
| isNeighbour | boolean | Connected to the hovered or selected node. | |
| edgeLabel | edge | FlowEdge | The edge. |
| label | string | edge.label. | |
| isSelected | boolean | Selected now. | |
| isHovered | boolean | Under the pointer. | |
| x | number | Label anchor in flow coordinates. | |
| y | number | Label anchor y in flow coordinates. | |
| handle | node | FlowNode | The node. |
| handle | ResolvedHandle | Resolved handle with absolute centre. | |
| isConnectable | boolean | Connecting is allowed. | |
| isConnecting | boolean | This handle started the connection in progress. | |
| isConnectionCandidate | boolean | This handle is the snapped candidate of the connection in progress. | |
| isValidCandidate | boolean | null | true valid, false refused, null not snapped. | |
| isConnectionInProgress | boolean | Any connection is being dragged. | |
| connectionLine | connection | ConnectionState | Full connection state. |
| path | EdgePathResult | Path in local coordinates of the connection line widget. | |
| from | XYPosition | Start point. | |
| to | XYPosition | End point: a snapped handle or the pointer. | |
| fromPosition | Position | Side the line leaves from. | |
| toPosition | Position | Side the line arrives at. | |
| isValid | boolean | null | true valid, false refused, null not snapped. | |
| origin | XYPosition | Top-left of the widget in flow coordinates. | |
| size | Dimensions | Size of the widget. | |
| background | viewport | Viewport | Current x, y and zoom. |
| width | number | Pane width. | |
| height | number | Pane height. | |
| selectionBox | rect | Rect | Rectangle in pane pixels. |
| nodesSelectionRect | rect | Rect | Bounds of the selected nodes in flow coordinates. |
| nodes | FlowNode[] | The selected nodes. | |
| resizeControl | node | FlowNode | The node. |
| position | ResizeControlPosition | Which corner or side. | |
| variant | "line" | "handle" | line for a side, handle for a corner. | |
| isResizing | boolean | A resize is in progress. | |
| reconnectHandle | edge | FlowEdge | The edge. |
| end | HandleType | source or target. | |
| size | number | Diameter of the grab area in flow pixels. |
Controller
Builders get it as context. P2 marks methods still being built.
Graph
| Member | Signature | Description |
|---|---|---|
| nodes | nodes: FlowNode[] | Current nodes. |
| edges | edges: FlowEdge[] | Current edges. |
| getNode | getNode(id: string): FlowNode | undefined | One node by id. |
| getEdge | getEdge(id: string): FlowEdge | undefined | One edge by id. |
| setNodes | setNodes(nodes: FlowNode[] | ((nodes: FlowNode[]) => FlowNode[])): void | Replace all nodes, or map them. |
| setEdges | setEdges(edges: FlowEdge[] | ((edges: FlowEdge[]) => FlowEdge[])): void | Replace all edges, or map them. |
| addNodes | addNodes(nodes: FlowNode | FlowNode[]): void | Add one or more nodes. |
| addEdges | addEdges(edges: (Partial<FlowEdge> & Connection) | FlowEdge | (Partial<FlowEdge> & Connection)[] | FlowEdge[]): void | Add one or more edges. |
| updateNode | updateNode(id: string, update: Partial<FlowNode> | ((node: FlowNode) => Partial<FlowNode>), options?: { replace?: boolean }): void | Patch a node. Rebuilds only that node. |
| updateNodeData | updateNodeData(id: string, data: Record<string, unknown> | ((node: FlowNode) => Record<string, unknown>), options?: { replace?: boolean }): void | Merge into node.data, or replace it. |
| updateEdge | updateEdge(id: string, update: Partial<FlowEdge> | ((edge: FlowEdge) => Partial<FlowEdge>), options?: { replace?: boolean }): void | Patch an edge. |
| updateEdgeData | updateEdgeData(id: string, data: Record<string, unknown> | ((edge: FlowEdge) => Record<string, unknown>), options?: { replace?: boolean }): void | Merge into edge.data, or replace it. |
| deleteElements | deleteElements(elements: { nodes?: (FlowNode | { id: string })[]; edges?: (FlowEdge | { id: string })[] } | string[], options?: { reconnect?: boolean }): Promise<{ deletedNodes: FlowNode[]; deletedEdges: FlowEdge[] }> | Delete with cascade. reconnect: true links the neighbours. Runs on.beforeDelete. |
| reconnectEdge | reconnectEdge(oldEdge: FlowEdge, connection: Connection, options?: { shouldReplaceId?: boolean }): void | Move an edge to a new connection. |
| getIncomers | getIncomers(node: FlowNode | { id: string }): FlowNode[] | Nodes with an edge into this one. |
| getOutgoers | getOutgoers(node: FlowNode | { id: string }): FlowNode[] | Nodes this one has an edge to. |
| getConnectedEdges | getConnectedEdges(nodes: (FlowNode | { id: string })[]): FlowEdge[] | Edges touching any of these nodes. |
| getNeighbours | getNeighbours(id: string): { nodes: FlowNode[]; edges: FlowEdge[] } | Nodes one edge away. |
| toObject | toObject(): { nodes: FlowNode[]; edges: FlowEdge[]; viewport: Viewport } | Nodes, edges and viewport, for saving. |
| insertNodeOnEdge | insertNodeOnEdge(edgeId: string, node: FlowNode): void | Split an edge with a new node. |
| setParent | setParent(id: string, parentId: string | null): void | Move a node into a group, or out with null. |
Selection
| Member | Signature | Description |
|---|---|---|
| getSelectedNodes | getSelectedNodes(): FlowNode[] | Selected nodes. |
| getSelectedEdges | getSelectedEdges(): FlowEdge[] | Selected edges. |
| selectNodes | selectNodes(ids: string[], options?: { additive?: boolean }): void | Select nodes by id. additive keeps the rest. |
| selectEdges | selectEdges(ids: string[], options?: { additive?: boolean }): void | Select edges by id. |
| clearSelection | clearSelection(): void | Deselect everything. |
| selectAll | selectAll(): void | Select every selectable node. |
| bringToFront | bringToFront(ids?: string[]): void | Raise nodes above the rest. |
Viewport
| Member | Signature | Description |
|---|---|---|
| viewport | viewport: Viewport | Current x, y and zoom. |
| zoom | zoom: number | Current zoom. |
| setViewport | setViewport(viewport: Partial<Viewport>, options?: { duration?: number }): Promise<void> | Jump or animate to a viewport. |
| panBy | panBy(delta: XYPosition): boolean | Pan by a pixel delta. |
| zoomIn | zoomIn(options?: { duration?: number }): Promise<void> | Zoom in one step. |
| zoomOut | zoomOut(options?: { duration?: number }): Promise<void> | Zoom out one step. |
| zoomTo | zoomTo(zoom: number, options?: { duration?: number }): Promise<void> | Zoom to a level around the centre. |
| zoomAt | zoomAt(point: XYPosition, ratio: number, options?: { duration?: number }): Promise<void> | Zoom by a ratio around a point. |
| fitView | fitView(options?: FitViewOptions): Promise<boolean> | Fit all or some nodes in view. |
| fitBounds | fitBounds(bounds: Rect, options?: { padding?: number; duration?: number; minZoom?: number; maxZoom?: number }): Promise<void> | Fit a rectangle in view. |
| setCenter | setCenter(x: number, y: number, options?: { zoom?: number; duration?: number }): Promise<void> | Centre a flow point. |
Geometry
| Member | Signature | Description |
|---|---|---|
| screenToFlowPosition | screenToFlowPosition(point: XYPosition, options?: { snapToGrid?: boolean }): XYPosition | Browser point to flow coordinates. |
| flowToScreenPosition | flowToScreenPosition(point: XYPosition): XYPosition | Flow point to browser coordinates. |
| pointerFlowPosition | pointerFlowPosition: XYPosition | Last pointer position in flow coordinates. |
| getNodePositionAbsolute | getNodePositionAbsolute(node: FlowNode): XYPosition | Top-left after parent offsets. |
| getNodeRect | getNodeRect(nodeOrId: FlowNode | string): Rect | null | Absolute rectangle of a measured node. |
| getNodesBounds | getNodesBounds(nodes?: (FlowNode | { id: string } | string)[]): Rect | Bounds of some or all nodes. |
| getIntersectingNodes | getIntersectingNodes(target: FlowNode | { id: string } | Rect, partially?, nodes?: FlowNode[]): FlowNode[] | Nodes that overlap a node or rectangle. |
| getNodeHandles | getNodeHandles(nodeOrId: FlowNode | string): ResolvedHandle[] | Resolved handles with absolute centres. |
| getEdgeEndpoints | getEdgeEndpoints(edge: FlowEdge): EdgeEndpoints | null | Resolved endpoints and sides of an edge. |
| getVisibleNodes | getVisibleNodes(): FlowNode[] | Nodes that are not hidden, in paint order. |
History and clipboard
| Member | Signature | Description |
|---|---|---|
| history | history | undo, redo, canUndo, canRedo, mark, clear. |
| run | run(fn: () => T, options: { history: "ignore" | "merge" }): T | Batch changes as one undo step, or keep them out of history. |
| getContent | getContent(ids?: string[]): FlowContent | Nodes and inner edges for copying. |
| putContent | putContent(content: FlowContent, options?: { at?: XYPosition; offset?: XYPosition; select?: boolean }): FlowContent | Insert copied content with fresh ids. |
| duplicate | duplicate(ids?: string[]): FlowContent | Copy and paste in one step. |
| copy | copy(): Promise<void> | Copy the selection. |
| paste | paste(): Promise<FlowContent> | Paste at the pointer. |
Editing
| Member | Signature | Description |
|---|---|---|
| editingId | editingId: string | null | Node in inline text edit, or null. |
| startEditing | startEditing(id: string): void | Start inline text edit on a node. |
| stopEditing | stopEditing(options?: { commit?: boolean }): void | End the edit; commit or cancel. |
| insertWaypoint | insertWaypoint(edgeId: string, index: number, point: XYPosition): void | Add a bend to an edge. |
| moveWaypoint | moveWaypoint(edgeId: string, index: number, point: XYPosition): void | Move a bend. |
| removeWaypoint | removeWaypoint(edgeId: string, index: number): void | Remove a bend. |
| guides | guides: Guide[] | Alignment guides of the current drag. |
| resolveOverlaps | resolveOverlaps(ids?: string[], options?: { margin?: number; overlapThreshold?: number }): void | Move the given nodes, or the selection, clear of the nodes they overlap. |
| collapse | collapse(id: string): void | Hide downstream nodes no other visible node reaches. Without outgoing edges, hide child nodes. |
| expand | expand(id: string): void | Show it again. |
| toggleCollapsed | toggleCollapsed(id: string): void | Collapse or expand. |
| hiddenChildCount | hiddenChildCount(id: string): number | How many nodes a collapsed node hides. |
| isNodeHidden | isNodeHidden(node: FlowNode): boolean | Hidden by node.hidden or by a collapse. |
| nudge | nudge(direction: "left" | "right" | "up" | "down", multiplier?, merge?): void | Move the selection by multiplier flow pixels in a direction. |
| alignNodes | alignNodes(ids: string[], mode: "left" | "centerX" | "right" | "top" | "centerY" | "bottom"): void | Align nodes to one side or centre. |
| distributeNodes | distributeNodes(ids: string[], axis: "x" | "y"): void | Space nodes evenly. |
Layout
| Member | Signature | Description |
|---|---|---|
| layout | layout(algorithm?: LayoutAlgorithm, options?: LayoutOptions & { fitView?: boolean }): Promise<void> | Run the layout prop, or another algorithm, now. |
State
| Member | Signature | Description |
|---|---|---|
| interaction | interaction: Readonly<FlowInteraction> | Resolved interaction config. |
| setInteraction | setInteraction(partial: DeepPartial<FlowInteraction>): void | Merge a partial interaction config at runtime. |
| can | can(gesture: Gesture, target: GestureTarget, fallback?): boolean | Ask whether a gesture is allowed on a target. |
| hoveredNodeId | hoveredNodeId: string | null | Node under the pointer. |
| hoveredEdgeId | hoveredEdgeId: string | null | Edge under the pointer. |
| connection | connection: ConnectionState | null | Connection being dragged, or null. |
| isDraggingNodes | isDraggingNodes: boolean | A node drag is active. |
| setInteractive | setInteractive(interactive: boolean): void | Lock or unlock editing, like the lock button in the controls. |
| cancelConnection | cancelConnection(): void | Abort the connection in progress. |
| dispose | dispose(): void | Release listeners. Call it from your State's dispose. |
Types
FlowNode
| Field | Type | Description |
|---|---|---|
| id | string | Unique id. |
| position | XYPosition | Top-left in flow coordinates (relative to the parent when `parentId` is set). |
| data | TData | Your data. Builders read it. |
| type? | string | Application-defined type. Select visual builders inside custom.node or custom.edge. |
| width? | number | Fixed size; when omitted the node is measured after layout. |
| height? | number | Fixed height; measured when omitted. |
| measured? | Dimensions | Written by the engine after measurement. |
| selected? | boolean | Selected. |
| dragging? | boolean | Written while dragging. |
| draggable? | boolean | Per-node drag permission. |
| selectable? | boolean | Per-item selection permission. |
| connectable? | boolean | Per-node connect permission. |
| deletable? | boolean | Per-item delete permission. |
| hidden? | boolean | Not drawn or hit tested. |
| parentId? | string | Parent group. position is then relative to it. |
| collapsible? | boolean | Marks a node that can collapse. The default context menu then offers Collapse and Expand. |
| collapsed? | boolean | Hides downstream nodes no other visible node reaches. Without outgoing edges, hides its child nodes. |
| extent? | CoordinateExtent | "parent" | Drag bounds, or parent to stay inside the parent. |
| zIndex? | number | Paint order. |
| sourcePosition? | Position | Fallback edge anchor sides when the node has no handles. |
| targetPosition? | Position | Fallback target side when there are no handles. |
| handles? | HandleSpec[] | Overrides the node type's handles. |
| resizable? | boolean | Shows resize controls while selected. interaction.edit.resize sets the default. |
| resizeOptions? | NodeResizeOptions | Size limits and visible controls for this node. |
| resizing? | boolean | Written by the engine while a resize gesture is active. |
| toolbar? | NodeToolbarOptions | Placement of the node type's toolbar. |
FlowEdge
| Field | Type | Description |
|---|---|---|
| id | string | Unique id. |
| source | string | Source node id. |
| target | string | Target node id. |
| sourceHandle? | string | null | Source handle id, or null for the default. |
| targetHandle? | string | null | Target handle id, or null for the default. |
| type? | string | Application-defined type. Select visual builders inside custom.node or custom.edge. |
| data? | TData | Your data. Builders read it. |
| label? | string | Text for custom.edgeLabel. |
| selected? | boolean | Selected. |
| animated? | boolean | Animated dash. |
| hidden? | boolean | Not drawn or hit tested. |
| deletable? | boolean | Per-item delete permission. |
| selectable? | boolean | Per-item selection permission. |
| reconnectable? | boolean | "source" | "target" | Which ends may be dragged to another handle. |
| markerStart? | EdgeMarker | MarkerShape | Marker at the source end. |
| markerEnd? | EdgeMarker | MarkerShape | Marker at the target end. |
| zIndex? | number | Paint order. |
| style? | EdgeStyle | Stroke colour and width. |
| waypoints? | XYPosition[] | Bend points in flow coordinates. |
| adjusting? | "none" | "ends" | "stretch" | How bends follow moved ends: ends shifts the nearest bends, stretch scales all, none keeps them. |
| pathOptions? | { curvature?: number; offset?: number; borderRadius?: number } | Curvature, offset and corner radius for the built-in path types. |