Skip to content
D
Documentation

Interaction — interfaces a–t

reference
11 min readUpdated

Interfaces A–T

Import these from @grafloria/renderer.

Interfaces

AddWaypointResult

Result of adding a waypoint

ts
interface AddWaypointResult

Properties

NameTypeDefaultDescription
newPointsPoint[]
waypointIndexnumber
segmentIndexnumber

AlignmentGuide

A single alignment snapline. position is the aligned coordinate.

ts
interface AlignmentGuide

Properties

NameTypeDefaultDescription
orientation'vertical' | 'horizontal'
positionnumberWorld x (vertical guide) or world y (horizontal guide).
fromnumberExtent of the drawn line along the other axis.
tonumber
kind'edge' | 'center'

Announcement

ts
interface Announcement

Properties

NameTypeDefaultDescription
messagestring
politeness'polite' | 'assertive'assertive interrupts the screen reader (errors); default polite.
seqnumberMonotonic counter — hosts re-announce only when this changes.

ControlPoint

Control point information

ts
interface ControlPoint

Properties

NameTypeDefaultDescription
pointPointPosition of the control point
segmentIndexnumberIndex of the segment this control point belongs to
type'control1' | 'control2'Type of control point (control1 or control2)
anchorPointAnchor point (from/to) that this control point affects

ControlPointHitResult

Result of hit testing a control point

ts
interface ControlPointHitResult

Properties

NameTypeDefaultDescription
segmentIndexnumberIndex of the segment
controlType'control1' | 'control2'Type of control point
pointPointPosition of the control point
anchorPointAnchor point

DrawToolOptions

ts
interface DrawToolOptions

Properties

NameTypeDefaultDescription
color?string
width?number
opacity?numberHighlighter ink is translucent.
simplifyEpsilon?numberDouglas-Peucker tolerance at commit. Omit to use the model's tuned default.
label?stringAn author label for the committed ink — makes it a NAMED annotation in the a11y tree.
active?boolean

EraserToolOptions

ts
interface EraserToolOptions

Properties

NameTypeDefaultDescription
radius?numberExtra hit radius in world units around the eraser path. Default 8.
active?boolean

FocusRing

What the host draws as the visible focus ring.

ts
interface FocusRing

Properties

NameTypeDefaultDescription
typeFocusTargetType
idstring
bounds?RectangleNodes: the padded world box.
rotation?number
points?Point[]Links: the routed polyline.
labelstringThe accessible name announced for this target.

FocusTarget

ts
interface FocusTarget

Properties

NameTypeDefaultDescription
typeFocusTargetType
idstring

Highlighter

ts
interface Highlighter

Properties

NameTypeDefaultDescription
idstringStable key for the host's keyed list.
kindHighlighterKind
entity'node' | 'link'
entityIdstring
bounds?RectangleNode highlighters: the padded world box to outline.
rotation?numberNode highlighters: rotation (deg) about the box centre.
points?Point[]Link highlighters: the routed polyline to trace.
severity?'error' | 'warning'
message?stringValidation message (also the accessible description).
classNamestringSuggested CSS class, so a host can theme without re-deriving the kind.

HighlighterConfig

ts
interface HighlighterConfig

Properties

NameTypeDefaultDescription
hoverPaddingnumberWorld padding around a node's box, per kind.
selectionPaddingnumber
validationPaddingnumber
showHoverboolean
showSelectionboolean
showValidationboolean
showConnectTargetsboolean

InkOverlayOptions

ts
interface InkOverlayOptions

Properties

NameTypeDefaultDescription
rootHTMLElementThe mounted diagram's root (.grafloria-diagram-root).
viewportViewportController

InkPreviewStyle

How a preview should look while it is being drawn.

ts
interface InkPreviewStyle

Properties

NameTypeDefaultDescription
colorstring
widthnumber
opacity?number
dashed?booleanDashed outline, for the rectangle tool's rubber-band.

KeyboardConnectState

The keyboard-connect state machine.

ts
interface KeyboardConnectState

Properties

NameTypeDefaultDescription
phase'source' | 'target'
sourceNodeIdstring
sourcePortIdstring
targetNodeId?string
targetPortId?string
validbooleanTrue when the current source/target pair is a legal link.

