thymer docs
Documentation/Plugins/Plugin API reference

Plugin API reference

The SDK’s types.d.ts is the full reference, with every signature and comment. This page lists the main objects and methods. The API is still changing during the beta; check the declarations that match your app version.

Plugin classes

AppPlugin for the workspace, CollectionPlugin for one collection, DynCollectionPlugin for a dynamic collection. onLoad() is where you register things; onUnload() is where you clean up. All of them have ui, data, events, ws and window; collection plugins also have collection, properties and views.

Data

Method Returns
this.data.getRecord(guid) A record, or null
await this.data.getLineItem(guid) A PluginLineItem, or null if missing or deleted
this.data.getAllRecords() Every record in the workspace
await this.data.getAllCollections() The collections
this.data.getActiveUsers() The workspace’s active users
await this.data.searchByQuery(query, max) Matching records and lines
this.data.getPluginByGuid(guid) A plugin or collection object, or null if unavailable
const results = await this.data.searchByQuery("@task @overdue", 50);
for (const record of results.records) console.log(record.getName());

In a collection plugin, await this.collection.getAllRecords() loads its records and this.collection.createRecord(title) makes a new one, returning its guid.

Records

A record is a page. It has a guid and methods such as getName(), getCreatedAt(), getUpdatedAt(), getSubPageOf() and setSubPageOf(guid). Use await record.getLineItems() for its lines, or await record.getAsMarkdown({experimental: true}) for an object with the Markdown content and filename.

Reader Returns
record.number(name), record.text(name) A number or text, or null
record.choice(name) The choice id, or null
record.numbers(name), record.texts(name) All values of a multi-value property
record.users(name) User objects
record.linkedRecord(name), record.linkedRecords(name) One linked record, or all of them

Choices have an id and a label. Use record.prop(name)?.choiceLabel() to read the label. On a Choice property, setChoice() accepts a label or id, or an array for a multi-value property, and returns a boolean immediately.

Lines

A PluginLineItem knows its parent and children, its text segments and its task status. setSegments() replaces the content, setTaskStatus() changes the checkbox. A line’s text is made of segments, including references; replace only the segments you mean to change.

Properties and views

await this.views.getAllRecordsInView(name) returns a view’s records with its filter and sort applied. For property hooks and the callbacks to pass to this.views.register(name, fn), see Collection plugins.

Interface

this.ui.addCommandPaletteCommand(), addStatusBarItem(), addToaster(), addSidebarWidget(), registerCustomPanelType(), plus buttons, icons and tooltips that follow the theme. this.ui.getActivePanel() returns the active panel, or null, and a panel may have no record. Use the text APIs for anything a user typed; only pass HTML you built yourself to the HTML APIs.

Desktop window APIs only exist in the desktop app; check before calling them.