CanvasDocumentHost

Mounts a compiled document on a headless host and draws one of its scenes.

@internote/canvas-sdk/hostComponent
On this page
import { CanvasDocumentHost } from '@internote/canvas-sdk/host';

Builds the host with createHeadlessCanvasHost — rebuilt when the document, files or assets change, since each manifest arrives after the first render — and disposes it on unmount. It renders a CanvasSceneView for sceneIndex, clamped to the last scene, and nothing when the document has no scenes. The reading view mounts CanvasSceneView directly, with its own host.

#Props

Also takes className. Any other prop is passed to the rendered element.

assets
Uploaded image assets, file name → public URL — what an environment drawing an uploaded picture resolves against. null while the manifest is still arriving.
Record<string, string> | null
db
Database-tier backend for session+db environments; a no-op store when absent.
KeyValueStorage
documentRequired
The compiled and refined document.
{ body?: unknown; data?: Record<string, ChalkDataset> }
environments
Types to register before mounting (idempotent).
EnvironmentDefinition[]
files
The internote's uploaded text files by name, where attached dataset CSVs and geometry are read from. null while still loading; the host is rebuilt when it arrives.
Record<string, string> | null
internoteId
The internote's id, the first part of every environment's session key.
string
onStepChange
Called after the shown scene's step changes, with the new step and the scene's index.
(step: number, sceneIndex: number) => void
renderBlankElement
Draws blank-canvas content: the elements of a scene's detail outside its environments. Nothing is drawn for them when absent.
BlankElementRenderer
renderToolbar
Draws the host toolbar with the embedder's own buttons, in place of the minimal built-in one.
(toolbar: HostToolbarState) => ReactNode
resolveAssetUrl
Resolves a relative image source to a URL for blank-canvas content; null when it cannot.
(fileName: string) => string | null
sceneIndex
Which scene to show (index into the document's scenes).
number
Default0

Declared in packages/canvas-sdk/src/host/CanvasDocumentHost.tsx:600.

Last updated