KeyboardNavConfig

ts
interface KeyboardNavConfig

Properties

NameTypeDefaultDescription
nudgeStepnumberFine nudge step, world units (arrow key).
coarseNudgeStepnumberCoarse nudge step, world units (Shift + arrow).
wrapFocusbooleanFocus wraps around at the ends of the order.
focusRingPaddingnumberWorld padding of the focus ring around a node's box.

LinkPartHit

Part-aware link hit result: a link plus WHICH sub-part of it was hit (body / label / endpoint / arrow) and local info (label index, or the 0-1 position t along the path for body hits). Downstream edge features (inline label editing, endpoint reconnection, edge toolbar) key off part.

ts
interface LinkPartHit

Properties

NameTypeDefaultDescription
linkLinkModel
partLinkPart
labelIndex?number
t?number

PathHitResult

Result of hit testing a path segment

ts
interface PathHitResult

Properties

NameTypeDefaultDescription
segmentIndexnumber
insertPositionPoint
insertIndexnumber
distancenumber

Point

Point in 2D space

ts
interface Point

Properties

NameTypeDefaultDescription
xnumber
ynumber

PortHit

A port the magnet found, with its owner.

ts
interface PortHit

Properties

NameTypeDefaultDescription
portPortModel
nodeNodeModel
positionPointWorld position of the port.
distancenumber

ProximityCandidate

A proximity-connect candidate: link source → target if the user drops here.

ts
interface ProximityCandidate

Properties

NameTypeDefaultDescription
sourcePortPortModel
targetPortPortModel
sourceNodeIdstring
targetNodeIdstring
distancenumber

RectangleToolOptions

ts
interface RectangleToolOptions

Properties

NameTypeDefaultDescription
fill?string
stroke?string
strokeWidth?number
minSize?numberBelow this size (world px) the drag is treated as a mis-click and no node is made.
label?string
active?boolean

ResizeOptions

ts
interface ResizeOptions

Properties

NameTypeDefaultDescription
minWidth?number
minHeight?number
maxWidth?numberUpper bound on the dragged size, clamped DURING the gesture. Default ∞.
maxHeight?number
keepAspect?booleanPreserve the starting aspect ratio (corner handles only).
aspect?numberExplicit width÷height ratio to lock to (corner handles only). Set by a per-node aspect lock; overrides the start ratio and implies keepAspect.

SelectionToolLayer

Everything the host needs to draw the tool layer for the current selection.

ts
interface SelectionToolLayer

Properties

NameTypeDefaultDescription
boundsRectangle | nullWorld bbox of the selection; null when nothing is selected.
rotationnumberRotation (deg) of the single selected node; 0 otherwise.
centerPoint | nullWorld centre the bounds rotate about (the frame outline follows it).
nodeIdsstring[]
linkIdsstring[]
handlesToolHandle[]

SelectionToolsConfig

ts
interface SelectionToolsConfig

Properties

NameTypeDefaultDescription
handleSizenumberSide of a square resize handle, in SCREEN px.
rotateHandleOffsetnumberDistance from the selection's top edge to the rotate handle, SCREEN px.
haloGapnumberGap between the selection box and the halo column, SCREEN px.
haloButtonSizenumberDiameter of a halo button, SCREEN px.
showHalobooleanShow the Halo context toolbar.
showResizeHandlesbooleanShow the 8 resize handles (single-node selection only).
showRotateHandlebooleanShow the rotate handle (single-node selection, behavior.rotatable).
showRemoveButtonbooleanShow the ✕ remove button.
showLinkToolsbooleanShow link endpoint / vertex tools for a selected link.
minWidthnumberSmallest width/height a resize may produce, WORLD units.
minHeightnumber
rotationSnapDegreesnumberRotation snap while a modifier is held, in degrees.
resolveNodeToolbar?ToolbarResolverPer-TYPE toolbar policy. Layered on top of each node's own metadata.toolbar; lets a host decide which tools a node type exposes without touching per-node data. Omit for "every tool, every node".

SnapConfig

