Skip to content

LinkingConfig

since v0.8.0

Configuration for linking (edge creation) behavior.

defaultRelinkable: boolean | EdgeEnd

Default relinkable value for edges that do not set their own. true lets the user drag both ends of an edge to another port, 'source' or 'target' allows only that end, and false allows neither. A selected edge shows a handle at each end that can be relinked. Dragging a handle previews the new connection and commits it on drop. A drop on empty canvas detaches the endpoint when danglingEdges.enabled is true; otherwise the relink is reverted.

Relinking uses the same portSnapDistance, edge panning and temporaryEdgeDataBuilder settings as edge drawing. Each drop is validated with validateConnection, which receives a context with reason: 'relink' and the edge being relinked.

false

1.4.0


edgePanningEnabled: boolean

Enable edge panning when the routed edge is near the edge of the viewport.

true

edgePanningForce: number

Multiplier for edge panning speed while routing edge is near the edge of the viewport.

10

edgePanningThreshold: number

The threshold in pixels for edge panning to start. If the mouse pointer is within this distance from the edge of the viewport, panning will be triggered.

30

finalEdgeDataBuilder: (defaultFinalEdgeData) => Edge

Allows customization of the final edge object when the user completes edge creation. Receives the default finalized edge (with source/target node/port IDs) and should return a fully-formed Edge object to be added to the flow.

Edge

The default finalized edge data (may be incomplete).

Edge

The Edge object to use for the finalized edge.

(edge) => Edge

portSnapDistance: number

The maximum distance (in pixels) at temporary edge will snap to target port.

10

selectNodeOnPortPress: boolean

Whether to select a node when the user presses a port to start linking. When true (default), pressing a port also triggers node selection events. When false, port press only initiates the linking gesture without selecting the node.

true

1.2.0


temporaryEdgeDataBuilder: (defaultTemporaryEdgeData) => Edge

Allows customization of the temporary edge object shown while the user is dragging to create a new edge. Receives the default temporary edge (with source/target node/port IDs and positions) and should return a fully-formed Edge object for rendering the temporary edge.

Edge

The default temporary edge data (may be incomplete).

Edge

The Edge object to use for the temporary edge.

(edge) => Edge

validateConnection: (source, sourcePort, target, targetPort, context?) => boolean

Validates whether a connection between two nodes and ports is allowed.

Called for every operation that creates a connection: drawing a new edge, relinking an endpoint of an existing edge, and attachEdge. The optional context tells which operation is being validated (since 1.4.0).

source is null for draws started with startLinkingFromPosition. When an edge is relinked or attached, the other end of that edge can be free (dangling); the source or target for that end is then null.

The source node, or null when the source end is free.

null | Node

The source port.

null | Port

The target node, or null when the target end is free.

null | Node

The target port.

null | Port

ConnectionValidationContext

The operation being validated (draw when omitted).

boolean

True if the connection is valid, false otherwise.

() => true