PluginRows
Ready-made requests for changes to rows. Each one is called like a function and returns an Outcome, whose status tells what happened. created holds the ids of the rows that the change made, and it is empty when the change made none. Using them requires the write:rows permission.
Example
Section titled “Example”const outcome = await ctx.rows.modify({ id: row.id, title: 'Buy milk' });if (outcome.status !== 'committed') ctx.log('warn', `The title was not changed: ${outcome.status}`);Properties
Section titled “Properties”insert
Section titled “insert”insert: CommandToken<{ anchor?: string | null; facets?: Record<string, unknown>; how?: "after" | "before" | "child"; id?: string; marker?: "bullet" | "numbered" | "task"; note?: string | null; outline: string; title?: string;}, RowResult>;Inserts a row in an outline, next to an anchor row. how is after, before or child. Without an anchor, the row goes at the end of the outline. The row can have a title, a note, a marker and facets. The result includes created, the ids of the rows that the call made.
modify
Section titled “modify”modify: CommandToken<{ id: string; marker?: "bullet" | "numbered" | "task"; note?: string | null; title?: string;}, RowResult>;Changes the title, the note or the marker of a row. The marker is bullet, numbered or task. To change a facet, use the set and clear methods of the facet.
move: CommandToken<{ id: string; target: string; where: "after" | "first" | "before" | "inside";}, RowResult>;Moves the row id next to the row target. where is before or after, which makes the row a neighbour of the target, or first or inside, which makes the row the first or the last child of the target. A row cannot move into itself.
remove
Section titled “remove”remove: CommandToken<{ ids: string[];}, RowResult>;Deletes the rows that ids lists. The rows under each of them are deleted too.
Methods
Section titled “Methods”reveal()
Section titled “reveal()”reveal(reveal): object;Shows the person something other than what a row stores. An encrypted outline works this way: the stored text is unreadable, and reveal returns the readable title, note, marker or facets. Using it requires the read permission.
The function must return the same result for the same stored row. It returns nothing for a row that the plugin does not handle. The outline and the text editor read rows through this function, and nothing else does.
When an answer changes without any change to the library, for example after the plugin received or forgot a key, the plugin calls changed(), so that the app draws the rows again.
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
reveal |
(row) => Revealed | undefined |
the function that receives a stored row and returns what to show for it, or nothing |
Returns
Section titled “Returns”object
an object with dispose(), which removes the function, and changed(), which tells the app to draw the rows again
| Name | Type |
|---|---|
changed() |
() => void |
dispose() |
() => void |
