Skip to content
D
Documentation

DiagramEventMap

reference
2 min readUpdated

Import it from @grafloria/renderer.

ts
interface DiagramEventMap

Properties

NameTypeDefaultDescription
'connect:drop-empty'{ nodeId: string | undefined; portId: string; world: { x: number; y: number }; clientPoint: { x: number; y: number } }A connection drag (from a port, or its "+") ended over NOTHING. The host can offer the next step there; world is where, in diagram coordinates.
'link:insert-request'{ linkId: string; nodeId: string; clientPoint: { x: number; y: number } }A single node was dragged and released over a link (nodeDropOnLink). Nothing changed; the host decides.
'renderer:warning'EdgeWarningSomething in the input did not land as written, and the instance carried on: an edge dropped because an end resolves to no port, or attached to a fallback port because the one it names does not exist. Warnings raised while createDiagram applies its initial spec arrive a microtask later, so a listener added right after it returns still hears them.
'port:add-request'PortAddRequestThe "+" on an unconnected output port was pressed (affordances.portAdd).
'link:add-request'LinkAddRequestThe "+" at a hovered link's midpoint was pressed (affordances.linkAdd).
'link:delete-request'LinkAddRequestThe delete button beside it was pressed (affordances.linkDelete).
'nodes:change'{ nodes: NodeModel[] }
'edges:change'{ edges: LinkModel[] }
'selection:change'{ nodes: NodeModel[]; edges: LinkModel[] }
connect{ link: LinkModel }
reconnect{ link: LinkModel; endpoint: 'source' | 'target' }
'node:click'{ node: NodeModel; world: { x: number; y: number } }
'node:doubleclick'{ node: NodeModel; world: { x: number; y: number } }
'edge:click'{ edge: LinkModel; world: { x: number; y: number } }
'viewport:change'{ viewport: Rectangle; zoom: number }
readyvoid
'connect:drop-empty'{ nodeId: string | undefined; portId: string; world: { x: number; y: number }; clientPoint: { x: number; y: number } }A connection drag (from a port, or its "+") ended over NOTHING. The host can offer the next step there; world is where, in diagram coordinates.
'link:insert-request'{ linkId: string; nodeId: string; clientPoint: { x: number; y: number } }A single node was dragged and released over a link (nodeDropOnLink). Nothing changed; the host decides.
'renderer:warning'EdgeWarningSomething in the input did not land as written, and the instance carried on: an edge dropped because an end resolves to no port, or attached to a fallback port because the one it names does not exist. Warnings raised while createDiagram applies its initial spec arrive a microtask later, so a listener added right after it returns still hears them.
'port:add-request'PortAddRequestThe "+" on an unconnected output port was pressed (affordances.portAdd).
'link:add-request'LinkAddRequestThe "+" at a hovered link's midpoint was pressed (affordances.linkAdd).
'link:delete-request'LinkAddRequestThe delete button beside it was pressed (affordances.linkDelete).
'nodes:change'{ nodes: NodeModel[] }
'edges:change'{ edges: LinkModel[] }
'selection:change'{ nodes: NodeModel[]; edges: LinkModel[] }
'node:click'{ node: NodeModel; world: { x: number; y: number } }
'node:doubleclick'{ node: NodeModel; world: { x: number; y: number } }
'edge:click'{ edge: LinkModel; world: { x: number; y: number } }
'viewport:change'{ viewport: Rectangle; zoom: number }

Was this page helpful?