The unique type name of the adapter, which is used to associate it with nodes of a specific type. This type is typically registered with the NodeRegistry to enable the diagram control to find the appropriate adapter for each node.
OptionaliconOptional icon for this tool shown in the tool palette and any icon-aware UI.
Two formats are supported:
SVG string — provide the full <svg> markup for the icon:
icon: {
type: 'svg',
markup: '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">...</svg>',
}
Image URL — provide any resolvable URL (data URL, CDN, relative path):
icon: { type: 'url', src: 'https://example.com/my-tool.svg' }
When omitted the palette falls back to the built-in IconRegistry entry
matching this adapter's type, then to a text label.
Indicates whether the adapter is for a connector node, which may require special handling for rendering and hit testing.
Optionalmultistep_Indicates whether the node creation process involves multiple steps, such as defining multiple points for a polyline or curve. If true, the diagram control may need to handle additional user interactions during node creation.
Optionaldrag_Indicates whether the node can be created by dragging from the tool palette onto the canvas. If true, the adapter should implement the onCreateDraft method to provide the initial geometry of the draft node to be dragged.
The hollow mode determines how the node's hollow property is calculated based on its fill style.
Indicates whether the adapter supports rendering text within the node, which may affect how the node is rendered and whether text-related interactions are enabled.
Optionalsingle_Indicates whether the adapter supports single-line text rendering within the node. If true, the text will be rendered on a single line, and any overflow will be handled according to the text_overflow property. If false or undefined, multi-line text rendering may be supported.
The text overflow mode determines how text that exceeds the node's bounding box is handled.
Returns the text orientation values this node type supports.
Only relevant for nodes that support text (has_text === true).
When not defined, all orientations are assumed to be supported.
Adapters that render text differently (e.g. curved text) should override this to return a restricted subset.
Returns the text baseline values this node type supports.
Only relevant for nodes that support text (has_text === true).
When not defined, all baselines are assumed to be supported.
Adapters that render text differently (e.g. curved text) should override this to return a restricted subset.
The baseline determines how the text is aligned vertically relative to its bounding box or path.
For example, 'top' aligns the top of the text with the top of the bounding box, 'middle' centers the text vertically, and 'bottom' aligns the bottom of the text with the bottom of the bounding box.
Specifies the connection handles that this node type supports for connecting to other nodes. Each handle is represented by a NodeHandle value, which indicates the position or type of the handle on the node. This property is used to determine where connections can be made to this node and how the diagram control should render connection points. Adapters that support connections should override this to return the appropriate handles for their node type.
Optionalresize_Specifies which resize handles are available for this node type. If not defined, all resize handles are assumed to be supported. Each handle is represented by a NodeHandle value, which indicates the position or type of the handle on the node. This property is used to determine where the user can click and drag to resize the node and how the diagram control should render resize handles. Adapters that support resizing should override this to return the appropriate handles for their node type.
Optionalis_Indicates whether the adapter supports owning a group of other nodes.
Optionalcan_Indicates whether the adapter supports rotation of the node. If true, the diagram control may provide rotation handles and allow the user to rotate the node.
Optionalcan_Indicates whether the adapter supports snapping the node to a grid or guides when moving or resizing. If true, the diagram control may adjust the node's position and size to align with the grid or guides.
Additional logic to determine whether a connection can be made to this node from the specified direction and handle. This method is called during connection creation to validate whether a connection is allowed based on the node's state, geometry, or other criteria. The target can also be used to decide whether a connection can be made. The target can be the connection iteself or the node that is being connected to. The point parameter can be used to determine the world-space coordinates of the connection point, if available. Adapters that support connections should override this to implement custom connection rules.
The node to which the connection is being made.
The connection handle on the node.
The direction of the connection, either 'from' (outgoing) or 'to' (incoming).
Optionaltarget: Partial<INode>The target node or connection that is being connected to, if available. This can be used to determine whether the connection is allowed based on the target's type or state.
Optionalpoint: IPointThe world-space coordinates of the connection point, if available.
Returns a default connection object for this node type, which can be used to create a new connection when the user initiates a connection to this node.
OptionalonCreates and returns a new draft node for the given tool when the user initiates a drag-create action from the tool palette. This will only be called if the adapter's drag_create property is true.
The tool identifier for which to create the draft node.
The newly created draft node, or undefined if the draft node should not be created.
OptionalafterAny special handling to perform after a connection is made to this node, such as updating its geometry or state based on the new connection.
The node that was connected.
The direction of the connection ('from' or 'to').
The connection anchor involved in the connection, or null if none.
OptionalafterUpdates the node's size while the user is dragging a resize handle. Called on every pointermove while a resize is active.
The node being resized.
The handle being used to resize the node.
OptionalonPerforms a hit test on the given node with the specified point.
The handle of the node that was hit, or NodeHandle.NONE if no hit occurred.
Snaps the given node to the specified grid by modifying its points.
The node to snap.
The grid to snap the node to.
Optionalhandle: NodeHandleThe handle being used to resize the node.
Renders the given node on the specified canvas context.
The node to render.
The canvas rendering context to draw on.
Optionalshow: "all" | "quick"Renders the selection state of the given node on the specified canvas context.
The node whose selection state to render.
The canvas rendering context to draw on.
Specifies whether to show all handles or connection handles.
Where to place the text for this node, if it has any. This is used for rendering and in-place editing.
The node whose text placement to determine.
The text placement information, or undefined if the node has no text.
Returns the visual bounding rect of the node's rendered path in world coordinates.
For most nodes this equals the rect computed from their points.
Adapters whose paths extend beyond that rect (e.g. a document node whose
wavy bottom dips below the bottom edge) should override this to return the
true visual bounds so that cover-mode images fill the entire visible shape.
The default implementation returns rect unchanged.
The visual bounding rect.
Optionaldirection: "from" | "to" | "any"Writes the given node to a JSON-serializable format using the provided serializer.
The node to serialize.
The serializer to use for converting the node to JSON.
The JSON-serializable representation of the node.
Reads a node from the given JSON data using the provided serializer.
The JSON data to read the node from.
The serializer to use for converting the JSON data to a node.
A promise that resolves to the deserialized node.
INodeAdapter defines the interface for handling different types of nodes in the diagram. It includes methods for hit testing, rendering, and serialization/deserialization of nodes.