Framework-agnostic and pure w.r.t. the geometry it is handed: computeSnap takes the moving box + the boxes it may align to and returns the corrected box PLUS the guides a host should draw. Nothing here renders, and nothing mutates the model — except the explicit port-highlight helper, which sets the same isHighlighted / isValidTarget flags the renderer already draws for connection dragging.

Everything is measured in WORLD units. Hosts that want a constant on-screen feel pass snapThreshold: px / zoom (see DiagramCanvasComponent).

ts
interface SnapConfig

Properties

NameTypeDefaultDescription
enabledbooleanMaster switch for alignment snaplines + equal spacing.
snapToGridbooleanQuantise the box to a grid (applied when no alignment guide claims an axis).
gridSizenumber
snapThresholdnumberDistance (world units) within which an alignment candidate snaps.
equalSpacingbooleanEmit equal-spacing guides (Figma/GoJS-style distribution hints).
keepInBoundsRectangle | nullWorld rectangle the moving box must stay inside (null = unbounded).
snapToPortRadiusnumberMagnetic port radius — the engine's snapToPortRadius lives here.
proximityConnectRadiusnumberDrop-a-node-near-a-port auto-link radius (React-Flow proximity connect).

SnapResult

ts
interface SnapResult

Properties

NameTypeDefaultDescription
boxRectangleThe corrected box (grid / alignment / spacing / bounds applied).
dxnumberCorrection applied to the input box.
dynumber
guidesAlignmentGuide[]
spacingSpacingGuide[]

SpacingGuide

An equal-spacing hint: two or more equal gaps, each with a distance label.

ts
interface SpacingGuide

Properties

NameTypeDefaultDescription
orientation'horizontal' | 'vertical'
gapnumberThe equal gap, in world units.
labelstringHuman label the host draws at the segment's midpoint (e.g. "40").
segmentsArray<{ x1: number; y1: number; x2: number; y2: number }>The measured gaps, as segments to draw.

StrokeEditToolOptions

ts
interface StrokeEditToolOptions

Properties

NameTypeDefaultDescription
tolerance?numberExtra hit radius in world units around the ink. Default 6 — finger-friendly.
highlightColor?stringHighlight colour for the selected stroke's ghost.
active?boolean

TextEditSession

ts
interface TextEditSession

Properties

NameTypeDefaultDescription
targetTextEditTarget
valuestringThe text the editor opens with.
boundsRectangleWorld rectangle the editor should cover.
centerPointWorld point the editor centres on (labels have no box of their own).
multilinebooleanNode labels wrap; link labels are single-line.

TextEditTarget

ts
interface TextEditTarget

Properties

NameTypeDefaultDescription
typeTextEditTargetType
nodeId?stringNode being edited (type: 'node').
linkId?stringLink owning the label (type: 'link-label').
labelIndex?numberWhich label on that link. Links carry TWO label dialects: the positioned labels[] collection, and the DISPLAY label every spec input writes (edges: [{label}] → metadata.label, painted at the path midpoint).

ToolModifierState

Modifier snapshot a host forwards from its pointer events.

ts
interface ToolModifierState

Properties

NameTypeDefaultDescription
shift?boolean
alt?boolean
ctrl?boolean
meta?boolean

TouchGestureHost

Everything the gesture controller needs from its host (keeps it DI-free).

ts
interface TouchGestureHost

Properties

NameTypeDefaultDescription
viewportViewportController
interactionInteractionController

Members

  • getEngine(): DiagramEngine | null
  • getRect(): CanvasRect
  • requestRender(): void
  • emit(event: string, payload: unknown): void
  • isReadonly(): boolean — Live read — read-only can be toggled while the canvas is mounted.

TouchGestureOptions

ts
interface TouchGestureOptions

Properties

NameTypeDefaultDescription
enablePan?boolean
enableZoom?boolean
longPressMs?numberms a finger must rest before it becomes a context-menu gesture. Default 500.
moveTolerancePx?numberCSS px of travel that cancels a long-press / promotes a tap to a drag. Default 10.
tapMaxMs?numberMax ms for a press+release to count as a tap. Default 300.

Was this page helpful?

Interaction — interfaces a–t — Grafloria