# Classes

Import these from `@grafloria/renderer`.

## Classes

### `DrawTool`

```ts
class 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): void`
- `onPointerMove(ev: ToolPointerEvent, _hit?: ToolHitContext): void`
- `onPointerUp(ev: ToolPointerEvent, _hit?: ToolHitContext): void`
- `setActive(active: boolean): void`
- `isActive(): boolean`
- `hitTest(): boolean`
- `dispose(): void`
- `onCancel(): void`

### `EraserTool`

```ts
class 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): void`
- `onPointerMove(ev: ToolPointerEvent, _hit?: ToolHitContext): void`
- `onPointerUp(_ev?: ToolPointerEvent, _hit?: ToolHitContext): void`
- `override onCancel(): void`
- `setActive(active: boolean): void`
- `isActive(): boolean`
- `hitTest(): boolean`
- `dispose(): void`

### `HighlighterController`

```ts
class HighlighterController
```

**Methods**

- `constructor(config: Partial<HighlighterConfig> = {})`
- `getConfig(): HighlighterConfig`
- `updateConfig(patch: Partial<HighlighterConfig>): void`
- `refreshValidation(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.

```ts
class 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 through `points` (world coordinates). ONE `d` attribute 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`

```ts
class InPlaceTextEditor
```

**Methods**

- `getSession(): TextEditSession | null`
- `isEditing(): boolean`
- `begin(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`

```ts
class 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): void`
- `onPointerMove(ev: ToolPointerEvent, _hit?: ToolHitContext): void`
- `onPointerUp(ev: ToolPointerEvent, _hit?: ToolHitContext): void`
- `setActive(active: boolean): void`
- `isActive(): boolean`
- `hitTest(): boolean`
- `dispose(): void`
- `onCancel(): void`

### `StrokeEditTool`

```ts
class 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): void`
- `onPointerMove(ev: ToolPointerEvent, _hit?: ToolHitContext): void`
- `onPointerUp(ev: ToolPointerEvent, _hit?: ToolHitContext): void`
- `override onCancel(): void` — Escape / pointercancel: drop the gesture AND the selection. Nothing was committed.
- `override setActive(active: boolean): void`
- `isActive(): boolean`
- `dispose(): void`

### `TouchGestureController`

```ts
class 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): void`
- `onPointerMove(event: PointerEvent): void`
- `onPointerUp(event: PointerEvent): void`
- `onPointerCancel(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).
