ReadonlycameraReadonlyconstraintReadonlydomReadonlyelementReadonlyhistoryReadonlyhistoryReadonlylayerReadonlystoreReadonlytoolReadonlytoolPresentation controls for this viewport.
Shortcuts help controls for this viewport.
Optionalopts: {Optionaldata?: Record<string, unknown>OptionalhtmlType?: stringOptionalinteractive?: booleanControls take clicks; padding selects and moves. Persisted and synced.
Optionalorigin?: stringNon-'local' origin marks the add as external: no undo step, tagged for observers.
Optionaltransient?: booleanHost-owned element: excluded from exported state and never sent to the sync hub.
Adds selected root subtrees as children of an existing frame.
Removes a frame while preserving its direct children as roots.
Declares htmlTypes that route to canvas painters even before a painter for
them registers, so the element renderer never treats them as DOM-backed
(avoiding a DOM-mount flash while a host is still loading its painter).
Returns an idempotent release; each expect call is independently reference
counted by the registry.
Optionaloptions: ExportImageOptionsOptionaloptions: ExportPdfOptionsOptionaloptions: ExportSvgOptionsSize in CSS pixels of the canvas that getVisibleRect() measures.
Exposed because canvasEl is private: consumers can only reach the
wrapper (via domLayer.parentElement), so without this accessor the
canonical size behind getVisibleRect() is unreachable and callers
resort to getVisibleRect().w * camera.zoom. Capture and restore must
measure the same element or saved views do not round-trip.
Topmost element at a world point, using the same geometry selection uses (rotation-aware, grid excluded, real stroke/line hit paths).
match participates in the topmost-first walk rather than filtering the
result, so a non-matching element on top does not swallow the hit.
Invisible layers are never returned, in any mode.
Optionaloptions: HitTestOptionsDirect access to the viewport's live html-painter registry — the same
instance the viewport itself uses to route canvas-backed html elements.
Beyond register/expectCanvasHtmlTypes (already exposed above), this
hands out getActivePainter, canvasTypes, onChange, and version,
so a surface such as the minimap that needs to read routing state or
react to registry changes can do so without the viewport re-deriving or
proxying each capability individually.
getSelectedIds() and the onSelectionChange emitter never surface stale ids: once the enclosing history transaction completes, both reflect the current selection.
Unlike getSelectionStyle() — which returns {} for a style-less
selection — this returns null when no style field is applicable.
Returns the active, resolved board theme.
World-space rectangle currently visible through the canvas.
Whether an embedded board takes touch input; always true when not embedded.
Subscribes to element activations. Persistent and independent of
setActivation: subscribing before activation is enabled, or across a
replacement, keeps working. Emission iterates a snapshot with per-listener
try/catch. Returns an idempotent unsubscribe.
Notifies on each engaged-state change, including Escape; never fires when not embedded.
Subscribes to diagnostics emitted while painting canvas-routed html elements (missing painter, painter threw, degenerate size). Deduped per element/target/kind against the current registry and element versions, so a fail -> repair -> fail-again sequence reports twice rather than being suppressed forever. Returns an idempotent unsubscribe.
Notifies after the host container resizes (ResizeObserver-driven). A resize changes the visible world rect without a camera event; overlays such as the minimap subscribe to stay current. Returns an idempotent unsubscribe.
Persistent, viewport-owned selection-change emitter. Subscribing works
regardless of whether a select tool is registered yet; it forwards
events from whichever select tool is currently attached via
toolManager.onRegister. Never delivers stale ids once the enclosing
history transaction completes.
Fires synchronously after any change exportState() would reflect; returns a disposer.
Fires after the viewport resolves to a different theme.
Notifies for each plain wheel an embedded board leaves to the page; never fires otherwise.
Registers the canvas painter for htmlType. Later registrations for the
same type shadow earlier ones (LIFO); unregistering restores the previous
entry. Existing elements of this type reconcile synchronously — DOM nodes
detach and the render loop repaints on the next frame.
Registers a world-space overlay drawn on every frame, regardless of the
active tool — the surface for remote presence visuals such as laser
trails, cursors, pings, and shared rulers. Overlays draw above elements
and DOM content, beneath the active tool's own renderOverlay, and never
touch elements, history, or persisted state. Returns an idempotent
unsubscribe that also erases the overlay's last frame.
Removes existing elements as one undoable operation and returns the number removed.
Removes selected direct children from an existing frame.
Repaints only the overlay stratum (tool overlay, registered overlays, overlay hooks) on the
next frame. Use requestRender for anything that changes elements, layers, the camera or
other hooks.
Clears authored elbow route axes and returns whether an arrow changed.
Returns whether the action ran.
Enables (or replaces, or with null disables) pointer activation of
canvas-painted elements — the bridge for elements that are drawn rather than
mounted and so cannot receive DOM events. Default off, so every existing
consumer behaves identically.
The controller is a passive observer: listeners are { passive: true } and
it never calls preventDefault, stopPropagation, or takes pointer capture.
Changing or disabling activation resets all active and pending gestures.
Throws RangeError for a non-finite/negative slopPx or a non-positive
doubleDelayMs, leaving any existing activation untouched.
The returned disposer clears only its own generation, so a stale Strict-Mode cleanup cannot tear down a newer registration.
Engages or disengages an embedded board; a no-op when not embedded or after destroy().
Sets or clears (null) the link on every id as one undo step; throws before mutating.
Sets an element's direct parent, or clears its parent when passed null.
Mutations in the window arrive as one batch event, unrecorded in history and without origin.
Groups synchronous local store and layer mutations into one undo step. Joins any open transaction (a nested call or a live tool gesture); a pending keyboard nudge is committed first. If the callback throws, mutations already applied remain undoable and the original error is rethrown.
Command palette controls for this viewport.