> ## Documentation Index
> Fetch the complete documentation index at: https://rive.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# EditorContext

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`

<div class="signature">
  ```lua theme={null}
  image(name: string) -> Image?
  ```
</div>

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

### `blob`

<div class="signature">
  ```lua theme={null}
  blob(name: string) -> Blob?
  ```
</div>

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

### `artboard`

<div class="signature">
  ```lua theme={null}
  artboard(name: string) -> Artboard<ViewModel?>?
  ```
</div>

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`

<div class="signature">
  ```lua theme={null}
  hostArtboard(name: string) -> Artboard<ViewModel?>?
  ```
</div>

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`

<div class="signature">
  ```lua theme={null}
  theme() -> EditorTheme
  ```
</div>

The editor's current theme.

### `openUrl`

<div class="signature">
  ```lua theme={null}
  openUrl(url: string)
  ```
</div>

Opens a url in the user's browser.

### `themeFont`

<div class="signature">
  ```lua theme={null}
  themeFont() -> Font?
  ```
</div>

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

### `defaultFont`

<div class="signature">
  ```lua theme={null}
  defaultFont() -> Font?
  ```
</div>

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

### `codeFont`

<div class="signature">
  ```lua theme={null}
  codeFont() -> Font?
  ```
</div>

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

### `editorScroll`

<div class="signature">
  ```lua theme={null}
  editorScroll() -> EditorScroll?
  ```
</div>

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`

<div class="signature">
  ```lua theme={null}
  scrollTo(x: number, y: number) -> ()
  ```
</div>

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`

<div class="signature">
  ```lua theme={null}
  scrollEditorTo(line: number) -> ()
  ```
</div>

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`

<div class="signature">
  ```lua theme={null}
  requestDraw() -> ()
  ```
</div>

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

### `shader`

<div class="signature">
  ```lua theme={null}
  shader(name: string) -> Shader?
  ```
</div>

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

### `canvas`

<div class="signature">
  ```lua theme={null}
  canvas(desc: {width: number?, height: number?}?) -> Canvas
  ```
</div>

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

### `gpuCanvas`

<div class="signature">
  ```lua theme={null}
  gpuCanvas(desc: {width: number?, height: number?}?) -> GPUCanvas
  ```
</div>

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

### `features`

<div class="signature">
  ```lua theme={null}
  features() -> GPUFeatures
  ```
</div>

Capabilities of the active GPU device.

### `decodeImage`

<div class="signature">
  ```lua theme={null}
  decodeImage(data: buffer) -> Promise<DecodedImage>
  ```
</div>

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