Classes
Import these from @grafloria/renderer.
Classes
DrawTool
tsclass DrawTool extends WhiteboardTool implements CanvasTool
Properties
| Name | Type | Default | Description |
|---|---|---|---|
id | 'whiteboard-draw' | ||
priority | Every whiteboard tool STATES its tier — see the arbitration header above. |
Methods
constructor(host: WhiteboardHost, private readonly opts: DrawToolOptions = {})onPointerDown(ev: ToolPointerEvent, _hit?: ToolHitContext): voidonPointerMove(ev: ToolPointerEvent, _hit?: ToolHitContext): voidonPointerUp(ev: ToolPointerEvent, _hit?: ToolHitContext): voidsetActive(active: boolean): voidisActive(): booleanhitTest(): booleandispose(): voidonCancel(): void
EraserTool
tsclass EraserTool extends WhiteboardTool implements CanvasTool
Properties
| Name | Type | Default | Description |
|---|---|---|---|
id | 'whiteboard-eraser' | ||
priority | Every whiteboard tool STATES its tier — see the arbitration header above. |
Methods
constructor(host: WhiteboardHost, private readonly opts: EraserToolOptions = {})onPointerDown(ev: ToolPointerEvent, _hit?: ToolHitContext): voidonPointerMove(ev: ToolPointerEvent, _hit?: ToolHitContext): voidonPointerUp(_ev?: ToolPointerEvent, _hit?: ToolHitContext): voidoverride onCancel(): voidsetActive(active: boolean): voidisActive(): booleanhitTest(): booleandispose(): void
HighlighterController
tsclass HighlighterController
Methods
constructor(config: Partial<HighlighterConfig> = {})getConfig(): HighlighterConfigupdateConfig(patch: Partial<HighlighterConfig>): voidrefreshValidation(engine: DiagramEngine): ValidationIssue[]— Run the engine's validation once and cache the per-entity issues.
Called on structure changes (node/link added/removed/reconnected) — NOT per
frame: validateDiagram() walks every node, link, hierarchy and group.
getIssues(entityId: string): ValidationIssue[]— Issues cached for one entity (empty when clean / never refreshed).clearValidation(): void— Drop the cached validation (e.g. when the diagram is swapped).compute(engine: DiagramEngine): Highlighter[]— Every highlighter that applies right now, in paint order: validation first (bottom), then selection, then hover, then connect targets (top).
InkOverlay
A camera-registered SVG scratch layer for transient drawing feedback.
Draws in WORLD coordinates: the layer's <g> carries the same translate+scale the SVG
layer's viewBox implies, so a pan or a zoom re-registers every preview with ONE transform
write instead of re-projecting points in JS.
tsclass InkOverlay
Methods
constructor(private readonly options: InkOverlayOptions)get element(): SVGSVGElement— For tests and the a11y audit — the DOM this owns.drawPolyline(points: ReadonlyArray<{ x: number; y: number }>, style: InkPreviewStyle): void— Paint (or repaint) the in-progress freehand line throughpoints(world coordinates). ONEdattribute write — no VNode, no frame.drawRect(x: number, y: number, width: number, height: number, style: InkPreviewStyle): void— Paint the rubber-band rectangle for the rectangle tool (world coordinates).clear(): void— Remove all preview geometry. Called on pointerup/cancel, once per gesture.dispose(): void
InPlaceTextEditor
tsclass InPlaceTextEditor
Methods
getSession(): TextEditSession | nullisEditing(): booleanbegin(engine: DiagramEngine, target: TextEditTarget): TextEditSession | null— Open a session on a target. Returns null when the target does not exist or is not editable (behavior.editable === false, or a locked node).commit(engine: DiagramEngine, value: string): Command | null— Commit the session's new value. Returns the undoable command (null for a no-op edit, or when the session is gone). Always ends the session.cancel(): void— Abandon the session without touching the model.
RectangleTool
tsclass RectangleTool extends WhiteboardTool implements CanvasTool
Properties
| Name | Type | Default | Description |
|---|---|---|---|
id | 'whiteboard-rectangle' | ||
priority | Every whiteboard tool STATES its tier — see the arbitration header above. |
Methods
constructor(host: WhiteboardHost, private readonly opts: RectangleToolOptions = {})onPointerDown(ev: ToolPointerEvent, _hit?: ToolHitContext): voidonPointerMove(ev: ToolPointerEvent, _hit?: ToolHitContext): voidonPointerUp(ev: ToolPointerEvent, _hit?: ToolHitContext): voidsetActive(active: boolean): voidisActive(): booleanhitTest(): booleandispose(): voidonCancel(): void
StrokeEditTool
tsclass StrokeEditTool extends WhiteboardTool implements CanvasTool
Properties
| Name | Type | Default | Description |
|---|---|---|---|
id | 'whiteboard-stroke-edit' | ||
priority | INK tier: outranks the mode tools, and is SAFE to because {@link hitTest} only ever claims a press that lands on ink — see the arbitration header. |
Methods
constructor(host: WhiteboardHost, private readonly opts: StrokeEditToolOptions = {})getSelectedStroke(): StrokeModel | null— What the tool considers selected — for hosts, tests, and a future style panel.override hitTest(ev?: ToolPointerEvent): boolean— CLAIM the gesture only when ink is under the pointer. This is what lets the tool coexist with the whole built-in ladder instead of monopolising the canvas.onPointerDown(ev: ToolPointerEvent, _hit?: ToolHitContext): voidonPointerMove(ev: ToolPointerEvent, _hit?: ToolHitContext): voidonPointerUp(ev: ToolPointerEvent, _hit?: ToolHitContext): voidoverride onCancel(): void— Escape / pointercancel: drop the gesture AND the selection. Nothing was committed.override setActive(active: boolean): voidisActive(): booleandispose(): void
TouchGestureController
tsclass TouchGestureController
Methods
constructor( private readonly host: TouchGestureHost, options: TouchGestureOptions = {}, private readonly selectionTools?: SelectionToolsController )get activePointerCount(): number— How many fingers are down. Exposed for tests and for the binder's cursor logic.get isPinching(): boolean— True while a two-finger pinch owns the gesture.onPointerDown(event: PointerEvent): voidonPointerMove(event: PointerEvent): voidonPointerUp(event: PointerEvent): voidonPointerCancel(event: PointerEvent): void— The OS took the gesture (call, notification, browser back-swipe). Abort cleanly.reset(): void— Drop every listener-visible bit of state (binder detach).
Was this page helpful?