Skip to main content
Edit time context handed to FileFormat views. Everything it returns is either immutable or a private instance; nothing reaches back into the open file’s live state.

Methods

image

Looks up an image asset by name, or nil when missing.

blob

Looks up a blob asset by name, or nil when missing.

artboard

A fresh instance of a named artboard, private to this view. The artboard’s default view model instance is bound and reachable through data, nil when the artboard has no view model. Names resolve against this script’s own file, so a format shipped in a library reaches that library’s artboards. Prefix a name with a library’s namespace (markdown@0/Document) to name one explicitly, and use hostArtboard for the file being edited.

hostArtboard

Like artboard, but always resolves in the file being edited. When this script is authored in that same file the two are identical, so a library developed in place behaves as it does once shipped.

theme

The editor’s current theme.

openUrl

Opens a url in the user’s browser.

themeFont

The font the code editor renders with, for previews that want to match its typography. Assign to a view model font property.

defaultFont

The editor’s default UI font, for preview prose. Assign to a view model font property.

codeFont

The editor’s built-in code font, for preview code regions. Assign to a view model font property.

editorScroll

The text editor’s scroll position, refreshed each draw while the user scrolls, or nil on surfaces without an attached editor (inspector, viewer tab). Use with scrollTo to keep the preview in sync.

scrollTo

Scrolls the pane hosting this view to a content offset, clamped to the measured content. Only meaningful for pane views with measure; elsewhere it is ignored.

scrollEditorTo

Scrolls the attached text editor to a fractional line factor (the same unit editorScroll reports), clamped to the editor’s range. Ignored without an attached editor. Guard against ping-pong when combining with editorScroll driven syncing.

requestDraw

Asks the host to repaint the view outside the advance loop, e.g. when an async decode completes.

shader

Looks up a compiled shader by name, or nil when missing.

canvas

Creates a CPU canvas. Zero or missing size defers the backing texture.

gpuCanvas

Creates a GPU canvas for render pass drawing. Zero or missing size defers the backing texture.

features

Capabilities of the active GPU device.

decodeImage

Decodes an encoded image (png, jpeg, webp) into a drawable image.