Skip to content

Build your personal knowledge base with Trilium Notes

docs(scripting): drop the type prefixes from the script references

Elian Doran031cbab899f9
diff --git a/apps/server/src/assets/help/help_content.json b/apps/server/src/assets/help/help_content.json
index ab7baca720..1e253c2dcc 100644
--- a/apps/server/src/assets/help/help_content.json
+++ b/apps/server/src/assets/help/help_content.json
@@ -275,9 +275,9 @@
"_help_GPERMystNGTB": "<p><a href=\"#root/_help_CdNpE2pqjmI6\">Script</a> notes can be triggered by events. Note that these are backend events and thus relation need to point to the \"JavaScript (Trilium backend)\" code note.</p><h2>Global events</h2><p>Global events are attached to the script note via label. Simply create a <code>run</code> label with some of these values and script note will be executed once the event occurs.</p><figure class=\"table\"><table><thead><tr><th>Label</th><th>Description</th></tr></thead><tbody><tr><td><code>run</code></td><td><p>Defines on which events script should run. Possible values are:</p><ul><li><code>backendStartup</code> - when Trilium backend starts up</li><li><code>hourly</code> - run once an hour. You can use additional label <code>runAtHour</code> to specify at which hour, on the back-end.</li><li><code>daily</code> - run once a day, on the back-end</li></ul></td></tr><tr><td><code>runOnInstance</code></td><td>Specifies that the script should only run on a particular&nbsp;<a class=\"reference-link\" href=\"#root/_help_c5xB8m4g2IY6\">Trilium instance</a>.</td></tr><tr><td><code>runAtHour</code></td><td>On which hour should this run. Should be used together with <code>#run=hourly</code>. Can be defined multiple times for more runs during the day.</td></tr></tbody></table></figure><p>Frontend scripts also have similar&nbsp;<a class=\"reference-link\" href=\"#root/_help_irkwjdNtjcxR\">Events</a>, such as when the application starts.</p><aside class=\"admonition note\"><p>One script can be triggered on multiple events, this can be done by adding multiple <code>run</code> labels. Separating multiple values by commas <strong>is not</strong> supported.</p></aside><h2>Entity events</h2><p>Other events are bound to some entity, these are defined as <a href=\"#root/_help_zEY4DaJG4YT5\">relations</a> - meaning that script is triggered only if note has this script attached to it through relations (or it can inherit it).</p><figure class=\"table\"><table><thead><tr><th>Relation</th><th>Trigger condition</th><th>Origin entity (see below)</th></tr></thead><tbody><tr><td><code>runOnNoteCreation</code></td><td>executes when note is created on backend. Use this relation if you want to run the script for all notes created under a specific subtree. In that case, create it on the subtree root note and make it inheritable. A new note created within the subtree (any depth) will trigger the script.</td><td>The <code>BNote</code> that got created.</td></tr><tr><td><code>runOnChildNoteCreation</code></td><td>executes when new note is created under the note where this relation is defined</td><td>The <code>BNote</code> of the child that got created.</td></tr><tr><td><code>runOnNoteTitleChange</code></td><td>executes when note title is changed (includes note creation as well)</td><td>The <code>BNote</code> of the note whose title got changed.</td></tr><tr><td><code>runOnNoteContentChange</code></td><td>executes when note content is changed (includes note creation as well).</td><td>The <code>BNote</code> of the note whose content got changed.</td></tr><tr><td><code>runOnNoteChange</code></td><td>executes when note is changed (includes note creation as well). Does not include content changes</td><td>The <code>BNote</code> of the note that got changed.</td></tr><tr><td><code>runOnNoteDeletion</code></td><td>executes when note is being deleted</td><td>The <code>BNote</code> of the note that got (soft) deleted.</td></tr><tr><td><code>runOnBranchCreation</code></td><td>executes when a branch is created. Branch is a link between parent note and child note and is created e.g. when cloning or moving note.</td><td>The <code>BBranch</code> that got created.</td></tr><tr><td><code>runOnBranchChange</code></td><td>executes when a branch is updated. (since v0.62)</td><td>The <code>BBranch</code> that got changed.</td></tr><tr><td><code>runOnBranchDeletion</code></td><td>executes when a branch is deleted. Branch is a link between parent note and child note and is deleted e.g. when moving note (old branch/link is deleted).</td><td>The <code>BBranch</code> that got (soft) deleted.</td></tr><tr><td><code>runOnAttributeCreation</code></td><td>executes when new attribute is created for the note which defines this relation</td><td>The <code>BAttribute</code> that got created.</td></tr><tr><td><code>runOnAttributeChange</code></td><td>executes when the attribute is changed of a note which defines this relation. This is triggered also when the attribute is deleted</td><td>The <code>BAttribute</code> that got changed.</td></tr></tbody></table></figure><h2>Origin entity</h2><p>When a script is run by an event such as the ones described above, <code>api.originEntity</code> will get populated with the note, branch or attribute that triggered the change.</p><p>For example, here's a script with <code>~runOnAttributeChange</code> which automatically changes the color of a note based on the value of the <code>mycategory</code> label:</p><pre><code class=\"language-text-javascript\">const attr = api.originEntity;\nif (attr.name !== \"mycategory\") return;\nconst note = api.getNote(attr.noteId);\nif (attr.value === \"Health\") {\n note.setLabel(\"color\", \"green\");\n} else {\n note.removeLabel(\"color\");\n}</code></pre><h2>Safe mode</h2><p>While <a href=\"#root/_help_64ZTlUPgEPtW\">safe mode</a> is active, scripts with events won't trigger.</p>",
"_help_hA834UaHhSNn": "<p>For both&nbsp;<a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a>&nbsp;and more complicated scripts, it's generally useful to split the code into multiple&nbsp;<a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a>&nbsp;notes.</p><p>When a script is run, the sub-children of the script being run (or the&nbsp;<a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a>) are checked for children. If the children are Code notes of the corresponding type (front-end or backend) as the code being run, they will be evaluated as well.</p><p>The collection of a script and its child notes is called a <em>bundle</em>. A child note inside a bundle is called a <em>module</em>.</p><p>As a basic example of dependencies, consider the following note structure:</p><ul><li><p><em>Script with dependency</em></p><pre><code class=\"language-text-javascript\">api.log(MyMath.sum(2, 2));</code></pre><ul><li><p><em>MyMath</em></p><pre><code class=\"language-text-javascript\">module.exports = {\n sum(a, b) {\n return a + b;\n }\n};</code></pre></li></ul></li></ul><p>When <em>Script with dependency</em> is run, it will detect <em>MyMath</em> as a submodule and provide the result of its <code>module.exports</code> object into a global object with the same name as the note.</p><aside class=\"admonition note\"><p>If the note contains spaces or special characters, they will be stripped. For example <code>My Nice Note!</code> becomes <code>MyNiceNote</code>.</p></aside><h2>Alternative syntax</h2><p>Instead of providing an object to <code>module.exports</code>, it's also possible to add fields individually:</p><pre><code class=\"language-text-javascript\">module.exports.sum = (a, b) =&gt; a + b;\nmodule.exports.subtract = (a, b) =&gt; a - b;</code></pre><h2>Ignoring a code script from a bundle</h2><p>To ignore a script from being included in a bundle (e.g. if it's unrelated to the parent script note), apply the <code>#disableInclusion</code> label.</p><h2>Sharing a module across multiple bundles</h2><p>Modules can be reused across multiple scripts by simply cloning the shared module between two modules (see&nbsp;<a class=\"reference-link\" href=\"#root/_help_IakOLONlIfGI\">Cloning Notes</a>).</p><p>Optionally, a separate note can be used to contain all the different reusable modules for an easy way to discover them.</p>",
"_help_GLks18SNjxmC": "<p>For <a href=\"#root/_help_CdNpE2pqjmI6\">script code notes</a>, Trilium offers an API that gives them access to various features of the application.</p><p>There are two APIs:</p><ul><li>One for the front-end scripts:&nbsp;<a class=\"reference-link\" href=\"#root/_help_Q2z6av6JZVWm\">Frontend API</a></li><li>One for the back-end scripts:&nbsp;<a class=\"reference-link\" href=\"#root/_help_MEtfsqa5VwNi\">Backend API</a></li></ul><p>In both cases, the API resides in a global variable, <code>api</code>, that can be used anywhere in the script.</p><p>For example, to display a message to the user the following front-end script can be used:</p><pre><code class=\"language-text-x-trilium-auto\">api.showMessage(\"Hello world.\");</code></pre><aside class=\"admonition note\"><p><strong>Note</strong><br>The Script API is currently experimental and may undergo changes in future updates.</p></aside>",
- "_help_Q2z6av6JZVWm": "<h2><code>FrontendApi</code></h2><p>The <code>api</code> global available inside <strong>frontend</strong> script notes (<code>application/javascript;env=frontend</code>).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>$container</code></td><td><p><code>unknown</code><br>Container of all the rendered script content</p></td></tr><tr><td><code>startNote</code></td><td><p><code>ScriptFNote</code><br>Note where the script execution started — the entry point of the current script bundle (in C terms, the file containing <code>main()</code>). When a script is spread across multiple code notes (descendant code notes loaded as modules via <code>require()</code>), every note in the bundle shares the same <code>startNote</code>, while <code>currentNote</code> differs per note. Messages from <code>api.log()</code> are grouped under this note.</p></td></tr><tr><td><code>currentNote</code></td><td><p><code>ScriptFNote</code><br>Note containing the source code that is currently executing (in C terms, <code>__FILE__</code>). Equal to <code>startNote</code> unless execution has moved into a descendant module note loaded via <code>require()</code>. Don't confuse this with the note open in the UI — use <code>api.getActiveContextNote()</code> for that.</p></td></tr><tr><td><code>originEntity</code></td><td><p><code>unknown</code><br>Entity whose event triggered this execution, or <code>null</code>. Most frontend scripts are started by the user or by the UI (startup scripts, widgets), so this is usually <code>null</code>. It is set to a note when: - the script runs through a <code>~renderNote</code> relation — then it's the note being rendered (the one carrying the relation), not the script note; - a backend script calls <code>api.runOnFrontend()</code> — then it's the backend execution's <code>originEntity</code>, provided that entity was a note.</p></td></tr><tr><td><code>dayjs</code></td><td><p><code>ScriptDayjs</code><br>day.js library for date manipulation. See <code>https://day.js.org</code> for documentation</p></td></tr><tr><td><code>RightPanelWidget</code></td><td><p><code>WidgetClass&lt;RightPanelWidget&gt;</code><br>Base class for right-panel widgets — <code>class X extends api.RightPanelWidget { … }</code>.</p></td></tr><tr><td><code>NoteContextAwareWidget</code></td><td><p><code>WidgetClass&lt;NoteContextAwareWidget&gt;</code><br>Base class for note-context-aware widgets — <code>class X extends api.NoteContextAwareWidget { … }</code>.</p></td></tr><tr><td><code>BasicWidget</code></td><td><p><code>WidgetClass&lt;BasicWidget&gt;</code><br>Base class for basic widgets — <code>class X extends api.BasicWidget { … }</code>.</p></td></tr><tr><td><code>activateNote</code></td><td><pre><code class=\"language-application-typescript\">activateNote(notePath: string): Promise&lt;void&gt;</code></pre><p>Activates note in the tree and in the note detail.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>notePath</code></td><td><code>string</code><br>(or noteId)</td></tr></tbody></table></figure></td></tr><tr><td><code>activateNewNote</code></td><td><pre><code class=\"language-application-typescript\">activateNewNote(notePath: string): Promise&lt;void&gt;</code></pre><p>Activates newly created note. Compared to this.activateNote() also makes sure that frontend has been fully synced.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>notePath</code></td><td><code>string</code><br>(or noteId)</td></tr></tbody></table></figure></td></tr><tr><td><code>openTabWithNote</code></td><td><pre><code class=\"language-application-typescript\">openTabWithNote(notePath: string, activate: boolean): Promise&lt;void&gt;</code></pre><p>Open a note in a new tab.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>notePath</code></td><td><code>string</code><br>(or noteId)</td></tr><tr><td><code>activate</code></td><td><code>boolean</code><br>set to true to activate the new tab, false to stay on the current tab</td></tr></tbody></table></figure></td></tr><tr><td><code>openSplitWithNote</code></td><td><pre><code class=\"language-application-typescript\">openSplitWithNote(notePath: string, activate: boolean): Promise&lt;void&gt;</code></pre><p>Open a note in a new split.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>notePath</code></td><td><code>string</code><br>(or noteId)</td></tr><tr><td><code>activate</code></td><td><code>boolean</code><br>set to true to activate the new split, false to stay on the current split</td></tr></tbody></table></figure></td></tr><tr><td><code>runOnBackend</code></td><td><pre><code class=\"language-application-typescript\">runOnBackend(func: Func, params?: unknown[]): Promise&lt;unknown&gt;</code></pre><p>Executes given anonymous function on the backend. Internally this serializes the anonymous function into string and sends it to backend via AJAX. Please make sure that the supplied function is synchronous. Only sync functions will work correctly with transaction management. If you really know what you're doing, you can call api.runAsyncOnBackendWithManualTransactionHandling()</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>func</code></td><td><code>Func</code><br>(synchronous) function to be executed on the backend</td></tr><tr><td><code>params</code><br><em>optional</em></td><td><code>unknown[]</code><br>list of parameters to the anonymous function to be sent to backend</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;unknown&gt;</code>: return value of the executed function on the backend</p></td></tr><tr><td><code>runAsyncOnBackendWithManualTransactionHandling</code></td><td><pre><code class=\"language-application-typescript\">runAsyncOnBackendWithManualTransactionHandling(func: Func, params?: unknown[]): Promise&lt;unknown&gt;</code></pre><p>Executes given anonymous function on the backend. Internally this serializes the anonymous function into string and sends it to backend via AJAX. This function is meant for advanced needs where an async function is necessary. In this case, the automatic request-scoped transaction management is not applied, and you need to manually define transaction via api.transactional().</p><p>If you have a synchronous function, please use api.runOnBackend().</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>func</code></td><td><code>Func</code><br>(synchronous) function to be executed on the backend</td></tr><tr><td><code>params</code><br><em>optional</em></td><td><code>unknown[]</code><br>list of parameters to the anonymous function to be sent to backend</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;unknown&gt;</code>: return value of the executed function on the backend</p></td></tr><tr><td><code>isBackendScriptingEnabled</code></td><td><pre><code class=\"language-application-typescript\">isBackendScriptingEnabled(): boolean</code></pre><p>Whether backend script execution is enabled on the server (the <code>[Security] backendScriptingEnabled</code> config toggle). When it's disabled, <code>api.runOnBackend()</code> / <code>api.runAsyncOnBackendWithManualTransactionHandling()</code> reject with a \"Backend script execution is disabled\" error, so check this first to let a script degrade gracefully instead of throwing.</p></td></tr><tr><td><code>isSqlConsoleEnabled</code></td><td><pre><code class=\"language-application-typescript\">isSqlConsoleEnabled(): boolean</code></pre><p>Whether the SQL console is enabled on the server (the <code>[Security] sqlConsoleEnabled</code> config toggle). When it's disabled, backend scripts that run raw SQL (<code>api.sql.*</code>) fail, so check this before invoking SQL-backed logic via <code>api.runOnBackend()</code>.</p></td></tr><tr><td><code>searchForNotes</code></td><td><pre><code class=\"language-application-typescript\">searchForNotes(searchString: string): Promise&lt;ScriptFNote[]&gt;</code></pre><p>This is a powerful search method - you can search by attributes and their values, e.g.: \"#dateModified =* MONTH AND #log\". See full documentation for all options at: <a href=\"https://triliumnext.github.io/Docs/Wiki/search.html\">https://triliumnext.github.io/Docs/Wiki/search.html</a></p></td></tr><tr><td><code>searchForNote</code></td><td><pre><code class=\"language-application-typescript\">searchForNote(searchString: string): Promise&lt;ScriptFNote | null&gt;</code></pre><p>This is a powerful search method - you can search by attributes and their values, e.g.: \"#dateModified =* MONTH AND #log\". See full documentation for all options at: <a href=\"https://triliumnext.github.io/Docs/Wiki/search.html\">https://triliumnext.github.io/Docs/Wiki/search.html</a></p></td></tr><tr><td><code>getNote</code></td><td><pre><code class=\"language-application-typescript\">getNote(noteId: string): Promise&lt;ScriptFNote | null&gt;</code></pre><p>Returns note by given noteId. If note is missing from the cache, it's loaded.</p></td></tr><tr><td><code>getNotes</code></td><td><pre><code class=\"language-application-typescript\">getNotes(noteIds: string[], silentNotFoundError?: boolean): Promise&lt;ScriptFNote[]&gt;</code></pre><p>Returns list of notes. If note is missing from the cache, it's loaded.</p><p>This is often used to bulk-fill the cache with notes which would have to be picked one by one otherwise (by e.g. createLink())</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>noteIds</code></td><td><code>string[]</code></td></tr><tr><td><code>silentNotFoundError</code><br><em>optional</em></td><td><code>boolean</code><br>don't report error if the note is not found</td></tr></tbody></table></figure></td></tr><tr><td><code>reloadNotes</code></td><td><pre><code class=\"language-application-typescript\">reloadNotes(noteIds: string[]): Promise&lt;void&gt;</code></pre><p>Update frontend tree (note) cache from the backend.</p></td></tr><tr><td><code>createNote</code></td><td><pre><code class=\"language-application-typescript\">createNote(parentNotePath: string, opts?: ScriptCreateNoteOpts): Promise&lt;{ note: ScriptFNote | null; branch: ScriptFBranch | undefined }&gt;</code></pre><p>Creates a new note as a child of the given parent, entirely on the frontend — no backend scripting required (unlike <code>api.runOnBackend(() =&gt; api.createTextNote(...))</code>). By default the new note is activated in the current tab with its title focused for editing; pass <code>{ activate: false }</code> to create it silently.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>parentNotePath</code></td><td><code>string</code><br>note path (or noteId) of the parent under which to create the note</td></tr><tr><td><code>opts</code><br><em>optional</em></td><td><code>ScriptCreateNoteOpts</code><br>creation options — e.g. <code>{ title, content, type, mime, activate }</code></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;{ note: ScriptFNote | null; branch: ScriptFBranch | undefined }&gt;</code>: the created note and its branch, resolved from the frontend cache</p></td></tr><tr><td><code>getInstanceName</code></td><td><pre><code class=\"language-application-typescript\">getInstanceName(): string | null</code></pre><p>Instance name identifies particular Trilium instance. It can be useful for scripts if some action needs to happen on only one specific instance.</p></td></tr><tr><td><code>addTextToActiveContextEditor</code></td><td><pre><code class=\"language-application-typescript\">addTextToActiveContextEditor(text: string): void</code></pre><p>Adds given text to the editor cursor</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>text</code></td><td><code>string</code><br>this must be clear text, HTML is not supported.</td></tr></tbody></table></figure></td></tr><tr><td><code>getActiveContextNote</code></td><td><pre><code class=\"language-application-typescript\">getActiveContextNote(): ScriptFNote</code></pre><p><strong>Returns</strong> <code>ScriptFNote</code>: active note (loaded into center pane)</p></td></tr><tr><td><code>getActiveContext</code></td><td><pre><code class=\"language-application-typescript\">getActiveContext(): ScriptNoteContext</code></pre><p>Obtains the currently active/focused split in the current tab.</p><p>Note that this method does not return the note context of the \"Quick edit\" panel, it will return the note context behind it.</p></td></tr><tr><td><code>getActiveMainContext</code></td><td><pre><code class=\"language-application-typescript\">getActiveMainContext(): ScriptNoteContext</code></pre><p>Obtains the main context of the current tab. This is the left-most split.</p><p>Note that this method does not return the note context of the \"Quick edit\" panel, it will return the note context behind it.</p></td></tr><tr><td><code>getNoteContexts</code></td><td><pre><code class=\"language-application-typescript\">getNoteContexts(): ScriptNoteContext[]</code></pre><p><strong>Returns</strong> <code>ScriptNoteContext[]</code>: returns all note contexts (splits) in all tabs</p></td></tr><tr><td><code>getMainNoteContexts</code></td><td><pre><code class=\"language-application-typescript\">getMainNoteContexts(): ScriptNoteContext[]</code></pre><p><strong>Returns</strong> <code>ScriptNoteContext[]</code>: returns all main contexts representing tabs</p></td></tr><tr><td><code>getActiveContextTextEditor</code></td><td><pre><code class=\"language-application-typescript\">getActiveContextTextEditor(): Promise&lt;unknown&gt;</code></pre><p>See <a href=\"https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html\">https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html</a> for documentation on the returned instance.</p><p><strong>Returns</strong> <code>Promise&lt;unknown&gt;</code>: instance of CKEditor</p></td></tr><tr><td><code>getActiveContextCodeEditor</code></td><td><pre><code class=\"language-application-typescript\">getActiveContextCodeEditor(): Promise&lt;unknown&gt;</code></pre><p>See <a href=\"https://codemirror.net/doc/manual.html#api\">https://codemirror.net/doc/manual.html#api</a></p><p><strong>Returns</strong> <code>Promise&lt;unknown&gt;</code>: instance of CodeMirror</p></td></tr><tr><td><code>getActiveNoteDetailWidget</code></td><td><pre><code class=\"language-application-typescript\">getActiveNoteDetailWidget(): Promise&lt;unknown&gt;</code></pre><p>Get access to the widget handling note detail. Methods like <code>getWidgetType()</code> and <code>getTypeWidget()</code> to get to the implementation of actual widget type.</p></td></tr><tr><td><code>getActiveContextNotePath</code></td><td><pre><code class=\"language-application-typescript\">getActiveContextNotePath(): string | null</code></pre><p><strong>Returns</strong> <code>string | null</code>: returns a note path of active note or null if there isn't active note</p></td></tr><tr><td><code>getComponentByEl</code></td><td><pre><code class=\"language-application-typescript\">getComponentByEl(el: HTMLElement): unknown</code></pre><p>Returns component which owns the given DOM element (the nearest parent component in DOM tree)</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>el</code></td><td><code>HTMLElement</code><br>DOM element</td></tr></tbody></table></figure></td></tr><tr><td><code>showMessage</code></td><td><pre><code class=\"language-application-typescript\">showMessage(message: string, delay?: number): void</code></pre><p>Show an info toast message to the user.</p></td></tr><tr><td><code>showError</code></td><td><pre><code class=\"language-application-typescript\">showError(message: string, delay?: number): void</code></pre><p>Show an error toast message to the user.</p></td></tr><tr><td><code>showInfoDialog</code></td><td><pre><code class=\"language-application-typescript\">showInfoDialog(message: string): Promise&lt;void&gt;</code></pre><p>Show an info dialog to the user.</p></td></tr><tr><td><code>showConfirmDialog</code></td><td><pre><code class=\"language-application-typescript\">showConfirmDialog(message: string): Promise&lt;boolean&gt;</code></pre><p>Show confirm dialog to the user.</p><p><strong>Returns</strong> <code>Promise&lt;boolean&gt;</code>: promise resolving to true if the user confirmed</p></td></tr><tr><td><code>showPromptDialog</code></td><td><pre><code class=\"language-application-typescript\">showPromptDialog(props: { title?: string; message?: string; defaultValue?: string }): Promise&lt;string | null&gt;</code></pre><p>Show prompt dialog to the user.</p><p><strong>Returns</strong> <code>Promise&lt;string | null&gt;</code>: promise resolving to the answer provided by the user</p></td></tr><tr><td><code>pickSingleItem</code></td><td><pre><code class=\"language-application-typescript\">pickSingleItem(props: { title?: string; items: PickerItem[] | PickerItemGroup[]; placeholder?: string }): Promise&lt;PickerItem | null&gt;</code></pre><p>Show a dialog for picking one item out of many, grouped and searchable.</p><p><code>items</code> are either the items themselves or groups of them, never the two mixed. Named for the one thing it does now: picking several at once will be a method of its own beside this.</p><p><strong>Returns</strong> <code>Promise&lt;PickerItem | null&gt;</code>: promise resolving to the item picked, or null where the user backed out.</p></td></tr><tr><td><code>createLink</code></td><td><pre><code class=\"language-application-typescript\">createLink(notePath: string, params?: Record&lt;string, unknown&gt;): unknown</code></pre><p>Create a note link (jQuery object) for given note.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>notePath</code></td><td><code>string</code><br>(or noteId)</td></tr><tr><td><code>params</code><br><em>optional</em></td><td><code>Record&lt;string, unknown&gt;</code></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>unknown</code>: - jQuery element with the link (wrapped in <span>)</span></p></td></tr><tr><td><code>createNoteLink</code></td><td><pre><code class=\"language-application-typescript\">createNoteLink(notePath: string, params?: Record&lt;string, unknown&gt;): unknown</code></pre><aside class=\"admonition warning\"><p>Deprecated. - use api.createLink() instead</p></aside></td></tr><tr><td><code>triggerCommand</code></td><td><pre><code class=\"language-application-typescript\">triggerCommand(name: string, data?: Record&lt;string, unknown&gt;): Promise&lt;unknown&gt;</code></pre><p>Trigger command. This is a very low-level API which should be avoided if possible.</p></td></tr><tr><td><code>triggerEvent</code></td><td><pre><code class=\"language-application-typescript\">triggerEvent(name: string, data?: Record&lt;string, unknown&gt;): Promise&lt;unknown&gt;</code></pre><p>Trigger event. This is a very low-level API which should be avoided if possible.</p></td></tr><tr><td><code>setupElementTooltip</code></td><td><pre><code class=\"language-application-typescript\">setupElementTooltip(el: unknown): void</code></pre><p>Shows a preview of the linked note while the mouse pointer rests on the element, as Trilium does for links in note content. The element must be a link whose <code>href</code> or <code>data-href</code> points to a note, such as <code>#root/abc123</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>el</code></td><td><code>unknown</code><br>The link, as a jQuery object.</td></tr></tbody></table></figure></td></tr><tr><td><code>protectNote</code></td><td><pre><code class=\"language-application-typescript\">protectNote(noteId: string, protect: boolean): Promise&lt;void&gt;</code></pre><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>noteId</code></td><td><code>string</code></td></tr><tr><td><code>protect</code></td><td><code>boolean</code><br>true to protect note, false to unprotect</td></tr></tbody></table></figure></td></tr><tr><td><code>protectSubTree</code></td><td><pre><code class=\"language-application-typescript\">protectSubTree(noteId: string, protect: boolean): Promise&lt;void&gt;</code></pre><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>noteId</code></td><td><code>string</code></td></tr><tr><td><code>protect</code></td><td><code>boolean</code><br>true to protect subtree, false to unprotect</td></tr></tbody></table></figure></td></tr><tr><td><code>getTodayNote</code></td><td><pre><code class=\"language-application-typescript\">getTodayNote(): Promise&lt;ScriptFNote&gt;</code></pre><p>Returns date-note for today. If it doesn't exist, it is automatically created.</p></td></tr><tr><td><code>getDayNote</code></td><td><pre><code class=\"language-application-typescript\">getDayNote(date: string): Promise&lt;ScriptFNote&gt;</code></pre><p>Returns day note for a given date. If it doesn't exist, it is automatically created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>e.g. \"2019-04-29\"</td></tr></tbody></table></figure></td></tr><tr><td><code>getWeekFirstDayNote</code></td><td><pre><code class=\"language-application-typescript\">getWeekFirstDayNote(date: string): Promise&lt;ScriptFNote&gt;</code></pre><p>Returns day note for the first date of the week of the given date. If it doesn't exist, it is automatically created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>e.g. \"2019-04-29\"</td></tr></tbody></table></figure></td></tr><tr><td><code>getWeekNote</code></td><td><pre><code class=\"language-application-typescript\">getWeekNote(date: string): Promise&lt;ScriptFNote&gt;</code></pre><p>Returns week note for given date. If such a note doesn't exist, it is automatically created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM-DD format</td></tr></tbody></table></figure></td></tr><tr><td><code>getMonthNote</code></td><td><pre><code class=\"language-application-typescript\">getMonthNote(month: string): Promise&lt;ScriptFNote&gt;</code></pre><p>Returns month-note. If it doesn't exist, it is automatically created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>month</code></td><td><code>string</code><br>e.g. \"2019-04\"</td></tr></tbody></table></figure></td></tr><tr><td><code>getQuarterNote</code></td><td><pre><code class=\"language-application-typescript\">getQuarterNote(date: string): Promise&lt;ScriptFNote&gt;</code></pre><p>Returns quarter note for given date. If such a note doesn't exist, it is automatically created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM format</td></tr></tbody></table></figure></td></tr><tr><td><code>getYearNote</code></td><td><pre><code class=\"language-application-typescript\">getYearNote(year: string): Promise&lt;ScriptFNote&gt;</code></pre><p>Returns year-note. If it doesn't exist, it is automatically created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>year</code></td><td><code>string</code><br>e.g. \"2019\"</td></tr></tbody></table></figure></td></tr><tr><td><code>setHoistedNoteId</code></td><td><pre><code class=\"language-application-typescript\">setHoistedNoteId(noteId: string): void</code></pre><p>Hoist note in the current tab. See <a href=\"https://triliumnext.github.io/Docs/Wiki/note-hoisting.html\">https://triliumnext.github.io/Docs/Wiki/note-hoisting.html</a></p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>noteId</code></td><td><code>string</code><br>set hoisted note. 'root' will effectively unhoist</td></tr></tbody></table></figure></td></tr><tr><td><code>bindGlobalShortcut</code></td><td><pre><code class=\"language-application-typescript\">bindGlobalShortcut(keyboardShortcut: string, handler: () =&gt; void, namespace?: string): void</code></pre><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>keyboardShortcut</code></td><td><code>string</code><br>e.g. \"ctrl+shift+a\"</td></tr><tr><td><code>handler</code></td><td><code>() =&gt; void</code></td></tr><tr><td><code>namespace</code><br><em>optional</em></td><td><code>string</code><br>specify namespace of the handler for the cases where call for bind may be repeated. If a handler with this ID exists, it's replaced by the new handler.</td></tr></tbody></table></figure></td></tr><tr><td><code>waitUntilSynced</code></td><td><pre><code class=\"language-application-typescript\">waitUntilSynced(): Promise&lt;unknown&gt;</code></pre><p>Trilium runs in a backend and frontend process, when something is changed on the backend from a script, frontend will get asynchronously synchronized.</p><p>This method returns a promise which resolves once all the backend -&gt; frontend synchronization is finished. Typical use case is when a new note has been created, we should wait until it is synced into frontend and only then activate it.</p></td></tr><tr><td><code>refreshIncludedNote</code></td><td><pre><code class=\"language-application-typescript\">refreshIncludedNote(includedNoteId: string): void</code></pre><p>This will refresh all currently opened notes which have included note specified in the parameter</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>includedNoteId</code></td><td><code>string</code><br>noteId of the included note</td></tr></tbody></table></figure></td></tr><tr><td><code>randomString</code></td><td><pre><code class=\"language-application-typescript\">randomString(length: number): string</code></pre><p>Return randomly generated string of given length. This random string generation is NOT cryptographically secure.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>length</code></td><td><code>number</code><br>of the string</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>string</code>: random string</p></td></tr><tr><td><code>formatSize</code></td><td><pre><code class=\"language-application-typescript\">formatSize(size: number): string</code></pre><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>size</code></td><td><code>number</code><br>in bytes</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>string</code>: formatted string</p></td></tr><tr><td><code>formatNoteSize</code></td><td><pre><code class=\"language-application-typescript\">formatNoteSize(size: number): string</code></pre><aside class=\"admonition warning\"><p>Deprecated. - use api.formatSize()</p></aside><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>size</code></td><td><code>number</code><br>in bytes</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>string</code>: formatted string</p></td></tr><tr><td><code>htmlToMarkdown</code></td><td><pre><code class=\"language-application-typescript\">htmlToMarkdown(html: string): Promise&lt;string&gt;</code></pre><p>Converts the given HTML string to Markdown.</p><p>Unlike the backend API, this runs on the server (the HTML→Markdown converter is backend-only), so it returns a promise.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>html</code></td><td><code>string</code><br>HTML content to convert</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;string&gt;</code>: Markdown representation of the input HTML</p></td></tr><tr><td><code>markdownToHtml</code></td><td><pre><code class=\"language-application-typescript\">markdownToHtml(markdown: string): Promise&lt;string&gt;</code></pre><p>Converts the given Markdown string to HTML.</p><p>Runs entirely in the browser; the promise is only needed because the Markdown renderer is loaded on demand.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>markdown</code></td><td><code>string</code><br>Markdown content to convert</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;string&gt;</code>: HTML representation of the input Markdown</p></td></tr><tr><td><code>formatDateISO</code></td><td><pre><code class=\"language-application-typescript\">formatDateISO(date: Date): string</code></pre><p><strong>Returns</strong> <code>string</code>: date in YYYY-MM-DD format</p></td></tr><tr><td><code>parseDate</code></td><td><pre><code class=\"language-application-typescript\">parseDate(str: string): Date</code></pre><p>Parses a date string into a Date.</p></td></tr><tr><td><code>logMessages</code></td><td><p><code>Record&lt;string, string[]&gt;</code><br>Per-note log message buffers shown in the UI log pane.</p></td></tr><tr><td><code>logSpacedUpdates</code></td><td><p><code>Record&lt;string, unknown&gt;</code><br>Per-note spaced-update handlers for the log pane.</p></td></tr><tr><td><code>log</code></td><td><pre><code class=\"language-application-typescript\">log(...args: unknown[]): void</code></pre><p>Log given message to the log pane in UI. Accepts multiple arguments which are joined with spaces, similar to <code>console.log</code>.</p></td></tr><tr><td><code>preact</code></td><td><p><code>unknown</code><br>The Preact API surface (components, hooks) for render scripts.</p></td></tr></tbody></table></figure><h2><code>ScriptFNote</code></h2><p>A note as seen by frontend scripts (subset of the client's <code>FNote</code>).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>noteId</code></td><td><p><code>string</code><br>The ID of the note.</p></td></tr><tr><td><code>title</code></td><td><p><code>string</code><br>The title of the note. For a protected note, it is <code>[protected]</code> until a protected session is started.</p></td></tr><tr><td><code>type</code></td><td><p><code>string</code><br>The note type, such as <code>text</code>, <code>code</code>, <code>file</code>, <code>image</code>, <code>search</code>, <code>book</code>, <code>render</code> or <code>launcher</code>.</p></td></tr><tr><td><code>mime</code></td><td><p><code>string</code><br>The MIME type of the note's content, such as <code>application/json</code>.</p></td></tr><tr><td><code>isProtected</code></td><td><p><code>boolean</code><br>Whether the note is protected (encrypted).</p></td></tr><tr><td><code>isArchived</code></td><td><p><code>boolean</code><br>Whether the note is archived (has the <code>archived</code> label).</p></td></tr><tr><td><code>isMetadataReadOnly</code></td><td><p><code>boolean</code><br>Whether the note's title and icon cannot be edited, which is the case for the system notes behind the options, the in-app help and the launch bar configuration.</p></td></tr><tr><td><code>attributes</code></td><td><p><code>string[]</code><br>IDs of this note's owned attributes.</p></td></tr><tr><td><code>targetRelations</code></td><td><p><code>string[]</code><br>IDs of relations pointing <em>at</em> this note.</p></td></tr><tr><td><code>parents</code></td><td><p><code>string[]</code><br>Parent note IDs.</p></td></tr><tr><td><code>children</code></td><td><p><code>string[]</code><br>Child note IDs.</p></td></tr><tr><td><code>getParentNotes</code></td><td><pre><code class=\"language-application-typescript\">getParentNotes(): ScriptFNote[]</code></pre><p>Returns the parent notes that the client has already loaded. A parent that is not loaded is skipped, and a search note that shows this note in its results counts as a parent.</p></td></tr><tr><td><code>getChildNotes</code></td><td><pre><code class=\"language-application-typescript\">getChildNotes(): Promise&lt;ScriptFNote[]&gt;</code></pre><p>Loads any missing child notes from the server, then returns all child notes in tree order. Archived children are included.</p></td></tr><tr><td><code>getParentNoteIds</code></td><td><pre><code class=\"language-application-typescript\">getParentNoteIds(): string[]</code></pre><p>Returns the IDs of the parent notes. The returned array is the note's own list, so do not change it.</p></td></tr><tr><td><code>getChildNoteIds</code></td><td><pre><code class=\"language-application-typescript\">getChildNoteIds(): string[]</code></pre><p>Returns the IDs of the child notes in tree order, archived ones included. The returned array is the note's own list, so do not change it.</p></td></tr><tr><td><code>getChildNoteIdsWithArchiveFiltering</code></td><td><pre><code class=\"language-application-typescript\">getChildNoteIdsWithArchiveFiltering(includeArchived?: boolean): Promise&lt;string[]&gt;</code></pre><p>Returns the IDs of the child notes in tree order, leaving out archived notes unless <code>includeArchived</code> is <code>true</code>. Leaving out archived notes takes a search on the server; for a search note or a note in the hidden subtree, all children are returned.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>includeArchived</code><br><em>optional</em></td><td><code>boolean</code><br>whether to keep archived children. Defaults to <code>false</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>getSubtreeNotes</code></td><td><pre><code class=\"language-application-typescript\">getSubtreeNotes(): Promise&lt;ScriptFNote[]&gt;</code></pre><p>Returns all descendants of the note, loading missing ones from the server one level at a time. An archived note and everything below it are left out, and the note itself is not included.</p></td></tr><tr><td><code>getSubtreeNoteIds</code></td><td><pre><code class=\"language-application-typescript\">getSubtreeNoteIds(includeArchived?: boolean): Promise&lt;string[]&gt;</code></pre><p>Returns the IDs of all the note's descendants, depth-first, without the note itself. Archived notes and the notes below them are left out unless <code>includeArchived</code> is <code>true</code>.</p></td></tr><tr><td><code>hasChildren</code></td><td><pre><code class=\"language-application-typescript\">hasChildren(): boolean</code></pre><p>Returns <code>true</code> if the note has at least one child, archived ones included. For a search note, the results count as children only once they are loaded.</p></td></tr><tr><td><code>hasAncestor</code></td><td><pre><code class=\"language-application-typescript\">hasAncestor(ancestorNoteId: string, followTemplates?: boolean): boolean</code></pre><p>Returns <code>true</code> if the note with the given ID is this note or one of its ancestors. It walks only parents the client has already loaded.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>ancestorNoteId</code></td><td><code>string</code></td></tr><tr><td><code>followTemplates</code><br><em>optional</em></td><td><code>boolean</code><br>whether to also walk up from the notes this note takes attributes from through <code>~template</code> and <code>~inherit</code> relations. Defaults to <code>false</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>isRoot</code></td><td><pre><code class=\"language-application-typescript\">isRoot(): boolean</code></pre><p>Returns <code>true</code> if this is the root note of the tree.</p></td></tr><tr><td><code>getParentBranchIds</code></td><td><pre><code class=\"language-application-typescript\">getParentBranchIds(): string[]</code></pre><p>Returns the IDs of the branches that place this note under each of its parents.</p></td></tr><tr><td><code>getBranchIds</code></td><td><pre><code class=\"language-application-typescript\">getBranchIds(): string[]</code></pre><p>Returns the IDs of the branches that place the note under its parents.</p><aside class=\"admonition warning\"><p>Deprecated. Use <code>getParentBranchIds()</code> instead.</p></aside></td></tr><tr><td><code>getParentBranches</code></td><td><pre><code class=\"language-application-typescript\">getParentBranches(): ScriptFBranch[]</code></pre><p>Returns the branches that place this note under each of its parents. A branch the client has not loaded is skipped.</p></td></tr><tr><td><code>getChildBranches</code></td><td><pre><code class=\"language-application-typescript\">getChildBranches(): ScriptFBranch[]</code></pre><p>Returns the branches to this note's children, in tree order. A branch the client has not loaded is skipped.</p></td></tr><tr><td><code>getBranches</code></td><td><pre><code class=\"language-application-typescript\">getBranches(): ScriptFBranch[]</code></pre><p>Returns the branches that place the note under its parents.</p><aside class=\"admonition warning\"><p>Deprecated. Use <code>getParentBranches()</code> instead.</p></aside></td></tr><tr><td><code>getFilteredChildBranches</code></td><td><pre><code class=\"language-application-typescript\">getFilteredChildBranches(): ScriptFBranch[]</code></pre><p>Returns the same branches as <code>getChildBranches()</code>. Despite the name, archived children are not filtered out.</p></td></tr><tr><td><code>getAllNotePaths</code></td><td><pre><code class=\"language-application-typescript\">getAllNotePaths(): string[][]</code></pre><p>Returns every path from the root to the note, each as a list of note IDs that starts with <code>root</code>. Paths that pass through a search note are left out.</p></td></tr><tr><td><code>getBestNotePath</code></td><td><pre><code class=\"language-application-typescript\">getBestNotePath(hoistedNoteId?: string, activeNotePath?: string | null): string[]</code></pre><p>Returns the note's best path as a list of note IDs that starts with <code>root</code>. Paths inside the hoisted note's subtree come first, then paths without archived or hidden notes; among equal paths, the one sharing the longest start with <code>activeNotePath</code> wins, then the shortest.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>hoistedNoteId</code><br><em>optional</em></td><td><code>string</code><br>The hoisted note, <code>root</code> by default.</td></tr><tr><td><code>activeNotePath</code><br><em>optional</em></td><td><code>string | null</code><br>The path of the active note, as note IDs joined by <code>/</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>getBestNotePathString</code></td><td><pre><code class=\"language-application-typescript\">getBestNotePathString(hoistedNoteId?: string): string</code></pre><p>Returns the note's best path, as <code>getBestNotePath()</code> chooses it, as note IDs joined by <code>/</code>, such as <code>root/a1h315/js725h</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>hoistedNoteId</code><br><em>optional</em></td><td><code>string</code><br>The hoisted note, <code>root</code> by default.</td></tr></tbody></table></figure></td></tr><tr><td><code>getSortedNotePathRecords</code></td><td><pre><code class=\"language-application-typescript\">getSortedNotePathRecords(hoistedNoteId?: string, activeNotePath?: string | null): ScriptNotePathRecord[]</code></pre><p>Returns every path from the root to this note, best first. Paths inside the hoisted note come first, then paths that do not pass through an archived note or the hidden subtree, then paths that share the most with <code>activeNotePath</code>, then shorter paths. Paths through search notes are left out, and only parents the client has loaded are followed.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>hoistedNoteId</code><br><em>optional</em></td><td><code>string</code><br>the ID of the hoisted note. Defaults to <code>root</code>.</td></tr><tr><td><code>activeNotePath</code><br><em>optional</em></td><td><code>string | null</code><br>a note path such as <code>root/abc123/def456</code>, used to prefer paths close to it.</td></tr></tbody></table></figure></td></tr><tr><td><code>getAttributes</code></td><td><pre><code class=\"language-application-typescript\">getAttributes(type?: string, name?: string): ScriptAttribute[]</code></pre><p>Returns the note's attributes, including inherited ones, optionally only those of the given type and name. The note's own attributes come first, then the ones inherited from its parents, then the ones from its templates.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code><br><em>optional</em></td><td><code>string</code><br><code>label</code> or <code>relation</code>; any other value throws an error.</td></tr><tr><td><code>name</code><br><em>optional</em></td><td><code>string</code><br>The attribute name, without the <code>#</code> or <code>~</code> prefix.</td></tr></tbody></table></figure></td></tr><tr><td><code>getOwnedAttributes</code></td><td><pre><code class=\"language-application-typescript\">getOwnedAttributes(type?: string, name?: string): ScriptAttribute[]</code></pre><p>Returns the note's own attributes, without inherited ones, optionally only those of the given type and name.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code><br><em>optional</em></td><td><code>string</code><br><code>label</code> or <code>relation</code>; any other value throws an error.</td></tr><tr><td><code>name</code><br><em>optional</em></td><td><code>string</code><br>The attribute name, without the <code>#</code> or <code>~</code> prefix.</td></tr></tbody></table></figure></td></tr><tr><td><code>getAttribute</code></td><td><pre><code class=\"language-application-typescript\">getAttribute(type: string, name: string): ScriptAttribute | null</code></pre><p>Returns the first attribute of the given type and name, including inherited ones, or <code>undefined</code> if the note has none.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>getOwnedAttribute</code></td><td><pre><code class=\"language-application-typescript\">getOwnedAttribute(type: string, name: string): ScriptAttribute | null</code></pre><p>Returns the first of the note's own attributes with the given type and name, or <code>undefined</code> if the note has none.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>getAttributeValue</code></td><td><pre><code class=\"language-application-typescript\">getAttributeValue(type: string, name: string): string | null</code></pre><p>Returns the value of the first attribute of the given type and name, including inherited ones, or <code>null</code> if the note has none.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>getOwnedAttributeValue</code></td><td><pre><code class=\"language-application-typescript\">getOwnedAttributeValue(type: string, name: string): string | null</code></pre><p>Returns the value of the first of the note's own attributes with the given type and name, or <code>null</code> if the note has none.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>hasAttribute</code></td><td><pre><code class=\"language-application-typescript\">hasAttribute(type: string, name: string): boolean</code></pre><p>Returns whether the note has an attribute of the given type and name, including inherited ones.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>hasOwnedAttribute</code></td><td><pre><code class=\"language-application-typescript\">hasOwnedAttribute(type: string, name: string): boolean</code></pre><p>Returns whether the note itself has an attribute of the given type and name, without inherited ones.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>getAttributeDefinitions</code></td><td><pre><code class=\"language-application-typescript\">getAttributeDefinitions(): ScriptAttribute[]</code></pre><p>Returns the attribute definitions that apply to the note, at most one per defined name. When the note gets a definition from several places, such as its own, an ancestor's and a template's, the nearest one wins, in the order <code>getAttributes()</code> lists them.</p></td></tr><tr><td><code>getPromotedDefinitionAttributes</code></td><td><pre><code class=\"language-application-typescript\">getPromotedDefinitionAttributes(): ScriptAttribute[]</code></pre><p>Returns the attribute definitions that are marked as promoted, at most one per name, grouped by the note that owns them and ordered by position. Returns an empty array if the note has a truthy <code>hidePromotedAttributes</code> label.</p></td></tr><tr><td><code>getLabels</code></td><td><pre><code class=\"language-application-typescript\">getLabels(name?: string): ScriptAttribute[]</code></pre><p>Returns the note's labels, including inherited ones, optionally only those with <code>name</code>.</p></td></tr><tr><td><code>getOwnedLabels</code></td><td><pre><code class=\"language-application-typescript\">getOwnedLabels(name?: string): ScriptAttribute[]</code></pre><p>Returns the note's own labels, without inherited ones, optionally only those with <code>name</code>.</p></td></tr><tr><td><code>getLabel</code></td><td><pre><code class=\"language-application-typescript\">getLabel(name: string): ScriptAttribute | null</code></pre><p>Returns the first label with the given name, including inherited ones, or <code>undefined</code> if the note has none.</p></td></tr><tr><td><code>getOwnedLabel</code></td><td><pre><code class=\"language-application-typescript\">getOwnedLabel(name: string): ScriptAttribute | null</code></pre><p>Returns the first of the note's own labels with the given name, or <code>undefined</code> if the note has none.</p></td></tr><tr><td><code>getLabelValue</code></td><td><pre><code class=\"language-application-typescript\">getLabelValue(name: string): string | null</code></pre><p>Returns the value of the first label with the given name, including inherited ones, or <code>null</code> if the note has none.</p></td></tr><tr><td><code>getOwnedLabelValue</code></td><td><pre><code class=\"language-application-typescript\">getOwnedLabelValue(name: string): string | null</code></pre><p>Returns the value of the first of the note's own labels with the given name, or <code>null</code> if the note has none.</p></td></tr><tr><td><code>hasLabel</code></td><td><pre><code class=\"language-application-typescript\">hasLabel(name: string): boolean</code></pre><p>Returns whether the note has a label with the given name, including inherited ones.</p></td></tr><tr><td><code>hasOwnedLabel</code></td><td><pre><code class=\"language-application-typescript\">hasOwnedLabel(name: string): boolean</code></pre><p>Returns whether the note itself has a label with the given name, without inherited ones.</p></td></tr><tr><td><code>hasLabelOrDisabled</code></td><td><pre><code class=\"language-application-typescript\">hasLabelOrDisabled(name: string): boolean</code></pre><p>Returns whether the note has a label with the given name, including inherited ones, or the same label with the <code>disabled:</code> prefix, which a safe import gives it.</p></td></tr><tr><td><code>isLabelTruthy</code></td><td><pre><code class=\"language-application-typescript\">isLabelTruthy(name: string): boolean</code></pre><p>Returns whether the note has a label with the given name, including inherited ones, whose value is anything but <code>false</code>. A label without a value counts as true.</p></td></tr><tr><td><code>getRelations</code></td><td><pre><code class=\"language-application-typescript\">getRelations(name?: string): ScriptAttribute[]</code></pre><p>Returns the note's relations, including inherited ones, optionally only those with <code>name</code>.</p></td></tr><tr><td><code>getOwnedRelations</code></td><td><pre><code class=\"language-application-typescript\">getOwnedRelations(name: string): ScriptAttribute[]</code></pre><p>Returns the note's own relations, without inherited ones, optionally only those with <code>name</code>.</p></td></tr><tr><td><code>getRelation</code></td><td><pre><code class=\"language-application-typescript\">getRelation(name: string): ScriptAttribute | null</code></pre><p>Returns the first relation with the given name, including inherited ones, or <code>undefined</code> if the note has none.</p></td></tr><tr><td><code>getOwnedRelation</code></td><td><pre><code class=\"language-application-typescript\">getOwnedRelation(name: string): ScriptAttribute | null</code></pre><p>Returns the first of the note's own relations with the given name, or <code>undefined</code> if the note has none.</p></td></tr><tr><td><code>getRelationValue</code></td><td><pre><code class=\"language-application-typescript\">getRelationValue(name: string): string | null</code></pre><p>Returns the target note ID of the first relation with the given name, including inherited ones, or <code>null</code> if the note has none.</p></td></tr><tr><td><code>getOwnedRelationValue</code></td><td><pre><code class=\"language-application-typescript\">getOwnedRelationValue(name: string): string | null</code></pre><p>Returns the target note ID of the first of the note's own relations with the given name, or <code>null</code> if the note has none.</p></td></tr><tr><td><code>hasRelation</code></td><td><pre><code class=\"language-application-typescript\">hasRelation(name: string): boolean</code></pre><p>Returns whether the note has a relation with the given name, including inherited ones.</p></td></tr><tr><td><code>hasOwnedRelation</code></td><td><pre><code class=\"language-application-typescript\">hasOwnedRelation(name: string): boolean</code></pre><p>Returns whether the note itself has a relation with the given name, without inherited ones.</p></td></tr><tr><td><code>getLabelOrRelation</code></td><td><pre><code class=\"language-application-typescript\">getLabelOrRelation(nameWithPrefix: string): string | null</code></pre><p>Returns the value of a label or relation, inherited ones included, or <code>null</code> if the note has none. A relation's value is the ID of its target note.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>nameWithPrefix</code></td><td><code>string</code><br>the attribute name prefixed with <code>#</code> for a label or <code>~</code> for a relation. A name without a prefix is looked up as a label.</td></tr></tbody></table></figure></td></tr><tr><td><code>getRelationTarget</code></td><td><pre><code class=\"language-application-typescript\">getRelationTarget(name: string): Promise&lt;ScriptFNote | null&gt;</code></pre><p>Returns the target note of the first relation with the given name, including inherited ones. Returns <code>null</code> if the note has no such relation, the relation has no target, or the target note does not exist.</p></td></tr><tr><td><code>getRelationTargets</code></td><td><pre><code class=\"language-application-typescript\">getRelationTargets(name: string): Promise&lt;(ScriptFNote | null)[]&gt;</code></pre><p>Returns the target notes of the note's relations with the given name, including inherited ones, in the order of the relations. A relation whose target is missing gives <code>null</code>.</p></td></tr><tr><td><code>getTargetRelations</code></td><td><pre><code class=\"language-application-typescript\">getTargetRelations(): ScriptAttribute[]</code></pre><p>Returns the relations, owned by any note, that point at this note.</p></td></tr><tr><td><code>getTargetRelationSourceNotes</code></td><td><pre><code class=\"language-application-typescript\">getTargetRelationSourceNotes(): Promise&lt;ScriptFNote[]&gt;</code></pre><p>Returns the notes that own a relation pointing at this note.</p></td></tr><tr><td><code>getContent</code></td><td><pre><code class=\"language-application-typescript\">getContent(): Promise&lt;string | Uint8Array&lt;ArrayBufferLike&gt;&gt;</code></pre><p>Fetches the note's content from the server. Resolves to a string for text-based notes; for a binary note such as an image or file, the content is not sent, and for a protected note without a protected session, it is an empty string.</p></td></tr><tr><td><code>getJsonContent</code></td><td><pre><code class=\"language-application-typescript\">getJsonContent(): Promise&lt;unknown&gt;</code></pre><p>Fetches the note's content and parses it as JSON. Resolves to <code>null</code> if the content is empty, is not a string, or is not valid JSON.</p></td></tr><tr><td><code>getBlob</code></td><td><pre><code class=\"language-application-typescript\">getBlob(): Promise&lt;ScriptBlob | null&gt;</code></pre><p>Fetches the note's content together with its blob ID, length and modification date. Resolves to <code>null</code> if the request fails.</p></td></tr><tr><td><code>getNoteComplement</code></td><td><pre><code class=\"language-application-typescript\">getNoteComplement(): Promise&lt;ScriptBlob | null&gt;</code></pre><p>Returns the blob that holds the note's content.</p><aside class=\"admonition warning\"><p>Deprecated. Use <code>getBlob()</code> instead.</p></aside></td></tr><tr><td><code>getMetadata</code></td><td><pre><code class=\"language-application-typescript\">getMetadata(): Promise&lt;ScriptNoteMetadata&gt;</code></pre><p>Returns the note's creation and modification dates, which it requests from the server.</p></td></tr><tr><td><code>attachments</code></td><td><p><code>ScriptAttachment[] | null</code><br>The note's attachments, or <code>null</code> until <code>getAttachments()</code> loads them. Use <code>getAttachments()</code> instead of reading this property.</p></td></tr><tr><td><code>getAttachments</code></td><td><pre><code class=\"language-application-typescript\">getAttachments(): Promise&lt;ScriptAttachment[]&gt;</code></pre><p>Returns the note's attachments. The first call loads them from the server, and later calls reuse that list.</p></td></tr><tr><td><code>getAttachmentsByRole</code></td><td><pre><code class=\"language-application-typescript\">getAttachmentsByRole(role: string): Promise&lt;ScriptAttachment[]&gt;</code></pre><p>Returns the note's attachments with the given role, such as <code>image</code> or <code>file</code>.</p></td></tr><tr><td><code>getAttachmentById</code></td><td><pre><code class=\"language-application-typescript\">getAttachmentById(attachmentId: string): Promise&lt;ScriptAttachment | undefined&gt;</code></pre><p>Returns the note's attachment with the given ID, or <code>undefined</code> if this note has no such attachment.</p></td></tr><tr><td><code>getNotesToInheritAttributesFrom</code></td><td><pre><code class=\"language-application-typescript\">getNotesToInheritAttributesFrom(): ScriptFNote[]</code></pre><p>Returns the target notes of this note's <code>~template</code> and <code>~inherit</code> relations, inherited relations included. A target note that the client has not loaded appears as <code>undefined</code>.</p></td></tr><tr><td><code>getIcon</code></td><td><pre><code class=\"language-application-typescript\">getIcon(): string</code></pre><p>Returns the CSS classes of the note's icon, such as <code>tn-icon bx bx-note</code>. The icon comes from the <code>iconClass</code> label, then the <code>workspaceIconClass</code> label, then a default for the note type.</p></td></tr><tr><td><code>isFolder</code></td><td><pre><code class=\"language-application-typescript\">isFolder(): boolean</code></pre><p>Returns <code>true</code> if the note shows as a folder in the tree: a search note, or a note with children (archived ones included). Always <code>false</code> when the note has a truthy <code>subtreeHidden</code> label.</p></td></tr><tr><td><code>isShared</code></td><td><pre><code class=\"language-application-typescript\">isShared(): boolean</code></pre><p>Returns <code>true</code> if the note is placed, directly or through ancestors the client has loaded, under the shared notes root (<code>_share</code>).</p></td></tr><tr><td><code>isContentAvailable</code></td><td><pre><code class=\"language-application-typescript\">isContentAvailable(): boolean</code></pre><p>Returns <code>true</code> if the note's content can be read: the note is not protected, or a protected session is active.</p></td></tr><tr><td><code>isJson</code></td><td><pre><code class=\"language-application-typescript\">isJson(): boolean</code></pre><p>Returns <code>true</code> if the note's MIME type is <code>application/json</code>.</p></td></tr><tr><td><code>isJavaScript</code></td><td><pre><code class=\"language-application-typescript\">isJavaScript(): boolean</code></pre><p>Returns whether the note is a code, file or launcher note with a JavaScript MIME type.</p></td></tr><tr><td><code>isJsx</code></td><td><pre><code class=\"language-application-typescript\">isJsx(): boolean</code></pre><p>Returns <code>true</code> if the note is a code note with the MIME type <code>text/jsx</code>.</p></td></tr><tr><td><code>isHtml</code></td><td><pre><code class=\"language-application-typescript\">isHtml(): boolean</code></pre><p>Returns whether the note is a code, file or render note with the <code>text/html</code> MIME type.</p></td></tr><tr><td><code>isMarkdown</code></td><td><pre><code class=\"language-application-typescript\">isMarkdown(): boolean</code></pre><p>Returns <code>true</code> if the note is a code note with a Markdown MIME type (<code>text/markdown</code>, <code>text/x-markdown</code> or <code>text/x-gfm</code>).</p></td></tr><tr><td><code>isOptions</code></td><td><pre><code class=\"language-application-typescript\">isOptions(): boolean</code></pre><p>Returns <code>true</code> if the note is one of Trilium's settings pages.</p></td></tr><tr><td><code>isTriliumScript</code></td><td><pre><code class=\"language-application-typescript\">isTriliumScript(): boolean</code></pre><p>Returns <code>true</code> if the note's MIME type starts with <code>application/javascript</code>, which covers both frontend and backend scripts. The note type is not checked.</p></td></tr><tr><td><code>isTriliumSqlite</code></td><td><pre><code class=\"language-application-typescript\">isTriliumSqlite(): boolean</code></pre><p>Returns <code>true</code> if the note is a SQL console note, which has the MIME type <code>text/x-sqlite;schema=trilium</code>.</p></td></tr><tr><td><code>isLaunchBarConfig</code></td><td><pre><code class=\"language-application-typescript\">isLaunchBarConfig(): boolean</code></pre><p>Returns <code>true</code> if the note is a launcher or one of the notes that hold the launch bar's launchers.</p></td></tr><tr><td><code>isHiddenCompletely</code></td><td><pre><code class=\"language-application-typescript\">isHiddenCompletely(): boolean</code></pre><p>Returns whether every path to the note runs through the hidden subtree, so that no clone of it appears in the visible tree. Paths through search notes are not counted.</p></td></tr><tr><td><code>isInHiddenSubtree</code></td><td><pre><code class=\"language-application-typescript\">isInHiddenSubtree(): boolean</code></pre><p>Returns <code>true</code> if the note is the hidden subtree's root (<code>_hidden</code>) or has it as an ancestor through any of its loaded parents, even when the note is also cloned into the visible tree.</p></td></tr><tr><td><code>isEligibleForConversionToAttachment</code></td><td><pre><code class=\"language-application-typescript\">isEligibleForConversionToAttachment(): boolean</code></pre><p>Returns <code>true</code> if the image note can be converted into an attachment of its parent: it is an image note without children, it has exactly one parent, that parent is a text note, the content of both is available, and no note other than the parent links to the image.</p></td></tr><tr><td><code>getColorClass</code></td><td><pre><code class=\"language-application-typescript\">getColorClass(): string</code></pre><p>Returns the CSS class that applies the note's <code>color</code> label, such as <code>color-ff0000</code>, or an empty string if the label is missing or not a valid color. The first call for a color adds the class's style rule to the page.</p></td></tr><tr><td><code>getCssClass</code></td><td><pre><code class=\"language-application-typescript\">getCssClass(): string</code></pre><p>Returns the values of all the note's <code>cssClass</code> labels, inherited ones included, separated by spaces.</p></td></tr><tr><td><code>getWorkspaceIconClass</code></td><td><pre><code class=\"language-application-typescript\">getWorkspaceIconClass(): string</code></pre><p>Returns the value of the note's <code>workspaceIconClass</code> label, or an empty string if it has none.</p></td></tr><tr><td><code>getWorkspaceTabBackgroundColor</code></td><td><pre><code class=\"language-application-typescript\">getWorkspaceTabBackgroundColor(): string</code></pre><p>Returns the value of the note's <code>workspaceTabBackgroundColor</code> label, or an empty string if it has none.</p></td></tr><tr><td><code>getScriptEnv</code></td><td><pre><code class=\"language-application-typescript\">getScriptEnv(): \"frontend\" | \"backend\" | null</code></pre><p>Returns where the note runs as a script: <code>frontend</code> for HTML, JSX, render notes and JavaScript with <code>env=frontend</code> in its MIME type, <code>backend</code> for JavaScript with <code>env=backend</code>, and <code>null</code> for any other note.</p></td></tr><tr><td><code>executeScript</code></td><td><pre><code class=\"language-application-typescript\">executeScript(): Promise&lt;unknown&gt;</code></pre><p>Runs the note as a frontend or backend script, depending on <code>getScriptEnv()</code>. For a frontend script, the promise resolves to the value the script returns; for a backend script, it resolves to <code>undefined</code> once the script has run. A frontend script that fails shows its error and resolves to <code>undefined</code>.</p></td></tr><tr><td><code>blobId</code></td><td><p><code>string</code><br>Blob ID of the current content; changes when content changes.</p></td></tr><tr><td><code>parentToBranch</code></td><td><p><code>Record&lt;string, string&gt;</code><br>Map of parent note ID → branch ID.</p></td></tr><tr><td><code>childToBranch</code></td><td><p><code>Record&lt;string, string&gt;</code><br>Map of child note ID → branch ID.</p></td></tr><tr><td><code>searchResultsLoaded</code><br><em>optional</em></td><td><p><code>boolean</code><br>For a search note, <code>true</code> once its results have been loaded as its children; otherwise not set.</p></td></tr><tr><td><code>highlightedTokens</code><br><em>optional</em></td><td><p><code>string[]</code><br>For a search note whose results are loaded, the search words to highlight in those results; otherwise not set.</p></td></tr><tr><td><code>dto</code></td><td><p><code>Record&lt;string, unknown&gt;</code><br>Plain data representation of the note (the live object minus its cache handle).</p></td></tr><tr><td><code>addParent</code></td><td><pre><code class=\"language-application-typescript\">addParent(parentNoteId: string, branchId: string, sort?: boolean): void</code></pre><p>Adds a parent to this note in the client's cache only. Trilium calls it when it loads branches; scripts do not normally call it, and the change is not saved. To place a note under another, use <code>api.runOnBackend()</code> with the backend API.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>parentNoteId</code></td><td><code>string</code></td></tr><tr><td><code>branchId</code></td><td><code>string</code><br>the ID of the branch that links the two notes.</td></tr><tr><td><code>sort</code><br><em>optional</em></td><td><code>boolean</code><br>whether to reorder the parents afterwards. Defaults to <code>true</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>addChild</code></td><td><pre><code class=\"language-application-typescript\">addChild(childNoteId: string, branchId: string, sort?: boolean): void</code></pre><p>Adds a child to this note in the client's cache only. Trilium calls it when it loads branches; scripts do not normally call it, and the change is not saved.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>childNoteId</code></td><td><code>string</code></td></tr><tr><td><code>branchId</code></td><td><code>string</code><br>the ID of the branch that links the two notes.</td></tr><tr><td><code>sort</code><br><em>optional</em></td><td><code>boolean</code><br>whether to reorder the children by their position afterwards. Defaults to <code>true</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>sortParents</code></td><td><pre><code class=\"language-application-typescript\">sortParents(): void</code></pre><p>Reorders the parent list in the client's cache so that ordinary parents come before search notes, archived notes and notes outside the visible tree. Trilium calls it itself; scripts do not normally call it.</p></td></tr><tr><td><code>sortChildren</code></td><td><pre><code class=\"language-application-typescript\">sortChildren(): void</code></pre><p>Reorders the child list in the client's cache by each branch's position. Trilium calls it itself; scripts do not normally call it, and it does not change the order saved in the database.</p></td></tr><tr><td><code>update</code></td><td><pre><code class=\"language-application-typescript\">update(row: Record&lt;string, unknown&gt;): void</code></pre><p>Overwrites the note's ID, title, type, MIME type, protection flag and blob ID in the client's cache with the values in <code>row</code>. Trilium calls it when changes arrive from the server; scripts do not normally call it, and the change is not saved.</p></td></tr><tr><td><code>invalidateAttributeCache</code></td><td><pre><code class=\"language-application-typescript\">invalidateAttributeCache(): void</code></pre><p>Does nothing; the note's attributes stay up to date without it.</p><aside class=\"admonition warning\"><p>Deprecated. Remove the call.</p></aside></td></tr><tr><td><code>toString</code></td><td><pre><code class=\"language-application-typescript\">toString(): string</code></pre><p>Returns a short description of the note for logging, such as <code>Note(noteId=abc123, title=My note)</code>.</p></td></tr></tbody></table></figure><h2><code>RightPanelWidget</code></h2><p>Instance shape of <code>RightPanelWidget</code> (subset) — a widget shown in the right sidebar.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>$widget</code></td><td><p><code>any</code><br>The widget's root jQuery element (assign in <code>doRender</code>, e.g. <code>this.$widget = $(TPL)</code>). Typed loosely because jQuery types can't be imported into this self-contained module; inside the editor it is a real <code>JQuery&lt;HTMLElement&gt;</code> so all jQuery methods work.</p></td></tr><tr><td><code>isEnabled</code></td><td><pre><code class=\"language-application-typescript\">isEnabled(): boolean | null | undefined</code></pre><p>Returns whether the widget is shown: always for a <code>BasicWidget</code>, and only while a note is active for a <code>NoteContextAwareWidget</code>. A disabled widget stays in the DOM, hidden, and a <code>NoteContextAwareWidget</code> does not call <code>refreshWithNote()</code> while it is disabled.</p></td></tr><tr><td><code>doRender</code></td><td><pre><code class=\"language-application-typescript\">doRender(): void</code></pre><p>Builds the widget's DOM. Override it to create the root element and assign it to <code>this.$widget</code> as a jQuery object.</p></td></tr><tr><td><code>render</code></td><td><pre><code class=\"language-application-typescript\">render(): unknown</code></pre><p>Renders the widget and returns its root element.</p></td></tr><tr><td><code>cleanup</code></td><td><pre><code class=\"language-application-typescript\">cleanup(): void</code></pre><p>Tears down the widget; override to release resources.</p></td></tr><tr><td><code>id</code></td><td><pre><code class=\"language-application-typescript\">id(id: string): this</code></pre><p>Fluent builder: set the element id. Chainable.</p></td></tr><tr><td><code>class</code></td><td><pre><code class=\"language-application-typescript\">class(className: string): this</code></pre><p>Fluent builder: add a CSS class. Chainable.</p></td></tr><tr><td><code>css</code></td><td><pre><code class=\"language-application-typescript\">css(name: string, value: string): this</code></pre><p>Sets an inline CSS property on the widget's root element, such as <code>css(\"padding-inline-start\", \"12px\")</code>, and returns the widget for chaining. It takes effect when the widget renders.</p></td></tr><tr><td><code>child</code></td><td><pre><code class=\"language-application-typescript\">child(...components: unknown[]): this</code></pre><p>Fluent builder: append child components. Chainable.</p></td></tr><tr><td><code>note</code></td><td><p><code>ScriptFNote | null</code><br>The note currently shown in this widget's context.</p></td></tr><tr><td><code>noteContext</code><br><em>optional</em></td><td><p><code>ScriptNoteContext</code><br>The note context (split) this widget is attached to.</p></td></tr><tr><td><code>refreshWithNote</code></td><td><pre><code class=\"language-application-typescript\">refreshWithNote(note: ScriptFNote | null | undefined): void | Promise&lt;void&gt;</code></pre><p>Updates the widget for the note in its context. Override it to refresh the widget's content; it runs when that note changes and on <code>refresh()</code>, as long as <code>isEnabled()</code> returns <code>true</code>.</p></td></tr><tr><td><code>refresh</code></td><td><pre><code class=\"language-application-typescript\">refresh(): void | Promise&lt;void&gt;</code></pre><p>Forces a refresh against the current note.</p></td></tr><tr><td><code>widgetTitle</code></td><td><p><code>string</code><br>The title shown in the panel's header, <code>Untitled widget</code> unless overridden. The panel reads it once, when it renders.</p></td></tr><tr><td><code>doRenderBody</code></td><td><pre><code class=\"language-application-typescript\">doRenderBody(): void | Promise&lt;void&gt;</code></pre><p>Builds the panel's body. Override it to fill <code>this.$body</code>, the jQuery element the panel creates for the content, instead of <code>doRender()</code>. It can return a promise when the body needs asynchronous work; an error that promise rejects with is logged.</p></td></tr></tbody></table></figure><h2><code>NoteContextAwareWidget</code></h2><p>Instance shape of <code>NoteContextAwareWidget</code> (subset) — reacts to the active note.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>$widget</code></td><td><p><code>any</code><br>The widget's root jQuery element (assign in <code>doRender</code>, e.g. <code>this.$widget = $(TPL)</code>). Typed loosely because jQuery types can't be imported into this self-contained module; inside the editor it is a real <code>JQuery&lt;HTMLElement&gt;</code> so all jQuery methods work.</p></td></tr><tr><td><code>isEnabled</code></td><td><pre><code class=\"language-application-typescript\">isEnabled(): boolean | null | undefined</code></pre><p>Returns whether the widget is shown: always for a <code>BasicWidget</code>, and only while a note is active for a <code>NoteContextAwareWidget</code>. A disabled widget stays in the DOM, hidden, and a <code>NoteContextAwareWidget</code> does not call <code>refreshWithNote()</code> while it is disabled.</p></td></tr><tr><td><code>doRender</code></td><td><pre><code class=\"language-application-typescript\">doRender(): void</code></pre><p>Builds the widget's DOM. Override it to create the root element and assign it to <code>this.$widget</code> as a jQuery object.</p></td></tr><tr><td><code>render</code></td><td><pre><code class=\"language-application-typescript\">render(): unknown</code></pre><p>Renders the widget and returns its root element.</p></td></tr><tr><td><code>cleanup</code></td><td><pre><code class=\"language-application-typescript\">cleanup(): void</code></pre><p>Tears down the widget; override to release resources.</p></td></tr><tr><td><code>id</code></td><td><pre><code class=\"language-application-typescript\">id(id: string): this</code></pre><p>Fluent builder: set the element id. Chainable.</p></td></tr><tr><td><code>class</code></td><td><pre><code class=\"language-application-typescript\">class(className: string): this</code></pre><p>Fluent builder: add a CSS class. Chainable.</p></td></tr><tr><td><code>css</code></td><td><pre><code class=\"language-application-typescript\">css(name: string, value: string): this</code></pre><p>Sets an inline CSS property on the widget's root element, such as <code>css(\"padding-inline-start\", \"12px\")</code>, and returns the widget for chaining. It takes effect when the widget renders.</p></td></tr><tr><td><code>child</code></td><td><pre><code class=\"language-application-typescript\">child(...components: unknown[]): this</code></pre><p>Fluent builder: append child components. Chainable.</p></td></tr><tr><td><code>note</code></td><td><p><code>ScriptFNote | null</code><br>The note currently shown in this widget's context.</p></td></tr><tr><td><code>noteContext</code><br><em>optional</em></td><td><p><code>ScriptNoteContext</code><br>The note context (split) this widget is attached to.</p></td></tr><tr><td><code>refreshWithNote</code></td><td><pre><code class=\"language-application-typescript\">refreshWithNote(note: ScriptFNote | null | undefined): void | Promise&lt;void&gt;</code></pre><p>Updates the widget for the note in its context. Override it to refresh the widget's content; it runs when that note changes and on <code>refresh()</code>, as long as <code>isEnabled()</code> returns <code>true</code>.</p></td></tr><tr><td><code>refresh</code></td><td><pre><code class=\"language-application-typescript\">refresh(): void | Promise&lt;void&gt;</code></pre><p>Forces a refresh against the current note.</p></td></tr></tbody></table></figure><h2><code>BasicWidget</code></h2><p>Instance shape of <code>BasicWidget</code> (subset) — the base for custom frontend widgets.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>$widget</code></td><td><p><code>any</code><br>The widget's root jQuery element (assign in <code>doRender</code>, e.g. <code>this.$widget = $(TPL)</code>). Typed loosely because jQuery types can't be imported into this self-contained module; inside the editor it is a real <code>JQuery&lt;HTMLElement&gt;</code> so all jQuery methods work.</p></td></tr><tr><td><code>isEnabled</code></td><td><pre><code class=\"language-application-typescript\">isEnabled(): boolean | null | undefined</code></pre><p>Returns whether the widget is shown: always for a <code>BasicWidget</code>, and only while a note is active for a <code>NoteContextAwareWidget</code>. A disabled widget stays in the DOM, hidden, and a <code>NoteContextAwareWidget</code> does not call <code>refreshWithNote()</code> while it is disabled.</p></td></tr><tr><td><code>doRender</code></td><td><pre><code class=\"language-application-typescript\">doRender(): void</code></pre><p>Builds the widget's DOM. Override it to create the root element and assign it to <code>this.$widget</code> as a jQuery object.</p></td></tr><tr><td><code>render</code></td><td><pre><code class=\"language-application-typescript\">render(): unknown</code></pre><p>Renders the widget and returns its root element.</p></td></tr><tr><td><code>cleanup</code></td><td><pre><code class=\"language-application-typescript\">cleanup(): void</code></pre><p>Tears down the widget; override to release resources.</p></td></tr><tr><td><code>id</code></td><td><pre><code class=\"language-application-typescript\">id(id: string): this</code></pre><p>Fluent builder: set the element id. Chainable.</p></td></tr><tr><td><code>class</code></td><td><pre><code class=\"language-application-typescript\">class(className: string): this</code></pre><p>Fluent builder: add a CSS class. Chainable.</p></td></tr><tr><td><code>css</code></td><td><pre><code class=\"language-application-typescript\">css(name: string, value: string): this</code></pre><p>Sets an inline CSS property on the widget's root element, such as <code>css(\"padding-inline-start\", \"12px\")</code>, and returns the widget for chaining. It takes effect when the widget renders.</p></td></tr><tr><td><code>child</code></td><td><pre><code class=\"language-application-typescript\">child(...components: unknown[]): this</code></pre><p>Fluent builder: append child components. Chainable.</p></td></tr></tbody></table></figure><h2><code>ScriptFBranch</code></h2><p>A branch (parent↔child link) as seen by frontend scripts (subset of <code>FBranch</code>).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>branchId</code></td><td><p><code>string</code><br>The unique ID of the branch.</p></td></tr><tr><td><code>noteId</code></td><td><p><code>string</code><br>The ID of the child note that this branch places in the tree.</p></td></tr><tr><td><code>parentNoteId</code></td><td><p><code>string</code><br>The ID of the parent note.</p></td></tr><tr><td><code>notePosition</code></td><td><p><code>number</code><br>The place of the note among its siblings; the note tree lists siblings by ascending <code>notePosition</code>. Trilium spaces positions 10 apart.</p></td></tr><tr><td><code>prefix</code><br><em>optional</em></td><td><p><code>string</code><br>The prefix shown before the note's title in the note tree, for this placement of the note only. It is empty or missing when the branch has none.</p></td></tr><tr><td><code>isExpanded</code><br><em>optional</em></td><td><p><code>boolean</code><br>Whether the note tree shows this branch expanded, with the note's children visible.</p></td></tr><tr><td><code>getNote</code></td><td><pre><code class=\"language-application-typescript\">getNote(): Promise&lt;ScriptFNote | null&gt;</code></pre><p>Returns the child note, loading it from the server if the frontend cache does not hold it yet. Resolves to <code>null</code> if the note does not exist.</p></td></tr><tr><td><code>getNoteFromCache</code></td><td><pre><code class=\"language-application-typescript\">getNoteFromCache(): ScriptFNote | undefined</code></pre><p>Returns the child note from the frontend cache, without contacting the server. Returns <code>undefined</code> if the note is not loaded yet.</p></td></tr><tr><td><code>getParentNote</code></td><td><pre><code class=\"language-application-typescript\">getParentNote(): Promise&lt;ScriptFNote | null&gt;</code></pre><p>Returns the parent note, loading it from the server if the frontend cache does not hold it yet. Resolves to <code>null</code> if the note does not exist.</p></td></tr><tr><td><code>isTopLevel</code></td><td><pre><code class=\"language-application-typescript\">isTopLevel(): boolean</code></pre><p>Returns whether the branch places its note directly under the root note.</p></td></tr></tbody></table></figure><h2><code>ScriptNoteContext</code></h2><p>A split/tab context as seen by frontend scripts (subset of <code>NoteContext</code>).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>ntxId</code></td><td><p><code>string | null</code><br>The ID of the note context, which identifies one tab or split.</p></td></tr><tr><td><code>note</code></td><td><p><code>ScriptFNote | null</code><br>The note this context shows, or <code>null</code> if the context is empty.</p></td></tr><tr><td><code>notePath</code></td><td><p><code>string | null</code><br>The path of the note this context shows, as note IDs from <code>root</code> joined by <code>/</code>, such as <code>root/abc123/def456</code>. It is <code>null</code> when the context is empty.</p></td></tr><tr><td><code>getCodeEditor</code></td><td><pre><code class=\"language-application-typescript\">getCodeEditor(): Promise&lt;unknown&gt;</code></pre><p>Returns the CodeMirror editor of the code note this context shows. Resolves to <code>null</code> if the context shows no code editor within 200 ms.</p></td></tr><tr><td><code>getTextEditor</code></td><td><pre><code class=\"language-application-typescript\">getTextEditor(): Promise&lt;unknown&gt;</code></pre><p>Returns the CKEditor instance of the editable text note this context shows. Resolves to <code>null</code> if the context shows no editable text note within 200 ms.</p></td></tr></tbody></table></figure><h2><code>ScriptDayjsInstance</code></h2><p>A date as day.js wraps it (subset).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>format</code></td><td><pre><code class=\"language-application-typescript\">format(template?: string): string</code></pre><p>Formats the date, such as <code>\"YYYY-MM-DD\"</code> for <code>2026-10-22</code>. Without a template, it returns the ISO 8601 form with the UTC offset, such as <code>2026-10-22T14:03:05+02:00</code>.</p></td></tr><tr><td><code>add</code></td><td><pre><code class=\"language-application-typescript\">add(value: number, unit: string): ScriptDayjsInstance</code></pre><p>Returns a new date, <code>value</code> units later. The date it is called on stays unchanged.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>number</code></td></tr><tr><td><code>unit</code></td><td><code>string</code><br>The unit, such as <code>\"day\"</code>, <code>\"week\"</code>, <code>\"month\"</code> or <code>\"year\"</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>subtract</code></td><td><pre><code class=\"language-application-typescript\">subtract(value: number, unit: string): ScriptDayjsInstance</code></pre><p>Returns a new date, <code>value</code> units earlier. The date it is called on stays unchanged.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>number</code></td></tr><tr><td><code>unit</code></td><td><code>string</code><br>The unit, such as <code>\"day\"</code>, <code>\"week\"</code>, <code>\"month\"</code> or <code>\"year\"</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>toDate</code></td><td><pre><code class=\"language-application-typescript\">toDate(): Date</code></pre><p>Returns the date as a JavaScript <code>Date</code>.</p></td></tr></tbody></table></figure><h2>Types</h2><h3><code>ScriptDayjs</code></h3><p>Minimal day.js surface (the real API exposes the full day.js factory).</p><pre><code class=\"language-application-typescript\">type ScriptDayjs = (date?: string | number | Date) =&gt; ScriptDayjsInstance</code></pre><h3><code>WidgetClass</code></h3><p>Constructor type allowing <code>class X extends api.Widget { … }</code>.</p><pre><code class=\"language-application-typescript\">type WidgetClass = (...args: unknown[]) =&gt; T</code></pre><h3><code>Func</code></h3><pre><code class=\"language-application-typescript\">type Func = (...args: unknown[]) =&gt; unknown | string</code></pre><h3><code>ScriptCreateNoteOpts</code></h3><p>Options accepted by <code>FrontendApi.createNote</code>.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>title</code> <br><em>optional</em></td><td><code>string | null</code> <br>Title of the new note.</td></tr><tr><td><code>content</code> <br><em>optional</em></td><td><code>string | null</code> <br>Content of the new note (HTML for text notes, source for code notes, etc.).</td></tr><tr><td><code>type</code> <br><em>optional</em></td><td><code>string</code> <br>Note type, e.g. \"text\" (default), \"code\", \"book\".</td></tr><tr><td><code>mime</code> <br><em>optional</em></td><td><code>string</code> <br>MIME type, e.g. \"application/javascript;env=frontend\" for a frontend code note.</td></tr><tr><td><code>templateNoteId</code> <br><em>optional</em></td><td><code>string</code> <br>Note ID of a template to apply to the new note.</td></tr><tr><td><code>isProtected</code> <br><em>optional</em></td><td><code>boolean</code> <br>Create the note as protected (only takes effect when a protected session is available).</td></tr><tr><td><code>activate</code> <br><em>optional</em></td><td><code>boolean</code> <br>Activate (open) the new note after creation. Defaults to <code>true</code>.</td></tr><tr><td><code>focus</code> <br><em>optional</em></td><td><code>\"title\" | \"content\"</code> <br>Which part of the activated note to focus. Defaults to \"title\".</td></tr><tr><td><code>target</code> <br><em>optional</em></td><td><code>string</code> <br>Where to place the note relative to the parent/target: \"into\" (default) or \"after\".</td></tr><tr><td><code>targetBranchId</code> <br><em>optional</em></td><td><code>string</code> <br>Branch ID used together with <code>target: \"after\"</code>.</td></tr><tr><td><code>attributes</code> <br><em>optional</em></td><td><code>ScriptCreateAttribute[]</code> <br>Attributes to set atomically on creation.</td></tr></tbody></table></figure><h3><code>PickerItem</code></h3><p>One thing a picker offers, as <code>pickSingleItem</code> takes and answers with.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>key</code></td><td><code>string</code> <br>The ID of the item. It must be unique within its group, and tells the script which item the user picked.</td></tr><tr><td><code>caption</code></td><td><code>string</code> <br>The text shown for the item. The search field filters items by it.</td></tr><tr><td><code>icon</code> <br><em>optional</em></td><td><code>string</code> <br>An icon class, <code>bx</code> prefix included.</td></tr><tr><td><code>tooltip</code> <br><em>optional</em></td><td><code>string</code> <br>HTML shown in a tooltip while the item is hovered.</td></tr></tbody></table></figure><h3><code>PickerItemGroup</code></h3><p>A run of picker items under a heading of their own.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>key</code></td><td><code>string</code> <br>The ID of the group. It must be unique among the groups.</td></tr><tr><td><code>groupHeader</code></td><td><code>string</code> <br>The heading shown above the group's items. An empty string shows the items without a heading.</td></tr><tr><td><code>items</code></td><td><code>PickerItem[]</code> <br>The items in the group, in the order the picker shows them.</td></tr></tbody></table></figure><h3><code>ScriptNotePathRecord</code></h3><p>One resolved tree path to a note (subset of the client's <code>NotePathRecord</code>).</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>isArchived</code></td><td><code>boolean</code> <br>Whether a note on the path, the note itself included, is archived, which means it has the <code>#archived</code> label, owned or inherited.</td></tr><tr><td><code>isInHoistedSubTree</code></td><td><code>boolean</code> <br>Whether the path passes through the hoisted note passed to <code>getSortedNotePathRecords()</code>. It is always <code>true</code> when the hoisted note is <code>root</code>.</td></tr><tr><td><code>isSearch</code> <br><em>optional</em></td><td><code>boolean</code> <br>Whether the note itself is a search note. Only frontend scripts get this property; backend records leave it out.</td></tr><tr><td><code>notePath</code></td><td><code>string[]</code> <br>The note IDs along the path, from <code>root</code> to the note itself.</td></tr><tr><td><code>isHidden</code></td><td><code>boolean</code> <br>Whether the path passes through the hidden subtree, <code>_hidden</code>, which holds Trilium's system notes.</td></tr></tbody></table></figure><h3><code>ScriptAttribute</code></h3><p>A label or relation attached to a note.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>attributeId</code></td><td><code>string</code> <br>The ID of the attribute.</td></tr><tr><td><code>type</code></td><td><code>\"label\" | \"relation\"</code> <br>The type of the attribute: <code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code> <br>The name of the attribute, without the <code>#</code> or <code>~</code> prefix.</td></tr><tr><td><code>value</code></td><td><code>string</code> <br>The value of the attribute. For a relation, it is the ID of the target note. For a label without a value, it is an empty string.</td></tr><tr><td><code>isInheritable</code></td><td><code>boolean</code> <br>Whether the note's descendants inherit the attribute.</td></tr><tr><td><code>isOwned</code></td><td><code>boolean</code> <br>Not set by Trilium: neither frontend nor backend attributes carry this property, so it reads <code>undefined</code>.</td></tr></tbody></table></figure><h3><code>ScriptBlob</code></h3><p>A note's binary/text content blob (subset of the client's <code>FBlob</code>).</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>blobId</code></td><td><code>string</code> <br>The ID of the blob, derived from its content. Notes, attachments and revisions with identical content share one blob.</td></tr><tr><td><code>content</code></td><td><code>string</code> <br>The content as text. It is <code>null</code> when the content is binary, as in images and files.</td></tr><tr><td><code>contentLength</code></td><td><code>number</code> <br>The length of the content as stored: characters for text, bytes for binary content. For a protected note, it measures the encrypted content.</td></tr><tr><td><code>dateModified</code></td><td><code>string</code> <br>The local date and time this content was first stored, with the UTC offset, such as <code>2026-10-22 14:03:05.123+0200</code>. A blob never changes, so new content gets a new blob.</td></tr><tr><td><code>utcDateModified</code></td><td><code>string</code> <br>The date and time, in UTC, that this content was first stored, such as <code>2026-10-22 12:03:05.123Z</code>.</td></tr></tbody></table></figure><h3><code>ScriptNoteMetadata</code></h3><p>Creation/modification timestamps returned by <code>ScriptFNote.getMetadata</code>.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>dateCreated</code></td><td><code>string</code> <br>The local date and time the note was created, with the UTC offset, such as <code>2026-10-22 14:03:05.123+0200</code>.</td></tr><tr><td><code>utcDateCreated</code></td><td><code>string</code> <br>The date and time, in UTC, that the note was created, such as <code>2026-10-22 12:03:05.123Z</code>.</td></tr><tr><td><code>dateModified</code></td><td><code>string</code> <br>The local date and time the note was last modified, with the UTC offset, such as <code>2026-10-22 14:03:05.123+0200</code>. A change to the note's content counts as a modification.</td></tr><tr><td><code>utcDateModified</code></td><td><code>string</code> <br>The date and time, in UTC, that the note was last modified, such as <code>2026-10-22 12:03:05.123Z</code>. A change to the note's content counts as a modification.</td></tr></tbody></table></figure><h3><code>ScriptAttachment</code></h3><p>An attachment as seen by frontend scripts (subset of the client's <code>FAttachment</code>).</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>attachmentId</code></td><td><code>string</code> <br>The ID of the attachment.</td></tr><tr><td><code>ownerId</code></td><td><code>string</code> <br>The ID of the note the attachment belongs to. For an attachment of a revision, it is the ID of the revision.</td></tr><tr><td><code>role</code></td><td><code>string</code> <br>The purpose of the attachment, such as <code>image</code> for an image shown in a text note or <code>file</code> for an attached file. Trilium also uses roles of its own, such as <code>viewConfig</code> for a collection's view settings.</td></tr><tr><td><code>mime</code></td><td><code>string</code> <br>The MIME type of the attachment's content, such as <code>image/png</code>.</td></tr><tr><td><code>title</code></td><td><code>string</code> <br>The title of the attachment, usually its file name.</td></tr><tr><td><code>utcDateModified</code></td><td><code>string</code> <br>The date and time, in UTC, that the attachment was last saved, such as <code>2026-10-22 12:03:05.123Z</code>. Replacing the content counts as saving.</td></tr><tr><td><code>contentLength</code></td><td><code>number</code> <br>The length of the attachment's content. Only some ways of loading an attachment fill it in, such as <code>getAttachments()</code>; on the backend, <code>getAttachmentsByRole()</code> leaves it <code>undefined</code>.</td></tr></tbody></table></figure><h3><code>ScriptCreateAttribute</code></h3><p>An attribute to create together with a note (see <code>ScriptCreateNoteOpts.attributes</code>).</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>\"label\" | \"relation\"</code> <br>The type of the attribute: <code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code> <br>The name of the attribute, without the <code>#</code> or <code>~</code> prefix.</td></tr><tr><td><code>value</code> <br><em>optional</em></td><td><code>string</code> <br>The value of the attribute. For a relation, it is the ID of the target note. Defaults to an empty string.</td></tr><tr><td><code>isInheritable</code> <br><em>optional</em></td><td><code>boolean</code> <br>Whether the note's descendants inherit the attribute. Defaults to <code>false</code>.</td></tr><tr><td><code>position</code> <br><em>optional</em></td><td><code>number</code> <br>The place of the attribute among the note's attributes, which are listed by ascending <code>position</code>. Defaults to 10 more than the highest position among the note's attributes.</td></tr></tbody></table></figure>",
- "_help_MEtfsqa5VwNi": "<h2><code>BackendApi</code></h2><p>The <code>api</code> global available inside <strong>backend</strong> script notes (<code>application/javascript;env=backend</code>). Runs server-side: no DOM, no jQuery.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>startNote</code><br><em>optional</em></td><td><p><code>ScriptBNote | null</code><br>Note where the script execution started — the entry point of the current script bundle (in C terms, the file containing <code>main()</code>). When a script is spread across multiple code notes (descendant code notes loaded as modules via <code>require()</code>), every note in the bundle shares the same <code>startNote</code>, while <code>currentNote</code> differs per note. Messages from <code>api.log()</code> are grouped under this note. When a frontend script calls <code>api.runOnBackend()</code>, the frontend's <code>startNote</code> is preserved here; since that note may not be resolvable on the backend, this can be null.</p></td></tr><tr><td><code>currentNote</code></td><td><p><code>ScriptBNote</code><br>Note containing the source code that is currently executing (in C terms, <code>__FILE__</code>). Equal to <code>startNote</code> unless execution has moved into a descendant module note loaded via <code>require()</code>. Don't confuse this with the concept of the active note in the UI.</p></td></tr><tr><td><code>originEntity</code><br><em>optional</em></td><td><p><code>unknown</code><br>Entity whose event triggered this execution; <code>undefined</code> when the run was not event-driven (e.g. started manually via \"Execute script\" or <code>note.executeScript()</code>). What it holds depends on the trigger: - <code>~runOnNoteCreation</code>, <code>~runOnNoteChange</code>, <code>~runOnNoteTitleChange</code>, <code>~runOnNoteContentChange</code> — the affected note; - <code>~runOnChildNoteCreation</code> — the newly created child note; - <code>~runOnAttributeCreation</code>, <code>~runOnAttributeChange</code> — the attribute; - <code>~runOnBranchCreation</code>, <code>~runOnBranchChange</code>, <code>~runOnBranchDeletion</code> — the branch; - scheduled scripts (<code>#run=backendStartup</code> / <code>#run=hourly</code> / <code>#run=daily</code>) — the script note itself; - search scripts (<code>~searchScript</code>) — the search note.</p></td></tr><tr><td><code>req</code></td><td><p><code>ScriptRequest</code><br>The HTTP request, present only when the script runs as a custom request handler: a note with the <code>#customRequestHandler</code> label, invoked through a <code>/custom/...</code> URL. It is <code>undefined</code> in every other backend script. The object is Express's own request, so it has more members than <code>ScriptRequest</code> lists.</p></td></tr><tr><td><code>res</code></td><td><p><code>ScriptResponse</code><br>The HTTP response to write the reply to, such as <code>api.res.status(200).json({ ok: true })</code>. Like <code>req</code>, it is present only in custom request handlers, and is Express's own response.</p></td></tr><tr><td><code>pathParams</code></td><td><p><code>string[]</code><br>The capture groups from the <code>#customRequestHandler</code> regex that matched this request's URL, in order. Available only inside custom request handlers.</p></td></tr><tr><td><code>dayjs</code></td><td><p><code>ScriptDayjs</code><br>day.js library for date manipulation. See <code>https://day.js.org</code> for documentation</p></td></tr><tr><td><code>xml2js</code></td><td><p><code>unknown</code><br>xml2js library for XML parsing. See <code>https://github.com/Leonidas-from-XIV/node-xml2js</code> for documentation</p></td></tr><tr><td><code>htmlParser</code></td><td><p><code>unknown</code><br>node-html-parser library for HTML parsing. See <code>https://github.com/taoqf/node-fast-html-parser</code> for documentation.</p></td></tr><tr><td><code>getInstanceName</code></td><td><pre><code class=\"language-application-typescript\">getInstanceName(): string | null</code></pre><p>Instance name identifies particular Trilium instance. It can be useful for scripts if some action needs to happen on only one specific instance.</p></td></tr><tr><td><code>getNote</code></td><td><pre><code class=\"language-application-typescript\">getNote(noteId: string): ScriptBNote | null</code></pre><p>Returns a note by its ID, or null.</p></td></tr><tr><td><code>getBranch</code></td><td><pre><code class=\"language-application-typescript\">getBranch(branchId: string): ScriptBBranch | null</code></pre><p>Returns a branch by its ID, or null.</p></td></tr><tr><td><code>getAttribute</code></td><td><pre><code class=\"language-application-typescript\">getAttribute(attributeId: string): ScriptAttribute | null</code></pre><p>Returns an attribute by its ID, or null.</p></td></tr><tr><td><code>getAttachment</code></td><td><pre><code class=\"language-application-typescript\">getAttachment(attachmentId: string): unknown</code></pre><p>Returns an attachment by its ID, or null.</p></td></tr><tr><td><code>getRevision</code></td><td><pre><code class=\"language-application-typescript\">getRevision(revisionId: string): unknown</code></pre><p>Returns a revision by its ID, or null.</p></td></tr><tr><td><code>getEtapiToken</code></td><td><pre><code class=\"language-application-typescript\">getEtapiToken(etapiTokenId: string): unknown</code></pre><p>Returns an ETAPI token by its ID, or null.</p></td></tr><tr><td><code>getEtapiTokens</code></td><td><pre><code class=\"language-application-typescript\">getEtapiTokens(): unknown[]</code></pre><p>Returns all ETAPI tokens.</p></td></tr><tr><td><code>getOption</code></td><td><pre><code class=\"language-application-typescript\">getOption(optionName: string): unknown</code></pre><p>Returns an option by name, or null.</p></td></tr><tr><td><code>getOptions</code></td><td><pre><code class=\"language-application-typescript\">getOptions(): unknown[]</code></pre><p>Returns all options.</p></td></tr><tr><td><code>searchForNotes</code></td><td><pre><code class=\"language-application-typescript\">searchForNotes(query: string, searchParams?: Record&lt;string, unknown&gt;): ScriptBNote[]</code></pre><p>This is a powerful search method - you can search by attributes and their values, e.g.: \"#dateModified =* MONTH AND #log\". See <code>https://triliumnext.github.io/Docs/Wiki/search.html</code> for full documentation for all options</p></td></tr><tr><td><code>searchForNote</code></td><td><pre><code class=\"language-application-typescript\">searchForNote(query: string, searchParams?: Record&lt;string, unknown&gt;): ScriptBNote | null</code></pre><p>This is a powerful search method - you can search by attributes and their values, e.g.: \"#dateModified =* MONTH AND #log\". See <code>https://triliumnext.github.io/Docs/Wiki/search.html</code> for full documentation for all options</p></td></tr><tr><td><code>getNotesWithLabel</code></td><td><pre><code class=\"language-application-typescript\">getNotesWithLabel(name: string, value?: string): ScriptBNote[]</code></pre><p>Retrieves notes with given label name &amp; value</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code><br>attribute name</td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>attribute value</td></tr></tbody></table></figure></td></tr><tr><td><code>getNoteWithLabel</code></td><td><pre><code class=\"language-application-typescript\">getNoteWithLabel(name: string, value?: string): ScriptBNote | null</code></pre><p>Retrieves first note with given label name &amp; value</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code><br>attribute name</td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>attribute value</td></tr></tbody></table></figure></td></tr><tr><td><code>ensureNoteIsPresentInParent</code></td><td><pre><code class=\"language-application-typescript\">ensureNoteIsPresentInParent(noteId: string, parentNoteId: string, prefix?: string): { branch: ScriptBBranch | null }</code></pre><p>If there's no branch between note and parent note, create one. Otherwise, do nothing. Returns the new or existing branch.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>noteId</code></td><td><code>string</code></td></tr><tr><td><code>parentNoteId</code></td><td><code>string</code></td></tr><tr><td><code>prefix</code><br><em>optional</em></td><td><code>string</code><br>if branch is created between note and parent note, set this prefix</td></tr></tbody></table></figure></td></tr><tr><td><code>ensureNoteIsAbsentFromParent</code></td><td><pre><code class=\"language-application-typescript\">ensureNoteIsAbsentFromParent(noteId: string, parentNoteId: string): void</code></pre><p>If there's a branch between note and parent note, remove it. Otherwise, do nothing.</p></td></tr><tr><td><code>toggleNoteInParent</code></td><td><pre><code class=\"language-application-typescript\">toggleNoteInParent(present: boolean, noteId: string, parentNoteId: string, prefix?: string): void</code></pre><p>Based on the value, either create or remove branch between note and parent note.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>present</code></td><td><code>boolean</code><br>true if we want the branch to exist, false if we want it gone</td></tr><tr><td><code>noteId</code></td><td><code>string</code></td></tr><tr><td><code>parentNoteId</code></td><td><code>string</code></td></tr><tr><td><code>prefix</code><br><em>optional</em></td><td><code>string</code><br>if branch is created between note and parent note, set this prefix</td></tr></tbody></table></figure></td></tr><tr><td><code>createTextNote</code></td><td><pre><code class=\"language-application-typescript\">createTextNote(parentNoteId: string, title: string, content: string): ScriptNoteAndBranch</code></pre><p>Create text note. See also createNewNote() for more options.</p></td></tr><tr><td><code>createDataNote</code></td><td><pre><code class=\"language-application-typescript\">createDataNote(parentNoteId: string, title: string, content: object): ScriptNoteAndBranch</code></pre><p>Create data note - data in this context means object serializable to JSON. Created note will be of type 'code' and JSON MIME type. See also createNewNote() for more options.</p></td></tr><tr><td><code>createNewNote</code></td><td><pre><code class=\"language-application-typescript\">createNewNote(params: { parentNoteId: string; title: string; content: string | Uint8Array&lt;ArrayBufferLike&gt;; type: string; mime?: string; [key: string]: unknown }): ScriptNoteAndBranch</code></pre><p><strong>Returns</strong> <code>ScriptNoteAndBranch</code>: object contains newly created entities note and branch</p></td></tr><tr><td><code>logMessages</code></td><td><p><code>Record&lt;string, string[]&gt;</code><br>Per-note log message buffers shown in the UI log pane.</p></td></tr><tr><td><code>logSpacedUpdates</code></td><td><p><code>Record&lt;string, unknown&gt;</code><br>Per-note spaced-update handlers for the log pane.</p></td></tr><tr><td><code>log</code></td><td><pre><code class=\"language-application-typescript\">log(...args: unknown[]): void</code></pre><p>Log given message to trilium logs and log pane in UI. Accepts multiple arguments which are joined with spaces, similar to <code>console.log</code>.</p></td></tr><tr><td><code>getRootCalendarNote</code></td><td><pre><code class=\"language-application-typescript\">getRootCalendarNote(): ScriptBNote | null</code></pre><p>Returns root note of the calendar.</p></td></tr><tr><td><code>getDayNote</code></td><td><pre><code class=\"language-application-typescript\">getDayNote(date: string, rootNote?: ScriptBNote): ScriptBNote | null</code></pre><p>Returns day note for given date. If such note doesn't exist, it is created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM-DD format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>ScriptBNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td></tr><tr><td><code>getTodayNote</code></td><td><pre><code class=\"language-application-typescript\">getTodayNote(rootNote?: ScriptBNote): ScriptBNote | null</code></pre><p>Returns today's day note. If such note doesn't exist, it is created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>ScriptBNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td></tr><tr><td><code>getWeekFirstDayNote</code></td><td><pre><code class=\"language-application-typescript\">getWeekFirstDayNote(date: string, rootNote?: ScriptBNote): ScriptBNote | null</code></pre><p>Returns note for the first date of the week of the given date.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM-DD format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>ScriptBNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td></tr><tr><td><code>getWeekNote</code></td><td><pre><code class=\"language-application-typescript\">getWeekNote(date: string, rootNote?: ScriptBNote): ScriptBNote | null</code></pre><p>Returns week note for given date. If such a note doesn't exist, it is created.</p><p>If the calendar does not support week notes, this method will return `null`.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM-DD format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>ScriptBNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>ScriptBNote | null</code>: an existing or newly created week note, or <code>null</code> if the calendar does not support week notes.</p></td></tr><tr><td><code>getMonthNote</code></td><td><pre><code class=\"language-application-typescript\">getMonthNote(date: string, rootNote?: ScriptBNote): ScriptBNote | null</code></pre><p>Returns month note for given date. If such a note doesn't exist, it is created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>ScriptBNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td></tr><tr><td><code>getQuarterNote</code></td><td><pre><code class=\"language-application-typescript\">getQuarterNote(date: string, rootNote?: ScriptBNote): ScriptBNote | null</code></pre><p>Returns quarter note for given date. If such a note doesn't exist, it is created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>ScriptBNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td></tr><tr><td><code>getYearNote</code></td><td><pre><code class=\"language-application-typescript\">getYearNote(year: string, rootNote?: ScriptBNote): ScriptBNote | null</code></pre><p>Returns year note for given year. If such a note doesn't exist, it is created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>year</code></td><td><code>string</code><br>in YYYY format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>ScriptBNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td></tr><tr><td><code>sortNotes</code></td><td><pre><code class=\"language-application-typescript\">sortNotes(parentNoteId: string, sortConfig: { sortBy?: string; reverse?: boolean; foldersFirst?: boolean }): void</code></pre><p>Sort child notes of a given note. <code>sortBy</code> takes the <code>#sorted</code> grammar — comma-separated levels of <code>title</code>, <code>dateCreated</code>, <code>dateModified</code> or a label name, each optionally followed by <code>asc</code> or <code>desc</code> (<code>priority desc, dueDate</code>); <code>reverse</code> is the direction of the levels without their own, of the folders grouping and of ties.</p></td></tr><tr><td><code>setNoteToParent</code></td><td><pre><code class=\"language-application-typescript\">setNoteToParent(noteId: string, prefix: string, parentNoteId: string | null): void</code></pre><p>This method finds note by its noteId and prefix and either sets it to the given parentNoteId or removes the branch (if parentNoteId is not given).</p><p>This method looks similar to toggleNoteInParent() but differs because we're looking up branch by prefix.</p><aside class=\"admonition warning\"><p>Deprecated. this method is pretty confusing and serves specialized purpose only</p></aside></td></tr><tr><td><code>transactional</code></td><td><pre><code class=\"language-application-typescript\">transactional(func: () =&gt; T): T</code></pre><p>This functions wraps code which is supposed to be running in transaction. If transaction already exists, then we'll use that transaction.</p><p><strong>Returns</strong> <code>T</code>: result of func callback</p></td></tr><tr><td><code>randomString</code></td><td><pre><code class=\"language-application-typescript\">randomString(length: number): string</code></pre><p>Return randomly generated string of given length. This random string generation is NOT cryptographically secure.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>length</code></td><td><code>number</code><br>of the string</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>string</code>: random string</p></td></tr><tr><td><code>escapeHtml</code></td><td><pre><code class=\"language-application-typescript\">escapeHtml(str: string): string</code></pre><p><strong>Returns</strong> <code>string</code>: escaped string</p></td></tr><tr><td><code>unescapeHtml</code></td><td><pre><code class=\"language-application-typescript\">unescapeHtml(str: string): string</code></pre><p><strong>Returns</strong> <code>string</code>: unescaped string</p></td></tr><tr><td><code>htmlToMarkdown</code></td><td><pre><code class=\"language-application-typescript\">htmlToMarkdown(html: string): string</code></pre><p>Converts the given HTML string to Markdown.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>html</code></td><td><code>string</code><br>HTML content to convert</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>string</code>: Markdown representation of the input HTML</p></td></tr><tr><td><code>markdownToHtml</code></td><td><pre><code class=\"language-application-typescript\">markdownToHtml(markdown: string): string</code></pre><p>Converts the given Markdown string to HTML.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>markdown</code></td><td><code>string</code><br>Markdown content to convert</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>string</code>: HTML representation of the input Markdown</p></td></tr><tr><td><code>sql</code></td><td><p><code>unknown</code><br>sql</p></td></tr><tr><td><code>getAppInfo</code></td><td><pre><code class=\"language-application-typescript\">getAppInfo(): unknown</code></pre><p>Application info (version, build date, etc.).</p></td></tr><tr><td><code>createOrUpdateLauncher</code></td><td><pre><code class=\"language-application-typescript\">createOrUpdateLauncher(opts: { id: string; type: \"note\" | \"script\" | \"customWidget\"; title: string; isVisible: boolean; icon: string; keyboardShortcut: string; targetNoteId?: string; scriptNoteId?: string; widgetNoteId?: string }): { note: ScriptBNote }</code></pre><p>Creates a new launcher to the launchbar. If the launcher (id) already exists, it will be updated.</p></td></tr><tr><td><code>exportSubtreeToZipFile</code></td><td><pre><code class=\"language-application-typescript\">exportSubtreeToZipFile(noteId: string, format: \"markdown\" | \"html\", zipFilePath: string): Promise&lt;void&gt;</code></pre><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>noteId</code></td><td><code>string</code></td></tr><tr><td><code>format</code></td><td><code>\"markdown\" | \"html\"</code><br>either 'html' or 'markdown'</td></tr><tr><td><code>zipFilePath</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>runOnFrontend</code></td><td><pre><code class=\"language-application-typescript\">runOnFrontend(script: string | () =&gt; void, params?: unknown[]): void</code></pre><p>Executes given anonymous function on the frontend(s). Internally, this serializes the anonymous function into string and sends it to frontend(s) via WebSocket. Note that there can be multiple connected frontend instances (e.g. in different tabs). In such case, all instances execute the given function.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>script</code></td><td><code>string | () =&gt; void</code><br>script to be executed on the frontend</td></tr><tr><td><code>params</code><br><em>optional</em></td><td><code>unknown[]</code><br>list of parameters to the anonymous function to be sent to frontend</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>void</code>: no return value is provided.</p></td></tr><tr><td><code>runOutsideOfSync</code></td><td><pre><code class=\"language-application-typescript\">runOutsideOfSync(callback: () =&gt; void): Promise&lt;void&gt;</code></pre><p>Sync process can make data intermittently inconsistent. Scripts which require strong data consistency can use this function to wait for a possible sync process to finish and prevent new sync process from starting while it is running.</p><p>Because this is an async process, the inner callback doesn't have automatic transaction handling, so in case you need to make some DB changes, you need to surround your call with api.transactional(...)</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>() =&gt; void</code><br>function to be executed while sync process is not running</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;void&gt;</code>: resolves once the callback is finished (callback is awaited)</p></td></tr><tr><td><code>backupNow</code></td><td><pre><code class=\"language-application-typescript\">backupNow(backupName: string): Promise&lt;string&gt;</code></pre><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>backupName</code></td><td><code>string</code><br>If the backupName is e.g. \"now\", then the backup will be written to \"backup-now.db\" file</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;string&gt;</code>: resolves once the backup is finished</p></td></tr><tr><td><code>duplicateSubtree</code></td><td><pre><code class=\"language-application-typescript\">duplicateSubtree(origNoteId: string, newParentNoteId: string): ScriptNoteAndBranch</code></pre><p>Enables the complete duplication of the specified original note and all its children into the specified parent note. The new note will be named the same as the original, with (Dup) added to the end of it.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>origNoteId</code></td><td><code>string</code><br>the noteId for the original note to be duplicated</td></tr><tr><td><code>newParentNoteId</code></td><td><code>string</code><br>the noteId for the parent note where the duplication is to be placed.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>ScriptNoteAndBranch</code>: the note and the branch of the newly created note.</p></td></tr></tbody></table></figure><h2><code>ScriptBNote</code></h2><p>A note as seen by backend scripts (subset of trilium-core's <code>BNote</code>).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>noteId</code></td><td><p><code>string</code><br>The ID of the note. The root note's ID is <code>root</code>. System notes have IDs that start with <code>_</code>, such as <code>_hidden</code>.</p></td></tr><tr><td><code>title</code></td><td><p><code>string</code><br>The title of the note. For a protected note read outside a protected session, this holds the encrypted title. Use <code>getTitleOrProtected()</code> to show a title safely.</p></td></tr><tr><td><code>type</code></td><td><p><code>string</code><br>The note type, such as <code>text</code>, <code>code</code>, <code>file</code>, <code>image</code>, <code>search</code> or <code>book</code>. Together with <code>mime</code>, it decides how Trilium renders the content.</p></td></tr><tr><td><code>mime</code></td><td><p><code>string</code><br>The MIME type of the note's content, such as <code>text/html</code> for a text note or <code>application/javascript;env=backend</code> for a backend script.</p></td></tr><tr><td><code>isProtected</code></td><td><p><code>boolean</code><br>Whether the note is protected. The title and content of a protected note are encrypted, and can be read or changed only while a protected session is active.</p></td></tr><tr><td><code>isArchived</code></td><td><p><code>boolean</code><br>Whether the note is archived: it has an <code>archived</code> label of its own or inherits one. A non-inheritable <code>archived</code> label on an ancestor does not count; see <code>areAllNotePathsArchived()</code>.</p></td></tr><tr><td><code>isDeleted</code></td><td><p><code>boolean</code><br>Whether the note has been deleted, or its deletion is in progress. It becomes <code>true</code> on an object a script still holds after the note is deleted.</p></td></tr><tr><td><code>shareId</code></td><td><p><code>string</code><br>Share root ID this note is published under, if any.</p></td></tr><tr><td><code>blobId</code></td><td><p><code>string</code><br>The ID of the blob that stores the note's content. It changes whenever the content changes, and notes with identical content share a blob.</p></td></tr><tr><td><code>dateCreated</code></td><td><p><code>string</code><br>The date and time the note was created, in local time with its UTC offset, for example <code>2026-10-22 14:03:05.123+0200</code>.</p></td></tr><tr><td><code>dateModified</code></td><td><p><code>string</code><br>The date and time the note was last modified, in local time with its UTC offset, for example <code>2026-10-22 14:03:05.123+0200</code>. It changes when the content changes or the note itself is saved, such as after a title change.</p></td></tr><tr><td><code>utcDateCreated</code></td><td><p><code>string</code><br>The date and time the note was created, in UTC, for example <code>2026-10-22 12:03:05.123Z</code>.</p></td></tr><tr><td><code>utcDateModified</code></td><td><p><code>string</code><br>The date and time the note was last modified, in UTC, for example <code>2026-10-22 12:03:05.123Z</code>. It changes when the content changes or the note itself is saved.</p></td></tr><tr><td><code>getContent</code></td><td><pre><code class=\"language-application-typescript\">getContent(): string | Uint8Array&lt;ArrayBufferLike&gt;</code></pre><p>Returns the content of the note: a string for text-based notes (see <code>hasStringContent()</code>), a <code>Uint8Array</code> for binary ones such as images and files. The content is read from the database on each call. For a protected note outside a protected session, it returns an empty string.</p></td></tr><tr><td><code>setContent</code></td><td><pre><code class=\"language-application-typescript\">setContent(content: string | Uint8Array&lt;ArrayBufferLike&gt;, opts?: { forceFrontendReload?: boolean }): void</code></pre><p>Replaces the content of the note and saves it immediately; there is no need to call <code>save()</code> afterwards. If the content is unchanged, nothing is saved and <code>dateModified</code> stays the same.</p><p>The call throws an error when <code>content</code> is <code>null</code> or <code>undefined</code>, when the note is protected and no protected session is active, and when the note is read-only, such as a page of the in-app help.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>content</code></td><td><code>string | Uint8Array&lt;ArrayBufferLike&gt;</code><br>The new content: a string for text-based notes, or a <code>Uint8Array</code> for binary ones such as images and files.</td></tr><tr><td><code>opts</code><br><em>optional</em></td><td><code>{ forceFrontendReload?: boolean }</code></td></tr></tbody></table></figure></td></tr><tr><td><code>getJsonContent</code></td><td><pre><code class=\"language-application-typescript\">getJsonContent(): T | null</code></pre><p>Returns the note's content parsed as JSON. Returns <code>null</code> when the content is empty, blank or binary, and throws an error when it is not valid JSON.</p></td></tr><tr><td><code>getJsonContentSafely</code></td><td><pre><code class=\"language-application-typescript\">getJsonContentSafely(): unknown</code></pre><p>Returns the note's content parsed as JSON, like <code>getJsonContent()</code>, but returns <code>null</code> instead of throwing an error when the content is not valid JSON.</p></td></tr><tr><td><code>setJsonContent</code></td><td><pre><code class=\"language-application-typescript\">setJsonContent(content: unknown): void</code></pre><p>Serializes <code>content</code> to JSON, indented with tabs, and saves it as the note's content through <code>setContent()</code>, with the same errors.</p></td></tr><tr><td><code>hasStringContent</code></td><td><pre><code class=\"language-application-typescript\">hasStringContent(): boolean</code></pre><p>Returns whether <code>getContent()</code> returns a string rather than a <code>Uint8Array</code>. This holds for text, code, canvas, Mermaid and other text-based note types, and for MIME types such as <code>text/*</code>, <code>application/json</code>, <code>application/javascript</code> and <code>image/svg+xml</code>.</p></td></tr><tr><td><code>getFileName</code></td><td><pre><code class=\"language-application-typescript\">getFileName(): string</code></pre><p>Returns a file name for the note, as used when it is downloaded or exported: the title with characters invalid in file names removed (<code>untitled</code> when the title is empty), plus an extension. The extension is <code>.html</code> for text notes, <code>.json</code> for relation maps, canvases and saved searches, and otherwise comes from the MIME type, unless the title already ends in a matching one.</p></td></tr><tr><td><code>getFlatText</code></td><td><pre><code class=\"language-application-typescript\">getFlatText(): string</code></pre><p>Returns a single line of text that Trilium searches when matching notes: the note ID, type, MIME type, branch prefixes, title and attributes (as <code>#name=value</code> and <code>~name=value</code>, inherited ones included), lowercased and with diacritics removed. The content is not included.</p></td></tr><tr><td><code>getPojo</code></td><td><pre><code class=\"language-application-typescript\">getPojo(): Record&lt;string, unknown&gt;</code></pre><p>Plain serialisable representation of the note (the real return type is <code>NotePojo</code>).</p></td></tr><tr><td><code>getTitleOrProtected</code></td><td><pre><code class=\"language-application-typescript\">getTitleOrProtected(): string</code></pre><p>Returns the note's title, or the literal string <code>[protected]</code> when the note is protected and no protected session is active.</p></td></tr><tr><td><code>getIcon</code></td><td><pre><code class=\"language-application-typescript\">getIcon(): string</code></pre><p>Returns the CSS classes of the note's icon, for example <code>tn-icon bx bx-note</code>. The icon comes from the note's <code>iconClass</code> label (its own or inherited) when it has one, and otherwise from its type.</p></td></tr><tr><td><code>parents</code></td><td><p><code>ScriptBNote[]</code><br>The parent notes of this note: one per place the note appears in the tree, so a cloned note has several. Parents that are not archived come first. This is the same array <code>getParentNotes()</code> returns; don't modify it.</p></td></tr><tr><td><code>children</code></td><td><p><code>ScriptBNote[]</code><br>The child notes of this note, in their order in the tree. This is the same array <code>getChildNotes()</code> returns; don't modify it.</p></td></tr><tr><td><code>parentBranches</code></td><td><p><code>ScriptBBranch[]</code><br>The branches that place this note under each of its parents, in the same order as <code>parents</code>. This is the same array <code>getParentBranches()</code> returns; don't modify it.</p></td></tr><tr><td><code>parentCount</code></td><td><p><code>number</code><br>The number of parent notes, which is greater than 1 for a cloned note.</p></td></tr><tr><td><code>childrenCount</code></td><td><p><code>number</code><br>The number of child notes, including hidden and system notes.</p></td></tr><tr><td><code>getParentNotes</code></td><td><pre><code class=\"language-application-typescript\">getParentNotes(): ScriptBNote[]</code></pre><p>Returns the parent notes of this note, one per place the note appears in the tree. Parents that are not archived come first. The result is the <code>parents</code> array itself; don't modify it.</p></td></tr><tr><td><code>getChildNotes</code></td><td><pre><code class=\"language-application-typescript\">getChildNotes(): ScriptBNote[]</code></pre><p>Returns the child notes of this note, in their order in the tree. The result is the <code>children</code> array itself; don't modify it.</p></td></tr><tr><td><code>getVisibleChildNotes</code></td><td><pre><code class=\"language-application-typescript\">getVisibleChildNotes(): ScriptBNote[]</code></pre><p>Returns the child notes that are shown in a shared note's navigation tree, in tree order. It leaves out system notes, whose IDs start with <code>_</code>, and notes with a <code>shareHiddenFromTree</code> label, their own or inherited. Archived notes are included.</p></td></tr><tr><td><code>getParentBranches</code></td><td><pre><code class=\"language-application-typescript\">getParentBranches(): ScriptBBranch[]</code></pre><p>Returns the branches that place this note under each of its parents. The result is the <code>parentBranches</code> array itself; don't modify it.</p></td></tr><tr><td><code>getChildBranches</code></td><td><pre><code class=\"language-application-typescript\">getChildBranches(): ScriptBBranch[]</code></pre><p>Returns the branches that connect this note to each of its children, in their order in the tree. A branch holds the child's position and prefix.</p></td></tr><tr><td><code>getVisibleChildBranches</code></td><td><pre><code class=\"language-application-typescript\">getVisibleChildBranches(): ScriptBBranch[]</code></pre><p>Returns the child branches whose notes are shown in a shared note's navigation tree, in tree order. It leaves out system notes, whose IDs start with <code>_</code>, and notes with a <code>shareHiddenFromTree</code> label, their own or inherited. Archived notes are included.</p></td></tr><tr><td><code>getStrongParentBranches</code></td><td><pre><code class=\"language-application-typescript\">getStrongParentBranches(): ScriptBBranch[]</code></pre><p>Returns the parent branches the user created, leaving out the automatic placements under the shared notes (<code>_share</code>) and the bookmarks (<code>_lbBookmarks</code>). A note whose last such branch is deleted is deleted too.</p></td></tr><tr><td><code>getFilteredChildBranches</code></td><td><pre><code class=\"language-application-typescript\">getFilteredChildBranches(): ScriptBBranch[]</code></pre><p>Returns the same branches as <code>getChildBranches()</code>. Despite its name, it filters nothing: archived and hidden children are included.</p></td></tr><tr><td><code>getBranches</code></td><td><pre><code class=\"language-application-typescript\">getBranches(): ScriptBBranch[]</code></pre><p>Returns the branches that place this note under each of its parents.</p><aside class=\"admonition warning\"><p>Deprecated. Use <code>getParentBranches()</code> instead.</p></aside></td></tr><tr><td><code>hasChildren</code></td><td><pre><code class=\"language-application-typescript\">hasChildren(): boolean</code></pre><p>Returns whether the note has at least one child note, including hidden and system notes.</p></td></tr><tr><td><code>hasVisibleChildren</code></td><td><pre><code class=\"language-application-typescript\">hasVisibleChildren(): boolean</code></pre><p>Returns whether <code>getVisibleChildNotes()</code> returns at least one note.</p></td></tr><tr><td><code>getAncestors</code></td><td><pre><code class=\"language-application-typescript\">getAncestors(): ScriptBNote[]</code></pre><p>Returns every ancestor of the note across all of its paths in the tree, each note once, up to and including the root note. The note itself is not included. The order follows the parents: each parent comes first, followed by its own ancestors.</p></td></tr><tr><td><code>getAncestorNoteIds</code></td><td><pre><code class=\"language-application-typescript\">getAncestorNoteIds(): string[]</code></pre><p>Returns the IDs of the notes <code>getAncestors()</code> returns, in the same order.</p></td></tr><tr><td><code>getDescendantNoteIds</code></td><td><pre><code class=\"language-application-typescript\">getDescendantNoteIds(): string[]</code></pre><p>Returns the IDs of this note and all its descendants.</p><aside class=\"admonition warning\"><p>Deprecated. Use <code>getSubtreeNoteIds()</code> instead.</p></aside></td></tr><tr><td><code>getDistanceToAncestor</code></td><td><pre><code class=\"language-application-typescript\">getDistanceToAncestor(ancestorNoteId: string): number</code></pre><p>Returns the number of levels between this note and the given ancestor along the shortest path: <code>1</code> for a parent, <code>2</code> for a grandparent, and <code>0</code> for the note itself. If the note is not a descendant of the given note, it returns <code>999999</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>ancestorNoteId</code></td><td><code>string</code><br>The ID of the ancestor note to measure the distance to.</td></tr></tbody></table></figure></td></tr><tr><td><code>hasAncestor</code></td><td><pre><code class=\"language-application-typescript\">hasAncestor(ancestorNoteId: string): boolean</code></pre><p>Returns whether the given note is an ancestor of this note on any of its paths. It returns <code>false</code> for the note's own ID.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>ancestorNoteId</code></td><td><code>string</code><br>The ID of the note to look for among the ancestors.</td></tr></tbody></table></figure></td></tr><tr><td><code>isDescendantOfNote</code></td><td><pre><code class=\"language-application-typescript\">isDescendantOfNote(ancestorNoteId: string): boolean</code></pre><p>Returns whether the given note lies on at least one of this note's paths from the root. Unlike <code>hasAncestor()</code>, it returns <code>true</code> for the note's own ID.</p></td></tr><tr><td><code>isRoot</code></td><td><pre><code class=\"language-application-typescript\">isRoot(): boolean</code></pre><p>Returns whether this note is the root of the note tree, whose ID is <code>root</code>.</p></td></tr><tr><td><code>getSubtree</code></td><td><pre><code class=\"language-application-typescript\">getSubtree(opts?: ScriptSubtreeOpts): { notes: ScriptBNote[]; relationships: ScriptSubtreeRelationship[] }</code></pre><p>Returns the note and all its descendants, each note once, together with every parent-child relationship among them, including those of cloned notes.</p><p><strong>Returns</strong> <code>{ notes: ScriptBNote[]; relationships: ScriptSubtreeRelationship[] }</code>: An object with <code>notes</code>, the notes of the subtree including this note, and <code>relationships</code>, the <code>{ parentNoteId, childNoteId }</code> pairs connecting them.</p></td></tr><tr><td><code>getSubtreeNoteIds</code></td><td><pre><code class=\"language-application-typescript\">getSubtreeNoteIds(opts?: ScriptSubtreeOpts): string[]</code></pre><p>Returns the IDs of this note and all its descendants, each once. Takes the same options as <code>getSubtree()</code>.</p></td></tr><tr><td><code>getSubtreeNotesIncludingTemplated</code></td><td><pre><code class=\"language-application-typescript\">getSubtreeNotesIncludingTemplated(): ScriptBNote[]</code></pre><p>Returns the notes that this note's inheritable attributes reach: the note itself, its descendants, and every note that uses one of them as a <code>template</code> or <code>inherit</code> relation target, along with that note's descendants. Each note appears once; the hidden subtree (<code>_hidden</code>) is skipped.</p></td></tr><tr><td><code>getInheritingNotes</code></td><td><pre><code class=\"language-application-typescript\">getInheritingNotes(): ScriptBNote[]</code></pre><p>Returns the notes that this note's non-inheritable attributes apply to: the note itself and every note that uses it as a <code>template</code> or <code>inherit</code> relation target. Their descendants are not included.</p></td></tr><tr><td><code>getAllNotePaths</code></td><td><pre><code class=\"language-application-typescript\">getAllNotePaths(): string[][]</code></pre><p>Returns every path from the root note to this note, one per placement in the tree. Each path is an array of note IDs that starts with <code>root</code> and ends with this note's ID.</p></td></tr><tr><td><code>getBestNotePath</code></td><td><pre><code class=\"language-application-typescript\">getBestNotePath(hoistedNoteId?: string): string[]</code></pre><p>Returns the best path from the root note to this note as an array of note IDs, ranked as in <code>getSortedNotePathRecords()</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>hoistedNoteId</code><br><em>optional</em></td><td><code>string</code><br>The ID of the note whose subtree is preferred. Defaults to <code>root</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>getBestNotePathString</code></td><td><pre><code class=\"language-application-typescript\">getBestNotePathString(hoistedNoteId?: string): string</code></pre><p>Returns the best path from the root note to this note as a string of note IDs joined by <code>/</code>, for example <code>root/a1h315/js725h</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>hoistedNoteId</code><br><em>optional</em></td><td><code>string</code><br>The ID of the note whose subtree is preferred. Defaults to <code>root</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>getSortedNotePathRecords</code></td><td><pre><code class=\"language-application-typescript\">getSortedNotePathRecords(hoistedNoteId?: string): ScriptNotePathRecord[]</code></pre><p>Returns a record for every path from the root note to this note, best path first. Paths within the hoisted note's subtree come first, then paths without archived notes, then paths outside the hidden subtree, then shorter paths.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>hoistedNoteId</code><br><em>optional</em></td><td><code>string</code><br>The ID of the note whose subtree is preferred. Defaults to <code>root</code>.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>ScriptNotePathRecord[]</code>: Records whose <code>notePath</code> holds the note IDs from the root to this note, with flags telling whether the path lies within the hoisted subtree (<code>isInHoistedSubTree</code>), passes through an archived note, the note itself included (<code>isArchived</code>), or lies within the hidden subtree (<code>isHidden</code>).</p></td></tr><tr><td><code>areAllNotePathsArchived</code></td><td><pre><code class=\"language-application-typescript\">areAllNotePathsArchived(): boolean</code></pre><p>Returns whether every path to this note passes through an archived note. Unlike <code>isArchived</code>, this also counts a non-inheritable <code>archived</code> label on an ancestor. It throws an error if the note has no path from the root.</p></td></tr><tr><td><code>ownedAttributes</code></td><td><p><code>ScriptAttribute[]</code><br>The labels and relations defined directly on this note, without inherited ones.</p></td></tr><tr><td><code>targetRelations</code></td><td><p><code>ScriptAttribute[]</code><br>The relations in other notes (or this one) that point to this note. This includes the link relations Trilium creates automatically for links in note content, such as <code>internalLink</code> and <code>imageLink</code>.</p></td></tr><tr><td><code>attributeCount</code></td><td><p><code>number</code><br>The number of labels and relations on this note, inherited ones and automatic link relations included.</p></td></tr><tr><td><code>ownedAttributeCount</code></td><td><p><code>number</code><br>The number of labels and relations defined directly on this note, automatic link relations included.</p></td></tr><tr><td><code>labelCount</code></td><td><p><code>number</code><br>The number of labels on this note, inherited ones included.</p></td></tr><tr><td><code>ownedLabelCount</code></td><td><p><code>number</code><br>The number of labels defined directly on this note.</p></td></tr><tr><td><code>relationCount</code></td><td><p><code>number</code><br>The number of relations on this note, inherited ones included. Excludes the link relations Trilium creates automatically for links in note content (<code>internalLink</code>, <code>imageLink</code>, <code>relationMapLink</code>, <code>includeNoteLink</code>).</p></td></tr><tr><td><code>relationCountIncludingLinks</code></td><td><p><code>number</code><br>The number of relations on this note, inherited ones included, together with the link relations Trilium creates automatically for links in note content.</p></td></tr><tr><td><code>ownedRelationCount</code></td><td><p><code>number</code><br>The number of relations defined directly on this note, excluding the link relations Trilium creates automatically for links in note content.</p></td></tr><tr><td><code>ownedRelationCountIncludingLinks</code></td><td><p><code>number</code><br>The number of relations defined directly on this note, together with the link relations Trilium creates automatically for links in note content.</p></td></tr><tr><td><code>targetRelationCount</code></td><td><p><code>number</code><br>The number of relations in other notes that point to this note, excluding the link relations Trilium creates automatically for links in note content.</p></td></tr><tr><td><code>targetRelationCountIncludingLinks</code></td><td><p><code>number</code><br>The number of relations in other notes that point to this note, together with the link relations Trilium creates automatically for links in note content.</p></td></tr><tr><td><code>getAttributes</code></td><td><pre><code class=\"language-application-typescript\">getAttributes(type?: string, name?: string): ScriptAttribute[]</code></pre><p>Returns the labels and relations of this note, inherited ones included, optionally filtered by type and name. Without a filter, the result is the note's own cached array; don't modify it.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code><br><em>optional</em></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>; any other value throws an error.</td></tr><tr><td><code>name</code><br><em>optional</em></td><td><code>string</code><br>The attribute name, without the leading <code>#</code> or <code>~</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>getOwnedAttributes</code></td><td><pre><code class=\"language-application-typescript\">getOwnedAttributes(type?: string, name?: string): ScriptAttribute[]</code></pre><p>Returns the labels and relations defined directly on this note, optionally filtered by type and name. Without a filter, the result is the <code>ownedAttributes</code> array itself; don't modify it.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code><br><em>optional</em></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>; any other value throws an error.</td></tr><tr><td><code>name</code><br><em>optional</em></td><td><code>string</code><br>The attribute name, without the leading <code>#</code> or <code>~</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>getAttribute</code></td><td><pre><code class=\"language-application-typescript\">getAttribute(type: string, name: string): ScriptAttribute | null</code></pre><p>Returns the first attribute of the given type and name, inherited ones included, or <code>null</code> if there is none.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>getOwnedAttribute</code></td><td><pre><code class=\"language-application-typescript\">getOwnedAttribute(type: string, name: string, value?: string | null): ScriptAttribute | null</code></pre><p>Returns the first attribute of the given type and name defined directly on this note, or <code>null</code> if there is none. It skips inheritance, so it can be much faster than <code>getAttribute()</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string | null</code><br>The value to match; when omitted, any value matches.</td></tr></tbody></table></figure></td></tr><tr><td><code>getAttributeValue</code></td><td><pre><code class=\"language-application-typescript\">getAttributeValue(type: string, name: string): string | null</code></pre><p>Returns the value of the first attribute of the given type and name, inherited ones included, or <code>null</code> if there is none. For a relation, the value is the target note's ID.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>getOwnedAttributeValue</code></td><td><pre><code class=\"language-application-typescript\">getOwnedAttributeValue(type: string, name: string): string | null</code></pre><p>Returns the value of the first attribute of the given type and name defined directly on this note, or <code>null</code> if there is none. For a relation, the value is the target note's ID.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>getAttributeById</code></td><td><pre><code class=\"language-application-typescript\">getAttributeById(attributeId: string): ScriptAttribute | undefined</code></pre><p>Returns the attribute of this note with the given ID, inherited ones included, or <code>undefined</code> if there is none.</p></td></tr><tr><td><code>getAttributeCaseInsensitive</code></td><td><pre><code class=\"language-application-typescript\">getAttributeCaseInsensitive(type: string, name: string, value?: string | null): ScriptAttribute | undefined</code></pre><p>Returns the first attribute of the given type whose name, and optionally value, matches regardless of letter case, or <code>undefined</code> if none does. Inherited attributes are included.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string | null</code><br>The value to match; an empty or omitted value matches any value.</td></tr></tbody></table></figure></td></tr><tr><td><code>hasAttribute</code></td><td><pre><code class=\"language-application-typescript\">hasAttribute(type: string, name: string): boolean</code></pre><p>Returns <code>true</code> if the note has a label or relation of the given type and name, inherited ones included.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>hasOwnedAttribute</code></td><td><pre><code class=\"language-application-typescript\">hasOwnedAttribute(type: string, name: string, value?: string): boolean</code></pre><p>Returns whether the note has a label or relation of the given type and name defined directly on it. Inherited attributes don't count.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The value to match; when omitted, any value matches.</td></tr></tbody></table></figure></td></tr><tr><td><code>getLabelDefinitions</code></td><td><pre><code class=\"language-application-typescript\">getLabelDefinitions(): ScriptAttribute[]</code></pre><p>Returns the attribute definitions on this note, inherited ones included. Currently returns the same <code>#relation:*</code> definitions as <code>getRelationDefinitions()</code>, not the <code>#label:*</code> ones; to read label definitions, filter <code>getLabels()</code> by names that start with <code>label:</code>.</p></td></tr><tr><td><code>getRelationDefinitions</code></td><td><pre><code class=\"language-application-typescript\">getRelationDefinitions(): ScriptAttribute[]</code></pre><p>Returns the relation definitions on this note, inherited ones included: the <code>#relation:*</code> labels that declare promoted relations, such as <code>#relation:author=\"promoted,single\"</code>.</p></td></tr><tr><td><code>getTargetRelations</code></td><td><pre><code class=\"language-application-typescript\">getTargetRelations(): ScriptAttribute[]</code></pre><p>Returns the relations in other notes (or this one) that point to this note, the automatic link relations included. Same as <code>targetRelations</code>.</p></td></tr><tr><td><code>getLabel</code></td><td><pre><code class=\"language-application-typescript\">getLabel(name: string): ScriptAttribute | null</code></pre><p>Returns the first label with the given name, inherited ones included, or <code>null</code> if there is none. Pass the name without the leading <code>#</code>.</p></td></tr><tr><td><code>getOwnedLabel</code></td><td><pre><code class=\"language-application-typescript\">getOwnedLabel(name: string): ScriptAttribute | null</code></pre><p>Returns the first label with the given name defined directly on this note, or <code>null</code> if there is none.</p></td></tr><tr><td><code>getLabels</code></td><td><pre><code class=\"language-application-typescript\">getLabels(name?: string): ScriptAttribute[]</code></pre><p>Returns the labels of this note, inherited ones included. When <code>name</code> is given, only labels with that name are returned.</p></td></tr><tr><td><code>getOwnedLabels</code></td><td><pre><code class=\"language-application-typescript\">getOwnedLabels(name: string): ScriptAttribute[]</code></pre><p>Returns the labels with the given name defined directly on this note.</p></td></tr><tr><td><code>getLabelValue</code></td><td><pre><code class=\"language-application-typescript\">getLabelValue(name: string): string | null</code></pre><p>Returns the value of the first label with the given name, inherited ones included, or <code>null</code> if there is none. A label without a value returns an empty string.</p></td></tr><tr><td><code>getOwnedLabelValue</code></td><td><pre><code class=\"language-application-typescript\">getOwnedLabelValue(name: string): string | null</code></pre><p>Returns the value of the first label with the given name defined directly on this note, or <code>null</code> if there is none.</p></td></tr><tr><td><code>getLabelValues</code></td><td><pre><code class=\"language-application-typescript\">getLabelValues(name: string): string[]</code></pre><p>Returns the values of all labels with the given name, inherited ones included, for labels that can occur more than once.</p></td></tr><tr><td><code>getOwnedLabelValues</code></td><td><pre><code class=\"language-application-typescript\">getOwnedLabelValues(name: string): string[]</code></pre><p>Returns the values of all labels with the given name defined directly on this note.</p></td></tr><tr><td><code>hasLabel</code></td><td><pre><code class=\"language-application-typescript\">hasLabel(name: string): boolean</code></pre><p>Returns whether the note has a label with the given name, inherited ones included.</p></td></tr><tr><td><code>hasOwnedLabel</code></td><td><pre><code class=\"language-application-typescript\">hasOwnedLabel(name: string, value?: string): boolean</code></pre><p>Returns whether the note has a label with the given name defined directly on it.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The value to match; when omitted, any value matches.</td></tr></tbody></table></figure></td></tr><tr><td><code>isLabelTruthy</code></td><td><pre><code class=\"language-application-typescript\">isLabelTruthy(name: string): boolean</code></pre><p>Returns whether the note has a label with the given name, inherited ones included, whose value is not <code>\"false\"</code>. A label without a value counts as <code>true</code>.</p></td></tr><tr><td><code>hasInheritableArchivedLabel</code></td><td><pre><code class=\"language-application-typescript\">hasInheritableArchivedLabel(): boolean</code></pre><p>Returns <code>true</code> if the note has an inheritable <code>#archived</code> label, owned or inherited, so that the note's descendants are archived too.</p></td></tr><tr><td><code>getRelation</code></td><td><pre><code class=\"language-application-typescript\">getRelation(name: string): ScriptAttribute | null</code></pre><p>Returns the first relation with the given name, inherited ones included, or <code>null</code> if there is none. Pass the name without the leading <code>~</code>.</p></td></tr><tr><td><code>getOwnedRelation</code></td><td><pre><code class=\"language-application-typescript\">getOwnedRelation(name: string): ScriptAttribute | null</code></pre><p>Returns the first relation with the given name defined directly on this note, or <code>null</code> if there is none.</p></td></tr><tr><td><code>getRelations</code></td><td><pre><code class=\"language-application-typescript\">getRelations(name?: string): ScriptAttribute[]</code></pre><p>Returns the relations of this note, inherited ones included. When <code>name</code> is given, only relations with that name are returned.</p></td></tr><tr><td><code>getOwnedRelations</code></td><td><pre><code class=\"language-application-typescript\">getOwnedRelations(name?: string | null): ScriptAttribute[]</code></pre><p>Returns the relations defined directly on this note. When <code>name</code> is given, only relations with that name are returned.</p></td></tr><tr><td><code>getRelationValue</code></td><td><pre><code class=\"language-application-typescript\">getRelationValue(name: string): string | null</code></pre><p>Returns the ID of the note that the first relation with the given name points to, inherited relations included, or <code>null</code> if there is none. To get the note itself, use <code>getRelationTarget()</code>.</p></td></tr><tr><td><code>getOwnedRelationValue</code></td><td><pre><code class=\"language-application-typescript\">getOwnedRelationValue(name: string): string | null</code></pre><p>Returns the ID of the note that the first relation with the given name defined directly on this note points to, or <code>null</code> if there is none.</p></td></tr><tr><td><code>getRelationTarget</code></td><td><pre><code class=\"language-application-typescript\">getRelationTarget(name: string): ScriptBNote | null</code></pre><p>Returns the note that the first relation with the given name points to, or <code>null</code> if the note has no such relation. Inherited relations are included.</p></td></tr><tr><td><code>hasRelation</code></td><td><pre><code class=\"language-application-typescript\">hasRelation(name: string, value?: string): boolean</code></pre><p>Returns whether the note has a relation with the given name, inherited ones included.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The ID of the target note to match; when omitted, any target matches.</td></tr></tbody></table></figure></td></tr><tr><td><code>hasOwnedRelation</code></td><td><pre><code class=\"language-application-typescript\">hasOwnedRelation(name: string, value?: string): boolean</code></pre><p>Returns whether the note has a relation with the given name defined directly on it.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The ID of the target note to match; when omitted, any target matches.</td></tr></tbody></table></figure></td></tr><tr><td><code>addLabel</code></td><td><pre><code class=\"language-application-typescript\">addLabel(name: string, value?: string, isInheritable?: boolean): ScriptAttribute</code></pre><p>Adds a label to this note, saves it and returns it. It adds a new label even when the note already has one with that name; to change an existing label instead, use <code>setLabel()</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code><br>The label name, without the leading <code>#</code>.</td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The label value. Defaults to an empty string.</td></tr><tr><td><code>isInheritable</code><br><em>optional</em></td><td><code>boolean</code><br>Whether the note's descendants inherit the label. Defaults to <code>false</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>addRelation</code></td><td><pre><code class=\"language-application-typescript\">addRelation(name: string, targetNoteId: string, isInheritable?: boolean): ScriptAttribute</code></pre><p>Adds a relation from this note to another note, saves it and returns it. It adds a new relation even when the note already has one with that name; to change an existing relation instead, use <code>setRelation()</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code><br>The relation name, without the leading <code>~</code>.</td></tr><tr><td><code>targetNoteId</code></td><td><code>string</code></td></tr><tr><td><code>isInheritable</code><br><em>optional</em></td><td><code>boolean</code><br>Whether the note's descendants inherit the relation. Defaults to <code>false</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>addAttribute</code></td><td><pre><code class=\"language-application-typescript\">addAttribute(type: string, name: string, value?: string, isInheritable?: boolean): ScriptAttribute</code></pre><p>Adds a label or relation to this note, saves it and returns it. <code>addLabel()</code> and <code>addRelation()</code> do the same for one type.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code><br>The attribute name, without the leading <code>#</code> or <code>~</code>.</td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The label's text, or the relation's target note ID. Defaults to an empty string.</td></tr><tr><td><code>isInheritable</code><br><em>optional</em></td><td><code>boolean</code><br>Whether the note's descendants inherit the attribute. Defaults to <code>false</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>setLabel</code></td><td><pre><code class=\"language-application-typescript\">setLabel(name: string, value?: string): void</code></pre><p>Sets the value of the first label with the given name defined directly on this note, or adds a non-inheritable label if the note has none of its own. Inherited labels are left alone. The change is saved immediately.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The new value. Defaults to an empty string.</td></tr></tbody></table></figure></td></tr><tr><td><code>setRelation</code></td><td><pre><code class=\"language-application-typescript\">setRelation(name: string, value?: string): void</code></pre><p>Points the first relation with the given name defined directly on this note to another note, or adds a non-inheritable relation if the note has none of its own. Inherited relations are left alone. The change is saved immediately.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The ID of the target note.</td></tr></tbody></table></figure></td></tr><tr><td><code>setAttribute</code></td><td><pre><code class=\"language-application-typescript\">setAttribute(type: string, name: string, value?: string): void</code></pre><p>Sets the value of the first attribute of the given type and name defined directly on this note, or adds a non-inheritable one if the note has none of its own. <code>setLabel()</code> and <code>setRelation()</code> do the same for one type. The change is saved immediately.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The label's text, or the relation's target note ID. Defaults to an empty string.</td></tr></tbody></table></figure></td></tr><tr><td><code>setAttributeValueById</code></td><td><pre><code class=\"language-application-typescript\">setAttributeValueById(attributeId: string, value?: string): void</code></pre><p>Sets the value of the attribute with the given ID, which must be defined directly on this note, and saves it. Throws an error if the note has no such attribute of its own.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>attributeId</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The new value. Defaults to an empty string.</td></tr></tbody></table></figure></td></tr><tr><td><code>toggleLabel</code></td><td><pre><code class=\"language-application-typescript\">toggleLabel(enabled: boolean, name: string, value?: string): void</code></pre><p>Sets the label like <code>setLabel()</code> when <code>enabled</code> is <code>true</code>, and removes it like <code>removeLabel()</code> when it is <code>false</code>.</p></td></tr><tr><td><code>toggleRelation</code></td><td><pre><code class=\"language-application-typescript\">toggleRelation(enabled: boolean, name: string, value?: string): void</code></pre><p>Sets the relation like <code>setRelation()</code> when <code>enabled</code> is <code>true</code>, and removes it like <code>removeRelation()</code> when it is <code>false</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>enabled</code></td><td><code>boolean</code></td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The ID of the target note.</td></tr></tbody></table></figure></td></tr><tr><td><code>toggleAttribute</code></td><td><pre><code class=\"language-application-typescript\">toggleAttribute(type: string, enabled: boolean, name: string, value?: string): void</code></pre><p>Sets the attribute like <code>setAttribute()</code> when <code>enabled</code> is <code>true</code>, and removes it like <code>removeAttribute()</code> when it is <code>false</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>enabled</code></td><td><code>boolean</code></td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>removeLabel</code></td><td><pre><code class=\"language-application-typescript\">removeLabel(name: string, value?: string): void</code></pre><p>Removes every label with the given name defined directly on this note. Inherited labels are not affected.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The value to match; when omitted, labels with any value are removed.</td></tr></tbody></table></figure></td></tr><tr><td><code>removeRelation</code></td><td><pre><code class=\"language-application-typescript\">removeRelation(name: string, value?: string): void</code></pre><p>Removes every relation with the given name defined directly on this note. Inherited relations are not affected.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The ID of the target note to match; when omitted, relations to any note are removed.</td></tr></tbody></table></figure></td></tr><tr><td><code>removeAttribute</code></td><td><pre><code class=\"language-application-typescript\">removeAttribute(type: string, name: string, value?: string): void</code></pre><p>Removes every attribute of the given type and name defined directly on this note. Inherited attributes are not affected.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The value to match; when omitted, attributes with any value are removed.</td></tr></tbody></table></figure></td></tr><tr><td><code>isInherited</code></td><td><pre><code class=\"language-application-typescript\">isInherited(): boolean</code></pre><p>Returns <code>true</code> if another note uses this note as its template or inheritance source, through a <code>~template</code> or <code>~inherit</code> relation. Despite the name, it does not tell whether this note inherits attributes itself.</p></td></tr><tr><td><code>revisionCount</code></td><td><p><code>number | null</code><br>The number of revisions of this note. It is <code>null</code> until a search that filters or sorts by <code>revisionCount</code> or one of the size properties has run; <code>getRevisions().length</code> always works.</p></td></tr><tr><td><code>getRevisions</code></td><td><pre><code class=\"language-application-typescript\">getRevisions(): ScriptBRevision[]</code></pre><p>Returns the saved revisions of this note, oldest first.</p></td></tr><tr><td><code>saveRevision</code></td><td><pre><code class=\"language-application-typescript\">saveRevision(opts?: { description?: string; source?: string }): ScriptBRevision</code></pre><p>Saves a revision that snapshots the note's current title, content and attachments, and returns it. Afterwards, Trilium erases the oldest revisions beyond the number the revision settings keep.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code><br><em>optional</em></td><td><code>{ description?: string; source?: string }</code><br><code>description</code> names the revision; <code>source</code> records what created it: <code>\"auto\"</code> (the default), <code>\"manual\"</code>, <code>\"etapi\"</code>, <code>\"llm\"</code> or <code>\"restore\"</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>getAttachments</code></td><td><pre><code class=\"language-application-typescript\">getAttachments(): ScriptAttachment[]</code></pre><p>Returns the attachments of this note, ordered by position. Deleted attachments are excluded.</p></td></tr><tr><td><code>getAttachmentById</code></td><td><pre><code class=\"language-application-typescript\">getAttachmentById(attachmentId: string): ScriptAttachment</code></pre><p>Returns the attachment of this note with the given ID. Returns <code>undefined</code> if this note has no such attachment, although the type does not say so.</p></td></tr><tr><td><code>getAttachmentByTitle</code></td><td><pre><code class=\"language-application-typescript\">getAttachmentByTitle(title: string): ScriptAttachment | undefined</code></pre><p>Returns the first attachment of this note whose title matches exactly, or <code>undefined</code> if none does.</p></td></tr><tr><td><code>getAttachmentsByRole</code></td><td><pre><code class=\"language-application-typescript\">getAttachmentsByRole(role: string): ScriptAttachment[]</code></pre><p>Returns the attachments of this note with the given role, such as <code>\"image\"</code> or <code>\"file\"</code>, ordered by position.</p></td></tr><tr><td><code>saveAttachment</code></td><td><pre><code class=\"language-application-typescript\">saveAttachment(attachment: ScriptSaveAttachmentInput, matchBy?: \"title\" | \"attachmentId\"): ScriptAttachment</code></pre><p>Saves an attachment of this note and returns it. If an existing attachment matches, only its content is replaced; otherwise a new attachment is created from <code>attachment</code>, protected if the note is. Missing content is saved as an empty string.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>attachment</code></td><td><code>ScriptSaveAttachmentInput</code></td></tr><tr><td><code>matchBy</code><br><em>optional</em></td><td><code>\"title\" | \"attachmentId\"</code><br>How to find an existing attachment to update: <code>\"attachmentId\"</code> (the default) by <code>attachment.attachmentId</code>, which throws an error if no attachment has that ID, or <code>\"title\"</code> by <code>attachment.title</code> among this note's attachments.</td></tr></tbody></table></figure></td></tr><tr><td><code>convertToParentAttachment</code></td><td><pre><code class=\"language-application-typescript\">convertToParentAttachment(opts?: Record&lt;string, unknown&gt;): ScriptAttachment | null</code></pre><p>Converts this image note into an image attachment of its parent text note, points the parent's content at the attachment, deletes this note and returns the attachment. Returns <code>null</code> and changes nothing when <code>isEligibleForConversionToAttachment()</code> returns <code>false</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code><br><em>optional</em></td><td><code>Record&lt;string, unknown&gt;</code><br>Pass <code>{ autoConversion: true }</code> to also require that the parent links the image.</td></tr></tbody></table></figure></td></tr><tr><td><code>isEligibleForConversionToAttachment</code></td><td><pre><code class=\"language-application-typescript\">isEligibleForConversionToAttachment(opts?: Record&lt;string, unknown&gt;): boolean</code></pre><p>Returns <code>true</code> if this note can be converted into an attachment of its parent: it is an image note with no children and a single parent, the parent is a text note, both are readable in the current session, and at most one <code>~imageLink</code> relation points to the image, from the parent.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code><br><em>optional</em></td><td><code>Record&lt;string, unknown&gt;</code><br>Pass <code>{ autoConversion: true }</code> to also require that the parent links the image.</td></tr></tbody></table></figure></td></tr><tr><td><code>contentSize</code></td><td><p><code>number | null</code><br>The size of the note's content in bytes. Like the other size properties, it is <code>null</code> until a search that filters or sorts by one of them, or by <code>revisionCount</code>, has run.</p></td></tr><tr><td><code>contentAndAttachmentsSize</code></td><td><p><code>number | null</code><br>The size in bytes of the note's content together with its attachments, counting content that several of them share once. It is <code>null</code> until a search that uses it has run.</p></td></tr><tr><td><code>contentAndAttachmentsAndRevisionsSize</code></td><td><p><code>number | null</code><br>The size in bytes of the note's content together with its attachments and its revisions and their attachments, counting shared content once. It is <code>null</code> until a search that uses it has run.</p></td></tr><tr><td><code>cloneTo</code></td><td><pre><code class=\"language-application-typescript\">cloneTo(parentNoteId: string): ScriptCloneResponse</code></pre><p>Places this note under another parent note as well, keeping its existing placements, and expands the new parent in the note tree. The result does not throw on failure; check <code>success</code>, and read <code>message</code> for why it failed (for example, the note is already in that parent, the target is a search note, or the clone would create a cycle).</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>parentNoteId</code></td><td><code>string</code><br>The ID of the note to clone into.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>ScriptCloneResponse</code>: On success, <code>branchId</code> of the new branch and <code>notePath</code> of the clone.</p></td></tr><tr><td><code>deleteNote</code></td><td><pre><code class=\"language-application-typescript\">deleteNote(deleteId?: string | null): void</code></pre><p>Deletes the note from every place in the tree, together with its descendants that have no other placement, and runs its <code>runOnNoteDeletion</code> relations first. Deleted notes stay recoverable until they are erased. Does nothing if the note is already deleted.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>deleteId</code><br><em>optional</em></td><td><code>string | null</code><br>An ID that groups the deleted notes, branches and attributes so that they can be restored together. Defaults to a new random ID.</td></tr></tbody></table></figure></td></tr><tr><td><code>sortParents</code></td><td><pre><code class=\"language-application-typescript\">sortParents(): void</code></pre><p>Reorders this note's <code>parents</code> and <code>parentBranches</code> in memory so that archived and hidden parents come last, which makes Trilium prefer the other paths when it picks a note path. Saves nothing.</p></td></tr><tr><td><code>sortChildren</code></td><td><pre><code class=\"language-application-typescript\">sortChildren(): void</code></pre><p>Reorders this note's <code>children</code> array in memory by each child's <code>notePosition</code>. Saves nothing and does not change the order shown in the note tree.</p></td></tr><tr><td><code>searchNotesInSubtree</code></td><td><pre><code class=\"language-application-typescript\">searchNotesInSubtree(searchString: string): ScriptBNote[]</code></pre><p>Returns the notes that match a search query. Despite the name, the search covers the whole tree, not only this note's subtree, and leaves out archived and hidden notes; to limit it to this note's subtree, call <code>api.searchForNotes(query, { ancestorNoteId: note.noteId })</code>.</p></td></tr><tr><td><code>searchNoteInSubtree</code></td><td><pre><code class=\"language-application-typescript\">searchNoteInSubtree(searchString: string): ScriptBNote | null</code></pre><p>Returns the first note that matches a search query, or <code>undefined</code> if none does. Like <code>searchNotesInSubtree()</code>, the search covers the whole tree, not only this note's subtree.</p></td></tr><tr><td><code>getSearchResultNotes</code></td><td><pre><code class=\"language-application-typescript\">getSearchResultNotes(): ScriptBNote[]</code></pre><p>Runs the saved search of a search note and returns the notes it finds. Returns an empty array for other note types, and when the search fails (the error goes to the backend log).</p></td></tr><tr><td><code>isFolder</code></td><td><pre><code class=\"language-application-typescript\">isFolder(): boolean</code></pre><p>Returns <code>true</code> if this note is a search note or has at least one child, archived children included.</p></td></tr><tr><td><code>isContentAvailable</code></td><td><pre><code class=\"language-application-typescript\">isContentAvailable(): boolean</code></pre><p>Returns <code>true</code> if the note's title and content can be read: the note is not protected, or a protected session is open. Otherwise the content reads as an empty string and the title as <code>\"[protected]\"</code>.</p></td></tr><tr><td><code>isStringNote</code></td><td><pre><code class=\"language-application-typescript\">isStringNote(): boolean</code></pre><p>Returns whether <code>getContent()</code> returns a string rather than a <code>Uint8Array</code>.</p><aside class=\"admonition warning\"><p>Deprecated. Use <code>hasStringContent()</code> instead.</p></aside></td></tr><tr><td><code>isHtml</code></td><td><pre><code class=\"language-application-typescript\">isHtml(): boolean</code></pre><p>Returns whether this is a code, file or render note with the MIME type <code>text/html</code>.</p></td></tr><tr><td><code>isImage</code></td><td><pre><code class=\"language-application-typescript\">isImage(): boolean</code></pre><p>Returns whether this is an image note, or a file note with an <code>image/*</code> MIME type.</p></td></tr><tr><td><code>isJavaScript</code></td><td><pre><code class=\"language-application-typescript\">isJavaScript(): boolean</code></pre><p>Returns whether this is a code, file or launcher note with a JavaScript MIME type.</p></td></tr><tr><td><code>isJsx</code></td><td><pre><code class=\"language-application-typescript\">isJsx(): boolean</code></pre><p>Returns <code>true</code> if this is a code note with the MIME type <code>text/jsx</code>.</p></td></tr><tr><td><code>isJson</code></td><td><pre><code class=\"language-application-typescript\">isJson(): boolean</code></pre><p>Returns whether the note's MIME type is <code>application/json</code>, whatever its type.</p></td></tr><tr><td><code>isMarkdown</code></td><td><pre><code class=\"language-application-typescript\">isMarkdown(): boolean</code></pre><p>Returns whether this is a code note with a Markdown MIME type.</p></td></tr><tr><td><code>isOptions</code></td><td><pre><code class=\"language-application-typescript\">isOptions(): boolean</code></pre><p>Returns <code>true</code> if this note is one of the settings pages in the hidden subtree, whose IDs start with <code>_options</code>.</p></td></tr><tr><td><code>isLaunchBarConfig</code></td><td><pre><code class=\"language-application-typescript\">isLaunchBarConfig(): boolean</code></pre><p>Returns <code>true</code> if this note is a launcher or one of the containers that configure the desktop or mobile launch bar.</p></td></tr><tr><td><code>isHiddenCompletely</code></td><td><pre><code class=\"language-application-typescript\">isHiddenCompletely(): boolean</code></pre><p>Returns whether every path to this note passes through the hidden subtree (<code>_hidden</code>), so that the note has no placement in the visible tree. Returns <code>false</code> for the root note and for <code>_hidden</code> itself.</p></td></tr><tr><td><code>isInHiddenSubtree</code></td><td><pre><code class=\"language-application-typescript\">isInHiddenSubtree(): boolean</code></pre><p>Returns <code>true</code> if this note is the hidden root note (<code>_hidden</code>) or lies under it in any of its placements. The hidden subtree holds Trilium's system notes, such as settings, launchers and templates.</p></td></tr><tr><td><code>getScriptEnv</code></td><td><pre><code class=\"language-application-typescript\">getScriptEnv(): \"frontend\" | \"backend\" | null</code></pre><p>Returns where the note runs as a script: <code>\"backend\"</code> for JavaScript with <code>env=backend</code> in its MIME type, <code>\"frontend\"</code> for frontend JavaScript, JSX, HTML and render notes, and <code>null</code> for notes that are not scripts.</p></td></tr><tr><td><code>executeScript</code></td><td><pre><code class=\"language-application-typescript\">executeScript(): unknown</code></pre><p>Runs this note as a backend script and returns the script's return value, which is a promise for an async script. The note must be a backend JavaScript code note; for any other note it runs nothing and returns <code>undefined</code>. Throws an error if the note is protected and no protected session is active, or if backend scripting is disabled.</p></td></tr></tbody></table></figure><h2><code>ScriptRequest</code></h2><p>Minimal Express <code>Request</code> surface available to <strong>custom request handlers</strong> (a subset of Express's <code>Request</code> — re-declared here to keep this module self-contained). Only the commonly used members are typed; the real object is a full Express request.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>params</code></td><td><p><code>Record&lt;string, string&gt;</code><br>Route/path parameters.</p></td></tr><tr><td><code>query</code></td><td><p><code>Record&lt;string, unknown&gt;</code><br>Parsed query-string parameters.</p></td></tr><tr><td><code>body</code></td><td><p><code>unknown</code><br>Parsed request body (requires a matching body parser).</p></td></tr><tr><td><code>headers</code></td><td><p><code>Record&lt;string, string | string[] | undefined&gt;</code><br>Request headers (lower-cased names).</p></td></tr><tr><td><code>method</code></td><td><p><code>string</code><br>HTTP method, e.g. \"GET\", \"POST\".</p></td></tr><tr><td><code>url</code></td><td><p><code>string</code><br>Request URL (path + query string).</p></td></tr><tr><td><code>get</code></td><td><pre><code class=\"language-application-typescript\">get(headerName: string): string | undefined</code></pre><p>Returns the value of the given (case-insensitive) header.</p></td></tr></tbody></table></figure><h2><code>ScriptResponse</code></h2><p>Minimal Express <code>Response</code> surface available to <strong>custom request handlers</strong> (a subset of Express's <code>Response</code>). Write the HTTP response through this object, e.g. <code>api.res.status(200).json({ ok: true })</code>.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>status</code></td><td><pre><code class=\"language-application-typescript\">status(code: number): ScriptResponse</code></pre><p>Sets the HTTP status code (chainable).</p></td></tr><tr><td><code>send</code></td><td><pre><code class=\"language-application-typescript\">send(body?: unknown): ScriptResponse</code></pre><p>Sends the response body (string, Buffer, object, …) and ends the response.</p></td></tr><tr><td><code>json</code></td><td><pre><code class=\"language-application-typescript\">json(body: unknown): ScriptResponse</code></pre><p>Sends a JSON response and ends the response.</p></td></tr><tr><td><code>setHeader</code></td><td><pre><code class=\"language-application-typescript\">setHeader(name: string, value: string | string[]): ScriptResponse</code></pre><p>Sets a response header (chainable).</p></td></tr><tr><td><code>set</code></td><td><pre><code class=\"language-application-typescript\">set(field: string, value?: string): ScriptResponse</code></pre><p>Sets a response header (Express alias of <code>setHeader</code>, chainable).</p></td></tr><tr><td><code>redirect</code></td><td><pre><code class=\"language-application-typescript\">redirect(url: string): void</code></pre><p>Redirects to the given URL.</p></td></tr><tr><td><code>end</code></td><td><pre><code class=\"language-application-typescript\">end(): void</code></pre><p>Ends the response without further data.</p></td></tr></tbody></table></figure><h2><code>ScriptBBranch</code></h2><p>A branch (note→parent placement) as seen by backend scripts (subset of <code>BBranch</code>).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>branchId</code></td><td><p><code>string</code><br>The ID of the branch. Moving a note to another parent replaces its branch with a new one, so store the note ID rather than the branch ID when you need a stable reference.</p></td></tr><tr><td><code>noteId</code></td><td><p><code>string</code><br>The ID of the child note this branch places in the tree.</p></td></tr><tr><td><code>parentNoteId</code></td><td><p><code>string</code><br>The ID of the parent note. For the root note's branch, it is <code>\"none\"</code>.</p></td></tr><tr><td><code>prefix</code></td><td><p><code>string | null</code><br>The text shown before the note's title in the note tree for this placement only, or <code>null</code> if there is none.</p></td></tr><tr><td><code>notePosition</code></td><td><p><code>number</code><br>The position of the note among its siblings under this parent; notes with lower values come first.</p></td></tr><tr><td><code>isExpanded</code></td><td><p><code>boolean</code><br>Whether the note is expanded in the note tree at this placement, showing its children.</p></td></tr><tr><td><code>getNote</code></td><td><pre><code class=\"language-application-typescript\">getNote(): ScriptBNote</code></pre><p>Returns the child note this branch places in the tree.</p></td></tr><tr><td><code>getParentNote</code></td><td><pre><code class=\"language-application-typescript\">getParentNote(): ScriptBNote | null</code></pre><p>Returns the parent note. The root note's branch has no parent note.</p></td></tr></tbody></table></figure><h2><code>ScriptBRevision</code></h2><p>A note revision as seen by backend scripts (subset of trilium-core's <code>BRevision</code>).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>revisionId</code><br><em>optional</em></td><td><p><code>string</code><br>The ID of the revision.</p></td></tr><tr><td><code>noteId</code></td><td><p><code>string</code><br>The ID of the note this revision belongs to.</p></td></tr><tr><td><code>type</code></td><td><p><code>string</code><br>The note's type at the time of the revision, such as <code>\"text\"</code> or <code>\"code\"</code>.</p></td></tr><tr><td><code>mime</code></td><td><p><code>string</code><br>The note's MIME type at the time of the revision.</p></td></tr><tr><td><code>title</code></td><td><p><code>string</code><br>The note's title at the time of the revision. For a protected revision outside a protected session, it is <code>\"[protected]\"</code>.</p></td></tr><tr><td><code>dateLastEdited</code><br><em>optional</em></td><td><p><code>string</code><br>When the note was last edited before the revision was saved, in local time with its UTC offset, formatted as <code>YYYY-MM-DD HH:mm:ss.SSS+ZZZZ</code> (for example, <code>2026-10-22 14:05:09.123+0200</code>).</p></td></tr><tr><td><code>utcDateLastEdited</code><br><em>optional</em></td><td><p><code>string</code><br>When the note was last edited before the revision was saved, in UTC, formatted as <code>YYYY-MM-DD HH:mm:ss.SSSZ</code> (for example, <code>2026-10-22 12:05:09.123Z</code>).</p></td></tr><tr><td><code>contentLength</code><br><em>optional</em></td><td><p><code>number</code><br>The size of the revision's content in bytes, when it was loaded together with the revision. Revisions returned by <code>note.getRevisions()</code> and <code>note.saveRevision()</code> leave it <code>undefined</code>.</p></td></tr><tr><td><code>getContent</code></td><td><pre><code class=\"language-application-typescript\">getContent(): string | Uint8Array&lt;ArrayBufferLike&gt;</code></pre><p>Returns the content of the revision: a string for text-based note types, a <code>Uint8Array</code> for binary ones such as images and files. For a protected revision outside a protected session, it returns an empty string.</p></td></tr><tr><td><code>getJsonContent</code></td><td><pre><code class=\"language-application-typescript\">getJsonContent(): unknown</code></pre><p>Returns the revision's content parsed as JSON. Returns <code>null</code> when the content is empty, blank or binary, and throws an error when it is not valid JSON.</p></td></tr></tbody></table></figure><h2><code>ScriptDayjsInstance</code></h2><p>A date as day.js wraps it (subset).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>format</code></td><td><pre><code class=\"language-application-typescript\">format(template?: string): string</code></pre><p>Formats the date, such as <code>\"YYYY-MM-DD\"</code> for <code>2026-10-22</code>. Without a template, it returns the ISO 8601 form with the UTC offset, such as <code>2026-10-22T14:03:05+02:00</code>.</p></td></tr><tr><td><code>add</code></td><td><pre><code class=\"language-application-typescript\">add(value: number, unit: string): ScriptDayjsInstance</code></pre><p>Returns a new date, <code>value</code> units later. The date it is called on stays unchanged.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>number</code></td></tr><tr><td><code>unit</code></td><td><code>string</code><br>The unit, such as <code>\"day\"</code>, <code>\"week\"</code>, <code>\"month\"</code> or <code>\"year\"</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>subtract</code></td><td><pre><code class=\"language-application-typescript\">subtract(value: number, unit: string): ScriptDayjsInstance</code></pre><p>Returns a new date, <code>value</code> units earlier. The date it is called on stays unchanged.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>number</code></td></tr><tr><td><code>unit</code></td><td><code>string</code><br>The unit, such as <code>\"day\"</code>, <code>\"week\"</code>, <code>\"month\"</code> or <code>\"year\"</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>toDate</code></td><td><pre><code class=\"language-application-typescript\">toDate(): Date</code></pre><p>Returns the date as a JavaScript <code>Date</code>.</p></td></tr></tbody></table></figure><h2>Types</h2><h3><code>ScriptDayjs</code></h3><p>Minimal day.js surface (the real API exposes the full day.js factory).</p><pre><code class=\"language-application-typescript\">type ScriptDayjs = (date?: string | number | Date) =&gt; ScriptDayjsInstance</code></pre><h3><code>ScriptAttribute</code></h3><p>A label or relation attached to a note.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>attributeId</code></td><td><code>string</code> <br>The ID of the attribute.</td></tr><tr><td><code>type</code></td><td><code>\"label\" | \"relation\"</code> <br>The type of the attribute: <code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code> <br>The name of the attribute, without the <code>#</code> or <code>~</code> prefix.</td></tr><tr><td><code>value</code></td><td><code>string</code> <br>The value of the attribute. For a relation, it is the ID of the target note. For a label without a value, it is an empty string.</td></tr><tr><td><code>isInheritable</code></td><td><code>boolean</code> <br>Whether the note's descendants inherit the attribute.</td></tr><tr><td><code>isOwned</code></td><td><code>boolean</code> <br>Not set by Trilium: neither frontend nor backend attributes carry this property, so it reads <code>undefined</code>.</td></tr></tbody></table></figure><h3><code>ScriptNoteAndBranch</code></h3><p>Result of the backend note-creation helpers.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>note</code></td><td><code>ScriptBNote</code> <br>The new note. For <code>duplicateSubtree()</code>, it is the copy of the original note.</td></tr><tr><td><code>branch</code></td><td><code>ScriptBBranch</code> <br>The branch that places the new note under its parent.</td></tr></tbody></table></figure><h3><code>ScriptSubtreeOpts</code></h3><p>Options accepted by the subtree traversal helpers on <code>ScriptBNote</code>.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>includeArchived</code> <br><em>optional</em></td><td><code>boolean</code> <br>Whether to include archived notes and their descendants. Defaults to <code>true</code>.</td></tr><tr><td><code>includeHidden</code> <br><em>optional</em></td><td><code>boolean</code> <br>Whether to descend into the hidden subtree, <code>_hidden</code>, which holds Trilium's system notes. Defaults to <code>false</code>.</td></tr><tr><td><code>resolveSearch</code> <br><em>optional</em></td><td><code>boolean</code> <br>Whether to run each search note and include its results as its children. Defaults to <code>false</code>, which includes the search note but none of its results.</td></tr></tbody></table></figure><h3><code>ScriptSubtreeRelationship</code></h3><p>A single parent→child link in a subtree (<code>ScriptBNote.getSubtree</code>).</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>parentNoteId</code></td><td><code>string</code> <br>The ID of the parent note. With <code>resolveSearch</code>, it can be a search note and the child one of its results.</td></tr><tr><td><code>childNoteId</code></td><td><code>string</code> <br>The ID of the child note. With <code>includeArchived: false</code>, it can name an archived note that the list of notes leaves out.</td></tr></tbody></table></figure><h3><code>ScriptNotePathRecord</code></h3><p>One resolved tree path to a note (subset of the client's <code>NotePathRecord</code>).</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>isArchived</code></td><td><code>boolean</code> <br>Whether a note on the path, the note itself included, is archived, which means it has the <code>#archived</code> label, owned or inherited.</td></tr><tr><td><code>isInHoistedSubTree</code></td><td><code>boolean</code> <br>Whether the path passes through the hoisted note passed to <code>getSortedNotePathRecords()</code>. It is always <code>true</code> when the hoisted note is <code>root</code>.</td></tr><tr><td><code>isSearch</code> <br><em>optional</em></td><td><code>boolean</code> <br>Whether the note itself is a search note. Only frontend scripts get this property; backend records leave it out.</td></tr><tr><td><code>notePath</code></td><td><code>string[]</code> <br>The note IDs along the path, from <code>root</code> to the note itself.</td></tr><tr><td><code>isHidden</code></td><td><code>boolean</code> <br>Whether the path passes through the hidden subtree, <code>_hidden</code>, which holds Trilium's system notes.</td></tr></tbody></table></figure><h3><code>ScriptAttachment</code></h3><p>An attachment as seen by frontend scripts (subset of the client's <code>FAttachment</code>).</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>attachmentId</code></td><td><code>string</code> <br>The ID of the attachment.</td></tr><tr><td><code>ownerId</code></td><td><code>string</code> <br>The ID of the note the attachment belongs to. For an attachment of a revision, it is the ID of the revision.</td></tr><tr><td><code>role</code></td><td><code>string</code> <br>The purpose of the attachment, such as <code>image</code> for an image shown in a text note or <code>file</code> for an attached file. Trilium also uses roles of its own, such as <code>viewConfig</code> for a collection's view settings.</td></tr><tr><td><code>mime</code></td><td><code>string</code> <br>The MIME type of the attachment's content, such as <code>image/png</code>.</td></tr><tr><td><code>title</code></td><td><code>string</code> <br>The title of the attachment, usually its file name.</td></tr><tr><td><code>utcDateModified</code></td><td><code>string</code> <br>The date and time, in UTC, that the attachment was last saved, such as <code>2026-10-22 12:03:05.123Z</code>. Replacing the content counts as saving.</td></tr><tr><td><code>contentLength</code></td><td><code>number</code> <br>The length of the attachment's content. Only some ways of loading an attachment fill it in, such as <code>getAttachments()</code>; on the backend, <code>getAttachmentsByRole()</code> leaves it <code>undefined</code>.</td></tr></tbody></table></figure><h3><code>ScriptSaveAttachmentInput</code></h3><p>Input accepted by <code>ScriptBNote.saveAttachment</code>.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>attachmentId</code> <br><em>optional</em></td><td><code>string</code> <br>The ID of the attachment to update. Omit it to create a new attachment, which gets an ID of its own.</td></tr><tr><td><code>role</code></td><td><code>string</code> <br>The purpose of the attachment, such as <code>image</code> or <code>file</code>. Used only when a new attachment is created.</td></tr><tr><td><code>mime</code></td><td><code>string</code> <br>The MIME type of the content, such as <code>image/png</code>. Used only when a new attachment is created.</td></tr><tr><td><code>title</code></td><td><code>string</code> <br>The title of the attachment, usually its file name. Used when a new attachment is created, and to find the attachment to update when <code>matchBy</code> is <code>\"title\"</code>.</td></tr><tr><td><code>content</code> <br><em>optional</em></td><td><code>string | Uint8Array&lt;ArrayBufferLike&gt;</code> <br>The content of the attachment: a string, or bytes for binary content. Defaults to an empty string.</td></tr><tr><td><code>position</code> <br><em>optional</em></td><td><code>number</code> <br>The place of the attachment among the note's attachments, which <code>getAttachments()</code> lists by ascending <code>position</code>. Used only when a new attachment is created.</td></tr></tbody></table></figure><h3><code>ScriptCloneResponse</code></h3><p>Result of a clone operation (<code>ScriptBNote.cloneTo</code>); mirrors <code>CloneResponse</code>.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>success</code></td><td><code>boolean</code> <br>Whether the note was cloned.</td></tr><tr><td><code>message</code> <br><em>optional</em></td><td><code>string</code> <br>Why the clone failed, such as the note already being in that parent. Present only when <code>success</code> is <code>false</code>.</td></tr><tr><td><code>branchId</code> <br><em>optional</em></td><td><code>string</code> <br>The ID of the new branch that places the note under the new parent. Present only when <code>success</code> is <code>true</code>.</td></tr><tr><td><code>notePath</code> <br><em>optional</em></td><td><code>string</code> <br>The path of the clone, as note IDs from <code>root</code> joined by <code>/</code>, ending in the note's ID. Present only when <code>success</code> is <code>true</code>.</td></tr></tbody></table></figure>",
- "_help_GFXVHyblVN3d": "<p>The Electron API is the bridge between Trilium's interface and Electron's main process, exposed as the global <code>window.electronApi</code> in the desktop application.</p><p>It is not part of the <code>api</code> global of script notes, but frontend scripts running in the desktop application can call it directly. It is <code>undefined</code> in the browser and in the standalone build, so guard calls with <code>if (window.electronApi)</code>.</p><h2><code>ElectronApi</code></h2><p>The complete surface exposed to the renderer as <code>window.electronApi</code> via <code>contextBridge</code>. The renderer must access Electron-only functionality through this object — direct <code>require(\"electron\")</code> and <code>@electron/remote</code> are unavailable because <code>nodeIntegration</code> is disabled and <code>contextIsolation</code> is enabled.</p><p>The runtime value lives in <code>apps/desktop/src/preload.ts</code>; this interface is the contract both the preload script (<code>satisfies ElectronApi</code>) and the client (<code>window.electronApi</code>) share.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>window</code></td><td><code>ElectronWindowApi</code> <br>Window chrome, zoom, theme, lifecycle, and main → renderer events.</td></tr><tr><td><code>clipboard</code></td><td><code>ElectronClipboardApi</code> <br>System clipboard access beyond what the standard Web Clipboard API offers.</td></tr><tr><td><code>shell</code></td><td><code>ElectronShellApi</code> <br>Shell integration — opening URLs, files, and downloads with OS handlers.</td></tr><tr><td><code>contextMenu</code></td><td><code>ElectronContextMenuApi</code> <br>Native context-menu plumbing for right-click events on web contents.</td></tr><tr><td><code>spellcheck</code></td><td><code>ElectronSpellcheckApi</code> <br>Chromium spell checker controls (dictionary, language list).</td></tr><tr><td><code>systemIntegration</code></td><td><code>ElectronSystemIntegrationApi</code> <br>OS integration — system tray and autostart / launch-on-login.</td></tr><tr><td><code>printing</code></td><td><code>ElectronPrintingApi</code> <br>Printing and PDF export pipeline.</td></tr><tr><td><code>navigation</code></td><td><code>ElectronNavigationApi</code> <br>Read/write access to Chromium's back/forward navigation history.</td></tr><tr><td><code>ws</code></td><td><code>ElectronWsApi</code> <br>In-process bridge that replaces the renderer↔server WebSocket.</td></tr><tr><td><code>security</code></td><td><code>ElectronSecurityApi</code> <br>Security settings (backend scripting, SQL console) stored outside the DB.</td></tr><tr><td><code>backupPassphrase</code></td><td><code>ElectronBackupPassphraseApi</code> <br>Write-only access to the backup passphrase, kept in the OS keyring.</td></tr><tr><td><code>onenote</code></td><td><code>ElectronOneNoteApi</code> <br>OneNote importer sign-in via a loopback OAuth redirect (desktop only).</td></tr><tr><td><code>nativeExport</code></td><td><code>ElectronNativeExportApi</code> <br>Desktop-native subtree export that streams a <code>.zip</code> straight to a file.</td></tr><tr><td><code>nativeImport</code></td><td><code>ElectronNativeImportApi</code> <br>Desktop-native large-<code>.zip</code> import that reads the user's file in place via a capability token.</td></tr><tr><td><code>dialog</code></td><td><code>ElectronDialogApi</code> <br>Native OS pickers that hand the renderer a location the user chose themselves.</td></tr><tr><td><code>restore</code></td><td><code>ElectronRestoreApi</code> <br>Choosing a backup to restore during setup, read where it lies rather than uploaded.</td></tr><tr><td><code>transcription</code></td><td><code>ElectronTranscriptionApi</code> <br>Meeting transcription: starting and stopping a recording, and following its state.</td></tr></tbody></table></figure><h2><code>ElectronWindowApi</code></h2><p>Window-level controls: zoom, theme, title bar, full screen, lifecycle, and a handful of main → renderer event subscriptions.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>setZoomFactor</code></td><td><pre><code class=\"language-application-typescript\">setZoomFactor(factor: number): void</code></pre><p>Sets the page zoom factor for the current window.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>factor</code></td><td><code>number</code><br><code>1.0</code> is 100%; e.g. <code>1.2</code> zooms to 120%.</td></tr></tbody></table></figure></td></tr><tr><td><code>getZoomFactor</code></td><td><pre><code class=\"language-application-typescript\">getZoomFactor(): number</code></pre><p>Returns the current page zoom factor (<code>1.0</code> = 100%).</p></td></tr><tr><td><code>setNativeThemeSource</code></td><td><pre><code class=\"language-application-typescript\">setNativeThemeSource(source: \"system\" | \"light\" | \"dark\"): void</code></pre><p>Overrides the operating system's reported color scheme for this app.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>source</code></td><td><code>\"system\" | \"light\" | \"dark\"</code><br>The color scheme to report, or <code>\"system\"</code> to follow the OS setting.</td></tr></tbody></table></figure></td></tr><tr><td><code>setTitleBarOverlay</code></td><td><pre><code class=\"language-application-typescript\">setTitleBarOverlay(options: { color: string; symbolColor: string; height?: number }): void</code></pre><p>Customizes the Windows and Linux native title bar overlay (the area containing the minimize / maximize / close buttons). <code>height</code> also controls their vertical placement, since the buttons are centered within the overlay. It is given in device-independent pixels, which the page zoom does not scale — see <code>setWindowButtonPosition</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>options</code></td><td><code>{ color: string; symbolColor: string; height?: number }</code><br>The overlay's background color, the color of the button symbols, and the overlay's height.</td></tr></tbody></table></figure></td></tr><tr><td><code>setWindowButtonPosition</code></td><td><pre><code class=\"language-application-typescript\">setWindowButtonPosition(position: { x: number; y: number }): void</code></pre><p>Repositions the macOS traffic-light window buttons. Coordinates are relative to the window's top-left corner and given in device-independent pixels: the buttons are drawn by the system rather than by the page, so unlike the surrounding chrome they are unaffected by the page zoom factor and callers have to scale the offsets themselves.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>position</code></td><td><code>{ x: number; y: number }</code><br>The offset of the buttons from the window's top-left corner.</td></tr></tbody></table></figure></td></tr><tr><td><code>onEnterFullScreen</code></td><td><pre><code class=\"language-application-typescript\">onEnterFullScreen(callback: () =&gt; void): void</code></pre><p>Registers a callback fired whenever the window enters full-screen mode.</p></td></tr><tr><td><code>onLeaveFullScreen</code></td><td><pre><code class=\"language-application-typescript\">onLeaveFullScreen(callback: () =&gt; void): void</code></pre><p>Registers a callback fired whenever the window leaves full-screen mode.</p></td></tr><tr><td><code>isFullScreen</code></td><td><pre><code class=\"language-application-typescript\">isFullScreen(): boolean</code></pre><p>Synchronously returns whether the window is currently in full-screen mode.</p></td></tr><tr><td><code>setFullScreen</code></td><td><pre><code class=\"language-application-typescript\">setFullScreen(enabled: boolean): void</code></pre><p>Enters or leaves full-screen mode.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>enabled</code></td><td><code>boolean</code><br><code>true</code> to enter full-screen mode, <code>false</code> to leave it.</td></tr></tbody></table></figure></td></tr><tr><td><code>minimizeWindow</code></td><td><pre><code class=\"language-application-typescript\">minimizeWindow(): void</code></pre><p>Minimizes the current window to the taskbar / dock.</p></td></tr><tr><td><code>maximizeWindow</code></td><td><pre><code class=\"language-application-typescript\">maximizeWindow(): void</code></pre><p>Maximizes the current window to fill the available screen area.</p></td></tr><tr><td><code>unmaximizeWindow</code></td><td><pre><code class=\"language-application-typescript\">unmaximizeWindow(): void</code></pre><p>Restores the window from a maximized state to its previous size.</p></td></tr><tr><td><code>isMaximized</code></td><td><pre><code class=\"language-application-typescript\">isMaximized(): boolean</code></pre><p>Synchronously returns whether the window is currently maximized.</p></td></tr><tr><td><code>closeWindow</code></td><td><pre><code class=\"language-application-typescript\">closeWindow(): void</code></pre><p>Closes the current window.</p></td></tr><tr><td><code>isAlwaysOnTop</code></td><td><pre><code class=\"language-application-typescript\">isAlwaysOnTop(): boolean</code></pre><p>Synchronously returns whether the window is pinned above all others.</p></td></tr><tr><td><code>setAlwaysOnTop</code></td><td><pre><code class=\"language-application-typescript\">setAlwaysOnTop(enabled: boolean): void</code></pre><p>Pins the window above all others, or unpins it.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>enabled</code></td><td><code>boolean</code><br><code>true</code> to pin the window, <code>false</code> to unpin it.</td></tr></tbody></table></figure></td></tr><tr><td><code>toggleDevTools</code></td><td><pre><code class=\"language-application-typescript\">toggleDevTools(): void</code></pre><p>Opens or closes Chromium DevTools for the current window.</p></td></tr><tr><td><code>isDevToolsDocked</code></td><td><pre><code class=\"language-application-typescript\">isDevToolsDocked(): boolean</code></pre><p>Synchronously returns whether DevTools is currently open and docked into this window (as opposed to detached into a separate window).</p></td></tr><tr><td><code>setBackgroundMaterial</code></td><td><pre><code class=\"language-application-typescript\">setBackgroundMaterial(material: string): void</code></pre><p>Sets the Windows 11 backdrop material applied behind the window contents. No-op on other platforms.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>material</code></td><td><code>string</code><br>The material, such as <code>\"mica\"</code>, <code>\"acrylic\"</code>, <code>\"tabbed\"</code> or <code>\"none\"</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>setVibrancy</code></td><td><pre><code class=\"language-application-typescript\">setVibrancy(vibrancy: string): void</code></pre><p>Sets the macOS vibrancy effect applied behind the window contents. No-op on other platforms.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>vibrancy</code></td><td><code>string</code><br>The effect, such as <code>\"sidebar\"</code>, <code>\"under-window\"</code> or <code>\"fullscreen-ui\"</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>reloadAllWindows</code></td><td><pre><code class=\"language-application-typescript\">reloadAllWindows(): void</code></pre><p>Triggers a hard reload of every open Trilium window.</p></td></tr><tr><td><code>restartApp</code></td><td><pre><code class=\"language-application-typescript\">restartApp(): void</code></pre><p>Quits the app and immediately relaunches it.</p></td></tr><tr><td><code>toggleAllWindows</code></td><td><pre><code class=\"language-application-typescript\">toggleAllWindows(): void</code></pre><p>Shows all hidden windows or hides all visible ones — used by the \"show/hide app\" global shortcut and tray menu entry.</p></td></tr><tr><td><code>clearCache</code></td><td><pre><code class=\"language-application-typescript\">clearCache(): Promise&lt;void&gt;</code></pre><p>Clears the underlying Chromium HTTP cache. Resolves once the cache is empty.</p></td></tr><tr><td><code>showWindow</code></td><td><pre><code class=\"language-application-typescript\">showWindow(): void</code></pre><p>Brings the main window to the foreground, restoring it if minimized.</p></td></tr><tr><td><code>reportStartupMetric</code></td><td><pre><code class=\"language-application-typescript\">reportStartupMetric(metric: \"client-full-render\"): void</code></pre><p>Reports a renderer startup milestone to the main process, which records it relative to OS process creation alongside the main-process startup metrics. Only the first report of each metric is recorded; later reports (e.g. after a window reload or from extra windows) are ignored.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>metric</code></td><td><code>\"client-full-render\"</code><br>The milestone the renderer reached.</td></tr></tbody></table></figure></td></tr><tr><td><code>onGlobalShortcut</code></td><td><pre><code class=\"language-application-typescript\">onGlobalShortcut(callback: (actionName: string) =&gt; void): void</code></pre><p>Subscribes to globally registered keyboard shortcuts.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(actionName: string) =&gt; void</code><br>Receives the name of the action the shortcut triggers, not the keystroke.</td></tr></tbody></table></figure></td></tr><tr><td><code>onOpenInSameTab</code></td><td><pre><code class=\"language-application-typescript\">onOpenInSameTab(callback: (noteId: string) =&gt; void): void</code></pre><p>Subscribes to \"open note in active tab\" requests originating from outside the renderer (e.g. tray menu, deep links).</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(noteId: string) =&gt; void</code><br>Receives the ID of the note to open.</td></tr></tbody></table></figure></td></tr><tr><td><code>onDevToolsDockChanged</code></td><td><pre><code class=\"language-application-typescript\">onDevToolsDockChanged(callback: (docked: boolean) =&gt; void): void</code></pre><p>Subscribes to changes of the DevTools docking state. While DevTools is docked, Chromium disables the native window material (Mica / vibrancy).</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(docked: boolean) =&gt; void</code><br>Receives <code>true</code> while DevTools is attached to this window, and <code>false</code> when it is closed or in a separate window.</td></tr></tbody></table></figure></td></tr></tbody></table></figure><h2><code>ElectronClipboardApi</code></h2><p>Renderer access to the system clipboard for cases the standard Web API can't cover.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>copyImageToClipboard</code></td><td><pre><code class=\"language-application-typescript\">copyImageToClipboard(buffer: Uint8Array): void</code></pre><p>Writes a raw image (PNG-encoded bytes) to the system clipboard so it can be pasted into other applications as an image rather than as a file.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>buffer</code></td><td><code>Uint8Array</code><br>The PNG-encoded image.</td></tr></tbody></table></figure></td></tr><tr><td><code>readText</code></td><td><pre><code class=\"language-application-typescript\">readText(): Promise&lt;string&gt;</code></pre><p>Reads plain text from the system clipboard via the main-process <code>electron.clipboard</code>. Used instead of <code>navigator.clipboard.readText()</code> so the renderer's deny-by-default permission policy does not have to grant the sensitive <code>clipboard-read</code> permission to the whole session.</p></td></tr><tr><td><code>readHTML</code></td><td><pre><code class=\"language-application-typescript\">readHTML(): Promise&lt;string&gt;</code></pre><p>Reads the HTML flavor of the system clipboard, the same way as <code>readText</code>. Empty when the clipboard has no HTML.</p></td></tr></tbody></table></figure><h2><code>ElectronShellApi</code></h2><p>Wrappers around Electron's <code>shell</code> module for interacting with the OS (default browser, default file handler, downloads, etc.).</p><p>Every method here is validated in the main process before dispatch — see <code>apps/server/src/services/shell_validators.ts</code>. The renderer is treated as untrusted: invalid input throws on the main side rather than being silently passed through to <code>electron.shell</code> / <code>WebContents</code>.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>openExternal</code></td><td><pre><code class=\"language-application-typescript\">openExternal(url: string): void</code></pre><p>Opens a URL in the user's default external browser via <code>electron.shell.openExternal</code>.</p><p><strong>Security:</strong> the scheme is matched against the allowlist in <code>SHELL_OPEN_EXTERNAL_PROTOCOLS</code> (commons). Blocked schemes include <code>file:</code>, <code>data:</code>, <code>smb:</code>, <code>ldap:</code>, <code>ldaps:</code>, <code>jar:</code>, and <code>view-source:</code> — they cover Follina-class RCE primitives (<code>ms-msdt:</code>, <code>search-ms:</code>), NTLM credential theft, and Java loader vectors. URLs that fail to parse are rejected outright.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>url</code></td><td><code>string</code><br>The URL to open.</td></tr></tbody></table></figure></td></tr><tr><td><code>openPath</code></td><td><pre><code class=\"language-application-typescript\">openPath(path: string): Promise&lt;string&gt;</code></pre><p>Opens a local path with its default OS handler.</p><p><strong>Security:</strong> the path is canonicalized and must resolve to either the Trilium data directory (or a descendant) or the Trilium tmp directory (or a descendant). Anything else — absolute paths elsewhere on disk, traversal attempts, UNC paths that don't normalize under those roots — is rejected. Null bytes, empty strings, and non-existent files are also rejected.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>path</code></td><td><code>string</code><br>A file in the Trilium data or tmp directory.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;string&gt;</code>: An empty string on success, or an error message on failure.</p></td></tr><tr><td><code>showItemInFolder</code></td><td><pre><code class=\"language-application-typescript\">showItemInFolder(path: string): void</code></pre><p>Shows a local file in the OS file manager, with the file itself selected, via <code>electron.shell.showItemInFolder</code>. For pointing at a file the user is not meant to open — the database, whose reader is Trilium itself.</p><p><strong>Security:</strong> the same sandbox as <code>openPath</code>, with the database file added as a root of its own, since <code>TRILIUM_DOCUMENT_PATH</code> may put it outside the data directory. Revealing is the milder act of the two, the file being selected rather than launched, but a path the renderer names is still a path the renderer must not be free to choose.</p><p>Nothing is reported back: the OS is asked to bring a window forward, and whether it did is not something Electron answers.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>path</code></td><td><code>string</code><br>A file in the Trilium data or tmp directory, or the database file.</td></tr></tbody></table></figure></td></tr><tr><td><code>openFileUrl</code></td><td><pre><code class=\"language-application-typescript\">openFileUrl(fileUrl: string): Promise&lt;string&gt;</code></pre><p>Opens a <code>file://</code> URL with its default OS handler. Exists as a separate channel from <code>openExternal</code> because neither Electron API opens every target correctly on Windows: <code>shell.openExternal</code> mishandles Unicode characters in <code>file:</code> URLs, while <code>shell.openPath</code> opens a directory with the Explorer-specific <code>explore</code> verb, bypassing the user's file manager. The main process picks between them per target.</p><p><strong>Security:</strong> the URL must use the <code>file:</code> scheme and must have an empty hostname. UNC paths (<code>file://attacker.example/share/x</code>) are explicitly blocked because Windows would otherwise resolve them to <code>\\\\attacker.example\\share\\x</code> and leak the user's NTLM hash via SMB authentication. Drive-letter-as-host malformations like <code>file://C:/path</code> are normalized to <code>file:///C:/path</code> before parsing.</p><p>Note: unlike <code>openPath</code>, the resolved path is NOT confined to the Trilium data / tmp directories — this channel handles user-clicked <code>file://</code> links inside note content, which routinely reference arbitrary locations on disk (<code>file:///C:/Users/me/Documents/contract.pdf</code> and similar). Equivalent to a browser following a <code>file:</code> link the user clicked. Treat clicks on attacker-influenced note content accordingly.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>fileUrl</code></td><td><code>string</code><br>A <code>file:</code> URL with an empty hostname.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;string&gt;</code>: An empty string on success, or an error message on failure.</p></td></tr><tr><td><code>downloadURL</code></td><td><pre><code class=\"language-application-typescript\">downloadURL(url: string): void</code></pre><p>Triggers a Chromium download for the given URL — the file is saved through the normal \"Save As\" flow instead of being opened in the renderer.</p><p><strong>Security:</strong> locked to the renderer's own origin. The scheme, hostname, and port must all match the running app's origin (<code>http://localhost:PORT</code> for the dev server, or the custom <code>trilium-app://app/</code> protocol for packaged Electron). Cross-origin downloads, hostless URLs (<code>data:</code>, <code>blob:</code>, <code>about:</code>, plain <code>file:///</code>), and unparseable URLs are rejected. This stops a compromised renderer from pre-positioning a remote payload in the user's Downloads folder under a familiar name.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>url</code></td><td><code>string</code><br>A URL on the app's own origin.</td></tr></tbody></table></figure></td></tr><tr><td><code>openCustom</code></td><td><pre><code class=\"language-application-typescript\">openCustom(filePath: string): void</code></pre><p>Opens a file with a Trilium-specific custom handler (configured via the \"Open With\" option), falling back to the OS default if none is set.</p><p><strong>Security:</strong> the path must resolve to a strict descendant of Trilium's tmp directory and the file must exist on disk. The legitimate caller always passes a path that was just written by <code>saveToTmpDir</code>; anything else (the data dir itself, paths elsewhere on disk, null bytes, empty strings) is rejected.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>filePath</code></td><td><code>string</code><br>A file in Trilium's tmp directory, as written by <code>saveToTmpDir</code>.</td></tr></tbody></table></figure></td></tr></tbody></table></figure><h2><code>ElectronContextMenuApi</code></h2><p>Bridge for the native context menu shown over web contents.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>onContextMenu</code></td><td><pre><code class=\"language-application-typescript\">onContextMenu(callback: (params: ElectronContextMenuParams) =&gt; void): void</code></pre><p>Subscribes to right-click events forwarded from the main process.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(params: ElectronContextMenuParams) =&gt; void</code><br>Receives where the user clicked and what is under the cursor.</td></tr></tbody></table></figure></td></tr><tr><td><code>webContentsAction</code></td><td><pre><code class=\"language-application-typescript\">webContentsAction(action: \"cut\" | \"copy\" | \"paste\" | \"pasteAndMatchStyle\" | \"insertText\", text?: string): void</code></pre><p>Executes a clipboard / text-input action on the focused web contents.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>action</code></td><td><code>\"cut\" | \"copy\" | \"paste\" | \"pasteAndMatchStyle\" | \"insertText\"</code><br>The action to execute.</td></tr><tr><td><code>text</code><br><em>optional</em></td><td><code>string</code><br>The text to insert. <code>\"insertText\"</code> requires it; the other actions ignore it.</td></tr></tbody></table></figure></td></tr></tbody></table></figure><h2><code>ElectronSpellcheckApi</code></h2><p>Renderer-side access to Chromium's built-in spell checker.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>addWordToDictionary</code></td><td><pre><code class=\"language-application-typescript\">addWordToDictionary(word: string): void</code></pre><p>Adds a word to the user's personal dictionary so it is no longer flagged.</p></td></tr><tr><td><code>getAvailableSpellCheckerLanguages</code></td><td><pre><code class=\"language-application-typescript\">getAvailableSpellCheckerLanguages(): string[]</code></pre><p>Returns the BCP-47 language tags Chromium can spell-check on this platform.</p></td></tr><tr><td><code>setSpellCheckerLanguages</code></td><td><pre><code class=\"language-application-typescript\">setSpellCheckerLanguages(languageCodes: string[]): void</code></pre><p>Applies the spell-check language list to every open window's session immediately, without an application restart. No-op on macOS, where the OS spell checker auto-detects the language.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>languageCodes</code></td><td><code>string[]</code><br>Language tags returned by <code>getAvailableSpellCheckerLanguages</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>setSpellCheckerEnabled</code></td><td><pre><code class=\"language-application-typescript\">setSpellCheckerEnabled(enabled: boolean): void</code></pre><p>Enables or disables the built-in spell checker on every open window's session immediately, without an application restart.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>enabled</code></td><td><code>boolean</code><br><code>true</code> to enable the spell checker, <code>false</code> to disable it.</td></tr></tbody></table></figure></td></tr></tbody></table></figure><h2><code>ElectronSystemIntegrationApi</code></h2><p>OS integration controls — system tray and autostart / launch-on-login.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>reloadTray</code></td><td><pre><code class=\"language-application-typescript\">reloadTray(): void</code></pre><p>Rebuilds the tray icon and menu — call after changing tray-related settings.</p></td></tr><tr><td><code>reapplyLaunchOnStartup</code></td><td><pre><code class=\"language-application-typescript\">reapplyLaunchOnStartup(): void</code></pre><p>Re-applies the OS autostart entry after the <code>launchOnStartup</code> / <code>hideOnAutoStart</code> options change.</p></td></tr></tbody></table></figure><h2><code>ElectronPrintingApi</code></h2><p>Printing and PDF export flow. Trilium drives Electron's printing pipeline through a small state machine that the main process owns, with progress and results pushed back to the renderer via IPC events.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>sendPrintProgress</code></td><td><pre><code class=\"language-application-typescript\">sendPrintProgress(progress: number): void</code></pre><p>Reports rendering progress from the renderer to the main process.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>progress</code></td><td><code>number</code><br>The percentage rendered, from 0 to 100.</td></tr></tbody></table></figure></td></tr><tr><td><code>onPrintProgress</code></td><td><pre><code class=\"language-application-typescript\">onPrintProgress(callback: (data: { progress: number; action: string }) =&gt; void): void</code></pre><p>Subscribes to progress updates emitted by the main process during a print or PDF export run.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(data: { progress: number; action: string }) =&gt; void</code><br>Receives the percentage done and the current stage, such as <code>\"rendering\"</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>onPrintDone</code></td><td><pre><code class=\"language-application-typescript\">onPrintDone(callback: (printReport: unknown, liveJobId?: number) =&gt; void): void</code></pre><p>Subscribes to the \"print finished\" event, fired once the OS print job is dispatched.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(printReport: unknown, liveJobId?: number) =&gt; void</code><br>Receives the main process's report on the job, or an error with a <code>message</code>, and, for a job that printed the app window itself, the ID of the live print the job ended.</td></tr></tbody></table></figure></td></tr><tr><td><code>removePrintListeners</code></td><td><pre><code class=\"language-application-typescript\">removePrintListeners(): void</code></pre><p>Removes all listeners registered via <code>onPrintProgress</code> and <code>onPrintDone</code>.</p></td></tr><tr><td><code>getPrinters</code></td><td><pre><code class=\"language-application-typescript\">getPrinters(): Promise&lt;unknown[]&gt;</code></pre><p>Returns the list of printers known to the OS.</p></td></tr><tr><td><code>exportAsPdfPreview</code></td><td><pre><code class=\"language-application-typescript\">exportAsPdfPreview(opts: Record&lt;string, unknown&gt;): void</code></pre><p>Asks the main process to render the current note as a PDF and return the resulting bytes for the in-app preview. Result is delivered via <code>onExportAsPdfPreviewResult</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code></td><td><code>Record&lt;string, unknown&gt;</code><br>The note path, the page size, orientation, scale, margins and page ranges, and a <code>requestId</code> the result echoes back.</td></tr></tbody></table></figure></td></tr><tr><td><code>onExportAsPdfPreviewResult</code></td><td><pre><code class=\"language-application-typescript\">onExportAsPdfPreviewResult(callback: (result: { buffer?: Uint8Array&lt;ArrayBufferLike&gt;; error?: string; requestId?: number }) =&gt; void): void</code></pre><p>Subscribes to the result of an <code>exportAsPdfPreview</code> call.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(result: { buffer?: Uint8Array&lt;ArrayBufferLike&gt;; error?: string; requestId?: number }) =&gt; void</code><br>Receives the PDF bytes or an error message, and the <code>requestId</code> of the call the result answers.</td></tr></tbody></table></figure></td></tr><tr><td><code>removeExportAsPdfPreviewResultListener</code></td><td><pre><code class=\"language-application-typescript\">removeExportAsPdfPreviewResultListener(): void</code></pre><p>Removes the listener registered via <code>onExportAsPdfPreviewResult</code>.</p></td></tr><tr><td><code>savePdf</code></td><td><pre><code class=\"language-application-typescript\">savePdf(data: { title: string; buffer: Uint8Array }): void</code></pre><p>Persists a previously generated PDF buffer to disk via the native save dialog.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>data</code></td><td><code>{ title: string; buffer: Uint8Array }</code><br>The PDF bytes, and the title to suggest as the file name.</td></tr></tbody></table></figure></td></tr><tr><td><code>printFromPreview</code></td><td><pre><code class=\"language-application-typescript\">printFromPreview(opts: Record&lt;string, unknown&gt;): void</code></pre><p>Sends the previewed PDF to the OS print dialog with the given options.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code></td><td><code>Record&lt;string, unknown&gt;</code><br>The options of <code>exportAsPdfPreview</code>, plus <code>silent</code> to print without the dialog and <code>deviceName</code> to choose the printer.</td></tr></tbody></table></figure></td></tr></tbody></table></figure><h2><code>ElectronNavigationApi</code></h2><p>Accessors for the underlying Chromium navigation history of the current web contents (back/forward stack), exposed so the renderer can mirror it in custom UI such as the breadcrumb / tab back button.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>clearNavigationHistory</code></td><td><pre><code class=\"language-application-typescript\">clearNavigationHistory(): void</code></pre><p>Clears the entire back/forward navigation history.</p></td></tr><tr><td><code>navigationCanGoBack</code></td><td><pre><code class=\"language-application-typescript\">navigationCanGoBack(): boolean</code></pre><p>Synchronously returns whether a back navigation is possible.</p></td></tr><tr><td><code>navigationCanGoForward</code></td><td><pre><code class=\"language-application-typescript\">navigationCanGoForward(): boolean</code></pre><p>Synchronously returns whether a forward navigation is possible.</p></td></tr><tr><td><code>navigationGetAllEntries</code></td><td><pre><code class=\"language-application-typescript\">navigationGetAllEntries(): { url: string; title: string }[]</code></pre><p>Returns every entry in the navigation history, oldest first.</p></td></tr><tr><td><code>navigationGetActiveIndex</code></td><td><pre><code class=\"language-application-typescript\">navigationGetActiveIndex(): number</code></pre><p>Returns the index of the currently active entry inside <code>navigationGetAllEntries</code>.</p></td></tr><tr><td><code>navigationLength</code></td><td><pre><code class=\"language-application-typescript\">navigationLength(): number</code></pre><p>Returns the total number of entries in the navigation history.</p></td></tr><tr><td><code>navigationGoToIndex</code></td><td><pre><code class=\"language-application-typescript\">navigationGoToIndex(index: number): void</code></pre><p>Navigates to the entry at the given index in the history stack.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>index</code></td><td><code>number</code><br>An index into <code>navigationGetAllEntries</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>onDidNavigate</code></td><td><pre><code class=\"language-application-typescript\">onDidNavigate(callback: () =&gt; void): void</code></pre><p>Subscribes to top-level navigation events (URL changes that load a new document).</p></td></tr><tr><td><code>onDidNavigateInPage</code></td><td><pre><code class=\"language-application-typescript\">onDidNavigateInPage(callback: () =&gt; void): void</code></pre><p>Subscribes to in-page navigation events (hash changes, <code>history.pushState</code>).</p></td></tr><tr><td><code>removeDidNavigateListeners</code></td><td><pre><code class=\"language-application-typescript\">removeDidNavigateListeners(): void</code></pre><p>Removes all listeners registered via <code>onDidNavigate</code> and <code>onDidNavigateInPage</code>.</p></td></tr></tbody></table></figure><h2><code>ElectronWsApi</code></h2><p>In-process replacement for the renderer↔server WebSocket. Backed by Chromium IPC instead of a TCP socket — no port is bound and no auth check is needed because the channel is only reachable from the renderer the BrowserWindow owns. Wire format is whatever the server's <code>MessagingProvider</code> accepts (currently <code>WebSocketMessage</code> / log-error / log-info / ping).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>send</code></td><td><pre><code class=\"language-application-typescript\">send(message: unknown): void</code></pre><p>Sends a message from the renderer to the main-process messaging hub.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>message</code></td><td><code>unknown</code><br>A message the server's <code>MessagingProvider</code> accepts.</td></tr></tbody></table></figure></td></tr><tr><td><code>onMessage</code></td><td><pre><code class=\"language-application-typescript\">onMessage(callback: (message: unknown) =&gt; void): () =&gt; void</code></pre><p>Subscribes to messages pushed from the main process.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(message: unknown) =&gt; void</code><br>Receives each message.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>() =&gt; void</code>: An unsubscribe function. Call it when the listener is no longer needed (e.g. when a BrowserWindow is unloaded) to avoid leaking handlers.</p></td></tr></tbody></table></figure><h2><code>ElectronSecurityApi</code></h2><p>Security settings that live outside the database (in <code>data_dir/security.json</code>) to prevent malicious scripts from modifying them. Changes require a native OS confirmation dialog and an app restart to take effect.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>setLanAccessEnabled</code></td><td><pre><code class=\"language-application-typescript\">setLanAccessEnabled(enabled: boolean): Promise&lt;boolean&gt;</code></pre><p>Requests enabling/disabling LAN access. When enabled, the desktop binds its TCP listener to all interfaces (instead of loopback) so other devices can reach it — e.g. to sync from another device. Same confirmation + restart flow as above.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>enabled</code></td><td><code>boolean</code><br><code>true</code> to listen on all interfaces, <code>false</code> to listen on loopback only.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;boolean&gt;</code>: <code>true</code> once the user agreed and the change was written.</p></td></tr><tr><td><code>setBackendScriptingEnabled</code></td><td><pre><code class=\"language-application-typescript\">setBackendScriptingEnabled(enabled: boolean): Promise&lt;boolean&gt;</code></pre><p>Requests backend script execution be turned on or off.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>enabled</code></td><td><code>boolean</code><br><code>true</code> to allow backend scripts to run, <code>false</code> to block them.</td></tr></tbody></table></figure></td></tr><tr><td><code>setSqlConsoleEnabled</code></td><td><pre><code class=\"language-application-typescript\">setSqlConsoleEnabled(enabled: boolean): Promise&lt;boolean&gt;</code></pre><p>Requests the SQL console be turned on or off.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>enabled</code></td><td><code>boolean</code><br><code>true</code> to enable the SQL console, <code>false</code> to disable it.</td></tr></tbody></table></figure></td></tr></tbody></table></figure><h2><code>ElectronBackupPassphraseApi</code></h2><p>The backup passphrase, kept encrypted by the OS keyring in a file outside the database (the database is what ends up inside the backup, so a passphrase stored there would ride along inside the very container it protects).</p><p>Deliberately write-only: there is no way to read the passphrase back, so a frontend script cannot exfiltrate it. Only the main process ever sees the plaintext again, when it writes a backup.</p><p>Both changes are also gated on a native OS confirmation, which a script can request but cannot answer. Without that, a script could quietly swap in a passphrase of its own and every later backup would be encrypted to it.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>getStatus</code></td><td><pre><code class=\"language-application-typescript\">getStatus(): Promise&lt;BackupPassphraseStatus&gt;</code></pre><p>Whether a passphrase can be stored on this system, and whether one already is.</p></td></tr><tr><td><code>set</code></td><td><pre><code class=\"language-application-typescript\">set(passphrase: string): Promise&lt;BackupPassphraseChange&gt;</code></pre><p>Stores a passphrase, replacing any existing one, once the user has confirmed it.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>passphrase</code></td><td><code>string</code><br>The passphrase to encrypt later backups with.</td></tr></tbody></table></figure></td></tr><tr><td><code>clear</code></td><td><pre><code class=\"language-application-typescript\">clear(): Promise&lt;BackupPassphraseChange&gt;</code></pre><p>Forgets the stored passphrase. Existing backups keep the passphrase they were written with.</p></td></tr></tbody></table></figure><h2><code>ElectronOneNoteApi</code></h2><p>Desktop-only OneNote importer sign-in, driven from the main process via a loopback OAuth redirect.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>login</code></td><td><pre><code class=\"language-application-typescript\">login(): Promise&lt;OneNoteLoginResult&gt;</code></pre><p>Runs the Microsoft delegated-Graph OAuth flow: opens the system browser, captures the redirect on a throwaway loopback server, exchanges the code, and stores the token process-side. Resolves once the desktop session is connected (or with <code>connected: false</code> on failure/timeout).</p></td></tr></tbody></table></figure><h2><code>ElectronNativeExportApi</code></h2><p>Desktop-native subtree export that streams a <code>.zip</code> straight to a file.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>exportSubtreeToFile</code></td><td><pre><code class=\"language-application-typescript\">exportSubtreeToFile(opts: { branchId: string; format: string; title: string; taskId: string }): Promise&lt;NativeExportResult&gt;</code></pre><p>Prompts a native \"save as\" dialog, then streams a subtree (branch) export to the chosen path on disk. This bypasses the in-memory download path, so memory stays bounded regardless of archive size. Progress/success/error are reported over the WebSocket via <code>taskId</code>. Resolves once the dialog is dismissed (<code>cancelled</code>) or the export finishes (<code>saved</code> / <code>error</code>).</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code></td><td><code>{ branchId: string; format: string; title: string; taskId: string }</code><br>The branch to export, the export format (<code>\"html\"</code>, <code>\"markdown\"</code> or <code>\"share\"</code>), the title to suggest as the file name, and the ID of the task that reports progress.</td></tr></tbody></table></figure></td></tr></tbody></table></figure><h2><code>ElectronNativeImportApi</code></h2><p>Desktop-native import that reads the user's file <strong>in place</strong> (bounded memory, no temp copy) — the whole point being multi-GB <code>.zip</code> archives, though any importable file is accepted. The renderer never handles a filesystem path: <code>pickFiles</code> runs the OS dialog in the main process and returns opaque capability tokens, which <code>importFromToken</code> redeems. A script can't forge a token or pass a path, so it can never read an arbitrary file.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>pickFiles</code></td><td><pre><code class=\"language-application-typescript\">pickFiles(): Promise&lt;NativeImportPickResult&gt;</code></pre><p>Prompts a native \"open file\" dialog (multi-select, any type) and returns single-use tokens for the chosen files.</p></td></tr><tr><td><code>grantDroppedFiles</code></td><td><pre><code class=\"language-application-typescript\">grantDroppedFiles(files: File[]): Promise&lt;NativeImportPickResult&gt;</code></pre><p>Resolves files the user dropped onto a drop zone to capability tokens, so a drag-and-drop import takes the same in-place (streamed) path as the dialog. The <code>File</code> is the unforgeable capability: the path is obtained via <code>webUtils.getPathForFile</code>, which yields a real path only for a genuinely user-supplied file and an empty string for anything a script constructed — so a script can't smuggle in an arbitrary path. Returns <code>cancelled</code> when no dropped file resolved (e.g. dragged from a browser, not the OS), so the caller falls back to the normal upload route.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>files</code></td><td><code>File[]</code><br>The files of the drop event.</td></tr></tbody></table></figure></td></tr><tr><td><code>importFromToken</code></td><td><pre><code class=\"language-application-typescript\">importFromToken(opts: { token: string; parentNoteId: string; taskId: string; options: NativeImportOptions; last: boolean; format?: string }): Promise&lt;NativeImportResult&gt;</code></pre><p>Imports the file behind a token, with progress/success/error reported over the WebSocket like the HTTP import path.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code></td><td><code>{ token: string; parentNoteId: string; taskId: string; options: NativeImportOptions; last: boolean; format?: string }</code><br>The <code>token</code> to redeem, the <code>parentNoteId</code> to import under, the <code>taskId</code> that reports progress, and the import <code>options</code>. When importing several files in one batch, set <code>last</code> only on the final call so the success toast fires once, after everything is in. <code>format</code> routes the file to a specific importer (e.g. <code>\"obsidian\"</code>), mirroring the HTTP route's format tag.</td></tr></tbody></table></figure></td></tr></tbody></table></figure><h2><code>ElectronDialogApi</code></h2><p>Native OS pickers that hand the renderer a location the user chose themselves.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>pickDirectory</code></td><td><pre><code class=\"language-application-typescript\">pickDirectory(opts?: { defaultPath?: string }): Promise&lt;NativeDirectoryPickResult&gt;</code></pre><p>Prompts a native \"select folder\" dialog. The renderer cannot supply the answer: a script can at most pop the dialog, which the user still has to accept before any path comes back.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code><br><em>optional</em></td><td><code>{ defaultPath?: string }</code><br>The directory the dialog starts in, as <code>defaultPath</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>confirmStartOver</code></td><td><pre><code class=\"language-application-typescript\">confirmStartOver(): Promise&lt;boolean&gt;</code></pre><p>Prompts a native message box before the application restarts into the setup screen, where the user may replace or erase their knowledge base.</p><p>An OS dialog rather than one of the application's own, for the reason the security toggles use one: a note script can reach every dialog the app draws for itself, and this one guards the path to losing everything. It is never suppressible, so there is no \"don't ask again\" here.</p></td></tr></tbody></table></figure><h2><code>ElectronRestoreApi</code></h2><p>Choosing a backup to restore from the desktop, where the file is already on the same disk as the database it is going to replace and has no business being uploaded to reach it.</p><p>Only usable during setup: what it puts forward is restored by the ordinary <code>POST /api/setup/restore/start</code>, which refuses once the application is initialized.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>pickBackup</code></td><td><pre><code class=\"language-application-typescript\">pickBackup(): Promise&lt;NativeBackupPickResult&gt;</code></pre><p>Prompts a native \"open file\" dialog for a <code>.db</code> or <code>.tnbackup</code> backup and, if one is chosen, makes it the backup waiting to be restored.</p></td></tr></tbody></table></figure><h2><code>ElectronTranscriptionApi</code></h2><p>Meeting transcription, recorded and transcribed on this computer by the main process. The renderer only starts and stops it; the audio never passes through the renderer.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>isSupported</code></td><td><pre><code class=\"language-application-typescript\">isSupported(): Promise&lt;boolean&gt;</code></pre><p>Whether this build can transcribe on this computer: <code>false</code> when it carries no speech recognition engine for the platform and processor it runs on.</p></td></tr><tr><td><code>start</code></td><td><pre><code class=\"language-application-typescript\">start(noteId: string): Promise&lt;string&gt;</code></pre><p>Starts recording the microphone and the system audio for a meeting note.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>noteId</code></td><td><code>string</code><br>The meeting note the transcript belongs to.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;string&gt;</code>: An empty string once recording runs, or an error message when it cannot start.</p></td></tr><tr><td><code>stop</code></td><td><pre><code class=\"language-application-typescript\">stop(): Promise&lt;void&gt;</code></pre><p>Stops the recording, once the speech already captured has been transcribed.</p></td></tr><tr><td><code>getState</code></td><td><pre><code class=\"language-application-typescript\">getState(): Promise&lt;TranscriptionState&gt;</code></pre></td></tr><tr><td><code>renameSpeaker</code></td><td><pre><code class=\"language-application-typescript\">renameSpeaker(attachmentId: string, key: string, name: string): Promise&lt;boolean&gt;</code></pre><p>Names a speaker of a transcript attachment, if a running recording writes that transcript. The recording applies it, so no utterance it writes meanwhile is lost.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>attachmentId</code></td><td><code>string</code><br>The transcript attachment.</td></tr><tr><td><code>key</code></td><td><code>string</code><br>The speaker: <code>microphone</code> for the local speaker, <code>system:&lt;n&gt;</code> for an identified speaker of the system audio.</td></tr><tr><td><code>name</code></td><td><code>string</code><br>The name to give, or a blank string to restore the default name.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;boolean&gt;</code>: <code>false</code> when no recording writes <code>attachmentId</code>; it can then be saved whole.</p></td></tr><tr><td><code>getRecordingsDirectory</code></td><td><pre><code class=\"language-application-typescript\">getRecordingsDirectory(): Promise&lt;string&gt;</code></pre><p>Returns the directory that keeps the audio and the transcript as produced of each recording while <code>transcriptionKeepRecordings</code> is on, creating it if needed.</p></td></tr><tr><td><code>onStateChanged</code></td><td><pre><code class=\"language-application-typescript\">onStateChanged(callback: (state: TranscriptionState) =&gt; void): () =&gt; void</code></pre><p>Subscribes to changes of the transcription state, made from any window.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(state: TranscriptionState) =&gt; void</code><br>Receives the new state.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>() =&gt; void</code>: A function that removes the listener.</p></td></tr><tr><td><code>onLevel</code></td><td><pre><code class=\"language-application-typescript\">onLevel(callback: (source: TranscriptSource, level: number) =&gt; void): () =&gt; void</code></pre><p>Subscribes to the audio level of the running recording, about four times a second per source.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(source: TranscriptSource, level: number) =&gt; void</code><br>Receives the source and the RMS, from 0 to 1, of each chunk it delivers.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>() =&gt; void</code>: A function that stops the calls.</p></td></tr></tbody></table></figure><h2>Types</h2><h3><code>ElectronContextMenuParams</code></h3><p>Parameters delivered by the main process to the renderer when the user opens the system context menu (right-click) somewhere inside a web view.</p><p>Mirrors the subset of fields from Electron's <code>Electron.ContextMenuParams</code> that the renderer actually consumes when building its custom context menu.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>x</code></td><td><code>number</code> <br>Horizontal position of the click, in CSS pixels, relative to the web view.</td></tr><tr><td><code>y</code></td><td><code>number</code> <br>Vertical position of the click, in CSS pixels, relative to the web view.</td></tr><tr><td><code>linkURL</code></td><td><code>string</code> <br>URL of the link the user clicked on, or an empty string if not on a link.</td></tr><tr><td><code>linkText</code></td><td><code>string</code> <br>Visible text of the link the user clicked on, or an empty string.</td></tr><tr><td><code>mediaType</code></td><td><code>string</code> <br>Media kind under the cursor (e.g. <code>\"none\"</code>, <code>\"image\"</code>, <code>\"video\"</code>, <code>\"audio\"</code>).</td></tr><tr><td><code>isEditable</code></td><td><code>boolean</code> <br>Whether the element under the cursor is editable (input, textarea, contenteditable).</td></tr><tr><td><code>selectionText</code></td><td><code>string</code> <br>Currently selected text, or an empty string if nothing is selected.</td></tr><tr><td><code>misspelledWord</code></td><td><code>string</code> <br>The misspelled word under the cursor, or an empty string if none.</td></tr><tr><td><code>dictionarySuggestions</code></td><td><code>string[]</code> <br>Spell-check suggestions for <code>misspelledWord</code>, in order of relevance.</td></tr><tr><td><code>editFlags</code></td><td><code>{ canCut: boolean; canCopy: boolean; canPaste: boolean }</code> <br>Hints about which clipboard operations are currently available.</td></tr></tbody></table></figure><h3><code>BackupPassphraseStatus</code></h3><p>What the Options UI needs to know about the stored backup passphrase.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>available</code></td><td><code>boolean</code> <br>Whether the OS offers a keyring to keep the passphrase in. Without one it cannot be stored safely, and since unattended backups cannot ask for it, encryption is unavailable altogether.</td></tr><tr><td><code>set</code></td><td><code>boolean</code> <br>Whether a passphrase is currently stored.</td></tr></tbody></table></figure><h3><code>BackupPassphraseChange</code></h3><p>What became of a request to change the stored backup passphrase.</p><figure class=\"table\"><table><thead><tr><th>Value</th><th>Description</th></tr></thead><tbody><tr><td><code>\"applied\"</code></td><td>The change was confirmed and carried out.</td></tr><tr><td><code>\"cancelled\"</code></td><td>The user declined the OS confirmation, so nothing changed.</td></tr><tr><td><code>\"unavailable\"</code></td><td>There is no keyring on this system to keep a passphrase in.</td></tr></tbody></table></figure><h3><code>OneNoteLoginResult</code></h3><p>Outcome of a <code>ElectronOneNoteApi.login</code> attempt.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>connected</code></td><td><code>boolean</code> <br>True if sign-in completed and a Microsoft Graph token was stored.</td></tr><tr><td><code>account</code> <br><em>optional</em></td><td><code>{ name: string; email: string }</code> <br>The connected Microsoft account, present when <code>connected</code> is true.</td></tr><tr><td><code>error</code> <br><em>optional</em></td><td><code>string</code> <br>A human-readable failure reason when <code>connected</code> is false (absent on user cancellation).</td></tr></tbody></table></figure><h3><code>NativeExportResult</code></h3><p>Outcome of a <code>ElectronNativeExportApi.exportSubtreeToFile</code> request.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>status</code></td><td><code>\"cancelled\" | \"saved\" | \"error\"</code></td></tr><tr><td><code>filePath</code> <br><em>optional</em></td><td><code>string</code> <br>Absolute path the archive was written to (when <code>status === \"saved\"</code>).</td></tr><tr><td><code>message</code> <br><em>optional</em></td><td><code>string</code> <br>Failure detail (when <code>status === \"error\"</code>).</td></tr></tbody></table></figure><h3><code>NativeImportPickResult</code></h3><p>Outcome of <code>ElectronNativeImportApi.pickFiles</code>: capability tokens, never paths.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>status</code></td><td><code>\"cancelled\" | \"selected\"</code></td></tr><tr><td><code>files</code> <br><em>optional</em></td><td><code>NativeImportPickedFile[]</code> <br>The user-chosen files (when <code>status === \"selected\"</code>); one or more, since the dialog allows multi-select.</td></tr></tbody></table></figure><h3><code>NativeImportOptions</code></h3><p>Import flags forwarded to the native importer (mirrors the HTTP route's options; no path).</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>safeImport</code></td><td><code>boolean</code></td></tr><tr><td><code>shrinkImages</code></td><td><code>boolean</code></td></tr><tr><td><code>textImportedAsText</code></td><td><code>boolean</code></td></tr><tr><td><code>codeImportedAsCode</code></td><td><code>boolean</code></td></tr><tr><td><code>spreadsheetImportedAsSpreadsheet</code></td><td><code>boolean</code></td></tr><tr><td><code>explodeArchives</code></td><td><code>boolean</code></td></tr><tr><td><code>replaceUnderscoresWithSpaces</code></td><td><code>boolean</code></td></tr></tbody></table></figure><h3><code>NativeImportResult</code></h3><p>Outcome of <code>ElectronNativeImportApi.importFromToken</code>.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>status</code></td><td><code>\"error\" | \"imported\"</code></td></tr><tr><td><code>importedNoteId</code> <br><em>optional</em></td><td><code>string</code> <br>Root note of the import (when <code>status === \"imported\"</code>).</td></tr><tr><td><code>message</code> <br><em>optional</em></td><td><code>string</code> <br>Failure detail (when <code>status === \"error\"</code>).</td></tr></tbody></table></figure><h3><code>NativeDirectoryPickResult</code></h3><p>Outcome of <code>ElectronDialogApi.pickDirectory</code>.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>status</code></td><td><code>\"cancelled\" | \"selected\"</code></td></tr><tr><td><code>path</code> <br><em>optional</em></td><td><code>string</code> <br>Absolute path of the chosen directory (when <code>status === \"selected\"</code>).</td></tr></tbody></table></figure><h3><code>NativeBackupPickResult</code></h3><p>Outcome of <code>ElectronRestoreApi.pickBackup</code>: what the chosen backup is, never where it is.</p><p>The file itself stays with the main process, which holds it as the one waiting to be restored, so the renderer is given only what the screen has to show and decide with.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>status</code></td><td><code>\"cancelled\" | \"error\" | \"selected\"</code></td></tr><tr><td><code>fileName</code> <br><em>optional</em></td><td><code>string</code> <br>Display name of the chosen backup (when <code>status === \"selected\"</code>).</td></tr><tr><td><code>encrypted</code> <br><em>optional</em></td><td><code>boolean</code> <br>Whether a passphrase has to be asked for before it can be restored.</td></tr><tr><td><code>message</code> <br><em>optional</em></td><td><code>string</code> <br>Failure detail (when <code>status === \"error\"</code>), e.g. setup already being busy.</td></tr></tbody></table></figure><h3><code>TranscriptionState</code></h3><p>What <code>ElectronTranscriptionApi</code> reports to every window.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>status</code></td><td><code>\"idle\" | \"starting\" | \"recording\" | \"stopping\"</code> <br>Phase of the meeting transcription; at most one recording runs at a time.</td></tr><tr><td><code>noteId</code></td><td><code>string | null</code> <br>The meeting note the recording belongs to, or <code>null</code> when idle.</td></tr><tr><td><code>pendingSources</code></td><td><code>TranscriptSource[]</code> <br>The sources heard speaking, or whose speech is still being transcribed.</td></tr><tr><td><code>sourceIssues</code> <br><em>optional</em></td><td><code>Partial&lt;Record&lt;TranscriptSource, \"not_captured\" | \"no_audio\" | \"silent\"&gt;&gt;</code> <br>While recording, the sources whose audio is not being transcribed, and why; absent when every source delivers sound. <br>Why a source's audio is not being transcribed: its capture did not start (<code>not_captured</code>), it has delivered no audio for 10 s (<code>no_audio</code>), as when its capture hangs, or it has delivered only digital silence for a while (<code>silent</code>), as from a muted device.</td></tr><tr><td><code>startedAt</code> <br><em>optional</em></td><td><code>number</code> <br>When the recording started, in milliseconds since the epoch: set once it records, kept while it stops, absent otherwise.</td></tr><tr><td><code>error</code> <br><em>optional</em></td><td><code>string</code> <br>A problem to tell the user about, sent once with the state it concerns: the recording ended without being stopped, or its transcript cannot be saved. <code>getState()</code> never returns it.</td></tr></tbody></table></figure><h3><code>TranscriptSource</code></h3><p>Where an utterance was heard: the local speaker's microphone, or everyone else on the system output.</p><pre><code class=\"language-application-typescript\">type TranscriptSource = \"microphone\" | \"system\"</code></pre><h3><code>NativeImportPickedFile</code></h3><p>A single user-chosen file: a capability token (redeemed to import it) and its display name — never a path.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td><code>string</code> <br>Single-use, short-lived grant for the chosen file.</td></tr><tr><td><code>fileName</code></td><td><code>string</code> <br>Display name of the chosen file.</td></tr></tbody></table></figure>",
+ "_help_Q2z6av6JZVWm": "<h2><code>FrontendApi</code></h2><p>The <code>api</code> global available inside <strong>frontend</strong> script notes (<code>application/javascript;env=frontend</code>).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>$container</code></td><td><p><code>unknown</code><br>Container of all the rendered script content</p></td></tr><tr><td><code>startNote</code></td><td><p><code>FNote</code><br>Note where the script execution started — the entry point of the current script bundle (in C terms, the file containing <code>main()</code>). When a script is spread across multiple code notes (descendant code notes loaded as modules via <code>require()</code>), every note in the bundle shares the same <code>startNote</code>, while <code>currentNote</code> differs per note. Messages from <code>api.log()</code> are grouped under this note.</p></td></tr><tr><td><code>currentNote</code></td><td><p><code>FNote</code><br>Note containing the source code that is currently executing (in C terms, <code>__FILE__</code>). Equal to <code>startNote</code> unless execution has moved into a descendant module note loaded via <code>require()</code>. Don't confuse this with the note open in the UI — use <code>api.getActiveContextNote()</code> for that.</p></td></tr><tr><td><code>originEntity</code></td><td><p><code>unknown</code><br>Entity whose event triggered this execution, or <code>null</code>. Most frontend scripts are started by the user or by the UI (startup scripts, widgets), so this is usually <code>null</code>. It is set to a note when: - the script runs through a <code>~renderNote</code> relation — then it's the note being rendered (the one carrying the relation), not the script note; - a backend script calls <code>api.runOnFrontend()</code> — then it's the backend execution's <code>originEntity</code>, provided that entity was a note.</p></td></tr><tr><td><code>dayjs</code></td><td><p><code>Dayjs</code><br>day.js library for date manipulation. See <code>https://day.js.org</code> for documentation</p></td></tr><tr><td><code>RightPanelWidget</code></td><td><p><code>WidgetClass&lt;RightPanelWidget&gt;</code><br>Base class for right-panel widgets — <code>class X extends api.RightPanelWidget { … }</code>.</p></td></tr><tr><td><code>NoteContextAwareWidget</code></td><td><p><code>WidgetClass&lt;NoteContextAwareWidget&gt;</code><br>Base class for note-context-aware widgets — <code>class X extends api.NoteContextAwareWidget { … }</code>.</p></td></tr><tr><td><code>BasicWidget</code></td><td><p><code>WidgetClass&lt;BasicWidget&gt;</code><br>Base class for basic widgets — <code>class X extends api.BasicWidget { … }</code>.</p></td></tr><tr><td><code>activateNote</code></td><td><pre><code class=\"language-application-typescript\">activateNote(notePath: string): Promise&lt;void&gt;</code></pre><p>Activates note in the tree and in the note detail.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>notePath</code></td><td><code>string</code><br>(or noteId)</td></tr></tbody></table></figure></td></tr><tr><td><code>activateNewNote</code></td><td><pre><code class=\"language-application-typescript\">activateNewNote(notePath: string): Promise&lt;void&gt;</code></pre><p>Activates newly created note. Compared to this.activateNote() also makes sure that frontend has been fully synced.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>notePath</code></td><td><code>string</code><br>(or noteId)</td></tr></tbody></table></figure></td></tr><tr><td><code>openTabWithNote</code></td><td><pre><code class=\"language-application-typescript\">openTabWithNote(notePath: string, activate: boolean): Promise&lt;void&gt;</code></pre><p>Open a note in a new tab.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>notePath</code></td><td><code>string</code><br>(or noteId)</td></tr><tr><td><code>activate</code></td><td><code>boolean</code><br>set to true to activate the new tab, false to stay on the current tab</td></tr></tbody></table></figure></td></tr><tr><td><code>openSplitWithNote</code></td><td><pre><code class=\"language-application-typescript\">openSplitWithNote(notePath: string, activate: boolean): Promise&lt;void&gt;</code></pre><p>Open a note in a new split.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>notePath</code></td><td><code>string</code><br>(or noteId)</td></tr><tr><td><code>activate</code></td><td><code>boolean</code><br>set to true to activate the new split, false to stay on the current split</td></tr></tbody></table></figure></td></tr><tr><td><code>runOnBackend</code></td><td><pre><code class=\"language-application-typescript\">runOnBackend(func: Func, params?: unknown[]): Promise&lt;unknown&gt;</code></pre><p>Executes given anonymous function on the backend. Internally this serializes the anonymous function into string and sends it to backend via AJAX. Please make sure that the supplied function is synchronous. Only sync functions will work correctly with transaction management. If you really know what you're doing, you can call api.runAsyncOnBackendWithManualTransactionHandling()</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>func</code></td><td><code>Func</code><br>(synchronous) function to be executed on the backend</td></tr><tr><td><code>params</code><br><em>optional</em></td><td><code>unknown[]</code><br>list of parameters to the anonymous function to be sent to backend</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;unknown&gt;</code>: return value of the executed function on the backend</p></td></tr><tr><td><code>runAsyncOnBackendWithManualTransactionHandling</code></td><td><pre><code class=\"language-application-typescript\">runAsyncOnBackendWithManualTransactionHandling(func: Func, params?: unknown[]): Promise&lt;unknown&gt;</code></pre><p>Executes given anonymous function on the backend. Internally this serializes the anonymous function into string and sends it to backend via AJAX. This function is meant for advanced needs where an async function is necessary. In this case, the automatic request-scoped transaction management is not applied, and you need to manually define transaction via api.transactional().</p><p>If you have a synchronous function, please use api.runOnBackend().</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>func</code></td><td><code>Func</code><br>(synchronous) function to be executed on the backend</td></tr><tr><td><code>params</code><br><em>optional</em></td><td><code>unknown[]</code><br>list of parameters to the anonymous function to be sent to backend</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;unknown&gt;</code>: return value of the executed function on the backend</p></td></tr><tr><td><code>isBackendScriptingEnabled</code></td><td><pre><code class=\"language-application-typescript\">isBackendScriptingEnabled(): boolean</code></pre><p>Whether backend script execution is enabled on the server (the <code>[Security] backendScriptingEnabled</code> config toggle). When it's disabled, <code>api.runOnBackend()</code> / <code>api.runAsyncOnBackendWithManualTransactionHandling()</code> reject with a \"Backend script execution is disabled\" error, so check this first to let a script degrade gracefully instead of throwing.</p></td></tr><tr><td><code>isSqlConsoleEnabled</code></td><td><pre><code class=\"language-application-typescript\">isSqlConsoleEnabled(): boolean</code></pre><p>Whether the SQL console is enabled on the server (the <code>[Security] sqlConsoleEnabled</code> config toggle). When it's disabled, backend scripts that run raw SQL (<code>api.sql.*</code>) fail, so check this before invoking SQL-backed logic via <code>api.runOnBackend()</code>.</p></td></tr><tr><td><code>searchForNotes</code></td><td><pre><code class=\"language-application-typescript\">searchForNotes(searchString: string): Promise&lt;FNote[]&gt;</code></pre><p>This is a powerful search method - you can search by attributes and their values, e.g.: \"#dateModified =* MONTH AND #log\". See full documentation for all options at: <a href=\"https://triliumnext.github.io/Docs/Wiki/search.html\">https://triliumnext.github.io/Docs/Wiki/search.html</a></p></td></tr><tr><td><code>searchForNote</code></td><td><pre><code class=\"language-application-typescript\">searchForNote(searchString: string): Promise&lt;FNote | null&gt;</code></pre><p>This is a powerful search method - you can search by attributes and their values, e.g.: \"#dateModified =* MONTH AND #log\". See full documentation for all options at: <a href=\"https://triliumnext.github.io/Docs/Wiki/search.html\">https://triliumnext.github.io/Docs/Wiki/search.html</a></p></td></tr><tr><td><code>getNote</code></td><td><pre><code class=\"language-application-typescript\">getNote(noteId: string): Promise&lt;FNote | null&gt;</code></pre><p>Returns note by given noteId. If note is missing from the cache, it's loaded.</p></td></tr><tr><td><code>getNotes</code></td><td><pre><code class=\"language-application-typescript\">getNotes(noteIds: string[], silentNotFoundError?: boolean): Promise&lt;FNote[]&gt;</code></pre><p>Returns list of notes. If note is missing from the cache, it's loaded.</p><p>This is often used to bulk-fill the cache with notes which would have to be picked one by one otherwise (by e.g. createLink())</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>noteIds</code></td><td><code>string[]</code></td></tr><tr><td><code>silentNotFoundError</code><br><em>optional</em></td><td><code>boolean</code><br>don't report error if the note is not found</td></tr></tbody></table></figure></td></tr><tr><td><code>reloadNotes</code></td><td><pre><code class=\"language-application-typescript\">reloadNotes(noteIds: string[]): Promise&lt;void&gt;</code></pre><p>Update frontend tree (note) cache from the backend.</p></td></tr><tr><td><code>createNote</code></td><td><pre><code class=\"language-application-typescript\">createNote(parentNotePath: string, opts?: CreateNoteOpts): Promise&lt;{ note: FNote | null; branch: FBranch | undefined }&gt;</code></pre><p>Creates a new note as a child of the given parent, entirely on the frontend — no backend scripting required (unlike <code>api.runOnBackend(() =&gt; api.createTextNote(...))</code>). By default the new note is activated in the current tab with its title focused for editing; pass <code>{ activate: false }</code> to create it silently.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>parentNotePath</code></td><td><code>string</code><br>note path (or noteId) of the parent under which to create the note</td></tr><tr><td><code>opts</code><br><em>optional</em></td><td><code>CreateNoteOpts</code><br>creation options — e.g. <code>{ title, content, type, mime, activate }</code></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;{ note: FNote | null; branch: FBranch | undefined }&gt;</code>: the created note and its branch, resolved from the frontend cache</p></td></tr><tr><td><code>getInstanceName</code></td><td><pre><code class=\"language-application-typescript\">getInstanceName(): string | null</code></pre><p>Instance name identifies particular Trilium instance. It can be useful for scripts if some action needs to happen on only one specific instance.</p></td></tr><tr><td><code>addTextToActiveContextEditor</code></td><td><pre><code class=\"language-application-typescript\">addTextToActiveContextEditor(text: string): void</code></pre><p>Adds given text to the editor cursor</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>text</code></td><td><code>string</code><br>this must be clear text, HTML is not supported.</td></tr></tbody></table></figure></td></tr><tr><td><code>getActiveContextNote</code></td><td><pre><code class=\"language-application-typescript\">getActiveContextNote(): FNote</code></pre><p><strong>Returns</strong> <code>FNote</code>: active note (loaded into center pane)</p></td></tr><tr><td><code>getActiveContext</code></td><td><pre><code class=\"language-application-typescript\">getActiveContext(): NoteContext</code></pre><p>Obtains the currently active/focused split in the current tab.</p><p>Note that this method does not return the note context of the \"Quick edit\" panel, it will return the note context behind it.</p></td></tr><tr><td><code>getActiveMainContext</code></td><td><pre><code class=\"language-application-typescript\">getActiveMainContext(): NoteContext</code></pre><p>Obtains the main context of the current tab. This is the left-most split.</p><p>Note that this method does not return the note context of the \"Quick edit\" panel, it will return the note context behind it.</p></td></tr><tr><td><code>getNoteContexts</code></td><td><pre><code class=\"language-application-typescript\">getNoteContexts(): NoteContext[]</code></pre><p><strong>Returns</strong> <code>NoteContext[]</code>: returns all note contexts (splits) in all tabs</p></td></tr><tr><td><code>getMainNoteContexts</code></td><td><pre><code class=\"language-application-typescript\">getMainNoteContexts(): NoteContext[]</code></pre><p><strong>Returns</strong> <code>NoteContext[]</code>: returns all main contexts representing tabs</p></td></tr><tr><td><code>getActiveContextTextEditor</code></td><td><pre><code class=\"language-application-typescript\">getActiveContextTextEditor(): Promise&lt;unknown&gt;</code></pre><p>See <a href=\"https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html\">https://ckeditor.com/docs/ckeditor5/latest/api/module_core_editor_editor-Editor.html</a> for documentation on the returned instance.</p><p><strong>Returns</strong> <code>Promise&lt;unknown&gt;</code>: instance of CKEditor</p></td></tr><tr><td><code>getActiveContextCodeEditor</code></td><td><pre><code class=\"language-application-typescript\">getActiveContextCodeEditor(): Promise&lt;unknown&gt;</code></pre><p>See <a href=\"https://codemirror.net/doc/manual.html#api\">https://codemirror.net/doc/manual.html#api</a></p><p><strong>Returns</strong> <code>Promise&lt;unknown&gt;</code>: instance of CodeMirror</p></td></tr><tr><td><code>getActiveNoteDetailWidget</code></td><td><pre><code class=\"language-application-typescript\">getActiveNoteDetailWidget(): Promise&lt;unknown&gt;</code></pre><p>Get access to the widget handling note detail. Methods like <code>getWidgetType()</code> and <code>getTypeWidget()</code> to get to the implementation of actual widget type.</p></td></tr><tr><td><code>getActiveContextNotePath</code></td><td><pre><code class=\"language-application-typescript\">getActiveContextNotePath(): string | null</code></pre><p><strong>Returns</strong> <code>string | null</code>: returns a note path of active note or null if there isn't active note</p></td></tr><tr><td><code>getComponentByEl</code></td><td><pre><code class=\"language-application-typescript\">getComponentByEl(el: HTMLElement): unknown</code></pre><p>Returns component which owns the given DOM element (the nearest parent component in DOM tree)</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>el</code></td><td><code>HTMLElement</code><br>DOM element</td></tr></tbody></table></figure></td></tr><tr><td><code>showMessage</code></td><td><pre><code class=\"language-application-typescript\">showMessage(message: string, delay?: number): void</code></pre><p>Show an info toast message to the user.</p></td></tr><tr><td><code>showError</code></td><td><pre><code class=\"language-application-typescript\">showError(message: string, delay?: number): void</code></pre><p>Show an error toast message to the user.</p></td></tr><tr><td><code>showInfoDialog</code></td><td><pre><code class=\"language-application-typescript\">showInfoDialog(message: string): Promise&lt;void&gt;</code></pre><p>Show an info dialog to the user.</p></td></tr><tr><td><code>showConfirmDialog</code></td><td><pre><code class=\"language-application-typescript\">showConfirmDialog(message: string): Promise&lt;boolean&gt;</code></pre><p>Show confirm dialog to the user.</p><p><strong>Returns</strong> <code>Promise&lt;boolean&gt;</code>: promise resolving to true if the user confirmed</p></td></tr><tr><td><code>showPromptDialog</code></td><td><pre><code class=\"language-application-typescript\">showPromptDialog(props: { title?: string; message?: string; defaultValue?: string }): Promise&lt;string | null&gt;</code></pre><p>Show prompt dialog to the user.</p><p><strong>Returns</strong> <code>Promise&lt;string | null&gt;</code>: promise resolving to the answer provided by the user</p></td></tr><tr><td><code>pickSingleItem</code></td><td><pre><code class=\"language-application-typescript\">pickSingleItem(props: { title?: string; items: PickerItem[] | PickerItemGroup[]; placeholder?: string }): Promise&lt;PickerItem | null&gt;</code></pre><p>Show a dialog for picking one item out of many, grouped and searchable.</p><p><code>items</code> are either the items themselves or groups of them, never the two mixed. Named for the one thing it does now: picking several at once will be a method of its own beside this.</p><p><strong>Returns</strong> <code>Promise&lt;PickerItem | null&gt;</code>: promise resolving to the item picked, or null where the user backed out.</p></td></tr><tr><td><code>createLink</code></td><td><pre><code class=\"language-application-typescript\">createLink(notePath: string, params?: Record&lt;string, unknown&gt;): unknown</code></pre><p>Create a note link (jQuery object) for given note.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>notePath</code></td><td><code>string</code><br>(or noteId)</td></tr><tr><td><code>params</code><br><em>optional</em></td><td><code>Record&lt;string, unknown&gt;</code></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>unknown</code>: - jQuery element with the link (wrapped in <span>)</span></p></td></tr><tr><td><code>createNoteLink</code></td><td><pre><code class=\"language-application-typescript\">createNoteLink(notePath: string, params?: Record&lt;string, unknown&gt;): unknown</code></pre><aside class=\"admonition warning\"><p>Deprecated. - use api.createLink() instead</p></aside></td></tr><tr><td><code>triggerCommand</code></td><td><pre><code class=\"language-application-typescript\">triggerCommand(name: string, data?: Record&lt;string, unknown&gt;): Promise&lt;unknown&gt;</code></pre><p>Trigger command. This is a very low-level API which should be avoided if possible.</p></td></tr><tr><td><code>triggerEvent</code></td><td><pre><code class=\"language-application-typescript\">triggerEvent(name: string, data?: Record&lt;string, unknown&gt;): Promise&lt;unknown&gt;</code></pre><p>Trigger event. This is a very low-level API which should be avoided if possible.</p></td></tr><tr><td><code>setupElementTooltip</code></td><td><pre><code class=\"language-application-typescript\">setupElementTooltip(el: unknown): void</code></pre><p>Shows a preview of the linked note while the mouse pointer rests on the element, as Trilium does for links in note content. The element must be a link whose <code>href</code> or <code>data-href</code> points to a note, such as <code>#root/abc123</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>el</code></td><td><code>unknown</code><br>The link, as a jQuery object.</td></tr></tbody></table></figure></td></tr><tr><td><code>protectNote</code></td><td><pre><code class=\"language-application-typescript\">protectNote(noteId: string, protect: boolean): Promise&lt;void&gt;</code></pre><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>noteId</code></td><td><code>string</code></td></tr><tr><td><code>protect</code></td><td><code>boolean</code><br>true to protect note, false to unprotect</td></tr></tbody></table></figure></td></tr><tr><td><code>protectSubTree</code></td><td><pre><code class=\"language-application-typescript\">protectSubTree(noteId: string, protect: boolean): Promise&lt;void&gt;</code></pre><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>noteId</code></td><td><code>string</code></td></tr><tr><td><code>protect</code></td><td><code>boolean</code><br>true to protect subtree, false to unprotect</td></tr></tbody></table></figure></td></tr><tr><td><code>getTodayNote</code></td><td><pre><code class=\"language-application-typescript\">getTodayNote(): Promise&lt;FNote&gt;</code></pre><p>Returns date-note for today. If it doesn't exist, it is automatically created.</p></td></tr><tr><td><code>getDayNote</code></td><td><pre><code class=\"language-application-typescript\">getDayNote(date: string): Promise&lt;FNote&gt;</code></pre><p>Returns day note for a given date. If it doesn't exist, it is automatically created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>e.g. \"2019-04-29\"</td></tr></tbody></table></figure></td></tr><tr><td><code>getWeekFirstDayNote</code></td><td><pre><code class=\"language-application-typescript\">getWeekFirstDayNote(date: string): Promise&lt;FNote&gt;</code></pre><p>Returns day note for the first date of the week of the given date. If it doesn't exist, it is automatically created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>e.g. \"2019-04-29\"</td></tr></tbody></table></figure></td></tr><tr><td><code>getWeekNote</code></td><td><pre><code class=\"language-application-typescript\">getWeekNote(date: string): Promise&lt;FNote&gt;</code></pre><p>Returns week note for given date. If such a note doesn't exist, it is automatically created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM-DD format</td></tr></tbody></table></figure></td></tr><tr><td><code>getMonthNote</code></td><td><pre><code class=\"language-application-typescript\">getMonthNote(month: string): Promise&lt;FNote&gt;</code></pre><p>Returns month-note. If it doesn't exist, it is automatically created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>month</code></td><td><code>string</code><br>e.g. \"2019-04\"</td></tr></tbody></table></figure></td></tr><tr><td><code>getQuarterNote</code></td><td><pre><code class=\"language-application-typescript\">getQuarterNote(date: string): Promise&lt;FNote&gt;</code></pre><p>Returns quarter note for given date. If such a note doesn't exist, it is automatically created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM format</td></tr></tbody></table></figure></td></tr><tr><td><code>getYearNote</code></td><td><pre><code class=\"language-application-typescript\">getYearNote(year: string): Promise&lt;FNote&gt;</code></pre><p>Returns year-note. If it doesn't exist, it is automatically created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>year</code></td><td><code>string</code><br>e.g. \"2019\"</td></tr></tbody></table></figure></td></tr><tr><td><code>setHoistedNoteId</code></td><td><pre><code class=\"language-application-typescript\">setHoistedNoteId(noteId: string): void</code></pre><p>Hoist note in the current tab. See <a href=\"https://triliumnext.github.io/Docs/Wiki/note-hoisting.html\">https://triliumnext.github.io/Docs/Wiki/note-hoisting.html</a></p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>noteId</code></td><td><code>string</code><br>set hoisted note. 'root' will effectively unhoist</td></tr></tbody></table></figure></td></tr><tr><td><code>bindGlobalShortcut</code></td><td><pre><code class=\"language-application-typescript\">bindGlobalShortcut(keyboardShortcut: string, handler: () =&gt; void, namespace?: string): void</code></pre><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>keyboardShortcut</code></td><td><code>string</code><br>e.g. \"ctrl+shift+a\"</td></tr><tr><td><code>handler</code></td><td><code>() =&gt; void</code></td></tr><tr><td><code>namespace</code><br><em>optional</em></td><td><code>string</code><br>specify namespace of the handler for the cases where call for bind may be repeated. If a handler with this ID exists, it's replaced by the new handler.</td></tr></tbody></table></figure></td></tr><tr><td><code>waitUntilSynced</code></td><td><pre><code class=\"language-application-typescript\">waitUntilSynced(): Promise&lt;unknown&gt;</code></pre><p>Trilium runs in a backend and frontend process, when something is changed on the backend from a script, frontend will get asynchronously synchronized.</p><p>This method returns a promise which resolves once all the backend -&gt; frontend synchronization is finished. Typical use case is when a new note has been created, we should wait until it is synced into frontend and only then activate it.</p></td></tr><tr><td><code>refreshIncludedNote</code></td><td><pre><code class=\"language-application-typescript\">refreshIncludedNote(includedNoteId: string): void</code></pre><p>This will refresh all currently opened notes which have included note specified in the parameter</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>includedNoteId</code></td><td><code>string</code><br>noteId of the included note</td></tr></tbody></table></figure></td></tr><tr><td><code>randomString</code></td><td><pre><code class=\"language-application-typescript\">randomString(length: number): string</code></pre><p>Return randomly generated string of given length. This random string generation is NOT cryptographically secure.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>length</code></td><td><code>number</code><br>of the string</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>string</code>: random string</p></td></tr><tr><td><code>formatSize</code></td><td><pre><code class=\"language-application-typescript\">formatSize(size: number): string</code></pre><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>size</code></td><td><code>number</code><br>in bytes</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>string</code>: formatted string</p></td></tr><tr><td><code>formatNoteSize</code></td><td><pre><code class=\"language-application-typescript\">formatNoteSize(size: number): string</code></pre><aside class=\"admonition warning\"><p>Deprecated. - use api.formatSize()</p></aside><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>size</code></td><td><code>number</code><br>in bytes</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>string</code>: formatted string</p></td></tr><tr><td><code>htmlToMarkdown</code></td><td><pre><code class=\"language-application-typescript\">htmlToMarkdown(html: string): Promise&lt;string&gt;</code></pre><p>Converts the given HTML string to Markdown.</p><p>Unlike the backend API, this runs on the server (the HTML→Markdown converter is backend-only), so it returns a promise.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>html</code></td><td><code>string</code><br>HTML content to convert</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;string&gt;</code>: Markdown representation of the input HTML</p></td></tr><tr><td><code>markdownToHtml</code></td><td><pre><code class=\"language-application-typescript\">markdownToHtml(markdown: string): Promise&lt;string&gt;</code></pre><p>Converts the given Markdown string to HTML.</p><p>Runs entirely in the browser; the promise is only needed because the Markdown renderer is loaded on demand.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>markdown</code></td><td><code>string</code><br>Markdown content to convert</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;string&gt;</code>: HTML representation of the input Markdown</p></td></tr><tr><td><code>formatDateISO</code></td><td><pre><code class=\"language-application-typescript\">formatDateISO(date: Date): string</code></pre><p><strong>Returns</strong> <code>string</code>: date in YYYY-MM-DD format</p></td></tr><tr><td><code>parseDate</code></td><td><pre><code class=\"language-application-typescript\">parseDate(str: string): Date</code></pre><p>Parses a date string into a Date.</p></td></tr><tr><td><code>logMessages</code></td><td><p><code>Record&lt;string, string[]&gt;</code><br>Per-note log message buffers shown in the UI log pane.</p></td></tr><tr><td><code>logSpacedUpdates</code></td><td><p><code>Record&lt;string, unknown&gt;</code><br>Per-note spaced-update handlers for the log pane.</p></td></tr><tr><td><code>log</code></td><td><pre><code class=\"language-application-typescript\">log(...args: unknown[]): void</code></pre><p>Log given message to the log pane in UI. Accepts multiple arguments which are joined with spaces, similar to <code>console.log</code>.</p></td></tr><tr><td><code>preact</code></td><td><p><code>unknown</code><br>The Preact API surface (components, hooks) for render scripts.</p></td></tr></tbody></table></figure><h2><code>FNote</code></h2><p>A note as seen by frontend scripts (subset of the client's <code>FNote</code>).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>noteId</code></td><td><p><code>string</code><br>The ID of the note.</p></td></tr><tr><td><code>title</code></td><td><p><code>string</code><br>The title of the note. For a protected note, it is <code>[protected]</code> until a protected session is started.</p></td></tr><tr><td><code>type</code></td><td><p><code>string</code><br>The note type, such as <code>text</code>, <code>code</code>, <code>file</code>, <code>image</code>, <code>search</code>, <code>book</code>, <code>render</code> or <code>launcher</code>.</p></td></tr><tr><td><code>mime</code></td><td><p><code>string</code><br>The MIME type of the note's content, such as <code>application/json</code>.</p></td></tr><tr><td><code>isProtected</code></td><td><p><code>boolean</code><br>Whether the note is protected (encrypted).</p></td></tr><tr><td><code>isArchived</code></td><td><p><code>boolean</code><br>Whether the note is archived (has the <code>archived</code> label).</p></td></tr><tr><td><code>isMetadataReadOnly</code></td><td><p><code>boolean</code><br>Whether the note's title and icon cannot be edited, which is the case for the system notes behind the options, the in-app help and the launch bar configuration.</p></td></tr><tr><td><code>attributes</code></td><td><p><code>string[]</code><br>IDs of this note's owned attributes.</p></td></tr><tr><td><code>targetRelations</code></td><td><p><code>string[]</code><br>IDs of relations pointing <em>at</em> this note.</p></td></tr><tr><td><code>parents</code></td><td><p><code>string[]</code><br>Parent note IDs.</p></td></tr><tr><td><code>children</code></td><td><p><code>string[]</code><br>Child note IDs.</p></td></tr><tr><td><code>getParentNotes</code></td><td><pre><code class=\"language-application-typescript\">getParentNotes(): FNote[]</code></pre><p>Returns the parent notes that the client has already loaded. A parent that is not loaded is skipped, and a search note that shows this note in its results counts as a parent.</p></td></tr><tr><td><code>getChildNotes</code></td><td><pre><code class=\"language-application-typescript\">getChildNotes(): Promise&lt;FNote[]&gt;</code></pre><p>Loads any missing child notes from the server, then returns all child notes in tree order. Archived children are included.</p></td></tr><tr><td><code>getParentNoteIds</code></td><td><pre><code class=\"language-application-typescript\">getParentNoteIds(): string[]</code></pre><p>Returns the IDs of the parent notes. The returned array is the note's own list, so do not change it.</p></td></tr><tr><td><code>getChildNoteIds</code></td><td><pre><code class=\"language-application-typescript\">getChildNoteIds(): string[]</code></pre><p>Returns the IDs of the child notes in tree order, archived ones included. The returned array is the note's own list, so do not change it.</p></td></tr><tr><td><code>getChildNoteIdsWithArchiveFiltering</code></td><td><pre><code class=\"language-application-typescript\">getChildNoteIdsWithArchiveFiltering(includeArchived?: boolean): Promise&lt;string[]&gt;</code></pre><p>Returns the IDs of the child notes in tree order, leaving out archived notes unless <code>includeArchived</code> is <code>true</code>. Leaving out archived notes takes a search on the server; for a search note or a note in the hidden subtree, all children are returned.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>includeArchived</code><br><em>optional</em></td><td><code>boolean</code><br>whether to keep archived children. Defaults to <code>false</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>getSubtreeNotes</code></td><td><pre><code class=\"language-application-typescript\">getSubtreeNotes(): Promise&lt;FNote[]&gt;</code></pre><p>Returns all descendants of the note, loading missing ones from the server one level at a time. An archived note and everything below it are left out, and the note itself is not included.</p></td></tr><tr><td><code>getSubtreeNoteIds</code></td><td><pre><code class=\"language-application-typescript\">getSubtreeNoteIds(includeArchived?: boolean): Promise&lt;string[]&gt;</code></pre><p>Returns the IDs of all the note's descendants, depth-first, without the note itself. Archived notes and the notes below them are left out unless <code>includeArchived</code> is <code>true</code>.</p></td></tr><tr><td><code>hasChildren</code></td><td><pre><code class=\"language-application-typescript\">hasChildren(): boolean</code></pre><p>Returns <code>true</code> if the note has at least one child, archived ones included. For a search note, the results count as children only once they are loaded.</p></td></tr><tr><td><code>hasAncestor</code></td><td><pre><code class=\"language-application-typescript\">hasAncestor(ancestorNoteId: string, followTemplates?: boolean): boolean</code></pre><p>Returns <code>true</code> if the note with the given ID is this note or one of its ancestors. It walks only parents the client has already loaded.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>ancestorNoteId</code></td><td><code>string</code></td></tr><tr><td><code>followTemplates</code><br><em>optional</em></td><td><code>boolean</code><br>whether to also walk up from the notes this note takes attributes from through <code>~template</code> and <code>~inherit</code> relations. Defaults to <code>false</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>isRoot</code></td><td><pre><code class=\"language-application-typescript\">isRoot(): boolean</code></pre><p>Returns <code>true</code> if this is the root note of the tree.</p></td></tr><tr><td><code>getParentBranchIds</code></td><td><pre><code class=\"language-application-typescript\">getParentBranchIds(): string[]</code></pre><p>Returns the IDs of the branches that place this note under each of its parents.</p></td></tr><tr><td><code>getBranchIds</code></td><td><pre><code class=\"language-application-typescript\">getBranchIds(): string[]</code></pre><p>Returns the IDs of the branches that place the note under its parents.</p><aside class=\"admonition warning\"><p>Deprecated. Use <code>getParentBranchIds()</code> instead.</p></aside></td></tr><tr><td><code>getParentBranches</code></td><td><pre><code class=\"language-application-typescript\">getParentBranches(): FBranch[]</code></pre><p>Returns the branches that place this note under each of its parents. A branch the client has not loaded is skipped.</p></td></tr><tr><td><code>getChildBranches</code></td><td><pre><code class=\"language-application-typescript\">getChildBranches(): FBranch[]</code></pre><p>Returns the branches to this note's children, in tree order. A branch the client has not loaded is skipped.</p></td></tr><tr><td><code>getBranches</code></td><td><pre><code class=\"language-application-typescript\">getBranches(): FBranch[]</code></pre><p>Returns the branches that place the note under its parents.</p><aside class=\"admonition warning\"><p>Deprecated. Use <code>getParentBranches()</code> instead.</p></aside></td></tr><tr><td><code>getFilteredChildBranches</code></td><td><pre><code class=\"language-application-typescript\">getFilteredChildBranches(): FBranch[]</code></pre><p>Returns the same branches as <code>getChildBranches()</code>. Despite the name, archived children are not filtered out.</p></td></tr><tr><td><code>getAllNotePaths</code></td><td><pre><code class=\"language-application-typescript\">getAllNotePaths(): string[][]</code></pre><p>Returns every path from the root to the note, each as a list of note IDs that starts with <code>root</code>. Paths that pass through a search note are left out.</p></td></tr><tr><td><code>getBestNotePath</code></td><td><pre><code class=\"language-application-typescript\">getBestNotePath(hoistedNoteId?: string, activeNotePath?: string | null): string[]</code></pre><p>Returns the note's best path as a list of note IDs that starts with <code>root</code>. Paths inside the hoisted note's subtree come first, then paths without archived or hidden notes; among equal paths, the one sharing the longest start with <code>activeNotePath</code> wins, then the shortest.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>hoistedNoteId</code><br><em>optional</em></td><td><code>string</code><br>The hoisted note, <code>root</code> by default.</td></tr><tr><td><code>activeNotePath</code><br><em>optional</em></td><td><code>string | null</code><br>The path of the active note, as note IDs joined by <code>/</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>getBestNotePathString</code></td><td><pre><code class=\"language-application-typescript\">getBestNotePathString(hoistedNoteId?: string): string</code></pre><p>Returns the note's best path, as <code>getBestNotePath()</code> chooses it, as note IDs joined by <code>/</code>, such as <code>root/a1h315/js725h</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>hoistedNoteId</code><br><em>optional</em></td><td><code>string</code><br>The hoisted note, <code>root</code> by default.</td></tr></tbody></table></figure></td></tr><tr><td><code>getSortedNotePathRecords</code></td><td><pre><code class=\"language-application-typescript\">getSortedNotePathRecords(hoistedNoteId?: string, activeNotePath?: string | null): NotePathRecord[]</code></pre><p>Returns every path from the root to this note, best first. Paths inside the hoisted note come first, then paths that do not pass through an archived note or the hidden subtree, then paths that share the most with <code>activeNotePath</code>, then shorter paths. Paths through search notes are left out, and only parents the client has loaded are followed.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>hoistedNoteId</code><br><em>optional</em></td><td><code>string</code><br>the ID of the hoisted note. Defaults to <code>root</code>.</td></tr><tr><td><code>activeNotePath</code><br><em>optional</em></td><td><code>string | null</code><br>a note path such as <code>root/abc123/def456</code>, used to prefer paths close to it.</td></tr></tbody></table></figure></td></tr><tr><td><code>getAttributes</code></td><td><pre><code class=\"language-application-typescript\">getAttributes(type?: string, name?: string): Attribute[]</code></pre><p>Returns the note's attributes, including inherited ones, optionally only those of the given type and name. The note's own attributes come first, then the ones inherited from its parents, then the ones from its templates.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code><br><em>optional</em></td><td><code>string</code><br><code>label</code> or <code>relation</code>; any other value throws an error.</td></tr><tr><td><code>name</code><br><em>optional</em></td><td><code>string</code><br>The attribute name, without the <code>#</code> or <code>~</code> prefix.</td></tr></tbody></table></figure></td></tr><tr><td><code>getOwnedAttributes</code></td><td><pre><code class=\"language-application-typescript\">getOwnedAttributes(type?: string, name?: string): Attribute[]</code></pre><p>Returns the note's own attributes, without inherited ones, optionally only those of the given type and name.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code><br><em>optional</em></td><td><code>string</code><br><code>label</code> or <code>relation</code>; any other value throws an error.</td></tr><tr><td><code>name</code><br><em>optional</em></td><td><code>string</code><br>The attribute name, without the <code>#</code> or <code>~</code> prefix.</td></tr></tbody></table></figure></td></tr><tr><td><code>getAttribute</code></td><td><pre><code class=\"language-application-typescript\">getAttribute(type: string, name: string): Attribute | null</code></pre><p>Returns the first attribute of the given type and name, including inherited ones, or <code>undefined</code> if the note has none.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>getOwnedAttribute</code></td><td><pre><code class=\"language-application-typescript\">getOwnedAttribute(type: string, name: string): Attribute | null</code></pre><p>Returns the first of the note's own attributes with the given type and name, or <code>undefined</code> if the note has none.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>getAttributeValue</code></td><td><pre><code class=\"language-application-typescript\">getAttributeValue(type: string, name: string): string | null</code></pre><p>Returns the value of the first attribute of the given type and name, including inherited ones, or <code>null</code> if the note has none.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>getOwnedAttributeValue</code></td><td><pre><code class=\"language-application-typescript\">getOwnedAttributeValue(type: string, name: string): string | null</code></pre><p>Returns the value of the first of the note's own attributes with the given type and name, or <code>null</code> if the note has none.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>hasAttribute</code></td><td><pre><code class=\"language-application-typescript\">hasAttribute(type: string, name: string): boolean</code></pre><p>Returns whether the note has an attribute of the given type and name, including inherited ones.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>hasOwnedAttribute</code></td><td><pre><code class=\"language-application-typescript\">hasOwnedAttribute(type: string, name: string): boolean</code></pre><p>Returns whether the note itself has an attribute of the given type and name, without inherited ones.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>getAttributeDefinitions</code></td><td><pre><code class=\"language-application-typescript\">getAttributeDefinitions(): Attribute[]</code></pre><p>Returns the attribute definitions that apply to the note, at most one per defined name. When the note gets a definition from several places, such as its own, an ancestor's and a template's, the nearest one wins, in the order <code>getAttributes()</code> lists them.</p></td></tr><tr><td><code>getPromotedDefinitionAttributes</code></td><td><pre><code class=\"language-application-typescript\">getPromotedDefinitionAttributes(): Attribute[]</code></pre><p>Returns the attribute definitions that are marked as promoted, at most one per name, grouped by the note that owns them and ordered by position. Returns an empty array if the note has a truthy <code>hidePromotedAttributes</code> label.</p></td></tr><tr><td><code>getLabels</code></td><td><pre><code class=\"language-application-typescript\">getLabels(name?: string): Attribute[]</code></pre><p>Returns the note's labels, including inherited ones, optionally only those with <code>name</code>.</p></td></tr><tr><td><code>getOwnedLabels</code></td><td><pre><code class=\"language-application-typescript\">getOwnedLabels(name?: string): Attribute[]</code></pre><p>Returns the note's own labels, without inherited ones, optionally only those with <code>name</code>.</p></td></tr><tr><td><code>getLabel</code></td><td><pre><code class=\"language-application-typescript\">getLabel(name: string): Attribute | null</code></pre><p>Returns the first label with the given name, including inherited ones, or <code>undefined</code> if the note has none.</p></td></tr><tr><td><code>getOwnedLabel</code></td><td><pre><code class=\"language-application-typescript\">getOwnedLabel(name: string): Attribute | null</code></pre><p>Returns the first of the note's own labels with the given name, or <code>undefined</code> if the note has none.</p></td></tr><tr><td><code>getLabelValue</code></td><td><pre><code class=\"language-application-typescript\">getLabelValue(name: string): string | null</code></pre><p>Returns the value of the first label with the given name, including inherited ones, or <code>null</code> if the note has none.</p></td></tr><tr><td><code>getOwnedLabelValue</code></td><td><pre><code class=\"language-application-typescript\">getOwnedLabelValue(name: string): string | null</code></pre><p>Returns the value of the first of the note's own labels with the given name, or <code>null</code> if the note has none.</p></td></tr><tr><td><code>hasLabel</code></td><td><pre><code class=\"language-application-typescript\">hasLabel(name: string): boolean</code></pre><p>Returns whether the note has a label with the given name, including inherited ones.</p></td></tr><tr><td><code>hasOwnedLabel</code></td><td><pre><code class=\"language-application-typescript\">hasOwnedLabel(name: string): boolean</code></pre><p>Returns whether the note itself has a label with the given name, without inherited ones.</p></td></tr><tr><td><code>hasLabelOrDisabled</code></td><td><pre><code class=\"language-application-typescript\">hasLabelOrDisabled(name: string): boolean</code></pre><p>Returns whether the note has a label with the given name, including inherited ones, or the same label with the <code>disabled:</code> prefix, which a safe import gives it.</p></td></tr><tr><td><code>isLabelTruthy</code></td><td><pre><code class=\"language-application-typescript\">isLabelTruthy(name: string): boolean</code></pre><p>Returns whether the note has a label with the given name, including inherited ones, whose value is anything but <code>false</code>. A label without a value counts as true.</p></td></tr><tr><td><code>getRelations</code></td><td><pre><code class=\"language-application-typescript\">getRelations(name?: string): Attribute[]</code></pre><p>Returns the note's relations, including inherited ones, optionally only those with <code>name</code>.</p></td></tr><tr><td><code>getOwnedRelations</code></td><td><pre><code class=\"language-application-typescript\">getOwnedRelations(name: string): Attribute[]</code></pre><p>Returns the note's own relations, without inherited ones, optionally only those with <code>name</code>.</p></td></tr><tr><td><code>getRelation</code></td><td><pre><code class=\"language-application-typescript\">getRelation(name: string): Attribute | null</code></pre><p>Returns the first relation with the given name, including inherited ones, or <code>undefined</code> if the note has none.</p></td></tr><tr><td><code>getOwnedRelation</code></td><td><pre><code class=\"language-application-typescript\">getOwnedRelation(name: string): Attribute | null</code></pre><p>Returns the first of the note's own relations with the given name, or <code>undefined</code> if the note has none.</p></td></tr><tr><td><code>getRelationValue</code></td><td><pre><code class=\"language-application-typescript\">getRelationValue(name: string): string | null</code></pre><p>Returns the target note ID of the first relation with the given name, including inherited ones, or <code>null</code> if the note has none.</p></td></tr><tr><td><code>getOwnedRelationValue</code></td><td><pre><code class=\"language-application-typescript\">getOwnedRelationValue(name: string): string | null</code></pre><p>Returns the target note ID of the first of the note's own relations with the given name, or <code>null</code> if the note has none.</p></td></tr><tr><td><code>hasRelation</code></td><td><pre><code class=\"language-application-typescript\">hasRelation(name: string): boolean</code></pre><p>Returns whether the note has a relation with the given name, including inherited ones.</p></td></tr><tr><td><code>hasOwnedRelation</code></td><td><pre><code class=\"language-application-typescript\">hasOwnedRelation(name: string): boolean</code></pre><p>Returns whether the note itself has a relation with the given name, without inherited ones.</p></td></tr><tr><td><code>getLabelOrRelation</code></td><td><pre><code class=\"language-application-typescript\">getLabelOrRelation(nameWithPrefix: string): string | null</code></pre><p>Returns the value of a label or relation, inherited ones included, or <code>null</code> if the note has none. A relation's value is the ID of its target note.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>nameWithPrefix</code></td><td><code>string</code><br>the attribute name prefixed with <code>#</code> for a label or <code>~</code> for a relation. A name without a prefix is looked up as a label.</td></tr></tbody></table></figure></td></tr><tr><td><code>getRelationTarget</code></td><td><pre><code class=\"language-application-typescript\">getRelationTarget(name: string): Promise&lt;FNote | null&gt;</code></pre><p>Returns the target note of the first relation with the given name, including inherited ones. Returns <code>null</code> if the note has no such relation, the relation has no target, or the target note does not exist.</p></td></tr><tr><td><code>getRelationTargets</code></td><td><pre><code class=\"language-application-typescript\">getRelationTargets(name: string): Promise&lt;(FNote | null)[]&gt;</code></pre><p>Returns the target notes of the note's relations with the given name, including inherited ones, in the order of the relations. A relation whose target is missing gives <code>null</code>.</p></td></tr><tr><td><code>getTargetRelations</code></td><td><pre><code class=\"language-application-typescript\">getTargetRelations(): Attribute[]</code></pre><p>Returns the relations, owned by any note, that point at this note.</p></td></tr><tr><td><code>getTargetRelationSourceNotes</code></td><td><pre><code class=\"language-application-typescript\">getTargetRelationSourceNotes(): Promise&lt;FNote[]&gt;</code></pre><p>Returns the notes that own a relation pointing at this note.</p></td></tr><tr><td><code>getContent</code></td><td><pre><code class=\"language-application-typescript\">getContent(): Promise&lt;string | Uint8Array&lt;ArrayBufferLike&gt;&gt;</code></pre><p>Fetches the note's content from the server. Resolves to a string for text-based notes; for a binary note such as an image or file, the content is not sent, and for a protected note without a protected session, it is an empty string.</p></td></tr><tr><td><code>getJsonContent</code></td><td><pre><code class=\"language-application-typescript\">getJsonContent(): Promise&lt;unknown&gt;</code></pre><p>Fetches the note's content and parses it as JSON. Resolves to <code>null</code> if the content is empty, is not a string, or is not valid JSON.</p></td></tr><tr><td><code>getBlob</code></td><td><pre><code class=\"language-application-typescript\">getBlob(): Promise&lt;Blob | null&gt;</code></pre><p>Fetches the note's content together with its blob ID, length and modification date. Resolves to <code>null</code> if the request fails.</p></td></tr><tr><td><code>getNoteComplement</code></td><td><pre><code class=\"language-application-typescript\">getNoteComplement(): Promise&lt;Blob | null&gt;</code></pre><p>Returns the blob that holds the note's content.</p><aside class=\"admonition warning\"><p>Deprecated. Use <code>getBlob()</code> instead.</p></aside></td></tr><tr><td><code>getMetadata</code></td><td><pre><code class=\"language-application-typescript\">getMetadata(): Promise&lt;NoteMetadata&gt;</code></pre><p>Returns the note's creation and modification dates, which it requests from the server.</p></td></tr><tr><td><code>attachments</code></td><td><p><code>Attachment[] | null</code><br>The note's attachments, or <code>null</code> until <code>getAttachments()</code> loads them. Use <code>getAttachments()</code> instead of reading this property.</p></td></tr><tr><td><code>getAttachments</code></td><td><pre><code class=\"language-application-typescript\">getAttachments(): Promise&lt;Attachment[]&gt;</code></pre><p>Returns the note's attachments. The first call loads them from the server, and later calls reuse that list.</p></td></tr><tr><td><code>getAttachmentsByRole</code></td><td><pre><code class=\"language-application-typescript\">getAttachmentsByRole(role: string): Promise&lt;Attachment[]&gt;</code></pre><p>Returns the note's attachments with the given role, such as <code>image</code> or <code>file</code>.</p></td></tr><tr><td><code>getAttachmentById</code></td><td><pre><code class=\"language-application-typescript\">getAttachmentById(attachmentId: string): Promise&lt;Attachment | undefined&gt;</code></pre><p>Returns the note's attachment with the given ID, or <code>undefined</code> if this note has no such attachment.</p></td></tr><tr><td><code>getNotesToInheritAttributesFrom</code></td><td><pre><code class=\"language-application-typescript\">getNotesToInheritAttributesFrom(): FNote[]</code></pre><p>Returns the target notes of this note's <code>~template</code> and <code>~inherit</code> relations, inherited relations included. A target note that the client has not loaded appears as <code>undefined</code>.</p></td></tr><tr><td><code>getIcon</code></td><td><pre><code class=\"language-application-typescript\">getIcon(): string</code></pre><p>Returns the CSS classes of the note's icon, such as <code>tn-icon bx bx-note</code>. The icon comes from the <code>iconClass</code> label, then the <code>workspaceIconClass</code> label, then a default for the note type.</p></td></tr><tr><td><code>isFolder</code></td><td><pre><code class=\"language-application-typescript\">isFolder(): boolean</code></pre><p>Returns <code>true</code> if the note shows as a folder in the tree: a search note, or a note with children (archived ones included). Always <code>false</code> when the note has a truthy <code>subtreeHidden</code> label.</p></td></tr><tr><td><code>isShared</code></td><td><pre><code class=\"language-application-typescript\">isShared(): boolean</code></pre><p>Returns <code>true</code> if the note is placed, directly or through ancestors the client has loaded, under the shared notes root (<code>_share</code>).</p></td></tr><tr><td><code>isContentAvailable</code></td><td><pre><code class=\"language-application-typescript\">isContentAvailable(): boolean</code></pre><p>Returns <code>true</code> if the note's content can be read: the note is not protected, or a protected session is active.</p></td></tr><tr><td><code>isJson</code></td><td><pre><code class=\"language-application-typescript\">isJson(): boolean</code></pre><p>Returns <code>true</code> if the note's MIME type is <code>application/json</code>.</p></td></tr><tr><td><code>isJavaScript</code></td><td><pre><code class=\"language-application-typescript\">isJavaScript(): boolean</code></pre><p>Returns whether the note is a code, file or launcher note with a JavaScript MIME type.</p></td></tr><tr><td><code>isJsx</code></td><td><pre><code class=\"language-application-typescript\">isJsx(): boolean</code></pre><p>Returns <code>true</code> if the note is a code note with the MIME type <code>text/jsx</code>.</p></td></tr><tr><td><code>isHtml</code></td><td><pre><code class=\"language-application-typescript\">isHtml(): boolean</code></pre><p>Returns whether the note is a code, file or render note with the <code>text/html</code> MIME type.</p></td></tr><tr><td><code>isMarkdown</code></td><td><pre><code class=\"language-application-typescript\">isMarkdown(): boolean</code></pre><p>Returns <code>true</code> if the note is a code note with a Markdown MIME type (<code>text/markdown</code>, <code>text/x-markdown</code> or <code>text/x-gfm</code>).</p></td></tr><tr><td><code>isOptions</code></td><td><pre><code class=\"language-application-typescript\">isOptions(): boolean</code></pre><p>Returns <code>true</code> if the note is one of Trilium's settings pages.</p></td></tr><tr><td><code>isTriliumScript</code></td><td><pre><code class=\"language-application-typescript\">isTriliumScript(): boolean</code></pre><p>Returns <code>true</code> if the note's MIME type starts with <code>application/javascript</code>, which covers both frontend and backend scripts. The note type is not checked.</p></td></tr><tr><td><code>isTriliumSqlite</code></td><td><pre><code class=\"language-application-typescript\">isTriliumSqlite(): boolean</code></pre><p>Returns <code>true</code> if the note is a SQL console note, which has the MIME type <code>text/x-sqlite;schema=trilium</code>.</p></td></tr><tr><td><code>isLaunchBarConfig</code></td><td><pre><code class=\"language-application-typescript\">isLaunchBarConfig(): boolean</code></pre><p>Returns <code>true</code> if the note is a launcher or one of the notes that hold the launch bar's launchers.</p></td></tr><tr><td><code>isHiddenCompletely</code></td><td><pre><code class=\"language-application-typescript\">isHiddenCompletely(): boolean</code></pre><p>Returns whether every path to the note runs through the hidden subtree, so that no clone of it appears in the visible tree. Paths through search notes are not counted.</p></td></tr><tr><td><code>isInHiddenSubtree</code></td><td><pre><code class=\"language-application-typescript\">isInHiddenSubtree(): boolean</code></pre><p>Returns <code>true</code> if the note is the hidden subtree's root (<code>_hidden</code>) or has it as an ancestor through any of its loaded parents, even when the note is also cloned into the visible tree.</p></td></tr><tr><td><code>isEligibleForConversionToAttachment</code></td><td><pre><code class=\"language-application-typescript\">isEligibleForConversionToAttachment(): boolean</code></pre><p>Returns <code>true</code> if the image note can be converted into an attachment of its parent: it is an image note without children, it has exactly one parent, that parent is a text note, the content of both is available, and no note other than the parent links to the image.</p></td></tr><tr><td><code>getColorClass</code></td><td><pre><code class=\"language-application-typescript\">getColorClass(): string</code></pre><p>Returns the CSS class that applies the note's <code>color</code> label, such as <code>color-ff0000</code>, or an empty string if the label is missing or not a valid color. The first call for a color adds the class's style rule to the page.</p></td></tr><tr><td><code>getCssClass</code></td><td><pre><code class=\"language-application-typescript\">getCssClass(): string</code></pre><p>Returns the values of all the note's <code>cssClass</code> labels, inherited ones included, separated by spaces.</p></td></tr><tr><td><code>getWorkspaceIconClass</code></td><td><pre><code class=\"language-application-typescript\">getWorkspaceIconClass(): string</code></pre><p>Returns the value of the note's <code>workspaceIconClass</code> label, or an empty string if it has none.</p></td></tr><tr><td><code>getWorkspaceTabBackgroundColor</code></td><td><pre><code class=\"language-application-typescript\">getWorkspaceTabBackgroundColor(): string</code></pre><p>Returns the value of the note's <code>workspaceTabBackgroundColor</code> label, or an empty string if it has none.</p></td></tr><tr><td><code>getScriptEnv</code></td><td><pre><code class=\"language-application-typescript\">getScriptEnv(): \"frontend\" | \"backend\" | null</code></pre><p>Returns where the note runs as a script: <code>frontend</code> for HTML, JSX, render notes and JavaScript with <code>env=frontend</code> in its MIME type, <code>backend</code> for JavaScript with <code>env=backend</code>, and <code>null</code> for any other note.</p></td></tr><tr><td><code>executeScript</code></td><td><pre><code class=\"language-application-typescript\">executeScript(): Promise&lt;unknown&gt;</code></pre><p>Runs the note as a frontend or backend script, depending on <code>getScriptEnv()</code>. For a frontend script, the promise resolves to the value the script returns; for a backend script, it resolves to <code>undefined</code> once the script has run. A frontend script that fails shows its error and resolves to <code>undefined</code>.</p></td></tr><tr><td><code>blobId</code></td><td><p><code>string</code><br>Blob ID of the current content; changes when content changes.</p></td></tr><tr><td><code>parentToBranch</code></td><td><p><code>Record&lt;string, string&gt;</code><br>Map of parent note ID → branch ID.</p></td></tr><tr><td><code>childToBranch</code></td><td><p><code>Record&lt;string, string&gt;</code><br>Map of child note ID → branch ID.</p></td></tr><tr><td><code>searchResultsLoaded</code><br><em>optional</em></td><td><p><code>boolean</code><br>For a search note, <code>true</code> once its results have been loaded as its children; otherwise not set.</p></td></tr><tr><td><code>highlightedTokens</code><br><em>optional</em></td><td><p><code>string[]</code><br>For a search note whose results are loaded, the search words to highlight in those results; otherwise not set.</p></td></tr><tr><td><code>dto</code></td><td><p><code>Record&lt;string, unknown&gt;</code><br>Plain data representation of the note (the live object minus its cache handle).</p></td></tr><tr><td><code>addParent</code></td><td><pre><code class=\"language-application-typescript\">addParent(parentNoteId: string, branchId: string, sort?: boolean): void</code></pre><p>Adds a parent to this note in the client's cache only. Trilium calls it when it loads branches; scripts do not normally call it, and the change is not saved. To place a note under another, use <code>api.runOnBackend()</code> with the backend API.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>parentNoteId</code></td><td><code>string</code></td></tr><tr><td><code>branchId</code></td><td><code>string</code><br>the ID of the branch that links the two notes.</td></tr><tr><td><code>sort</code><br><em>optional</em></td><td><code>boolean</code><br>whether to reorder the parents afterwards. Defaults to <code>true</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>addChild</code></td><td><pre><code class=\"language-application-typescript\">addChild(childNoteId: string, branchId: string, sort?: boolean): void</code></pre><p>Adds a child to this note in the client's cache only. Trilium calls it when it loads branches; scripts do not normally call it, and the change is not saved.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>childNoteId</code></td><td><code>string</code></td></tr><tr><td><code>branchId</code></td><td><code>string</code><br>the ID of the branch that links the two notes.</td></tr><tr><td><code>sort</code><br><em>optional</em></td><td><code>boolean</code><br>whether to reorder the children by their position afterwards. Defaults to <code>true</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>sortParents</code></td><td><pre><code class=\"language-application-typescript\">sortParents(): void</code></pre><p>Reorders the parent list in the client's cache so that ordinary parents come before search notes, archived notes and notes outside the visible tree. Trilium calls it itself; scripts do not normally call it.</p></td></tr><tr><td><code>sortChildren</code></td><td><pre><code class=\"language-application-typescript\">sortChildren(): void</code></pre><p>Reorders the child list in the client's cache by each branch's position. Trilium calls it itself; scripts do not normally call it, and it does not change the order saved in the database.</p></td></tr><tr><td><code>update</code></td><td><pre><code class=\"language-application-typescript\">update(row: Record&lt;string, unknown&gt;): void</code></pre><p>Overwrites the note's ID, title, type, MIME type, protection flag and blob ID in the client's cache with the values in <code>row</code>. Trilium calls it when changes arrive from the server; scripts do not normally call it, and the change is not saved.</p></td></tr><tr><td><code>invalidateAttributeCache</code></td><td><pre><code class=\"language-application-typescript\">invalidateAttributeCache(): void</code></pre><p>Does nothing; the note's attributes stay up to date without it.</p><aside class=\"admonition warning\"><p>Deprecated. Remove the call.</p></aside></td></tr><tr><td><code>toString</code></td><td><pre><code class=\"language-application-typescript\">toString(): string</code></pre><p>Returns a short description of the note for logging, such as <code>Note(noteId=abc123, title=My note)</code>.</p></td></tr></tbody></table></figure><h2><code>RightPanelWidget</code></h2><p>Instance shape of <code>RightPanelWidget</code> (subset) — a widget shown in the right sidebar.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>$widget</code></td><td><p><code>any</code><br>The widget's root jQuery element (assign in <code>doRender</code>, e.g. <code>this.$widget = $(TPL)</code>). Typed loosely because jQuery types can't be imported into this self-contained module; inside the editor it is a real <code>JQuery&lt;HTMLElement&gt;</code> so all jQuery methods work.</p></td></tr><tr><td><code>isEnabled</code></td><td><pre><code class=\"language-application-typescript\">isEnabled(): boolean | null | undefined</code></pre><p>Returns whether the widget is shown: always for a <code>BasicWidget</code>, and only while a note is active for a <code>NoteContextAwareWidget</code>. A disabled widget stays in the DOM, hidden, and a <code>NoteContextAwareWidget</code> does not call <code>refreshWithNote()</code> while it is disabled.</p></td></tr><tr><td><code>doRender</code></td><td><pre><code class=\"language-application-typescript\">doRender(): void</code></pre><p>Builds the widget's DOM. Override it to create the root element and assign it to <code>this.$widget</code> as a jQuery object.</p></td></tr><tr><td><code>render</code></td><td><pre><code class=\"language-application-typescript\">render(): unknown</code></pre><p>Renders the widget and returns its root element.</p></td></tr><tr><td><code>cleanup</code></td><td><pre><code class=\"language-application-typescript\">cleanup(): void</code></pre><p>Tears down the widget; override to release resources.</p></td></tr><tr><td><code>id</code></td><td><pre><code class=\"language-application-typescript\">id(id: string): this</code></pre><p>Fluent builder: set the element id. Chainable.</p></td></tr><tr><td><code>class</code></td><td><pre><code class=\"language-application-typescript\">class(className: string): this</code></pre><p>Fluent builder: add a CSS class. Chainable.</p></td></tr><tr><td><code>css</code></td><td><pre><code class=\"language-application-typescript\">css(name: string, value: string): this</code></pre><p>Sets an inline CSS property on the widget's root element, such as <code>css(\"padding-inline-start\", \"12px\")</code>, and returns the widget for chaining. It takes effect when the widget renders.</p></td></tr><tr><td><code>child</code></td><td><pre><code class=\"language-application-typescript\">child(...components: unknown[]): this</code></pre><p>Fluent builder: append child components. Chainable.</p></td></tr><tr><td><code>note</code></td><td><p><code>FNote | null</code><br>The note currently shown in this widget's context.</p></td></tr><tr><td><code>noteContext</code><br><em>optional</em></td><td><p><code>NoteContext</code><br>The note context (split) this widget is attached to.</p></td></tr><tr><td><code>refreshWithNote</code></td><td><pre><code class=\"language-application-typescript\">refreshWithNote(note: FNote | null | undefined): void | Promise&lt;void&gt;</code></pre><p>Updates the widget for the note in its context. Override it to refresh the widget's content; it runs when that note changes and on <code>refresh()</code>, as long as <code>isEnabled()</code> returns <code>true</code>.</p></td></tr><tr><td><code>refresh</code></td><td><pre><code class=\"language-application-typescript\">refresh(): void | Promise&lt;void&gt;</code></pre><p>Forces a refresh against the current note.</p></td></tr><tr><td><code>widgetTitle</code></td><td><p><code>string</code><br>The title shown in the panel's header, <code>Untitled widget</code> unless overridden. The panel reads it once, when it renders.</p></td></tr><tr><td><code>doRenderBody</code></td><td><pre><code class=\"language-application-typescript\">doRenderBody(): void | Promise&lt;void&gt;</code></pre><p>Builds the panel's body. Override it to fill <code>this.$body</code>, the jQuery element the panel creates for the content, instead of <code>doRender()</code>. It can return a promise when the body needs asynchronous work; an error that promise rejects with is logged.</p></td></tr></tbody></table></figure><h2><code>NoteContextAwareWidget</code></h2><p>Instance shape of <code>NoteContextAwareWidget</code> (subset) — reacts to the active note.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>$widget</code></td><td><p><code>any</code><br>The widget's root jQuery element (assign in <code>doRender</code>, e.g. <code>this.$widget = $(TPL)</code>). Typed loosely because jQuery types can't be imported into this self-contained module; inside the editor it is a real <code>JQuery&lt;HTMLElement&gt;</code> so all jQuery methods work.</p></td></tr><tr><td><code>isEnabled</code></td><td><pre><code class=\"language-application-typescript\">isEnabled(): boolean | null | undefined</code></pre><p>Returns whether the widget is shown: always for a <code>BasicWidget</code>, and only while a note is active for a <code>NoteContextAwareWidget</code>. A disabled widget stays in the DOM, hidden, and a <code>NoteContextAwareWidget</code> does not call <code>refreshWithNote()</code> while it is disabled.</p></td></tr><tr><td><code>doRender</code></td><td><pre><code class=\"language-application-typescript\">doRender(): void</code></pre><p>Builds the widget's DOM. Override it to create the root element and assign it to <code>this.$widget</code> as a jQuery object.</p></td></tr><tr><td><code>render</code></td><td><pre><code class=\"language-application-typescript\">render(): unknown</code></pre><p>Renders the widget and returns its root element.</p></td></tr><tr><td><code>cleanup</code></td><td><pre><code class=\"language-application-typescript\">cleanup(): void</code></pre><p>Tears down the widget; override to release resources.</p></td></tr><tr><td><code>id</code></td><td><pre><code class=\"language-application-typescript\">id(id: string): this</code></pre><p>Fluent builder: set the element id. Chainable.</p></td></tr><tr><td><code>class</code></td><td><pre><code class=\"language-application-typescript\">class(className: string): this</code></pre><p>Fluent builder: add a CSS class. Chainable.</p></td></tr><tr><td><code>css</code></td><td><pre><code class=\"language-application-typescript\">css(name: string, value: string): this</code></pre><p>Sets an inline CSS property on the widget's root element, such as <code>css(\"padding-inline-start\", \"12px\")</code>, and returns the widget for chaining. It takes effect when the widget renders.</p></td></tr><tr><td><code>child</code></td><td><pre><code class=\"language-application-typescript\">child(...components: unknown[]): this</code></pre><p>Fluent builder: append child components. Chainable.</p></td></tr><tr><td><code>note</code></td><td><p><code>FNote | null</code><br>The note currently shown in this widget's context.</p></td></tr><tr><td><code>noteContext</code><br><em>optional</em></td><td><p><code>NoteContext</code><br>The note context (split) this widget is attached to.</p></td></tr><tr><td><code>refreshWithNote</code></td><td><pre><code class=\"language-application-typescript\">refreshWithNote(note: FNote | null | undefined): void | Promise&lt;void&gt;</code></pre><p>Updates the widget for the note in its context. Override it to refresh the widget's content; it runs when that note changes and on <code>refresh()</code>, as long as <code>isEnabled()</code> returns <code>true</code>.</p></td></tr><tr><td><code>refresh</code></td><td><pre><code class=\"language-application-typescript\">refresh(): void | Promise&lt;void&gt;</code></pre><p>Forces a refresh against the current note.</p></td></tr></tbody></table></figure><h2><code>BasicWidget</code></h2><p>Instance shape of <code>BasicWidget</code> (subset) — the base for custom frontend widgets.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>$widget</code></td><td><p><code>any</code><br>The widget's root jQuery element (assign in <code>doRender</code>, e.g. <code>this.$widget = $(TPL)</code>). Typed loosely because jQuery types can't be imported into this self-contained module; inside the editor it is a real <code>JQuery&lt;HTMLElement&gt;</code> so all jQuery methods work.</p></td></tr><tr><td><code>isEnabled</code></td><td><pre><code class=\"language-application-typescript\">isEnabled(): boolean | null | undefined</code></pre><p>Returns whether the widget is shown: always for a <code>BasicWidget</code>, and only while a note is active for a <code>NoteContextAwareWidget</code>. A disabled widget stays in the DOM, hidden, and a <code>NoteContextAwareWidget</code> does not call <code>refreshWithNote()</code> while it is disabled.</p></td></tr><tr><td><code>doRender</code></td><td><pre><code class=\"language-application-typescript\">doRender(): void</code></pre><p>Builds the widget's DOM. Override it to create the root element and assign it to <code>this.$widget</code> as a jQuery object.</p></td></tr><tr><td><code>render</code></td><td><pre><code class=\"language-application-typescript\">render(): unknown</code></pre><p>Renders the widget and returns its root element.</p></td></tr><tr><td><code>cleanup</code></td><td><pre><code class=\"language-application-typescript\">cleanup(): void</code></pre><p>Tears down the widget; override to release resources.</p></td></tr><tr><td><code>id</code></td><td><pre><code class=\"language-application-typescript\">id(id: string): this</code></pre><p>Fluent builder: set the element id. Chainable.</p></td></tr><tr><td><code>class</code></td><td><pre><code class=\"language-application-typescript\">class(className: string): this</code></pre><p>Fluent builder: add a CSS class. Chainable.</p></td></tr><tr><td><code>css</code></td><td><pre><code class=\"language-application-typescript\">css(name: string, value: string): this</code></pre><p>Sets an inline CSS property on the widget's root element, such as <code>css(\"padding-inline-start\", \"12px\")</code>, and returns the widget for chaining. It takes effect when the widget renders.</p></td></tr><tr><td><code>child</code></td><td><pre><code class=\"language-application-typescript\">child(...components: unknown[]): this</code></pre><p>Fluent builder: append child components. Chainable.</p></td></tr></tbody></table></figure><h2><code>FBranch</code></h2><p>A branch (parent↔child link) as seen by frontend scripts (subset of <code>FBranch</code>).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>branchId</code></td><td><p><code>string</code><br>The unique ID of the branch.</p></td></tr><tr><td><code>noteId</code></td><td><p><code>string</code><br>The ID of the child note that this branch places in the tree.</p></td></tr><tr><td><code>parentNoteId</code></td><td><p><code>string</code><br>The ID of the parent note.</p></td></tr><tr><td><code>notePosition</code></td><td><p><code>number</code><br>The place of the note among its siblings; the note tree lists siblings by ascending <code>notePosition</code>. Trilium spaces positions 10 apart.</p></td></tr><tr><td><code>prefix</code><br><em>optional</em></td><td><p><code>string</code><br>The prefix shown before the note's title in the note tree, for this placement of the note only. It is empty or missing when the branch has none.</p></td></tr><tr><td><code>isExpanded</code><br><em>optional</em></td><td><p><code>boolean</code><br>Whether the note tree shows this branch expanded, with the note's children visible.</p></td></tr><tr><td><code>getNote</code></td><td><pre><code class=\"language-application-typescript\">getNote(): Promise&lt;FNote | null&gt;</code></pre><p>Returns the child note, loading it from the server if the frontend cache does not hold it yet. Resolves to <code>null</code> if the note does not exist.</p></td></tr><tr><td><code>getNoteFromCache</code></td><td><pre><code class=\"language-application-typescript\">getNoteFromCache(): FNote | undefined</code></pre><p>Returns the child note from the frontend cache, without contacting the server. Returns <code>undefined</code> if the note is not loaded yet.</p></td></tr><tr><td><code>getParentNote</code></td><td><pre><code class=\"language-application-typescript\">getParentNote(): Promise&lt;FNote | null&gt;</code></pre><p>Returns the parent note, loading it from the server if the frontend cache does not hold it yet. Resolves to <code>null</code> if the note does not exist.</p></td></tr><tr><td><code>isTopLevel</code></td><td><pre><code class=\"language-application-typescript\">isTopLevel(): boolean</code></pre><p>Returns whether the branch places its note directly under the root note.</p></td></tr></tbody></table></figure><h2><code>NoteContext</code></h2><p>A split/tab context as seen by frontend scripts (subset of <code>NoteContext</code>).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>ntxId</code></td><td><p><code>string | null</code><br>The ID of the note context, which identifies one tab or split.</p></td></tr><tr><td><code>note</code></td><td><p><code>FNote | null</code><br>The note this context shows, or <code>null</code> if the context is empty.</p></td></tr><tr><td><code>notePath</code></td><td><p><code>string | null</code><br>The path of the note this context shows, as note IDs from <code>root</code> joined by <code>/</code>, such as <code>root/abc123/def456</code>. It is <code>null</code> when the context is empty.</p></td></tr><tr><td><code>getCodeEditor</code></td><td><pre><code class=\"language-application-typescript\">getCodeEditor(): Promise&lt;unknown&gt;</code></pre><p>Returns the CodeMirror editor of the code note this context shows. Resolves to <code>null</code> if the context shows no code editor within 200 ms.</p></td></tr><tr><td><code>getTextEditor</code></td><td><pre><code class=\"language-application-typescript\">getTextEditor(): Promise&lt;unknown&gt;</code></pre><p>Returns the CKEditor instance of the editable text note this context shows. Resolves to <code>null</code> if the context shows no editable text note within 200 ms.</p></td></tr></tbody></table></figure><h2><code>DayjsInstance</code></h2><p>A date as day.js wraps it (subset).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>format</code></td><td><pre><code class=\"language-application-typescript\">format(template?: string): string</code></pre><p>Formats the date, such as <code>\"YYYY-MM-DD\"</code> for <code>2026-10-22</code>. Without a template, it returns the ISO 8601 form with the UTC offset, such as <code>2026-10-22T14:03:05+02:00</code>.</p></td></tr><tr><td><code>add</code></td><td><pre><code class=\"language-application-typescript\">add(value: number, unit: string): DayjsInstance</code></pre><p>Returns a new date, <code>value</code> units later. The date it is called on stays unchanged.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>number</code></td></tr><tr><td><code>unit</code></td><td><code>string</code><br>The unit, such as <code>\"day\"</code>, <code>\"week\"</code>, <code>\"month\"</code> or <code>\"year\"</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>subtract</code></td><td><pre><code class=\"language-application-typescript\">subtract(value: number, unit: string): DayjsInstance</code></pre><p>Returns a new date, <code>value</code> units earlier. The date it is called on stays unchanged.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>number</code></td></tr><tr><td><code>unit</code></td><td><code>string</code><br>The unit, such as <code>\"day\"</code>, <code>\"week\"</code>, <code>\"month\"</code> or <code>\"year\"</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>toDate</code></td><td><pre><code class=\"language-application-typescript\">toDate(): Date</code></pre><p>Returns the date as a JavaScript <code>Date</code>.</p></td></tr></tbody></table></figure><h2>Types</h2><h3><code>Dayjs</code></h3><p>Minimal day.js surface (the real API exposes the full day.js factory).</p><pre><code class=\"language-application-typescript\">type Dayjs = (date?: string | number | Date) =&gt; DayjsInstance</code></pre><h3><code>WidgetClass</code></h3><p>Constructor type allowing <code>class X extends api.Widget { … }</code>.</p><pre><code class=\"language-application-typescript\">type WidgetClass = (...args: unknown[]) =&gt; T</code></pre><h3><code>Func</code></h3><pre><code class=\"language-application-typescript\">type Func = (...args: unknown[]) =&gt; unknown | string</code></pre><h3><code>CreateNoteOpts</code></h3><p>Options accepted by <code>FrontendApi.createNote</code>.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>title</code> <br><em>optional</em></td><td><code>string | null</code> <br>Title of the new note.</td></tr><tr><td><code>content</code> <br><em>optional</em></td><td><code>string | null</code> <br>Content of the new note (HTML for text notes, source for code notes, etc.).</td></tr><tr><td><code>type</code> <br><em>optional</em></td><td><code>string</code> <br>Note type, e.g. \"text\" (default), \"code\", \"book\".</td></tr><tr><td><code>mime</code> <br><em>optional</em></td><td><code>string</code> <br>MIME type, e.g. \"application/javascript;env=frontend\" for a frontend code note.</td></tr><tr><td><code>templateNoteId</code> <br><em>optional</em></td><td><code>string</code> <br>Note ID of a template to apply to the new note.</td></tr><tr><td><code>isProtected</code> <br><em>optional</em></td><td><code>boolean</code> <br>Create the note as protected (only takes effect when a protected session is available).</td></tr><tr><td><code>activate</code> <br><em>optional</em></td><td><code>boolean</code> <br>Activate (open) the new note after creation. Defaults to <code>true</code>.</td></tr><tr><td><code>focus</code> <br><em>optional</em></td><td><code>\"title\" | \"content\"</code> <br>Which part of the activated note to focus. Defaults to \"title\".</td></tr><tr><td><code>target</code> <br><em>optional</em></td><td><code>string</code> <br>Where to place the note relative to the parent/target: \"into\" (default) or \"after\".</td></tr><tr><td><code>targetBranchId</code> <br><em>optional</em></td><td><code>string</code> <br>Branch ID used together with <code>target: \"after\"</code>.</td></tr><tr><td><code>attributes</code> <br><em>optional</em></td><td><code>CreateAttribute[]</code> <br>Attributes to set atomically on creation.</td></tr></tbody></table></figure><h3><code>PickerItem</code></h3><p>One thing a picker offers, as <code>pickSingleItem</code> takes and answers with.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>key</code></td><td><code>string</code> <br>The ID of the item. It must be unique within its group, and tells the script which item the user picked.</td></tr><tr><td><code>caption</code></td><td><code>string</code> <br>The text shown for the item. The search field filters items by it.</td></tr><tr><td><code>icon</code> <br><em>optional</em></td><td><code>string</code> <br>An icon class, <code>bx</code> prefix included.</td></tr><tr><td><code>tooltip</code> <br><em>optional</em></td><td><code>string</code> <br>HTML shown in a tooltip while the item is hovered.</td></tr></tbody></table></figure><h3><code>PickerItemGroup</code></h3><p>A run of picker items under a heading of their own.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>key</code></td><td><code>string</code> <br>The ID of the group. It must be unique among the groups.</td></tr><tr><td><code>groupHeader</code></td><td><code>string</code> <br>The heading shown above the group's items. An empty string shows the items without a heading.</td></tr><tr><td><code>items</code></td><td><code>PickerItem[]</code> <br>The items in the group, in the order the picker shows them.</td></tr></tbody></table></figure><h3><code>NotePathRecord</code></h3><p>One resolved tree path to a note (subset of the client's <code>NotePathRecord</code>).</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>isArchived</code></td><td><code>boolean</code> <br>Whether a note on the path, the note itself included, is archived, which means it has the <code>#archived</code> label, owned or inherited.</td></tr><tr><td><code>isInHoistedSubTree</code></td><td><code>boolean</code> <br>Whether the path passes through the hoisted note passed to <code>getSortedNotePathRecords()</code>. It is always <code>true</code> when the hoisted note is <code>root</code>.</td></tr><tr><td><code>isSearch</code> <br><em>optional</em></td><td><code>boolean</code> <br>Whether the note itself is a search note. Only frontend scripts get this property; backend records leave it out.</td></tr><tr><td><code>notePath</code></td><td><code>string[]</code> <br>The note IDs along the path, from <code>root</code> to the note itself.</td></tr><tr><td><code>isHidden</code></td><td><code>boolean</code> <br>Whether the path passes through the hidden subtree, <code>_hidden</code>, which holds Trilium's system notes.</td></tr></tbody></table></figure><h3><code>Attribute</code></h3><p>A label or relation attached to a note.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>attributeId</code></td><td><code>string</code> <br>The ID of the attribute.</td></tr><tr><td><code>type</code></td><td><code>\"label\" | \"relation\"</code> <br>The type of the attribute: <code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code> <br>The name of the attribute, without the <code>#</code> or <code>~</code> prefix.</td></tr><tr><td><code>value</code></td><td><code>string</code> <br>The value of the attribute. For a relation, it is the ID of the target note. For a label without a value, it is an empty string.</td></tr><tr><td><code>isInheritable</code></td><td><code>boolean</code> <br>Whether the note's descendants inherit the attribute.</td></tr><tr><td><code>isOwned</code></td><td><code>boolean</code> <br>Not set by Trilium: neither frontend nor backend attributes carry this property, so it reads <code>undefined</code>.</td></tr></tbody></table></figure><h3><code>Blob</code></h3><p>A note's binary/text content blob (subset of the client's <code>FBlob</code>).</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>blobId</code></td><td><code>string</code> <br>The ID of the blob, derived from its content. Notes, attachments and revisions with identical content share one blob.</td></tr><tr><td><code>content</code></td><td><code>string</code> <br>The content as text. It is <code>null</code> when the content is binary, as in images and files.</td></tr><tr><td><code>contentLength</code></td><td><code>number</code> <br>The length of the content as stored: characters for text, bytes for binary content. For a protected note, it measures the encrypted content.</td></tr><tr><td><code>dateModified</code></td><td><code>string</code> <br>The local date and time this content was first stored, with the UTC offset, such as <code>2026-10-22 14:03:05.123+0200</code>. A blob never changes, so new content gets a new blob.</td></tr><tr><td><code>utcDateModified</code></td><td><code>string</code> <br>The date and time, in UTC, that this content was first stored, such as <code>2026-10-22 12:03:05.123Z</code>.</td></tr></tbody></table></figure><h3><code>NoteMetadata</code></h3><p>Creation/modification timestamps returned by <code>FNote.getMetadata</code>.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>dateCreated</code></td><td><code>string</code> <br>The local date and time the note was created, with the UTC offset, such as <code>2026-10-22 14:03:05.123+0200</code>.</td></tr><tr><td><code>utcDateCreated</code></td><td><code>string</code> <br>The date and time, in UTC, that the note was created, such as <code>2026-10-22 12:03:05.123Z</code>.</td></tr><tr><td><code>dateModified</code></td><td><code>string</code> <br>The local date and time the note was last modified, with the UTC offset, such as <code>2026-10-22 14:03:05.123+0200</code>. A change to the note's content counts as a modification.</td></tr><tr><td><code>utcDateModified</code></td><td><code>string</code> <br>The date and time, in UTC, that the note was last modified, such as <code>2026-10-22 12:03:05.123Z</code>. A change to the note's content counts as a modification.</td></tr></tbody></table></figure><h3><code>Attachment</code></h3><p>An attachment as seen by frontend scripts (subset of the client's <code>FAttachment</code>).</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>attachmentId</code></td><td><code>string</code> <br>The ID of the attachment.</td></tr><tr><td><code>ownerId</code></td><td><code>string</code> <br>The ID of the note the attachment belongs to. For an attachment of a revision, it is the ID of the revision.</td></tr><tr><td><code>role</code></td><td><code>string</code> <br>The purpose of the attachment, such as <code>image</code> for an image shown in a text note or <code>file</code> for an attached file. Trilium also uses roles of its own, such as <code>viewConfig</code> for a collection's view settings.</td></tr><tr><td><code>mime</code></td><td><code>string</code> <br>The MIME type of the attachment's content, such as <code>image/png</code>.</td></tr><tr><td><code>title</code></td><td><code>string</code> <br>The title of the attachment, usually its file name.</td></tr><tr><td><code>utcDateModified</code></td><td><code>string</code> <br>The date and time, in UTC, that the attachment was last saved, such as <code>2026-10-22 12:03:05.123Z</code>. Replacing the content counts as saving.</td></tr><tr><td><code>contentLength</code></td><td><code>number</code> <br>The length of the attachment's content. Only some ways of loading an attachment fill it in, such as <code>getAttachments()</code>; on the backend, <code>getAttachmentsByRole()</code> leaves it <code>undefined</code>.</td></tr></tbody></table></figure><h3><code>CreateAttribute</code></h3><p>An attribute to create together with a note (see <code>CreateNoteOpts.attributes</code>).</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>\"label\" | \"relation\"</code> <br>The type of the attribute: <code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code> <br>The name of the attribute, without the <code>#</code> or <code>~</code> prefix.</td></tr><tr><td><code>value</code> <br><em>optional</em></td><td><code>string</code> <br>The value of the attribute. For a relation, it is the ID of the target note. Defaults to an empty string.</td></tr><tr><td><code>isInheritable</code> <br><em>optional</em></td><td><code>boolean</code> <br>Whether the note's descendants inherit the attribute. Defaults to <code>false</code>.</td></tr><tr><td><code>position</code> <br><em>optional</em></td><td><code>number</code> <br>The place of the attribute among the note's attributes, which are listed by ascending <code>position</code>. Defaults to 10 more than the highest position among the note's attributes.</td></tr></tbody></table></figure>",
+ "_help_MEtfsqa5VwNi": "<h2><code>BackendApi</code></h2><p>The <code>api</code> global available inside <strong>backend</strong> script notes (<code>application/javascript;env=backend</code>). Runs server-side: no DOM, no jQuery.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>startNote</code><br><em>optional</em></td><td><p><code>BNote | null</code><br>Note where the script execution started — the entry point of the current script bundle (in C terms, the file containing <code>main()</code>). When a script is spread across multiple code notes (descendant code notes loaded as modules via <code>require()</code>), every note in the bundle shares the same <code>startNote</code>, while <code>currentNote</code> differs per note. Messages from <code>api.log()</code> are grouped under this note. When a frontend script calls <code>api.runOnBackend()</code>, the frontend's <code>startNote</code> is preserved here; since that note may not be resolvable on the backend, this can be null.</p></td></tr><tr><td><code>currentNote</code></td><td><p><code>BNote</code><br>Note containing the source code that is currently executing (in C terms, <code>__FILE__</code>). Equal to <code>startNote</code> unless execution has moved into a descendant module note loaded via <code>require()</code>. Don't confuse this with the concept of the active note in the UI.</p></td></tr><tr><td><code>originEntity</code><br><em>optional</em></td><td><p><code>unknown</code><br>Entity whose event triggered this execution; <code>undefined</code> when the run was not event-driven (e.g. started manually via \"Execute script\" or <code>note.executeScript()</code>). What it holds depends on the trigger: - <code>~runOnNoteCreation</code>, <code>~runOnNoteChange</code>, <code>~runOnNoteTitleChange</code>, <code>~runOnNoteContentChange</code> — the affected note; - <code>~runOnChildNoteCreation</code> — the newly created child note; - <code>~runOnAttributeCreation</code>, <code>~runOnAttributeChange</code> — the attribute; - <code>~runOnBranchCreation</code>, <code>~runOnBranchChange</code>, <code>~runOnBranchDeletion</code> — the branch; - scheduled scripts (<code>#run=backendStartup</code> / <code>#run=hourly</code> / <code>#run=daily</code>) — the script note itself; - search scripts (<code>~searchScript</code>) — the search note.</p></td></tr><tr><td><code>req</code></td><td><p><code>Request</code><br>The HTTP request, present only when the script runs as a custom request handler: a note with the <code>#customRequestHandler</code> label, invoked through a <code>/custom/...</code> URL. It is <code>undefined</code> in every other backend script. The object is Express's own request, so it has more members than <code>Request</code> lists.</p></td></tr><tr><td><code>res</code></td><td><p><code>Response</code><br>The HTTP response to write the reply to, such as <code>api.res.status(200).json({ ok: true })</code>. Like <code>req</code>, it is present only in custom request handlers, and is Express's own response.</p></td></tr><tr><td><code>pathParams</code></td><td><p><code>string[]</code><br>The capture groups from the <code>#customRequestHandler</code> regex that matched this request's URL, in order. Available only inside custom request handlers.</p></td></tr><tr><td><code>dayjs</code></td><td><p><code>Dayjs</code><br>day.js library for date manipulation. See <code>https://day.js.org</code> for documentation</p></td></tr><tr><td><code>xml2js</code></td><td><p><code>unknown</code><br>xml2js library for XML parsing. See <code>https://github.com/Leonidas-from-XIV/node-xml2js</code> for documentation</p></td></tr><tr><td><code>htmlParser</code></td><td><p><code>unknown</code><br>node-html-parser library for HTML parsing. See <code>https://github.com/taoqf/node-fast-html-parser</code> for documentation.</p></td></tr><tr><td><code>getInstanceName</code></td><td><pre><code class=\"language-application-typescript\">getInstanceName(): string | null</code></pre><p>Instance name identifies particular Trilium instance. It can be useful for scripts if some action needs to happen on only one specific instance.</p></td></tr><tr><td><code>getNote</code></td><td><pre><code class=\"language-application-typescript\">getNote(noteId: string): BNote | null</code></pre><p>Returns a note by its ID, or null.</p></td></tr><tr><td><code>getBranch</code></td><td><pre><code class=\"language-application-typescript\">getBranch(branchId: string): BBranch | null</code></pre><p>Returns a branch by its ID, or null.</p></td></tr><tr><td><code>getAttribute</code></td><td><pre><code class=\"language-application-typescript\">getAttribute(attributeId: string): Attribute | null</code></pre><p>Returns an attribute by its ID, or null.</p></td></tr><tr><td><code>getAttachment</code></td><td><pre><code class=\"language-application-typescript\">getAttachment(attachmentId: string): unknown</code></pre><p>Returns an attachment by its ID, or null.</p></td></tr><tr><td><code>getRevision</code></td><td><pre><code class=\"language-application-typescript\">getRevision(revisionId: string): unknown</code></pre><p>Returns a revision by its ID, or null.</p></td></tr><tr><td><code>getEtapiToken</code></td><td><pre><code class=\"language-application-typescript\">getEtapiToken(etapiTokenId: string): unknown</code></pre><p>Returns an ETAPI token by its ID, or null.</p></td></tr><tr><td><code>getEtapiTokens</code></td><td><pre><code class=\"language-application-typescript\">getEtapiTokens(): unknown[]</code></pre><p>Returns all ETAPI tokens.</p></td></tr><tr><td><code>getOption</code></td><td><pre><code class=\"language-application-typescript\">getOption(optionName: string): unknown</code></pre><p>Returns an option by name, or null.</p></td></tr><tr><td><code>getOptions</code></td><td><pre><code class=\"language-application-typescript\">getOptions(): unknown[]</code></pre><p>Returns all options.</p></td></tr><tr><td><code>searchForNotes</code></td><td><pre><code class=\"language-application-typescript\">searchForNotes(query: string, searchParams?: Record&lt;string, unknown&gt;): BNote[]</code></pre><p>This is a powerful search method - you can search by attributes and their values, e.g.: \"#dateModified =* MONTH AND #log\". See <code>https://triliumnext.github.io/Docs/Wiki/search.html</code> for full documentation for all options</p></td></tr><tr><td><code>searchForNote</code></td><td><pre><code class=\"language-application-typescript\">searchForNote(query: string, searchParams?: Record&lt;string, unknown&gt;): BNote | null</code></pre><p>This is a powerful search method - you can search by attributes and their values, e.g.: \"#dateModified =* MONTH AND #log\". See <code>https://triliumnext.github.io/Docs/Wiki/search.html</code> for full documentation for all options</p></td></tr><tr><td><code>getNotesWithLabel</code></td><td><pre><code class=\"language-application-typescript\">getNotesWithLabel(name: string, value?: string): BNote[]</code></pre><p>Retrieves notes with given label name &amp; value</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code><br>attribute name</td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>attribute value</td></tr></tbody></table></figure></td></tr><tr><td><code>getNoteWithLabel</code></td><td><pre><code class=\"language-application-typescript\">getNoteWithLabel(name: string, value?: string): BNote | null</code></pre><p>Retrieves first note with given label name &amp; value</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code><br>attribute name</td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>attribute value</td></tr></tbody></table></figure></td></tr><tr><td><code>ensureNoteIsPresentInParent</code></td><td><pre><code class=\"language-application-typescript\">ensureNoteIsPresentInParent(noteId: string, parentNoteId: string, prefix?: string): { branch: BBranch | null }</code></pre><p>If there's no branch between note and parent note, create one. Otherwise, do nothing. Returns the new or existing branch.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>noteId</code></td><td><code>string</code></td></tr><tr><td><code>parentNoteId</code></td><td><code>string</code></td></tr><tr><td><code>prefix</code><br><em>optional</em></td><td><code>string</code><br>if branch is created between note and parent note, set this prefix</td></tr></tbody></table></figure></td></tr><tr><td><code>ensureNoteIsAbsentFromParent</code></td><td><pre><code class=\"language-application-typescript\">ensureNoteIsAbsentFromParent(noteId: string, parentNoteId: string): void</code></pre><p>If there's a branch between note and parent note, remove it. Otherwise, do nothing.</p></td></tr><tr><td><code>toggleNoteInParent</code></td><td><pre><code class=\"language-application-typescript\">toggleNoteInParent(present: boolean, noteId: string, parentNoteId: string, prefix?: string): void</code></pre><p>Based on the value, either create or remove branch between note and parent note.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>present</code></td><td><code>boolean</code><br>true if we want the branch to exist, false if we want it gone</td></tr><tr><td><code>noteId</code></td><td><code>string</code></td></tr><tr><td><code>parentNoteId</code></td><td><code>string</code></td></tr><tr><td><code>prefix</code><br><em>optional</em></td><td><code>string</code><br>if branch is created between note and parent note, set this prefix</td></tr></tbody></table></figure></td></tr><tr><td><code>createTextNote</code></td><td><pre><code class=\"language-application-typescript\">createTextNote(parentNoteId: string, title: string, content: string): NoteAndBranch</code></pre><p>Create text note. See also createNewNote() for more options.</p></td></tr><tr><td><code>createDataNote</code></td><td><pre><code class=\"language-application-typescript\">createDataNote(parentNoteId: string, title: string, content: object): NoteAndBranch</code></pre><p>Create data note - data in this context means object serializable to JSON. Created note will be of type 'code' and JSON MIME type. See also createNewNote() for more options.</p></td></tr><tr><td><code>createNewNote</code></td><td><pre><code class=\"language-application-typescript\">createNewNote(params: { parentNoteId: string; title: string; content: string | Uint8Array&lt;ArrayBufferLike&gt;; type: string; mime?: string; [key: string]: unknown }): NoteAndBranch</code></pre><p><strong>Returns</strong> <code>NoteAndBranch</code>: object contains newly created entities note and branch</p></td></tr><tr><td><code>logMessages</code></td><td><p><code>Record&lt;string, string[]&gt;</code><br>Per-note log message buffers shown in the UI log pane.</p></td></tr><tr><td><code>logSpacedUpdates</code></td><td><p><code>Record&lt;string, unknown&gt;</code><br>Per-note spaced-update handlers for the log pane.</p></td></tr><tr><td><code>log</code></td><td><pre><code class=\"language-application-typescript\">log(...args: unknown[]): void</code></pre><p>Log given message to trilium logs and log pane in UI. Accepts multiple arguments which are joined with spaces, similar to <code>console.log</code>.</p></td></tr><tr><td><code>getRootCalendarNote</code></td><td><pre><code class=\"language-application-typescript\">getRootCalendarNote(): BNote | null</code></pre><p>Returns root note of the calendar.</p></td></tr><tr><td><code>getDayNote</code></td><td><pre><code class=\"language-application-typescript\">getDayNote(date: string, rootNote?: BNote): BNote | null</code></pre><p>Returns day note for given date. If such note doesn't exist, it is created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM-DD format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>BNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td></tr><tr><td><code>getTodayNote</code></td><td><pre><code class=\"language-application-typescript\">getTodayNote(rootNote?: BNote): BNote | null</code></pre><p>Returns today's day note. If such note doesn't exist, it is created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>BNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td></tr><tr><td><code>getWeekFirstDayNote</code></td><td><pre><code class=\"language-application-typescript\">getWeekFirstDayNote(date: string, rootNote?: BNote): BNote | null</code></pre><p>Returns note for the first date of the week of the given date.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM-DD format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>BNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td></tr><tr><td><code>getWeekNote</code></td><td><pre><code class=\"language-application-typescript\">getWeekNote(date: string, rootNote?: BNote): BNote | null</code></pre><p>Returns week note for given date. If such a note doesn't exist, it is created.</p><p>If the calendar does not support week notes, this method will return `null`.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM-DD format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>BNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>BNote | null</code>: an existing or newly created week note, or <code>null</code> if the calendar does not support week notes.</p></td></tr><tr><td><code>getMonthNote</code></td><td><pre><code class=\"language-application-typescript\">getMonthNote(date: string, rootNote?: BNote): BNote | null</code></pre><p>Returns month note for given date. If such a note doesn't exist, it is created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>BNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td></tr><tr><td><code>getQuarterNote</code></td><td><pre><code class=\"language-application-typescript\">getQuarterNote(date: string, rootNote?: BNote): BNote | null</code></pre><p>Returns quarter note for given date. If such a note doesn't exist, it is created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>BNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td></tr><tr><td><code>getYearNote</code></td><td><pre><code class=\"language-application-typescript\">getYearNote(year: string, rootNote?: BNote): BNote | null</code></pre><p>Returns year note for given year. If such a note doesn't exist, it is created.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>year</code></td><td><code>string</code><br>in YYYY format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>BNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td></tr><tr><td><code>sortNotes</code></td><td><pre><code class=\"language-application-typescript\">sortNotes(parentNoteId: string, sortConfig: { sortBy?: string; reverse?: boolean; foldersFirst?: boolean }): void</code></pre><p>Sort child notes of a given note. <code>sortBy</code> takes the <code>#sorted</code> grammar — comma-separated levels of <code>title</code>, <code>dateCreated</code>, <code>dateModified</code> or a label name, each optionally followed by <code>asc</code> or <code>desc</code> (<code>priority desc, dueDate</code>); <code>reverse</code> is the direction of the levels without their own, of the folders grouping and of ties.</p></td></tr><tr><td><code>setNoteToParent</code></td><td><pre><code class=\"language-application-typescript\">setNoteToParent(noteId: string, prefix: string, parentNoteId: string | null): void</code></pre><p>This method finds note by its noteId and prefix and either sets it to the given parentNoteId or removes the branch (if parentNoteId is not given).</p><p>This method looks similar to toggleNoteInParent() but differs because we're looking up branch by prefix.</p><aside class=\"admonition warning\"><p>Deprecated. this method is pretty confusing and serves specialized purpose only</p></aside></td></tr><tr><td><code>transactional</code></td><td><pre><code class=\"language-application-typescript\">transactional(func: () =&gt; T): T</code></pre><p>This functions wraps code which is supposed to be running in transaction. If transaction already exists, then we'll use that transaction.</p><p><strong>Returns</strong> <code>T</code>: result of func callback</p></td></tr><tr><td><code>randomString</code></td><td><pre><code class=\"language-application-typescript\">randomString(length: number): string</code></pre><p>Return randomly generated string of given length. This random string generation is NOT cryptographically secure.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>length</code></td><td><code>number</code><br>of the string</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>string</code>: random string</p></td></tr><tr><td><code>escapeHtml</code></td><td><pre><code class=\"language-application-typescript\">escapeHtml(str: string): string</code></pre><p><strong>Returns</strong> <code>string</code>: escaped string</p></td></tr><tr><td><code>unescapeHtml</code></td><td><pre><code class=\"language-application-typescript\">unescapeHtml(str: string): string</code></pre><p><strong>Returns</strong> <code>string</code>: unescaped string</p></td></tr><tr><td><code>htmlToMarkdown</code></td><td><pre><code class=\"language-application-typescript\">htmlToMarkdown(html: string): string</code></pre><p>Converts the given HTML string to Markdown.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>html</code></td><td><code>string</code><br>HTML content to convert</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>string</code>: Markdown representation of the input HTML</p></td></tr><tr><td><code>markdownToHtml</code></td><td><pre><code class=\"language-application-typescript\">markdownToHtml(markdown: string): string</code></pre><p>Converts the given Markdown string to HTML.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>markdown</code></td><td><code>string</code><br>Markdown content to convert</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>string</code>: HTML representation of the input Markdown</p></td></tr><tr><td><code>sql</code></td><td><p><code>unknown</code><br>sql</p></td></tr><tr><td><code>getAppInfo</code></td><td><pre><code class=\"language-application-typescript\">getAppInfo(): unknown</code></pre><p>Application info (version, build date, etc.).</p></td></tr><tr><td><code>createOrUpdateLauncher</code></td><td><pre><code class=\"language-application-typescript\">createOrUpdateLauncher(opts: { id: string; type: \"note\" | \"script\" | \"customWidget\"; title: string; isVisible: boolean; icon: string; keyboardShortcut: string; targetNoteId?: string; scriptNoteId?: string; widgetNoteId?: string }): { note: BNote }</code></pre><p>Creates a new launcher to the launchbar. If the launcher (id) already exists, it will be updated.</p></td></tr><tr><td><code>exportSubtreeToZipFile</code></td><td><pre><code class=\"language-application-typescript\">exportSubtreeToZipFile(noteId: string, format: \"markdown\" | \"html\", zipFilePath: string): Promise&lt;void&gt;</code></pre><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>noteId</code></td><td><code>string</code></td></tr><tr><td><code>format</code></td><td><code>\"markdown\" | \"html\"</code><br>either 'html' or 'markdown'</td></tr><tr><td><code>zipFilePath</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>runOnFrontend</code></td><td><pre><code class=\"language-application-typescript\">runOnFrontend(script: string | () =&gt; void, params?: unknown[]): void</code></pre><p>Executes given anonymous function on the frontend(s). Internally, this serializes the anonymous function into string and sends it to frontend(s) via WebSocket. Note that there can be multiple connected frontend instances (e.g. in different tabs). In such case, all instances execute the given function.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>script</code></td><td><code>string | () =&gt; void</code><br>script to be executed on the frontend</td></tr><tr><td><code>params</code><br><em>optional</em></td><td><code>unknown[]</code><br>list of parameters to the anonymous function to be sent to frontend</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>void</code>: no return value is provided.</p></td></tr><tr><td><code>runOutsideOfSync</code></td><td><pre><code class=\"language-application-typescript\">runOutsideOfSync(callback: () =&gt; void): Promise&lt;void&gt;</code></pre><p>Sync process can make data intermittently inconsistent. Scripts which require strong data consistency can use this function to wait for a possible sync process to finish and prevent new sync process from starting while it is running.</p><p>Because this is an async process, the inner callback doesn't have automatic transaction handling, so in case you need to make some DB changes, you need to surround your call with api.transactional(...)</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>() =&gt; void</code><br>function to be executed while sync process is not running</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;void&gt;</code>: resolves once the callback is finished (callback is awaited)</p></td></tr><tr><td><code>backupNow</code></td><td><pre><code class=\"language-application-typescript\">backupNow(backupName: string): Promise&lt;string&gt;</code></pre><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>backupName</code></td><td><code>string</code><br>If the backupName is e.g. \"now\", then the backup will be written to \"backup-now.db\" file</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;string&gt;</code>: resolves once the backup is finished</p></td></tr><tr><td><code>duplicateSubtree</code></td><td><pre><code class=\"language-application-typescript\">duplicateSubtree(origNoteId: string, newParentNoteId: string): NoteAndBranch</code></pre><p>Enables the complete duplication of the specified original note and all its children into the specified parent note. The new note will be named the same as the original, with (Dup) added to the end of it.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>origNoteId</code></td><td><code>string</code><br>the noteId for the original note to be duplicated</td></tr><tr><td><code>newParentNoteId</code></td><td><code>string</code><br>the noteId for the parent note where the duplication is to be placed.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>NoteAndBranch</code>: the note and the branch of the newly created note.</p></td></tr></tbody></table></figure><h2><code>BNote</code></h2><p>A note as seen by backend scripts (subset of trilium-core's <code>BNote</code>).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>noteId</code></td><td><p><code>string</code><br>The ID of the note. The root note's ID is <code>root</code>. System notes have IDs that start with <code>_</code>, such as <code>_hidden</code>.</p></td></tr><tr><td><code>title</code></td><td><p><code>string</code><br>The title of the note. For a protected note read outside a protected session, this holds the encrypted title. Use <code>getTitleOrProtected()</code> to show a title safely.</p></td></tr><tr><td><code>type</code></td><td><p><code>string</code><br>The note type, such as <code>text</code>, <code>code</code>, <code>file</code>, <code>image</code>, <code>search</code> or <code>book</code>. Together with <code>mime</code>, it decides how Trilium renders the content.</p></td></tr><tr><td><code>mime</code></td><td><p><code>string</code><br>The MIME type of the note's content, such as <code>text/html</code> for a text note or <code>application/javascript;env=backend</code> for a backend script.</p></td></tr><tr><td><code>isProtected</code></td><td><p><code>boolean</code><br>Whether the note is protected. The title and content of a protected note are encrypted, and can be read or changed only while a protected session is active.</p></td></tr><tr><td><code>isArchived</code></td><td><p><code>boolean</code><br>Whether the note is archived: it has an <code>archived</code> label of its own or inherits one. A non-inheritable <code>archived</code> label on an ancestor does not count; see <code>areAllNotePathsArchived()</code>.</p></td></tr><tr><td><code>isDeleted</code></td><td><p><code>boolean</code><br>Whether the note has been deleted, or its deletion is in progress. It becomes <code>true</code> on an object a script still holds after the note is deleted.</p></td></tr><tr><td><code>shareId</code></td><td><p><code>string</code><br>Share root ID this note is published under, if any.</p></td></tr><tr><td><code>blobId</code></td><td><p><code>string</code><br>The ID of the blob that stores the note's content. It changes whenever the content changes, and notes with identical content share a blob.</p></td></tr><tr><td><code>dateCreated</code></td><td><p><code>string</code><br>The date and time the note was created, in local time with its UTC offset, for example <code>2026-10-22 14:03:05.123+0200</code>.</p></td></tr><tr><td><code>dateModified</code></td><td><p><code>string</code><br>The date and time the note was last modified, in local time with its UTC offset, for example <code>2026-10-22 14:03:05.123+0200</code>. It changes when the content changes or the note itself is saved, such as after a title change.</p></td></tr><tr><td><code>utcDateCreated</code></td><td><p><code>string</code><br>The date and time the note was created, in UTC, for example <code>2026-10-22 12:03:05.123Z</code>.</p></td></tr><tr><td><code>utcDateModified</code></td><td><p><code>string</code><br>The date and time the note was last modified, in UTC, for example <code>2026-10-22 12:03:05.123Z</code>. It changes when the content changes or the note itself is saved.</p></td></tr><tr><td><code>getContent</code></td><td><pre><code class=\"language-application-typescript\">getContent(): string | Uint8Array&lt;ArrayBufferLike&gt;</code></pre><p>Returns the content of the note: a string for text-based notes (see <code>hasStringContent()</code>), a <code>Uint8Array</code> for binary ones such as images and files. The content is read from the database on each call. For a protected note outside a protected session, it returns an empty string.</p></td></tr><tr><td><code>setContent</code></td><td><pre><code class=\"language-application-typescript\">setContent(content: string | Uint8Array&lt;ArrayBufferLike&gt;, opts?: { forceFrontendReload?: boolean }): void</code></pre><p>Replaces the content of the note and saves it immediately; there is no need to call <code>save()</code> afterwards. If the content is unchanged, nothing is saved and <code>dateModified</code> stays the same.</p><p>The call throws an error when <code>content</code> is <code>null</code> or <code>undefined</code>, when the note is protected and no protected session is active, and when the note is read-only, such as a page of the in-app help.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>content</code></td><td><code>string | Uint8Array&lt;ArrayBufferLike&gt;</code><br>The new content: a string for text-based notes, or a <code>Uint8Array</code> for binary ones such as images and files.</td></tr><tr><td><code>opts</code><br><em>optional</em></td><td><code>{ forceFrontendReload?: boolean }</code></td></tr></tbody></table></figure></td></tr><tr><td><code>getJsonContent</code></td><td><pre><code class=\"language-application-typescript\">getJsonContent(): T | null</code></pre><p>Returns the note's content parsed as JSON. Returns <code>null</code> when the content is empty, blank or binary, and throws an error when it is not valid JSON.</p></td></tr><tr><td><code>getJsonContentSafely</code></td><td><pre><code class=\"language-application-typescript\">getJsonContentSafely(): unknown</code></pre><p>Returns the note's content parsed as JSON, like <code>getJsonContent()</code>, but returns <code>null</code> instead of throwing an error when the content is not valid JSON.</p></td></tr><tr><td><code>setJsonContent</code></td><td><pre><code class=\"language-application-typescript\">setJsonContent(content: unknown): void</code></pre><p>Serializes <code>content</code> to JSON, indented with tabs, and saves it as the note's content through <code>setContent()</code>, with the same errors.</p></td></tr><tr><td><code>hasStringContent</code></td><td><pre><code class=\"language-application-typescript\">hasStringContent(): boolean</code></pre><p>Returns whether <code>getContent()</code> returns a string rather than a <code>Uint8Array</code>. This holds for text, code, canvas, Mermaid and other text-based note types, and for MIME types such as <code>text/*</code>, <code>application/json</code>, <code>application/javascript</code> and <code>image/svg+xml</code>.</p></td></tr><tr><td><code>getFileName</code></td><td><pre><code class=\"language-application-typescript\">getFileName(): string</code></pre><p>Returns a file name for the note, as used when it is downloaded or exported: the title with characters invalid in file names removed (<code>untitled</code> when the title is empty), plus an extension. The extension is <code>.html</code> for text notes, <code>.json</code> for relation maps, canvases and saved searches, and otherwise comes from the MIME type, unless the title already ends in a matching one.</p></td></tr><tr><td><code>getFlatText</code></td><td><pre><code class=\"language-application-typescript\">getFlatText(): string</code></pre><p>Returns a single line of text that Trilium searches when matching notes: the note ID, type, MIME type, branch prefixes, title and attributes (as <code>#name=value</code> and <code>~name=value</code>, inherited ones included), lowercased and with diacritics removed. The content is not included.</p></td></tr><tr><td><code>getPojo</code></td><td><pre><code class=\"language-application-typescript\">getPojo(): Record&lt;string, unknown&gt;</code></pre><p>Plain serialisable representation of the note (the real return type is <code>NotePojo</code>).</p></td></tr><tr><td><code>getTitleOrProtected</code></td><td><pre><code class=\"language-application-typescript\">getTitleOrProtected(): string</code></pre><p>Returns the note's title, or the literal string <code>[protected]</code> when the note is protected and no protected session is active.</p></td></tr><tr><td><code>getIcon</code></td><td><pre><code class=\"language-application-typescript\">getIcon(): string</code></pre><p>Returns the CSS classes of the note's icon, for example <code>tn-icon bx bx-note</code>. The icon comes from the note's <code>iconClass</code> label (its own or inherited) when it has one, and otherwise from its type.</p></td></tr><tr><td><code>parents</code></td><td><p><code>BNote[]</code><br>The parent notes of this note: one per place the note appears in the tree, so a cloned note has several. Parents that are not archived come first. This is the same array <code>getParentNotes()</code> returns; don't modify it.</p></td></tr><tr><td><code>children</code></td><td><p><code>BNote[]</code><br>The child notes of this note, in their order in the tree. This is the same array <code>getChildNotes()</code> returns; don't modify it.</p></td></tr><tr><td><code>parentBranches</code></td><td><p><code>BBranch[]</code><br>The branches that place this note under each of its parents, in the same order as <code>parents</code>. This is the same array <code>getParentBranches()</code> returns; don't modify it.</p></td></tr><tr><td><code>parentCount</code></td><td><p><code>number</code><br>The number of parent notes, which is greater than 1 for a cloned note.</p></td></tr><tr><td><code>childrenCount</code></td><td><p><code>number</code><br>The number of child notes, including hidden and system notes.</p></td></tr><tr><td><code>getParentNotes</code></td><td><pre><code class=\"language-application-typescript\">getParentNotes(): BNote[]</code></pre><p>Returns the parent notes of this note, one per place the note appears in the tree. Parents that are not archived come first. The result is the <code>parents</code> array itself; don't modify it.</p></td></tr><tr><td><code>getChildNotes</code></td><td><pre><code class=\"language-application-typescript\">getChildNotes(): BNote[]</code></pre><p>Returns the child notes of this note, in their order in the tree. The result is the <code>children</code> array itself; don't modify it.</p></td></tr><tr><td><code>getVisibleChildNotes</code></td><td><pre><code class=\"language-application-typescript\">getVisibleChildNotes(): BNote[]</code></pre><p>Returns the child notes that are shown in a shared note's navigation tree, in tree order. It leaves out system notes, whose IDs start with <code>_</code>, and notes with a <code>shareHiddenFromTree</code> label, their own or inherited. Archived notes are included.</p></td></tr><tr><td><code>getParentBranches</code></td><td><pre><code class=\"language-application-typescript\">getParentBranches(): BBranch[]</code></pre><p>Returns the branches that place this note under each of its parents. The result is the <code>parentBranches</code> array itself; don't modify it.</p></td></tr><tr><td><code>getChildBranches</code></td><td><pre><code class=\"language-application-typescript\">getChildBranches(): BBranch[]</code></pre><p>Returns the branches that connect this note to each of its children, in their order in the tree. A branch holds the child's position and prefix.</p></td></tr><tr><td><code>getVisibleChildBranches</code></td><td><pre><code class=\"language-application-typescript\">getVisibleChildBranches(): BBranch[]</code></pre><p>Returns the child branches whose notes are shown in a shared note's navigation tree, in tree order. It leaves out system notes, whose IDs start with <code>_</code>, and notes with a <code>shareHiddenFromTree</code> label, their own or inherited. Archived notes are included.</p></td></tr><tr><td><code>getStrongParentBranches</code></td><td><pre><code class=\"language-application-typescript\">getStrongParentBranches(): BBranch[]</code></pre><p>Returns the parent branches the user created, leaving out the automatic placements under the shared notes (<code>_share</code>) and the bookmarks (<code>_lbBookmarks</code>). A note whose last such branch is deleted is deleted too.</p></td></tr><tr><td><code>getFilteredChildBranches</code></td><td><pre><code class=\"language-application-typescript\">getFilteredChildBranches(): BBranch[]</code></pre><p>Returns the same branches as <code>getChildBranches()</code>. Despite its name, it filters nothing: archived and hidden children are included.</p></td></tr><tr><td><code>getBranches</code></td><td><pre><code class=\"language-application-typescript\">getBranches(): BBranch[]</code></pre><p>Returns the branches that place this note under each of its parents.</p><aside class=\"admonition warning\"><p>Deprecated. Use <code>getParentBranches()</code> instead.</p></aside></td></tr><tr><td><code>hasChildren</code></td><td><pre><code class=\"language-application-typescript\">hasChildren(): boolean</code></pre><p>Returns whether the note has at least one child note, including hidden and system notes.</p></td></tr><tr><td><code>hasVisibleChildren</code></td><td><pre><code class=\"language-application-typescript\">hasVisibleChildren(): boolean</code></pre><p>Returns whether <code>getVisibleChildNotes()</code> returns at least one note.</p></td></tr><tr><td><code>getAncestors</code></td><td><pre><code class=\"language-application-typescript\">getAncestors(): BNote[]</code></pre><p>Returns every ancestor of the note across all of its paths in the tree, each note once, up to and including the root note. The note itself is not included. The order follows the parents: each parent comes first, followed by its own ancestors.</p></td></tr><tr><td><code>getAncestorNoteIds</code></td><td><pre><code class=\"language-application-typescript\">getAncestorNoteIds(): string[]</code></pre><p>Returns the IDs of the notes <code>getAncestors()</code> returns, in the same order.</p></td></tr><tr><td><code>getDescendantNoteIds</code></td><td><pre><code class=\"language-application-typescript\">getDescendantNoteIds(): string[]</code></pre><p>Returns the IDs of this note and all its descendants.</p><aside class=\"admonition warning\"><p>Deprecated. Use <code>getSubtreeNoteIds()</code> instead.</p></aside></td></tr><tr><td><code>getDistanceToAncestor</code></td><td><pre><code class=\"language-application-typescript\">getDistanceToAncestor(ancestorNoteId: string): number</code></pre><p>Returns the number of levels between this note and the given ancestor along the shortest path: <code>1</code> for a parent, <code>2</code> for a grandparent, and <code>0</code> for the note itself. If the note is not a descendant of the given note, it returns <code>999999</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>ancestorNoteId</code></td><td><code>string</code><br>The ID of the ancestor note to measure the distance to.</td></tr></tbody></table></figure></td></tr><tr><td><code>hasAncestor</code></td><td><pre><code class=\"language-application-typescript\">hasAncestor(ancestorNoteId: string): boolean</code></pre><p>Returns whether the given note is an ancestor of this note on any of its paths. It returns <code>false</code> for the note's own ID.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>ancestorNoteId</code></td><td><code>string</code><br>The ID of the note to look for among the ancestors.</td></tr></tbody></table></figure></td></tr><tr><td><code>isDescendantOfNote</code></td><td><pre><code class=\"language-application-typescript\">isDescendantOfNote(ancestorNoteId: string): boolean</code></pre><p>Returns whether the given note lies on at least one of this note's paths from the root. Unlike <code>hasAncestor()</code>, it returns <code>true</code> for the note's own ID.</p></td></tr><tr><td><code>isRoot</code></td><td><pre><code class=\"language-application-typescript\">isRoot(): boolean</code></pre><p>Returns whether this note is the root of the note tree, whose ID is <code>root</code>.</p></td></tr><tr><td><code>getSubtree</code></td><td><pre><code class=\"language-application-typescript\">getSubtree(opts?: SubtreeOpts): { notes: BNote[]; relationships: SubtreeRelationship[] }</code></pre><p>Returns the note and all its descendants, each note once, together with every parent-child relationship among them, including those of cloned notes.</p><p><strong>Returns</strong> <code>{ notes: BNote[]; relationships: SubtreeRelationship[] }</code>: An object with <code>notes</code>, the notes of the subtree including this note, and <code>relationships</code>, the <code>{ parentNoteId, childNoteId }</code> pairs connecting them.</p></td></tr><tr><td><code>getSubtreeNoteIds</code></td><td><pre><code class=\"language-application-typescript\">getSubtreeNoteIds(opts?: SubtreeOpts): string[]</code></pre><p>Returns the IDs of this note and all its descendants, each once. Takes the same options as <code>getSubtree()</code>.</p></td></tr><tr><td><code>getSubtreeNotesIncludingTemplated</code></td><td><pre><code class=\"language-application-typescript\">getSubtreeNotesIncludingTemplated(): BNote[]</code></pre><p>Returns the notes that this note's inheritable attributes reach: the note itself, its descendants, and every note that uses one of them as a <code>template</code> or <code>inherit</code> relation target, along with that note's descendants. Each note appears once; the hidden subtree (<code>_hidden</code>) is skipped.</p></td></tr><tr><td><code>getInheritingNotes</code></td><td><pre><code class=\"language-application-typescript\">getInheritingNotes(): BNote[]</code></pre><p>Returns the notes that this note's non-inheritable attributes apply to: the note itself and every note that uses it as a <code>template</code> or <code>inherit</code> relation target. Their descendants are not included.</p></td></tr><tr><td><code>getAllNotePaths</code></td><td><pre><code class=\"language-application-typescript\">getAllNotePaths(): string[][]</code></pre><p>Returns every path from the root note to this note, one per placement in the tree. Each path is an array of note IDs that starts with <code>root</code> and ends with this note's ID.</p></td></tr><tr><td><code>getBestNotePath</code></td><td><pre><code class=\"language-application-typescript\">getBestNotePath(hoistedNoteId?: string): string[]</code></pre><p>Returns the best path from the root note to this note as an array of note IDs, ranked as in <code>getSortedNotePathRecords()</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>hoistedNoteId</code><br><em>optional</em></td><td><code>string</code><br>The ID of the note whose subtree is preferred. Defaults to <code>root</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>getBestNotePathString</code></td><td><pre><code class=\"language-application-typescript\">getBestNotePathString(hoistedNoteId?: string): string</code></pre><p>Returns the best path from the root note to this note as a string of note IDs joined by <code>/</code>, for example <code>root/a1h315/js725h</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>hoistedNoteId</code><br><em>optional</em></td><td><code>string</code><br>The ID of the note whose subtree is preferred. Defaults to <code>root</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>getSortedNotePathRecords</code></td><td><pre><code class=\"language-application-typescript\">getSortedNotePathRecords(hoistedNoteId?: string): NotePathRecord[]</code></pre><p>Returns a record for every path from the root note to this note, best path first. Paths within the hoisted note's subtree come first, then paths without archived notes, then paths outside the hidden subtree, then shorter paths.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>hoistedNoteId</code><br><em>optional</em></td><td><code>string</code><br>The ID of the note whose subtree is preferred. Defaults to <code>root</code>.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>NotePathRecord[]</code>: Records whose <code>notePath</code> holds the note IDs from the root to this note, with flags telling whether the path lies within the hoisted subtree (<code>isInHoistedSubTree</code>), passes through an archived note, the note itself included (<code>isArchived</code>), or lies within the hidden subtree (<code>isHidden</code>).</p></td></tr><tr><td><code>areAllNotePathsArchived</code></td><td><pre><code class=\"language-application-typescript\">areAllNotePathsArchived(): boolean</code></pre><p>Returns whether every path to this note passes through an archived note. Unlike <code>isArchived</code>, this also counts a non-inheritable <code>archived</code> label on an ancestor. It throws an error if the note has no path from the root.</p></td></tr><tr><td><code>ownedAttributes</code></td><td><p><code>Attribute[]</code><br>The labels and relations defined directly on this note, without inherited ones.</p></td></tr><tr><td><code>targetRelations</code></td><td><p><code>Attribute[]</code><br>The relations in other notes (or this one) that point to this note. This includes the link relations Trilium creates automatically for links in note content, such as <code>internalLink</code> and <code>imageLink</code>.</p></td></tr><tr><td><code>attributeCount</code></td><td><p><code>number</code><br>The number of labels and relations on this note, inherited ones and automatic link relations included.</p></td></tr><tr><td><code>ownedAttributeCount</code></td><td><p><code>number</code><br>The number of labels and relations defined directly on this note, automatic link relations included.</p></td></tr><tr><td><code>labelCount</code></td><td><p><code>number</code><br>The number of labels on this note, inherited ones included.</p></td></tr><tr><td><code>ownedLabelCount</code></td><td><p><code>number</code><br>The number of labels defined directly on this note.</p></td></tr><tr><td><code>relationCount</code></td><td><p><code>number</code><br>The number of relations on this note, inherited ones included. Excludes the link relations Trilium creates automatically for links in note content (<code>internalLink</code>, <code>imageLink</code>, <code>relationMapLink</code>, <code>includeNoteLink</code>).</p></td></tr><tr><td><code>relationCountIncludingLinks</code></td><td><p><code>number</code><br>The number of relations on this note, inherited ones included, together with the link relations Trilium creates automatically for links in note content.</p></td></tr><tr><td><code>ownedRelationCount</code></td><td><p><code>number</code><br>The number of relations defined directly on this note, excluding the link relations Trilium creates automatically for links in note content.</p></td></tr><tr><td><code>ownedRelationCountIncludingLinks</code></td><td><p><code>number</code><br>The number of relations defined directly on this note, together with the link relations Trilium creates automatically for links in note content.</p></td></tr><tr><td><code>targetRelationCount</code></td><td><p><code>number</code><br>The number of relations in other notes that point to this note, excluding the link relations Trilium creates automatically for links in note content.</p></td></tr><tr><td><code>targetRelationCountIncludingLinks</code></td><td><p><code>number</code><br>The number of relations in other notes that point to this note, together with the link relations Trilium creates automatically for links in note content.</p></td></tr><tr><td><code>getAttributes</code></td><td><pre><code class=\"language-application-typescript\">getAttributes(type?: string, name?: string): Attribute[]</code></pre><p>Returns the labels and relations of this note, inherited ones included, optionally filtered by type and name. Without a filter, the result is the note's own cached array; don't modify it.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code><br><em>optional</em></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>; any other value throws an error.</td></tr><tr><td><code>name</code><br><em>optional</em></td><td><code>string</code><br>The attribute name, without the leading <code>#</code> or <code>~</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>getOwnedAttributes</code></td><td><pre><code class=\"language-application-typescript\">getOwnedAttributes(type?: string, name?: string): Attribute[]</code></pre><p>Returns the labels and relations defined directly on this note, optionally filtered by type and name. Without a filter, the result is the <code>ownedAttributes</code> array itself; don't modify it.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code><br><em>optional</em></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>; any other value throws an error.</td></tr><tr><td><code>name</code><br><em>optional</em></td><td><code>string</code><br>The attribute name, without the leading <code>#</code> or <code>~</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>getAttribute</code></td><td><pre><code class=\"language-application-typescript\">getAttribute(type: string, name: string): Attribute | null</code></pre><p>Returns the first attribute of the given type and name, inherited ones included, or <code>null</code> if there is none.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>getOwnedAttribute</code></td><td><pre><code class=\"language-application-typescript\">getOwnedAttribute(type: string, name: string, value?: string | null): Attribute | null</code></pre><p>Returns the first attribute of the given type and name defined directly on this note, or <code>null</code> if there is none. It skips inheritance, so it can be much faster than <code>getAttribute()</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string | null</code><br>The value to match; when omitted, any value matches.</td></tr></tbody></table></figure></td></tr><tr><td><code>getAttributeValue</code></td><td><pre><code class=\"language-application-typescript\">getAttributeValue(type: string, name: string): string | null</code></pre><p>Returns the value of the first attribute of the given type and name, inherited ones included, or <code>null</code> if there is none. For a relation, the value is the target note's ID.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>getOwnedAttributeValue</code></td><td><pre><code class=\"language-application-typescript\">getOwnedAttributeValue(type: string, name: string): string | null</code></pre><p>Returns the value of the first attribute of the given type and name defined directly on this note, or <code>null</code> if there is none. For a relation, the value is the target note's ID.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>getAttributeById</code></td><td><pre><code class=\"language-application-typescript\">getAttributeById(attributeId: string): Attribute | undefined</code></pre><p>Returns the attribute of this note with the given ID, inherited ones included, or <code>undefined</code> if there is none.</p></td></tr><tr><td><code>getAttributeCaseInsensitive</code></td><td><pre><code class=\"language-application-typescript\">getAttributeCaseInsensitive(type: string, name: string, value?: string | null): Attribute | undefined</code></pre><p>Returns the first attribute of the given type whose name, and optionally value, matches regardless of letter case, or <code>undefined</code> if none does. Inherited attributes are included.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string | null</code><br>The value to match; an empty or omitted value matches any value.</td></tr></tbody></table></figure></td></tr><tr><td><code>hasAttribute</code></td><td><pre><code class=\"language-application-typescript\">hasAttribute(type: string, name: string): boolean</code></pre><p>Returns <code>true</code> if the note has a label or relation of the given type and name, inherited ones included.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>hasOwnedAttribute</code></td><td><pre><code class=\"language-application-typescript\">hasOwnedAttribute(type: string, name: string, value?: string): boolean</code></pre><p>Returns whether the note has a label or relation of the given type and name defined directly on it. Inherited attributes don't count.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The value to match; when omitted, any value matches.</td></tr></tbody></table></figure></td></tr><tr><td><code>getLabelDefinitions</code></td><td><pre><code class=\"language-application-typescript\">getLabelDefinitions(): Attribute[]</code></pre><p>Returns the attribute definitions on this note, inherited ones included. Currently returns the same <code>#relation:*</code> definitions as <code>getRelationDefinitions()</code>, not the <code>#label:*</code> ones; to read label definitions, filter <code>getLabels()</code> by names that start with <code>label:</code>.</p></td></tr><tr><td><code>getRelationDefinitions</code></td><td><pre><code class=\"language-application-typescript\">getRelationDefinitions(): Attribute[]</code></pre><p>Returns the relation definitions on this note, inherited ones included: the <code>#relation:*</code> labels that declare promoted relations, such as <code>#relation:author=\"promoted,single\"</code>.</p></td></tr><tr><td><code>getTargetRelations</code></td><td><pre><code class=\"language-application-typescript\">getTargetRelations(): Attribute[]</code></pre><p>Returns the relations in other notes (or this one) that point to this note, the automatic link relations included. Same as <code>targetRelations</code>.</p></td></tr><tr><td><code>getLabel</code></td><td><pre><code class=\"language-application-typescript\">getLabel(name: string): Attribute | null</code></pre><p>Returns the first label with the given name, inherited ones included, or <code>null</code> if there is none. Pass the name without the leading <code>#</code>.</p></td></tr><tr><td><code>getOwnedLabel</code></td><td><pre><code class=\"language-application-typescript\">getOwnedLabel(name: string): Attribute | null</code></pre><p>Returns the first label with the given name defined directly on this note, or <code>null</code> if there is none.</p></td></tr><tr><td><code>getLabels</code></td><td><pre><code class=\"language-application-typescript\">getLabels(name?: string): Attribute[]</code></pre><p>Returns the labels of this note, inherited ones included. When <code>name</code> is given, only labels with that name are returned.</p></td></tr><tr><td><code>getOwnedLabels</code></td><td><pre><code class=\"language-application-typescript\">getOwnedLabels(name: string): Attribute[]</code></pre><p>Returns the labels with the given name defined directly on this note.</p></td></tr><tr><td><code>getLabelValue</code></td><td><pre><code class=\"language-application-typescript\">getLabelValue(name: string): string | null</code></pre><p>Returns the value of the first label with the given name, inherited ones included, or <code>null</code> if there is none. A label without a value returns an empty string.</p></td></tr><tr><td><code>getOwnedLabelValue</code></td><td><pre><code class=\"language-application-typescript\">getOwnedLabelValue(name: string): string | null</code></pre><p>Returns the value of the first label with the given name defined directly on this note, or <code>null</code> if there is none.</p></td></tr><tr><td><code>getLabelValues</code></td><td><pre><code class=\"language-application-typescript\">getLabelValues(name: string): string[]</code></pre><p>Returns the values of all labels with the given name, inherited ones included, for labels that can occur more than once.</p></td></tr><tr><td><code>getOwnedLabelValues</code></td><td><pre><code class=\"language-application-typescript\">getOwnedLabelValues(name: string): string[]</code></pre><p>Returns the values of all labels with the given name defined directly on this note.</p></td></tr><tr><td><code>hasLabel</code></td><td><pre><code class=\"language-application-typescript\">hasLabel(name: string): boolean</code></pre><p>Returns whether the note has a label with the given name, inherited ones included.</p></td></tr><tr><td><code>hasOwnedLabel</code></td><td><pre><code class=\"language-application-typescript\">hasOwnedLabel(name: string, value?: string): boolean</code></pre><p>Returns whether the note has a label with the given name defined directly on it.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The value to match; when omitted, any value matches.</td></tr></tbody></table></figure></td></tr><tr><td><code>isLabelTruthy</code></td><td><pre><code class=\"language-application-typescript\">isLabelTruthy(name: string): boolean</code></pre><p>Returns whether the note has a label with the given name, inherited ones included, whose value is not <code>\"false\"</code>. A label without a value counts as <code>true</code>.</p></td></tr><tr><td><code>hasInheritableArchivedLabel</code></td><td><pre><code class=\"language-application-typescript\">hasInheritableArchivedLabel(): boolean</code></pre><p>Returns <code>true</code> if the note has an inheritable <code>#archived</code> label, owned or inherited, so that the note's descendants are archived too.</p></td></tr><tr><td><code>getRelation</code></td><td><pre><code class=\"language-application-typescript\">getRelation(name: string): Attribute | null</code></pre><p>Returns the first relation with the given name, inherited ones included, or <code>null</code> if there is none. Pass the name without the leading <code>~</code>.</p></td></tr><tr><td><code>getOwnedRelation</code></td><td><pre><code class=\"language-application-typescript\">getOwnedRelation(name: string): Attribute | null</code></pre><p>Returns the first relation with the given name defined directly on this note, or <code>null</code> if there is none.</p></td></tr><tr><td><code>getRelations</code></td><td><pre><code class=\"language-application-typescript\">getRelations(name?: string): Attribute[]</code></pre><p>Returns the relations of this note, inherited ones included. When <code>name</code> is given, only relations with that name are returned.</p></td></tr><tr><td><code>getOwnedRelations</code></td><td><pre><code class=\"language-application-typescript\">getOwnedRelations(name?: string | null): Attribute[]</code></pre><p>Returns the relations defined directly on this note. When <code>name</code> is given, only relations with that name are returned.</p></td></tr><tr><td><code>getRelationValue</code></td><td><pre><code class=\"language-application-typescript\">getRelationValue(name: string): string | null</code></pre><p>Returns the ID of the note that the first relation with the given name points to, inherited relations included, or <code>null</code> if there is none. To get the note itself, use <code>getRelationTarget()</code>.</p></td></tr><tr><td><code>getOwnedRelationValue</code></td><td><pre><code class=\"language-application-typescript\">getOwnedRelationValue(name: string): string | null</code></pre><p>Returns the ID of the note that the first relation with the given name defined directly on this note points to, or <code>null</code> if there is none.</p></td></tr><tr><td><code>getRelationTarget</code></td><td><pre><code class=\"language-application-typescript\">getRelationTarget(name: string): BNote | null</code></pre><p>Returns the note that the first relation with the given name points to, or <code>null</code> if the note has no such relation. Inherited relations are included.</p></td></tr><tr><td><code>hasRelation</code></td><td><pre><code class=\"language-application-typescript\">hasRelation(name: string, value?: string): boolean</code></pre><p>Returns whether the note has a relation with the given name, inherited ones included.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The ID of the target note to match; when omitted, any target matches.</td></tr></tbody></table></figure></td></tr><tr><td><code>hasOwnedRelation</code></td><td><pre><code class=\"language-application-typescript\">hasOwnedRelation(name: string, value?: string): boolean</code></pre><p>Returns whether the note has a relation with the given name defined directly on it.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The ID of the target note to match; when omitted, any target matches.</td></tr></tbody></table></figure></td></tr><tr><td><code>addLabel</code></td><td><pre><code class=\"language-application-typescript\">addLabel(name: string, value?: string, isInheritable?: boolean): Attribute</code></pre><p>Adds a label to this note, saves it and returns it. It adds a new label even when the note already has one with that name; to change an existing label instead, use <code>setLabel()</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code><br>The label name, without the leading <code>#</code>.</td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The label value. Defaults to an empty string.</td></tr><tr><td><code>isInheritable</code><br><em>optional</em></td><td><code>boolean</code><br>Whether the note's descendants inherit the label. Defaults to <code>false</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>addRelation</code></td><td><pre><code class=\"language-application-typescript\">addRelation(name: string, targetNoteId: string, isInheritable?: boolean): Attribute</code></pre><p>Adds a relation from this note to another note, saves it and returns it. It adds a new relation even when the note already has one with that name; to change an existing relation instead, use <code>setRelation()</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code><br>The relation name, without the leading <code>~</code>.</td></tr><tr><td><code>targetNoteId</code></td><td><code>string</code></td></tr><tr><td><code>isInheritable</code><br><em>optional</em></td><td><code>boolean</code><br>Whether the note's descendants inherit the relation. Defaults to <code>false</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>addAttribute</code></td><td><pre><code class=\"language-application-typescript\">addAttribute(type: string, name: string, value?: string, isInheritable?: boolean): Attribute</code></pre><p>Adds a label or relation to this note, saves it and returns it. <code>addLabel()</code> and <code>addRelation()</code> do the same for one type.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code><br>The attribute name, without the leading <code>#</code> or <code>~</code>.</td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The label's text, or the relation's target note ID. Defaults to an empty string.</td></tr><tr><td><code>isInheritable</code><br><em>optional</em></td><td><code>boolean</code><br>Whether the note's descendants inherit the attribute. Defaults to <code>false</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>setLabel</code></td><td><pre><code class=\"language-application-typescript\">setLabel(name: string, value?: string): void</code></pre><p>Sets the value of the first label with the given name defined directly on this note, or adds a non-inheritable label if the note has none of its own. Inherited labels are left alone. The change is saved immediately.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The new value. Defaults to an empty string.</td></tr></tbody></table></figure></td></tr><tr><td><code>setRelation</code></td><td><pre><code class=\"language-application-typescript\">setRelation(name: string, value?: string): void</code></pre><p>Points the first relation with the given name defined directly on this note to another note, or adds a non-inheritable relation if the note has none of its own. Inherited relations are left alone. The change is saved immediately.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The ID of the target note.</td></tr></tbody></table></figure></td></tr><tr><td><code>setAttribute</code></td><td><pre><code class=\"language-application-typescript\">setAttribute(type: string, name: string, value?: string): void</code></pre><p>Sets the value of the first attribute of the given type and name defined directly on this note, or adds a non-inheritable one if the note has none of its own. <code>setLabel()</code> and <code>setRelation()</code> do the same for one type. The change is saved immediately.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The label's text, or the relation's target note ID. Defaults to an empty string.</td></tr></tbody></table></figure></td></tr><tr><td><code>setAttributeValueById</code></td><td><pre><code class=\"language-application-typescript\">setAttributeValueById(attributeId: string, value?: string): void</code></pre><p>Sets the value of the attribute with the given ID, which must be defined directly on this note, and saves it. Throws an error if the note has no such attribute of its own.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>attributeId</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The new value. Defaults to an empty string.</td></tr></tbody></table></figure></td></tr><tr><td><code>toggleLabel</code></td><td><pre><code class=\"language-application-typescript\">toggleLabel(enabled: boolean, name: string, value?: string): void</code></pre><p>Sets the label like <code>setLabel()</code> when <code>enabled</code> is <code>true</code>, and removes it like <code>removeLabel()</code> when it is <code>false</code>.</p></td></tr><tr><td><code>toggleRelation</code></td><td><pre><code class=\"language-application-typescript\">toggleRelation(enabled: boolean, name: string, value?: string): void</code></pre><p>Sets the relation like <code>setRelation()</code> when <code>enabled</code> is <code>true</code>, and removes it like <code>removeRelation()</code> when it is <code>false</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>enabled</code></td><td><code>boolean</code></td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The ID of the target note.</td></tr></tbody></table></figure></td></tr><tr><td><code>toggleAttribute</code></td><td><pre><code class=\"language-application-typescript\">toggleAttribute(type: string, enabled: boolean, name: string, value?: string): void</code></pre><p>Sets the attribute like <code>setAttribute()</code> when <code>enabled</code> is <code>true</code>, and removes it like <code>removeAttribute()</code> when it is <code>false</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>enabled</code></td><td><code>boolean</code></td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code></td></tr></tbody></table></figure></td></tr><tr><td><code>removeLabel</code></td><td><pre><code class=\"language-application-typescript\">removeLabel(name: string, value?: string): void</code></pre><p>Removes every label with the given name defined directly on this note. Inherited labels are not affected.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The value to match; when omitted, labels with any value are removed.</td></tr></tbody></table></figure></td></tr><tr><td><code>removeRelation</code></td><td><pre><code class=\"language-application-typescript\">removeRelation(name: string, value?: string): void</code></pre><p>Removes every relation with the given name defined directly on this note. Inherited relations are not affected.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The ID of the target note to match; when omitted, relations to any note are removed.</td></tr></tbody></table></figure></td></tr><tr><td><code>removeAttribute</code></td><td><pre><code class=\"language-application-typescript\">removeAttribute(type: string, name: string, value?: string): void</code></pre><p>Removes every attribute of the given type and name defined directly on this note. Inherited attributes are not affected.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>\"label\"</code> or <code>\"relation\"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The value to match; when omitted, attributes with any value are removed.</td></tr></tbody></table></figure></td></tr><tr><td><code>isInherited</code></td><td><pre><code class=\"language-application-typescript\">isInherited(): boolean</code></pre><p>Returns <code>true</code> if another note uses this note as its template or inheritance source, through a <code>~template</code> or <code>~inherit</code> relation. Despite the name, it does not tell whether this note inherits attributes itself.</p></td></tr><tr><td><code>revisionCount</code></td><td><p><code>number | null</code><br>The number of revisions of this note. It is <code>null</code> until a search that filters or sorts by <code>revisionCount</code> or one of the size properties has run; <code>getRevisions().length</code> always works.</p></td></tr><tr><td><code>getRevisions</code></td><td><pre><code class=\"language-application-typescript\">getRevisions(): BRevision[]</code></pre><p>Returns the saved revisions of this note, oldest first.</p></td></tr><tr><td><code>saveRevision</code></td><td><pre><code class=\"language-application-typescript\">saveRevision(opts?: { description?: string; source?: string }): BRevision</code></pre><p>Saves a revision that snapshots the note's current title, content and attachments, and returns it. Afterwards, Trilium erases the oldest revisions beyond the number the revision settings keep.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code><br><em>optional</em></td><td><code>{ description?: string; source?: string }</code><br><code>description</code> names the revision; <code>source</code> records what created it: <code>\"auto\"</code> (the default), <code>\"manual\"</code>, <code>\"etapi\"</code>, <code>\"llm\"</code> or <code>\"restore\"</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>getAttachments</code></td><td><pre><code class=\"language-application-typescript\">getAttachments(): Attachment[]</code></pre><p>Returns the attachments of this note, ordered by position. Deleted attachments are excluded.</p></td></tr><tr><td><code>getAttachmentById</code></td><td><pre><code class=\"language-application-typescript\">getAttachmentById(attachmentId: string): Attachment</code></pre><p>Returns the attachment of this note with the given ID. Returns <code>undefined</code> if this note has no such attachment, although the type does not say so.</p></td></tr><tr><td><code>getAttachmentByTitle</code></td><td><pre><code class=\"language-application-typescript\">getAttachmentByTitle(title: string): Attachment | undefined</code></pre><p>Returns the first attachment of this note whose title matches exactly, or <code>undefined</code> if none does.</p></td></tr><tr><td><code>getAttachmentsByRole</code></td><td><pre><code class=\"language-application-typescript\">getAttachmentsByRole(role: string): Attachment[]</code></pre><p>Returns the attachments of this note with the given role, such as <code>\"image\"</code> or <code>\"file\"</code>, ordered by position.</p></td></tr><tr><td><code>saveAttachment</code></td><td><pre><code class=\"language-application-typescript\">saveAttachment(attachment: SaveAttachmentInput, matchBy?: \"title\" | \"attachmentId\"): Attachment</code></pre><p>Saves an attachment of this note and returns it. If an existing attachment matches, only its content is replaced; otherwise a new attachment is created from <code>attachment</code>, protected if the note is. Missing content is saved as an empty string.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>attachment</code></td><td><code>SaveAttachmentInput</code></td></tr><tr><td><code>matchBy</code><br><em>optional</em></td><td><code>\"title\" | \"attachmentId\"</code><br>How to find an existing attachment to update: <code>\"attachmentId\"</code> (the default) by <code>attachment.attachmentId</code>, which throws an error if no attachment has that ID, or <code>\"title\"</code> by <code>attachment.title</code> among this note's attachments.</td></tr></tbody></table></figure></td></tr><tr><td><code>convertToParentAttachment</code></td><td><pre><code class=\"language-application-typescript\">convertToParentAttachment(opts?: Record&lt;string, unknown&gt;): Attachment | null</code></pre><p>Converts this image note into an image attachment of its parent text note, points the parent's content at the attachment, deletes this note and returns the attachment. Returns <code>null</code> and changes nothing when <code>isEligibleForConversionToAttachment()</code> returns <code>false</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code><br><em>optional</em></td><td><code>Record&lt;string, unknown&gt;</code><br>Pass <code>{ autoConversion: true }</code> to also require that the parent links the image.</td></tr></tbody></table></figure></td></tr><tr><td><code>isEligibleForConversionToAttachment</code></td><td><pre><code class=\"language-application-typescript\">isEligibleForConversionToAttachment(opts?: Record&lt;string, unknown&gt;): boolean</code></pre><p>Returns <code>true</code> if this note can be converted into an attachment of its parent: it is an image note with no children and a single parent, the parent is a text note, both are readable in the current session, and at most one <code>~imageLink</code> relation points to the image, from the parent.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code><br><em>optional</em></td><td><code>Record&lt;string, unknown&gt;</code><br>Pass <code>{ autoConversion: true }</code> to also require that the parent links the image.</td></tr></tbody></table></figure></td></tr><tr><td><code>contentSize</code></td><td><p><code>number | null</code><br>The size of the note's content in bytes. Like the other size properties, it is <code>null</code> until a search that filters or sorts by one of them, or by <code>revisionCount</code>, has run.</p></td></tr><tr><td><code>contentAndAttachmentsSize</code></td><td><p><code>number | null</code><br>The size in bytes of the note's content together with its attachments, counting content that several of them share once. It is <code>null</code> until a search that uses it has run.</p></td></tr><tr><td><code>contentAndAttachmentsAndRevisionsSize</code></td><td><p><code>number | null</code><br>The size in bytes of the note's content together with its attachments and its revisions and their attachments, counting shared content once. It is <code>null</code> until a search that uses it has run.</p></td></tr><tr><td><code>cloneTo</code></td><td><pre><code class=\"language-application-typescript\">cloneTo(parentNoteId: string): CloneResponse</code></pre><p>Places this note under another parent note as well, keeping its existing placements, and expands the new parent in the note tree. The result does not throw on failure; check <code>success</code>, and read <code>message</code> for why it failed (for example, the note is already in that parent, the target is a search note, or the clone would create a cycle).</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>parentNoteId</code></td><td><code>string</code><br>The ID of the note to clone into.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>CloneResponse</code>: On success, <code>branchId</code> of the new branch and <code>notePath</code> of the clone.</p></td></tr><tr><td><code>deleteNote</code></td><td><pre><code class=\"language-application-typescript\">deleteNote(deleteId?: string | null): void</code></pre><p>Deletes the note from every place in the tree, together with its descendants that have no other placement, and runs its <code>runOnNoteDeletion</code> relations first. Deleted notes stay recoverable until they are erased. Does nothing if the note is already deleted.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>deleteId</code><br><em>optional</em></td><td><code>string | null</code><br>An ID that groups the deleted notes, branches and attributes so that they can be restored together. Defaults to a new random ID.</td></tr></tbody></table></figure></td></tr><tr><td><code>sortParents</code></td><td><pre><code class=\"language-application-typescript\">sortParents(): void</code></pre><p>Reorders this note's <code>parents</code> and <code>parentBranches</code> in memory so that archived and hidden parents come last, which makes Trilium prefer the other paths when it picks a note path. Saves nothing.</p></td></tr><tr><td><code>sortChildren</code></td><td><pre><code class=\"language-application-typescript\">sortChildren(): void</code></pre><p>Reorders this note's <code>children</code> array in memory by each child's <code>notePosition</code>. Saves nothing and does not change the order shown in the note tree.</p></td></tr><tr><td><code>searchNotesInSubtree</code></td><td><pre><code class=\"language-application-typescript\">searchNotesInSubtree(searchString: string): BNote[]</code></pre><p>Returns the notes that match a search query. Despite the name, the search covers the whole tree, not only this note's subtree, and leaves out archived and hidden notes; to limit it to this note's subtree, call <code>api.searchForNotes(query, { ancestorNoteId: note.noteId })</code>.</p></td></tr><tr><td><code>searchNoteInSubtree</code></td><td><pre><code class=\"language-application-typescript\">searchNoteInSubtree(searchString: string): BNote | null</code></pre><p>Returns the first note that matches a search query, or <code>undefined</code> if none does. Like <code>searchNotesInSubtree()</code>, the search covers the whole tree, not only this note's subtree.</p></td></tr><tr><td><code>getSearchResultNotes</code></td><td><pre><code class=\"language-application-typescript\">getSearchResultNotes(): BNote[]</code></pre><p>Runs the saved search of a search note and returns the notes it finds. Returns an empty array for other note types, and when the search fails (the error goes to the backend log).</p></td></tr><tr><td><code>isFolder</code></td><td><pre><code class=\"language-application-typescript\">isFolder(): boolean</code></pre><p>Returns <code>true</code> if this note is a search note or has at least one child, archived children included.</p></td></tr><tr><td><code>isContentAvailable</code></td><td><pre><code class=\"language-application-typescript\">isContentAvailable(): boolean</code></pre><p>Returns <code>true</code> if the note's title and content can be read: the note is not protected, or a protected session is open. Otherwise the content reads as an empty string and the title as <code>\"[protected]\"</code>.</p></td></tr><tr><td><code>isStringNote</code></td><td><pre><code class=\"language-application-typescript\">isStringNote(): boolean</code></pre><p>Returns whether <code>getContent()</code> returns a string rather than a <code>Uint8Array</code>.</p><aside class=\"admonition warning\"><p>Deprecated. Use <code>hasStringContent()</code> instead.</p></aside></td></tr><tr><td><code>isHtml</code></td><td><pre><code class=\"language-application-typescript\">isHtml(): boolean</code></pre><p>Returns whether this is a code, file or render note with the MIME type <code>text/html</code>.</p></td></tr><tr><td><code>isImage</code></td><td><pre><code class=\"language-application-typescript\">isImage(): boolean</code></pre><p>Returns whether this is an image note, or a file note with an <code>image/*</code> MIME type.</p></td></tr><tr><td><code>isJavaScript</code></td><td><pre><code class=\"language-application-typescript\">isJavaScript(): boolean</code></pre><p>Returns whether this is a code, file or launcher note with a JavaScript MIME type.</p></td></tr><tr><td><code>isJsx</code></td><td><pre><code class=\"language-application-typescript\">isJsx(): boolean</code></pre><p>Returns <code>true</code> if this is a code note with the MIME type <code>text/jsx</code>.</p></td></tr><tr><td><code>isJson</code></td><td><pre><code class=\"language-application-typescript\">isJson(): boolean</code></pre><p>Returns whether the note's MIME type is <code>application/json</code>, whatever its type.</p></td></tr><tr><td><code>isMarkdown</code></td><td><pre><code class=\"language-application-typescript\">isMarkdown(): boolean</code></pre><p>Returns whether this is a code note with a Markdown MIME type.</p></td></tr><tr><td><code>isOptions</code></td><td><pre><code class=\"language-application-typescript\">isOptions(): boolean</code></pre><p>Returns <code>true</code> if this note is one of the settings pages in the hidden subtree, whose IDs start with <code>_options</code>.</p></td></tr><tr><td><code>isLaunchBarConfig</code></td><td><pre><code class=\"language-application-typescript\">isLaunchBarConfig(): boolean</code></pre><p>Returns <code>true</code> if this note is a launcher or one of the containers that configure the desktop or mobile launch bar.</p></td></tr><tr><td><code>isHiddenCompletely</code></td><td><pre><code class=\"language-application-typescript\">isHiddenCompletely(): boolean</code></pre><p>Returns whether every path to this note passes through the hidden subtree (<code>_hidden</code>), so that the note has no placement in the visible tree. Returns <code>false</code> for the root note and for <code>_hidden</code> itself.</p></td></tr><tr><td><code>isInHiddenSubtree</code></td><td><pre><code class=\"language-application-typescript\">isInHiddenSubtree(): boolean</code></pre><p>Returns <code>true</code> if this note is the hidden root note (<code>_hidden</code>) or lies under it in any of its placements. The hidden subtree holds Trilium's system notes, such as settings, launchers and templates.</p></td></tr><tr><td><code>getScriptEnv</code></td><td><pre><code class=\"language-application-typescript\">getScriptEnv(): \"frontend\" | \"backend\" | null</code></pre><p>Returns where the note runs as a script: <code>\"backend\"</code> for JavaScript with <code>env=backend</code> in its MIME type, <code>\"frontend\"</code> for frontend JavaScript, JSX, HTML and render notes, and <code>null</code> for notes that are not scripts.</p></td></tr><tr><td><code>executeScript</code></td><td><pre><code class=\"language-application-typescript\">executeScript(): unknown</code></pre><p>Runs this note as a backend script and returns the script's return value, which is a promise for an async script. The note must be a backend JavaScript code note; for any other note it runs nothing and returns <code>undefined</code>. Throws an error if the note is protected and no protected session is active, or if backend scripting is disabled.</p></td></tr></tbody></table></figure><h2><code>Request</code></h2><p>Minimal Express <code>Request</code> surface available to <strong>custom request handlers</strong> (a subset of Express's <code>Request</code> — re-declared here to keep this module self-contained). Only the commonly used members are typed; the real object is a full Express request.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>params</code></td><td><p><code>Record&lt;string, string&gt;</code><br>Route/path parameters.</p></td></tr><tr><td><code>query</code></td><td><p><code>Record&lt;string, unknown&gt;</code><br>Parsed query-string parameters.</p></td></tr><tr><td><code>body</code></td><td><p><code>unknown</code><br>Parsed request body (requires a matching body parser).</p></td></tr><tr><td><code>headers</code></td><td><p><code>Record&lt;string, string | string[] | undefined&gt;</code><br>Request headers (lower-cased names).</p></td></tr><tr><td><code>method</code></td><td><p><code>string</code><br>HTTP method, e.g. \"GET\", \"POST\".</p></td></tr><tr><td><code>url</code></td><td><p><code>string</code><br>Request URL (path + query string).</p></td></tr><tr><td><code>get</code></td><td><pre><code class=\"language-application-typescript\">get(headerName: string): string | undefined</code></pre><p>Returns the value of the given (case-insensitive) header.</p></td></tr></tbody></table></figure><h2><code>Response</code></h2><p>Minimal Express <code>Response</code> surface available to <strong>custom request handlers</strong> (a subset of Express's <code>Response</code>). Write the HTTP response through this object, e.g. <code>api.res.status(200).json({ ok: true })</code>.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>status</code></td><td><pre><code class=\"language-application-typescript\">status(code: number): Response</code></pre><p>Sets the HTTP status code (chainable).</p></td></tr><tr><td><code>send</code></td><td><pre><code class=\"language-application-typescript\">send(body?: unknown): Response</code></pre><p>Sends the response body (string, Buffer, object, …) and ends the response.</p></td></tr><tr><td><code>json</code></td><td><pre><code class=\"language-application-typescript\">json(body: unknown): Response</code></pre><p>Sends a JSON response and ends the response.</p></td></tr><tr><td><code>setHeader</code></td><td><pre><code class=\"language-application-typescript\">setHeader(name: string, value: string | string[]): Response</code></pre><p>Sets a response header (chainable).</p></td></tr><tr><td><code>set</code></td><td><pre><code class=\"language-application-typescript\">set(field: string, value?: string): Response</code></pre><p>Sets a response header (Express alias of <code>setHeader</code>, chainable).</p></td></tr><tr><td><code>redirect</code></td><td><pre><code class=\"language-application-typescript\">redirect(url: string): void</code></pre><p>Redirects to the given URL.</p></td></tr><tr><td><code>end</code></td><td><pre><code class=\"language-application-typescript\">end(): void</code></pre><p>Ends the response without further data.</p></td></tr></tbody></table></figure><h2><code>BBranch</code></h2><p>A branch (note→parent placement) as seen by backend scripts (subset of <code>BBranch</code>).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>branchId</code></td><td><p><code>string</code><br>The ID of the branch. Moving a note to another parent replaces its branch with a new one, so store the note ID rather than the branch ID when you need a stable reference.</p></td></tr><tr><td><code>noteId</code></td><td><p><code>string</code><br>The ID of the child note this branch places in the tree.</p></td></tr><tr><td><code>parentNoteId</code></td><td><p><code>string</code><br>The ID of the parent note. For the root note's branch, it is <code>\"none\"</code>.</p></td></tr><tr><td><code>prefix</code></td><td><p><code>string | null</code><br>The text shown before the note's title in the note tree for this placement only, or <code>null</code> if there is none.</p></td></tr><tr><td><code>notePosition</code></td><td><p><code>number</code><br>The position of the note among its siblings under this parent; notes with lower values come first.</p></td></tr><tr><td><code>isExpanded</code></td><td><p><code>boolean</code><br>Whether the note is expanded in the note tree at this placement, showing its children.</p></td></tr><tr><td><code>getNote</code></td><td><pre><code class=\"language-application-typescript\">getNote(): BNote</code></pre><p>Returns the child note this branch places in the tree.</p></td></tr><tr><td><code>getParentNote</code></td><td><pre><code class=\"language-application-typescript\">getParentNote(): BNote | null</code></pre><p>Returns the parent note. The root note's branch has no parent note.</p></td></tr></tbody></table></figure><h2><code>BRevision</code></h2><p>A note revision as seen by backend scripts (subset of trilium-core's <code>BRevision</code>).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>revisionId</code><br><em>optional</em></td><td><p><code>string</code><br>The ID of the revision.</p></td></tr><tr><td><code>noteId</code></td><td><p><code>string</code><br>The ID of the note this revision belongs to.</p></td></tr><tr><td><code>type</code></td><td><p><code>string</code><br>The note's type at the time of the revision, such as <code>\"text\"</code> or <code>\"code\"</code>.</p></td></tr><tr><td><code>mime</code></td><td><p><code>string</code><br>The note's MIME type at the time of the revision.</p></td></tr><tr><td><code>title</code></td><td><p><code>string</code><br>The note's title at the time of the revision. For a protected revision outside a protected session, it is <code>\"[protected]\"</code>.</p></td></tr><tr><td><code>dateLastEdited</code><br><em>optional</em></td><td><p><code>string</code><br>When the note was last edited before the revision was saved, in local time with its UTC offset, formatted as <code>YYYY-MM-DD HH:mm:ss.SSS+ZZZZ</code> (for example, <code>2026-10-22 14:05:09.123+0200</code>).</p></td></tr><tr><td><code>utcDateLastEdited</code><br><em>optional</em></td><td><p><code>string</code><br>When the note was last edited before the revision was saved, in UTC, formatted as <code>YYYY-MM-DD HH:mm:ss.SSSZ</code> (for example, <code>2026-10-22 12:05:09.123Z</code>).</p></td></tr><tr><td><code>contentLength</code><br><em>optional</em></td><td><p><code>number</code><br>The size of the revision's content in bytes, when it was loaded together with the revision. Revisions returned by <code>note.getRevisions()</code> and <code>note.saveRevision()</code> leave it <code>undefined</code>.</p></td></tr><tr><td><code>getContent</code></td><td><pre><code class=\"language-application-typescript\">getContent(): string | Uint8Array&lt;ArrayBufferLike&gt;</code></pre><p>Returns the content of the revision: a string for text-based note types, a <code>Uint8Array</code> for binary ones such as images and files. For a protected revision outside a protected session, it returns an empty string.</p></td></tr><tr><td><code>getJsonContent</code></td><td><pre><code class=\"language-application-typescript\">getJsonContent(): unknown</code></pre><p>Returns the revision's content parsed as JSON. Returns <code>null</code> when the content is empty, blank or binary, and throws an error when it is not valid JSON.</p></td></tr></tbody></table></figure><h2><code>DayjsInstance</code></h2><p>A date as day.js wraps it (subset).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>format</code></td><td><pre><code class=\"language-application-typescript\">format(template?: string): string</code></pre><p>Formats the date, such as <code>\"YYYY-MM-DD\"</code> for <code>2026-10-22</code>. Without a template, it returns the ISO 8601 form with the UTC offset, such as <code>2026-10-22T14:03:05+02:00</code>.</p></td></tr><tr><td><code>add</code></td><td><pre><code class=\"language-application-typescript\">add(value: number, unit: string): DayjsInstance</code></pre><p>Returns a new date, <code>value</code> units later. The date it is called on stays unchanged.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>number</code></td></tr><tr><td><code>unit</code></td><td><code>string</code><br>The unit, such as <code>\"day\"</code>, <code>\"week\"</code>, <code>\"month\"</code> or <code>\"year\"</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>subtract</code></td><td><pre><code class=\"language-application-typescript\">subtract(value: number, unit: string): DayjsInstance</code></pre><p>Returns a new date, <code>value</code> units earlier. The date it is called on stays unchanged.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>number</code></td></tr><tr><td><code>unit</code></td><td><code>string</code><br>The unit, such as <code>\"day\"</code>, <code>\"week\"</code>, <code>\"month\"</code> or <code>\"year\"</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>toDate</code></td><td><pre><code class=\"language-application-typescript\">toDate(): Date</code></pre><p>Returns the date as a JavaScript <code>Date</code>.</p></td></tr></tbody></table></figure><h2>Types</h2><h3><code>Dayjs</code></h3><p>Minimal day.js surface (the real API exposes the full day.js factory).</p><pre><code class=\"language-application-typescript\">type Dayjs = (date?: string | number | Date) =&gt; DayjsInstance</code></pre><h3><code>Attribute</code></h3><p>A label or relation attached to a note.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>attributeId</code></td><td><code>string</code> <br>The ID of the attribute.</td></tr><tr><td><code>type</code></td><td><code>\"label\" | \"relation\"</code> <br>The type of the attribute: <code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code> <br>The name of the attribute, without the <code>#</code> or <code>~</code> prefix.</td></tr><tr><td><code>value</code></td><td><code>string</code> <br>The value of the attribute. For a relation, it is the ID of the target note. For a label without a value, it is an empty string.</td></tr><tr><td><code>isInheritable</code></td><td><code>boolean</code> <br>Whether the note's descendants inherit the attribute.</td></tr><tr><td><code>isOwned</code></td><td><code>boolean</code> <br>Not set by Trilium: neither frontend nor backend attributes carry this property, so it reads <code>undefined</code>.</td></tr></tbody></table></figure><h3><code>NoteAndBranch</code></h3><p>Result of the backend note-creation helpers.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>note</code></td><td><code>BNote</code> <br>The new note. For <code>duplicateSubtree()</code>, it is the copy of the original note.</td></tr><tr><td><code>branch</code></td><td><code>BBranch</code> <br>The branch that places the new note under its parent.</td></tr></tbody></table></figure><h3><code>SubtreeOpts</code></h3><p>Options accepted by the subtree traversal helpers on <code>BNote</code>.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>includeArchived</code> <br><em>optional</em></td><td><code>boolean</code> <br>Whether to include archived notes and their descendants. Defaults to <code>true</code>.</td></tr><tr><td><code>includeHidden</code> <br><em>optional</em></td><td><code>boolean</code> <br>Whether to descend into the hidden subtree, <code>_hidden</code>, which holds Trilium's system notes. Defaults to <code>false</code>.</td></tr><tr><td><code>resolveSearch</code> <br><em>optional</em></td><td><code>boolean</code> <br>Whether to run each search note and include its results as its children. Defaults to <code>false</code>, which includes the search note but none of its results.</td></tr></tbody></table></figure><h3><code>SubtreeRelationship</code></h3><p>A single parent→child link in a subtree (<code>BNote.getSubtree</code>).</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>parentNoteId</code></td><td><code>string</code> <br>The ID of the parent note. With <code>resolveSearch</code>, it can be a search note and the child one of its results.</td></tr><tr><td><code>childNoteId</code></td><td><code>string</code> <br>The ID of the child note. With <code>includeArchived: false</code>, it can name an archived note that the list of notes leaves out.</td></tr></tbody></table></figure><h3><code>NotePathRecord</code></h3><p>One resolved tree path to a note (subset of the client's <code>NotePathRecord</code>).</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>isArchived</code></td><td><code>boolean</code> <br>Whether a note on the path, the note itself included, is archived, which means it has the <code>#archived</code> label, owned or inherited.</td></tr><tr><td><code>isInHoistedSubTree</code></td><td><code>boolean</code> <br>Whether the path passes through the hoisted note passed to <code>getSortedNotePathRecords()</code>. It is always <code>true</code> when the hoisted note is <code>root</code>.</td></tr><tr><td><code>isSearch</code> <br><em>optional</em></td><td><code>boolean</code> <br>Whether the note itself is a search note. Only frontend scripts get this property; backend records leave it out.</td></tr><tr><td><code>notePath</code></td><td><code>string[]</code> <br>The note IDs along the path, from <code>root</code> to the note itself.</td></tr><tr><td><code>isHidden</code></td><td><code>boolean</code> <br>Whether the path passes through the hidden subtree, <code>_hidden</code>, which holds Trilium's system notes.</td></tr></tbody></table></figure><h3><code>Attachment</code></h3><p>An attachment as seen by frontend scripts (subset of the client's <code>FAttachment</code>).</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>attachmentId</code></td><td><code>string</code> <br>The ID of the attachment.</td></tr><tr><td><code>ownerId</code></td><td><code>string</code> <br>The ID of the note the attachment belongs to. For an attachment of a revision, it is the ID of the revision.</td></tr><tr><td><code>role</code></td><td><code>string</code> <br>The purpose of the attachment, such as <code>image</code> for an image shown in a text note or <code>file</code> for an attached file. Trilium also uses roles of its own, such as <code>viewConfig</code> for a collection's view settings.</td></tr><tr><td><code>mime</code></td><td><code>string</code> <br>The MIME type of the attachment's content, such as <code>image/png</code>.</td></tr><tr><td><code>title</code></td><td><code>string</code> <br>The title of the attachment, usually its file name.</td></tr><tr><td><code>utcDateModified</code></td><td><code>string</code> <br>The date and time, in UTC, that the attachment was last saved, such as <code>2026-10-22 12:03:05.123Z</code>. Replacing the content counts as saving.</td></tr><tr><td><code>contentLength</code></td><td><code>number</code> <br>The length of the attachment's content. Only some ways of loading an attachment fill it in, such as <code>getAttachments()</code>; on the backend, <code>getAttachmentsByRole()</code> leaves it <code>undefined</code>.</td></tr></tbody></table></figure><h3><code>SaveAttachmentInput</code></h3><p>Input accepted by <code>BNote.saveAttachment</code>.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>attachmentId</code> <br><em>optional</em></td><td><code>string</code> <br>The ID of the attachment to update. Omit it to create a new attachment, which gets an ID of its own.</td></tr><tr><td><code>role</code></td><td><code>string</code> <br>The purpose of the attachment, such as <code>image</code> or <code>file</code>. Used only when a new attachment is created.</td></tr><tr><td><code>mime</code></td><td><code>string</code> <br>The MIME type of the content, such as <code>image/png</code>. Used only when a new attachment is created.</td></tr><tr><td><code>title</code></td><td><code>string</code> <br>The title of the attachment, usually its file name. Used when a new attachment is created, and to find the attachment to update when <code>matchBy</code> is <code>\"title\"</code>.</td></tr><tr><td><code>content</code> <br><em>optional</em></td><td><code>string | Uint8Array&lt;ArrayBufferLike&gt;</code> <br>The content of the attachment: a string, or bytes for binary content. Defaults to an empty string.</td></tr><tr><td><code>position</code> <br><em>optional</em></td><td><code>number</code> <br>The place of the attachment among the note's attachments, which <code>getAttachments()</code> lists by ascending <code>position</code>. Used only when a new attachment is created.</td></tr></tbody></table></figure><h3><code>CloneResponse</code></h3><p>Result of a clone operation (<code>BNote.cloneTo</code>); mirrors <code>CloneResponse</code>.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>success</code></td><td><code>boolean</code> <br>Whether the note was cloned.</td></tr><tr><td><code>message</code> <br><em>optional</em></td><td><code>string</code> <br>Why the clone failed, such as the note already being in that parent. Present only when <code>success</code> is <code>false</code>.</td></tr><tr><td><code>branchId</code> <br><em>optional</em></td><td><code>string</code> <br>The ID of the new branch that places the note under the new parent. Present only when <code>success</code> is <code>true</code>.</td></tr><tr><td><code>notePath</code> <br><em>optional</em></td><td><code>string</code> <br>The path of the clone, as note IDs from <code>root</code> joined by <code>/</code>, ending in the note's ID. Present only when <code>success</code> is <code>true</code>.</td></tr></tbody></table></figure>",
+ "_help_GFXVHyblVN3d": "<p>The Electron API is the bridge between Trilium's interface and Electron's main process, exposed as the global <code>window.electronApi</code> in the desktop application.</p><p>It is not part of the <code>api</code> global of script notes, but frontend scripts running in the desktop application can call it directly. It is <code>undefined</code> in the browser and in the standalone build, so guard calls with <code>if (window.electronApi)</code>.</p><h2><code>Api</code></h2><p>The complete surface exposed to the renderer as <code>window.electronApi</code> via <code>contextBridge</code>. The renderer must access Electron-only functionality through this object — direct <code>require(\"electron\")</code> and <code>@electron/remote</code> are unavailable because <code>nodeIntegration</code> is disabled and <code>contextIsolation</code> is enabled.</p><p>The runtime value lives in <code>apps/desktop/src/preload.ts</code>; this interface is the contract both the preload script (<code>satisfies ElectronApi</code>) and the client (<code>window.electronApi</code>) share.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>window</code></td><td><code>WindowApi</code> <br>Window chrome, zoom, theme, lifecycle, and main → renderer events.</td></tr><tr><td><code>clipboard</code></td><td><code>ClipboardApi</code> <br>System clipboard access beyond what the standard Web Clipboard API offers.</td></tr><tr><td><code>shell</code></td><td><code>ShellApi</code> <br>Shell integration — opening URLs, files, and downloads with OS handlers.</td></tr><tr><td><code>contextMenu</code></td><td><code>ContextMenuApi</code> <br>Native context-menu plumbing for right-click events on web contents.</td></tr><tr><td><code>spellcheck</code></td><td><code>SpellcheckApi</code> <br>Chromium spell checker controls (dictionary, language list).</td></tr><tr><td><code>systemIntegration</code></td><td><code>SystemIntegrationApi</code> <br>OS integration — system tray and autostart / launch-on-login.</td></tr><tr><td><code>printing</code></td><td><code>PrintingApi</code> <br>Printing and PDF export pipeline.</td></tr><tr><td><code>navigation</code></td><td><code>NavigationApi</code> <br>Read/write access to Chromium's back/forward navigation history.</td></tr><tr><td><code>ws</code></td><td><code>WsApi</code> <br>In-process bridge that replaces the renderer↔server WebSocket.</td></tr><tr><td><code>security</code></td><td><code>SecurityApi</code> <br>Security settings (backend scripting, SQL console) stored outside the DB.</td></tr><tr><td><code>backupPassphrase</code></td><td><code>BackupPassphraseApi</code> <br>Write-only access to the backup passphrase, kept in the OS keyring.</td></tr><tr><td><code>onenote</code></td><td><code>OneNoteApi</code> <br>OneNote importer sign-in via a loopback OAuth redirect (desktop only).</td></tr><tr><td><code>nativeExport</code></td><td><code>NativeExportApi</code> <br>Desktop-native subtree export that streams a <code>.zip</code> straight to a file.</td></tr><tr><td><code>nativeImport</code></td><td><code>NativeImportApi</code> <br>Desktop-native large-<code>.zip</code> import that reads the user's file in place via a capability token.</td></tr><tr><td><code>dialog</code></td><td><code>DialogApi</code> <br>Native OS pickers that hand the renderer a location the user chose themselves.</td></tr><tr><td><code>restore</code></td><td><code>RestoreApi</code> <br>Choosing a backup to restore during setup, read where it lies rather than uploaded.</td></tr><tr><td><code>transcription</code></td><td><code>TranscriptionApi</code> <br>Meeting transcription: starting and stopping a recording, and following its state.</td></tr></tbody></table></figure><h2><code>WindowApi</code></h2><p>Window-level controls: zoom, theme, title bar, full screen, lifecycle, and a handful of main → renderer event subscriptions.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>setZoomFactor</code></td><td><pre><code class=\"language-application-typescript\">setZoomFactor(factor: number): void</code></pre><p>Sets the page zoom factor for the current window.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>factor</code></td><td><code>number</code><br><code>1.0</code> is 100%; e.g. <code>1.2</code> zooms to 120%.</td></tr></tbody></table></figure></td></tr><tr><td><code>getZoomFactor</code></td><td><pre><code class=\"language-application-typescript\">getZoomFactor(): number</code></pre><p>Returns the current page zoom factor (<code>1.0</code> = 100%).</p></td></tr><tr><td><code>setNativeThemeSource</code></td><td><pre><code class=\"language-application-typescript\">setNativeThemeSource(source: \"system\" | \"light\" | \"dark\"): void</code></pre><p>Overrides the operating system's reported color scheme for this app.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>source</code></td><td><code>\"system\" | \"light\" | \"dark\"</code><br>The color scheme to report, or <code>\"system\"</code> to follow the OS setting.</td></tr></tbody></table></figure></td></tr><tr><td><code>setTitleBarOverlay</code></td><td><pre><code class=\"language-application-typescript\">setTitleBarOverlay(options: { color: string; symbolColor: string; height?: number }): void</code></pre><p>Customizes the Windows and Linux native title bar overlay (the area containing the minimize / maximize / close buttons). <code>height</code> also controls their vertical placement, since the buttons are centered within the overlay. It is given in device-independent pixels, which the page zoom does not scale — see <code>setWindowButtonPosition</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>options</code></td><td><code>{ color: string; symbolColor: string; height?: number }</code><br>The overlay's background color, the color of the button symbols, and the overlay's height.</td></tr></tbody></table></figure></td></tr><tr><td><code>setWindowButtonPosition</code></td><td><pre><code class=\"language-application-typescript\">setWindowButtonPosition(position: { x: number; y: number }): void</code></pre><p>Repositions the macOS traffic-light window buttons. Coordinates are relative to the window's top-left corner and given in device-independent pixels: the buttons are drawn by the system rather than by the page, so unlike the surrounding chrome they are unaffected by the page zoom factor and callers have to scale the offsets themselves.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>position</code></td><td><code>{ x: number; y: number }</code><br>The offset of the buttons from the window's top-left corner.</td></tr></tbody></table></figure></td></tr><tr><td><code>onEnterFullScreen</code></td><td><pre><code class=\"language-application-typescript\">onEnterFullScreen(callback: () =&gt; void): void</code></pre><p>Registers a callback fired whenever the window enters full-screen mode.</p></td></tr><tr><td><code>onLeaveFullScreen</code></td><td><pre><code class=\"language-application-typescript\">onLeaveFullScreen(callback: () =&gt; void): void</code></pre><p>Registers a callback fired whenever the window leaves full-screen mode.</p></td></tr><tr><td><code>isFullScreen</code></td><td><pre><code class=\"language-application-typescript\">isFullScreen(): boolean</code></pre><p>Synchronously returns whether the window is currently in full-screen mode.</p></td></tr><tr><td><code>setFullScreen</code></td><td><pre><code class=\"language-application-typescript\">setFullScreen(enabled: boolean): void</code></pre><p>Enters or leaves full-screen mode.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>enabled</code></td><td><code>boolean</code><br><code>true</code> to enter full-screen mode, <code>false</code> to leave it.</td></tr></tbody></table></figure></td></tr><tr><td><code>minimizeWindow</code></td><td><pre><code class=\"language-application-typescript\">minimizeWindow(): void</code></pre><p>Minimizes the current window to the taskbar / dock.</p></td></tr><tr><td><code>maximizeWindow</code></td><td><pre><code class=\"language-application-typescript\">maximizeWindow(): void</code></pre><p>Maximizes the current window to fill the available screen area.</p></td></tr><tr><td><code>unmaximizeWindow</code></td><td><pre><code class=\"language-application-typescript\">unmaximizeWindow(): void</code></pre><p>Restores the window from a maximized state to its previous size.</p></td></tr><tr><td><code>isMaximized</code></td><td><pre><code class=\"language-application-typescript\">isMaximized(): boolean</code></pre><p>Synchronously returns whether the window is currently maximized.</p></td></tr><tr><td><code>closeWindow</code></td><td><pre><code class=\"language-application-typescript\">closeWindow(): void</code></pre><p>Closes the current window.</p></td></tr><tr><td><code>isAlwaysOnTop</code></td><td><pre><code class=\"language-application-typescript\">isAlwaysOnTop(): boolean</code></pre><p>Synchronously returns whether the window is pinned above all others.</p></td></tr><tr><td><code>setAlwaysOnTop</code></td><td><pre><code class=\"language-application-typescript\">setAlwaysOnTop(enabled: boolean): void</code></pre><p>Pins the window above all others, or unpins it.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>enabled</code></td><td><code>boolean</code><br><code>true</code> to pin the window, <code>false</code> to unpin it.</td></tr></tbody></table></figure></td></tr><tr><td><code>toggleDevTools</code></td><td><pre><code class=\"language-application-typescript\">toggleDevTools(): void</code></pre><p>Opens or closes Chromium DevTools for the current window.</p></td></tr><tr><td><code>isDevToolsDocked</code></td><td><pre><code class=\"language-application-typescript\">isDevToolsDocked(): boolean</code></pre><p>Synchronously returns whether DevTools is currently open and docked into this window (as opposed to detached into a separate window).</p></td></tr><tr><td><code>setBackgroundMaterial</code></td><td><pre><code class=\"language-application-typescript\">setBackgroundMaterial(material: string): void</code></pre><p>Sets the Windows 11 backdrop material applied behind the window contents. No-op on other platforms.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>material</code></td><td><code>string</code><br>The material, such as <code>\"mica\"</code>, <code>\"acrylic\"</code>, <code>\"tabbed\"</code> or <code>\"none\"</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>setVibrancy</code></td><td><pre><code class=\"language-application-typescript\">setVibrancy(vibrancy: string): void</code></pre><p>Sets the macOS vibrancy effect applied behind the window contents. No-op on other platforms.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>vibrancy</code></td><td><code>string</code><br>The effect, such as <code>\"sidebar\"</code>, <code>\"under-window\"</code> or <code>\"fullscreen-ui\"</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>reloadAllWindows</code></td><td><pre><code class=\"language-application-typescript\">reloadAllWindows(): void</code></pre><p>Triggers a hard reload of every open Trilium window.</p></td></tr><tr><td><code>restartApp</code></td><td><pre><code class=\"language-application-typescript\">restartApp(): void</code></pre><p>Quits the app and immediately relaunches it.</p></td></tr><tr><td><code>toggleAllWindows</code></td><td><pre><code class=\"language-application-typescript\">toggleAllWindows(): void</code></pre><p>Shows all hidden windows or hides all visible ones — used by the \"show/hide app\" global shortcut and tray menu entry.</p></td></tr><tr><td><code>clearCache</code></td><td><pre><code class=\"language-application-typescript\">clearCache(): Promise&lt;void&gt;</code></pre><p>Clears the underlying Chromium HTTP cache. Resolves once the cache is empty.</p></td></tr><tr><td><code>showWindow</code></td><td><pre><code class=\"language-application-typescript\">showWindow(): void</code></pre><p>Brings the main window to the foreground, restoring it if minimized.</p></td></tr><tr><td><code>reportStartupMetric</code></td><td><pre><code class=\"language-application-typescript\">reportStartupMetric(metric: \"client-full-render\"): void</code></pre><p>Reports a renderer startup milestone to the main process, which records it relative to OS process creation alongside the main-process startup metrics. Only the first report of each metric is recorded; later reports (e.g. after a window reload or from extra windows) are ignored.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>metric</code></td><td><code>\"client-full-render\"</code><br>The milestone the renderer reached.</td></tr></tbody></table></figure></td></tr><tr><td><code>onGlobalShortcut</code></td><td><pre><code class=\"language-application-typescript\">onGlobalShortcut(callback: (actionName: string) =&gt; void): void</code></pre><p>Subscribes to globally registered keyboard shortcuts.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(actionName: string) =&gt; void</code><br>Receives the name of the action the shortcut triggers, not the keystroke.</td></tr></tbody></table></figure></td></tr><tr><td><code>onOpenInSameTab</code></td><td><pre><code class=\"language-application-typescript\">onOpenInSameTab(callback: (noteId: string) =&gt; void): void</code></pre><p>Subscribes to \"open note in active tab\" requests originating from outside the renderer (e.g. tray menu, deep links).</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(noteId: string) =&gt; void</code><br>Receives the ID of the note to open.</td></tr></tbody></table></figure></td></tr><tr><td><code>onDevToolsDockChanged</code></td><td><pre><code class=\"language-application-typescript\">onDevToolsDockChanged(callback: (docked: boolean) =&gt; void): void</code></pre><p>Subscribes to changes of the DevTools docking state. While DevTools is docked, Chromium disables the native window material (Mica / vibrancy).</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(docked: boolean) =&gt; void</code><br>Receives <code>true</code> while DevTools is attached to this window, and <code>false</code> when it is closed or in a separate window.</td></tr></tbody></table></figure></td></tr></tbody></table></figure><h2><code>ClipboardApi</code></h2><p>Renderer access to the system clipboard for cases the standard Web API can't cover.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>copyImageToClipboard</code></td><td><pre><code class=\"language-application-typescript\">copyImageToClipboard(buffer: Uint8Array): void</code></pre><p>Writes a raw image (PNG-encoded bytes) to the system clipboard so it can be pasted into other applications as an image rather than as a file.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>buffer</code></td><td><code>Uint8Array</code><br>The PNG-encoded image.</td></tr></tbody></table></figure></td></tr><tr><td><code>readText</code></td><td><pre><code class=\"language-application-typescript\">readText(): Promise&lt;string&gt;</code></pre><p>Reads plain text from the system clipboard via the main-process <code>electron.clipboard</code>. Used instead of <code>navigator.clipboard.readText()</code> so the renderer's deny-by-default permission policy does not have to grant the sensitive <code>clipboard-read</code> permission to the whole session.</p></td></tr><tr><td><code>readHTML</code></td><td><pre><code class=\"language-application-typescript\">readHTML(): Promise&lt;string&gt;</code></pre><p>Reads the HTML flavor of the system clipboard, the same way as <code>readText</code>. Empty when the clipboard has no HTML.</p></td></tr></tbody></table></figure><h2><code>ShellApi</code></h2><p>Wrappers around Electron's <code>shell</code> module for interacting with the OS (default browser, default file handler, downloads, etc.).</p><p>Every method here is validated in the main process before dispatch — see <code>apps/server/src/services/shell_validators.ts</code>. The renderer is treated as untrusted: invalid input throws on the main side rather than being silently passed through to <code>electron.shell</code> / <code>WebContents</code>.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>openExternal</code></td><td><pre><code class=\"language-application-typescript\">openExternal(url: string): void</code></pre><p>Opens a URL in the user's default external browser via <code>electron.shell.openExternal</code>.</p><p><strong>Security:</strong> the scheme is matched against the allowlist in <code>SHELL_OPEN_EXTERNAL_PROTOCOLS</code> (commons). Blocked schemes include <code>file:</code>, <code>data:</code>, <code>smb:</code>, <code>ldap:</code>, <code>ldaps:</code>, <code>jar:</code>, and <code>view-source:</code> — they cover Follina-class RCE primitives (<code>ms-msdt:</code>, <code>search-ms:</code>), NTLM credential theft, and Java loader vectors. URLs that fail to parse are rejected outright.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>url</code></td><td><code>string</code><br>The URL to open.</td></tr></tbody></table></figure></td></tr><tr><td><code>openPath</code></td><td><pre><code class=\"language-application-typescript\">openPath(path: string): Promise&lt;string&gt;</code></pre><p>Opens a local path with its default OS handler.</p><p><strong>Security:</strong> the path is canonicalized and must resolve to either the Trilium data directory (or a descendant) or the Trilium tmp directory (or a descendant). Anything else — absolute paths elsewhere on disk, traversal attempts, UNC paths that don't normalize under those roots — is rejected. Null bytes, empty strings, and non-existent files are also rejected.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>path</code></td><td><code>string</code><br>A file in the Trilium data or tmp directory.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;string&gt;</code>: An empty string on success, or an error message on failure.</p></td></tr><tr><td><code>showItemInFolder</code></td><td><pre><code class=\"language-application-typescript\">showItemInFolder(path: string): void</code></pre><p>Shows a local file in the OS file manager, with the file itself selected, via <code>electron.shell.showItemInFolder</code>. For pointing at a file the user is not meant to open — the database, whose reader is Trilium itself.</p><p><strong>Security:</strong> the same sandbox as <code>openPath</code>, with the database file added as a root of its own, since <code>TRILIUM_DOCUMENT_PATH</code> may put it outside the data directory. Revealing is the milder act of the two, the file being selected rather than launched, but a path the renderer names is still a path the renderer must not be free to choose.</p><p>Nothing is reported back: the OS is asked to bring a window forward, and whether it did is not something Electron answers.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>path</code></td><td><code>string</code><br>A file in the Trilium data or tmp directory, or the database file.</td></tr></tbody></table></figure></td></tr><tr><td><code>openFileUrl</code></td><td><pre><code class=\"language-application-typescript\">openFileUrl(fileUrl: string): Promise&lt;string&gt;</code></pre><p>Opens a <code>file://</code> URL with its default OS handler. Exists as a separate channel from <code>openExternal</code> because neither Electron API opens every target correctly on Windows: <code>shell.openExternal</code> mishandles Unicode characters in <code>file:</code> URLs, while <code>shell.openPath</code> opens a directory with the Explorer-specific <code>explore</code> verb, bypassing the user's file manager. The main process picks between them per target.</p><p><strong>Security:</strong> the URL must use the <code>file:</code> scheme and must have an empty hostname. UNC paths (<code>file://attacker.example/share/x</code>) are explicitly blocked because Windows would otherwise resolve them to <code>\\\\attacker.example\\share\\x</code> and leak the user's NTLM hash via SMB authentication. Drive-letter-as-host malformations like <code>file://C:/path</code> are normalized to <code>file:///C:/path</code> before parsing.</p><p>Note: unlike <code>openPath</code>, the resolved path is NOT confined to the Trilium data / tmp directories — this channel handles user-clicked <code>file://</code> links inside note content, which routinely reference arbitrary locations on disk (<code>file:///C:/Users/me/Documents/contract.pdf</code> and similar). Equivalent to a browser following a <code>file:</code> link the user clicked. Treat clicks on attacker-influenced note content accordingly.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>fileUrl</code></td><td><code>string</code><br>A <code>file:</code> URL with an empty hostname.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;string&gt;</code>: An empty string on success, or an error message on failure.</p></td></tr><tr><td><code>downloadURL</code></td><td><pre><code class=\"language-application-typescript\">downloadURL(url: string): void</code></pre><p>Triggers a Chromium download for the given URL — the file is saved through the normal \"Save As\" flow instead of being opened in the renderer.</p><p><strong>Security:</strong> locked to the renderer's own origin. The scheme, hostname, and port must all match the running app's origin (<code>http://localhost:PORT</code> for the dev server, or the custom <code>trilium-app://app/</code> protocol for packaged Electron). Cross-origin downloads, hostless URLs (<code>data:</code>, <code>blob:</code>, <code>about:</code>, plain <code>file:///</code>), and unparseable URLs are rejected. This stops a compromised renderer from pre-positioning a remote payload in the user's Downloads folder under a familiar name.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>url</code></td><td><code>string</code><br>A URL on the app's own origin.</td></tr></tbody></table></figure></td></tr><tr><td><code>openCustom</code></td><td><pre><code class=\"language-application-typescript\">openCustom(filePath: string): void</code></pre><p>Opens a file with a Trilium-specific custom handler (configured via the \"Open With\" option), falling back to the OS default if none is set.</p><p><strong>Security:</strong> the path must resolve to a strict descendant of Trilium's tmp directory and the file must exist on disk. The legitimate caller always passes a path that was just written by <code>saveToTmpDir</code>; anything else (the data dir itself, paths elsewhere on disk, null bytes, empty strings) is rejected.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>filePath</code></td><td><code>string</code><br>A file in Trilium's tmp directory, as written by <code>saveToTmpDir</code>.</td></tr></tbody></table></figure></td></tr></tbody></table></figure><h2><code>ContextMenuApi</code></h2><p>Bridge for the native context menu shown over web contents.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>onContextMenu</code></td><td><pre><code class=\"language-application-typescript\">onContextMenu(callback: (params: ContextMenuParams) =&gt; void): void</code></pre><p>Subscribes to right-click events forwarded from the main process.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(params: ContextMenuParams) =&gt; void</code><br>Receives where the user clicked and what is under the cursor.</td></tr></tbody></table></figure></td></tr><tr><td><code>webContentsAction</code></td><td><pre><code class=\"language-application-typescript\">webContentsAction(action: \"cut\" | \"copy\" | \"paste\" | \"pasteAndMatchStyle\" | \"insertText\", text?: string): void</code></pre><p>Executes a clipboard / text-input action on the focused web contents.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>action</code></td><td><code>\"cut\" | \"copy\" | \"paste\" | \"pasteAndMatchStyle\" | \"insertText\"</code><br>The action to execute.</td></tr><tr><td><code>text</code><br><em>optional</em></td><td><code>string</code><br>The text to insert. <code>\"insertText\"</code> requires it; the other actions ignore it.</td></tr></tbody></table></figure></td></tr></tbody></table></figure><h2><code>SpellcheckApi</code></h2><p>Renderer-side access to Chromium's built-in spell checker.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>addWordToDictionary</code></td><td><pre><code class=\"language-application-typescript\">addWordToDictionary(word: string): void</code></pre><p>Adds a word to the user's personal dictionary so it is no longer flagged.</p></td></tr><tr><td><code>getAvailableSpellCheckerLanguages</code></td><td><pre><code class=\"language-application-typescript\">getAvailableSpellCheckerLanguages(): string[]</code></pre><p>Returns the BCP-47 language tags Chromium can spell-check on this platform.</p></td></tr><tr><td><code>setSpellCheckerLanguages</code></td><td><pre><code class=\"language-application-typescript\">setSpellCheckerLanguages(languageCodes: string[]): void</code></pre><p>Applies the spell-check language list to every open window's session immediately, without an application restart. No-op on macOS, where the OS spell checker auto-detects the language.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>languageCodes</code></td><td><code>string[]</code><br>Language tags returned by <code>getAvailableSpellCheckerLanguages</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>setSpellCheckerEnabled</code></td><td><pre><code class=\"language-application-typescript\">setSpellCheckerEnabled(enabled: boolean): void</code></pre><p>Enables or disables the built-in spell checker on every open window's session immediately, without an application restart.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>enabled</code></td><td><code>boolean</code><br><code>true</code> to enable the spell checker, <code>false</code> to disable it.</td></tr></tbody></table></figure></td></tr></tbody></table></figure><h2><code>SystemIntegrationApi</code></h2><p>OS integration controls — system tray and autostart / launch-on-login.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>reloadTray</code></td><td><pre><code class=\"language-application-typescript\">reloadTray(): void</code></pre><p>Rebuilds the tray icon and menu — call after changing tray-related settings.</p></td></tr><tr><td><code>reapplyLaunchOnStartup</code></td><td><pre><code class=\"language-application-typescript\">reapplyLaunchOnStartup(): void</code></pre><p>Re-applies the OS autostart entry after the <code>launchOnStartup</code> / <code>hideOnAutoStart</code> options change.</p></td></tr></tbody></table></figure><h2><code>PrintingApi</code></h2><p>Printing and PDF export flow. Trilium drives Electron's printing pipeline through a small state machine that the main process owns, with progress and results pushed back to the renderer via IPC events.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>sendPrintProgress</code></td><td><pre><code class=\"language-application-typescript\">sendPrintProgress(progress: number): void</code></pre><p>Reports rendering progress from the renderer to the main process.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>progress</code></td><td><code>number</code><br>The percentage rendered, from 0 to 100.</td></tr></tbody></table></figure></td></tr><tr><td><code>onPrintProgress</code></td><td><pre><code class=\"language-application-typescript\">onPrintProgress(callback: (data: { progress: number; action: string }) =&gt; void): void</code></pre><p>Subscribes to progress updates emitted by the main process during a print or PDF export run.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(data: { progress: number; action: string }) =&gt; void</code><br>Receives the percentage done and the current stage, such as <code>\"rendering\"</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>onPrintDone</code></td><td><pre><code class=\"language-application-typescript\">onPrintDone(callback: (printReport: unknown, liveJobId?: number) =&gt; void): void</code></pre><p>Subscribes to the \"print finished\" event, fired once the OS print job is dispatched.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(printReport: unknown, liveJobId?: number) =&gt; void</code><br>Receives the main process's report on the job, or an error with a <code>message</code>, and, for a job that printed the app window itself, the ID of the live print the job ended.</td></tr></tbody></table></figure></td></tr><tr><td><code>removePrintListeners</code></td><td><pre><code class=\"language-application-typescript\">removePrintListeners(): void</code></pre><p>Removes all listeners registered via <code>onPrintProgress</code> and <code>onPrintDone</code>.</p></td></tr><tr><td><code>getPrinters</code></td><td><pre><code class=\"language-application-typescript\">getPrinters(): Promise&lt;unknown[]&gt;</code></pre><p>Returns the list of printers known to the OS.</p></td></tr><tr><td><code>exportAsPdfPreview</code></td><td><pre><code class=\"language-application-typescript\">exportAsPdfPreview(opts: Record&lt;string, unknown&gt;): void</code></pre><p>Asks the main process to render the current note as a PDF and return the resulting bytes for the in-app preview. Result is delivered via <code>onExportAsPdfPreviewResult</code>.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code></td><td><code>Record&lt;string, unknown&gt;</code><br>The note path, the page size, orientation, scale, margins and page ranges, and a <code>requestId</code> the result echoes back.</td></tr></tbody></table></figure></td></tr><tr><td><code>onExportAsPdfPreviewResult</code></td><td><pre><code class=\"language-application-typescript\">onExportAsPdfPreviewResult(callback: (result: { buffer?: Uint8Array&lt;ArrayBufferLike&gt;; error?: string; requestId?: number }) =&gt; void): void</code></pre><p>Subscribes to the result of an <code>exportAsPdfPreview</code> call.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(result: { buffer?: Uint8Array&lt;ArrayBufferLike&gt;; error?: string; requestId?: number }) =&gt; void</code><br>Receives the PDF bytes or an error message, and the <code>requestId</code> of the call the result answers.</td></tr></tbody></table></figure></td></tr><tr><td><code>removeExportAsPdfPreviewResultListener</code></td><td><pre><code class=\"language-application-typescript\">removeExportAsPdfPreviewResultListener(): void</code></pre><p>Removes the listener registered via <code>onExportAsPdfPreviewResult</code>.</p></td></tr><tr><td><code>savePdf</code></td><td><pre><code class=\"language-application-typescript\">savePdf(data: { title: string; buffer: Uint8Array }): void</code></pre><p>Persists a previously generated PDF buffer to disk via the native save dialog.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>data</code></td><td><code>{ title: string; buffer: Uint8Array }</code><br>The PDF bytes, and the title to suggest as the file name.</td></tr></tbody></table></figure></td></tr><tr><td><code>printFromPreview</code></td><td><pre><code class=\"language-application-typescript\">printFromPreview(opts: Record&lt;string, unknown&gt;): void</code></pre><p>Sends the previewed PDF to the OS print dialog with the given options.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code></td><td><code>Record&lt;string, unknown&gt;</code><br>The options of <code>exportAsPdfPreview</code>, plus <code>silent</code> to print without the dialog and <code>deviceName</code> to choose the printer.</td></tr></tbody></table></figure></td></tr></tbody></table></figure><h2><code>NavigationApi</code></h2><p>Accessors for the underlying Chromium navigation history of the current web contents (back/forward stack), exposed so the renderer can mirror it in custom UI such as the breadcrumb / tab back button.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>clearNavigationHistory</code></td><td><pre><code class=\"language-application-typescript\">clearNavigationHistory(): void</code></pre><p>Clears the entire back/forward navigation history.</p></td></tr><tr><td><code>navigationCanGoBack</code></td><td><pre><code class=\"language-application-typescript\">navigationCanGoBack(): boolean</code></pre><p>Synchronously returns whether a back navigation is possible.</p></td></tr><tr><td><code>navigationCanGoForward</code></td><td><pre><code class=\"language-application-typescript\">navigationCanGoForward(): boolean</code></pre><p>Synchronously returns whether a forward navigation is possible.</p></td></tr><tr><td><code>navigationGetAllEntries</code></td><td><pre><code class=\"language-application-typescript\">navigationGetAllEntries(): { url: string; title: string }[]</code></pre><p>Returns every entry in the navigation history, oldest first.</p></td></tr><tr><td><code>navigationGetActiveIndex</code></td><td><pre><code class=\"language-application-typescript\">navigationGetActiveIndex(): number</code></pre><p>Returns the index of the currently active entry inside <code>navigationGetAllEntries</code>.</p></td></tr><tr><td><code>navigationLength</code></td><td><pre><code class=\"language-application-typescript\">navigationLength(): number</code></pre><p>Returns the total number of entries in the navigation history.</p></td></tr><tr><td><code>navigationGoToIndex</code></td><td><pre><code class=\"language-application-typescript\">navigationGoToIndex(index: number): void</code></pre><p>Navigates to the entry at the given index in the history stack.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>index</code></td><td><code>number</code><br>An index into <code>navigationGetAllEntries</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>onDidNavigate</code></td><td><pre><code class=\"language-application-typescript\">onDidNavigate(callback: () =&gt; void): void</code></pre><p>Subscribes to top-level navigation events (URL changes that load a new document).</p></td></tr><tr><td><code>onDidNavigateInPage</code></td><td><pre><code class=\"language-application-typescript\">onDidNavigateInPage(callback: () =&gt; void): void</code></pre><p>Subscribes to in-page navigation events (hash changes, <code>history.pushState</code>).</p></td></tr><tr><td><code>removeDidNavigateListeners</code></td><td><pre><code class=\"language-application-typescript\">removeDidNavigateListeners(): void</code></pre><p>Removes all listeners registered via <code>onDidNavigate</code> and <code>onDidNavigateInPage</code>.</p></td></tr></tbody></table></figure><h2><code>WsApi</code></h2><p>In-process replacement for the renderer↔server WebSocket. Backed by Chromium IPC instead of a TCP socket — no port is bound and no auth check is needed because the channel is only reachable from the renderer the BrowserWindow owns. Wire format is whatever the server's <code>MessagingProvider</code> accepts (currently <code>WebSocketMessage</code> / log-error / log-info / ping).</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>send</code></td><td><pre><code class=\"language-application-typescript\">send(message: unknown): void</code></pre><p>Sends a message from the renderer to the main-process messaging hub.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>message</code></td><td><code>unknown</code><br>A message the server's <code>MessagingProvider</code> accepts.</td></tr></tbody></table></figure></td></tr><tr><td><code>onMessage</code></td><td><pre><code class=\"language-application-typescript\">onMessage(callback: (message: unknown) =&gt; void): () =&gt; void</code></pre><p>Subscribes to messages pushed from the main process.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(message: unknown) =&gt; void</code><br>Receives each message.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>() =&gt; void</code>: An unsubscribe function. Call it when the listener is no longer needed (e.g. when a BrowserWindow is unloaded) to avoid leaking handlers.</p></td></tr></tbody></table></figure><h2><code>SecurityApi</code></h2><p>Security settings that live outside the database (in <code>data_dir/security.json</code>) to prevent malicious scripts from modifying them. Changes require a native OS confirmation dialog and an app restart to take effect.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>setLanAccessEnabled</code></td><td><pre><code class=\"language-application-typescript\">setLanAccessEnabled(enabled: boolean): Promise&lt;boolean&gt;</code></pre><p>Requests enabling/disabling LAN access. When enabled, the desktop binds its TCP listener to all interfaces (instead of loopback) so other devices can reach it — e.g. to sync from another device. Same confirmation + restart flow as above.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>enabled</code></td><td><code>boolean</code><br><code>true</code> to listen on all interfaces, <code>false</code> to listen on loopback only.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;boolean&gt;</code>: <code>true</code> once the user agreed and the change was written.</p></td></tr><tr><td><code>setBackendScriptingEnabled</code></td><td><pre><code class=\"language-application-typescript\">setBackendScriptingEnabled(enabled: boolean): Promise&lt;boolean&gt;</code></pre><p>Requests backend script execution be turned on or off.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>enabled</code></td><td><code>boolean</code><br><code>true</code> to allow backend scripts to run, <code>false</code> to block them.</td></tr></tbody></table></figure></td></tr><tr><td><code>setSqlConsoleEnabled</code></td><td><pre><code class=\"language-application-typescript\">setSqlConsoleEnabled(enabled: boolean): Promise&lt;boolean&gt;</code></pre><p>Requests the SQL console be turned on or off.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>enabled</code></td><td><code>boolean</code><br><code>true</code> to enable the SQL console, <code>false</code> to disable it.</td></tr></tbody></table></figure></td></tr></tbody></table></figure><h2><code>BackupPassphraseApi</code></h2><p>The backup passphrase, kept encrypted by the OS keyring in a file outside the database (the database is what ends up inside the backup, so a passphrase stored there would ride along inside the very container it protects).</p><p>Deliberately write-only: there is no way to read the passphrase back, so a frontend script cannot exfiltrate it. Only the main process ever sees the plaintext again, when it writes a backup.</p><p>Both changes are also gated on a native OS confirmation, which a script can request but cannot answer. Without that, a script could quietly swap in a passphrase of its own and every later backup would be encrypted to it.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>getStatus</code></td><td><pre><code class=\"language-application-typescript\">getStatus(): Promise&lt;BackupPassphraseStatus&gt;</code></pre><p>Whether a passphrase can be stored on this system, and whether one already is.</p></td></tr><tr><td><code>set</code></td><td><pre><code class=\"language-application-typescript\">set(passphrase: string): Promise&lt;BackupPassphraseChange&gt;</code></pre><p>Stores a passphrase, replacing any existing one, once the user has confirmed it.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>passphrase</code></td><td><code>string</code><br>The passphrase to encrypt later backups with.</td></tr></tbody></table></figure></td></tr><tr><td><code>clear</code></td><td><pre><code class=\"language-application-typescript\">clear(): Promise&lt;BackupPassphraseChange&gt;</code></pre><p>Forgets the stored passphrase. Existing backups keep the passphrase they were written with.</p></td></tr></tbody></table></figure><h2><code>OneNoteApi</code></h2><p>Desktop-only OneNote importer sign-in, driven from the main process via a loopback OAuth redirect.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>login</code></td><td><pre><code class=\"language-application-typescript\">login(): Promise&lt;OneNoteLoginResult&gt;</code></pre><p>Runs the Microsoft delegated-Graph OAuth flow: opens the system browser, captures the redirect on a throwaway loopback server, exchanges the code, and stores the token process-side. Resolves once the desktop session is connected (or with <code>connected: false</code> on failure/timeout).</p></td></tr></tbody></table></figure><h2><code>NativeExportApi</code></h2><p>Desktop-native subtree export that streams a <code>.zip</code> straight to a file.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>exportSubtreeToFile</code></td><td><pre><code class=\"language-application-typescript\">exportSubtreeToFile(opts: { branchId: string; format: string; title: string; taskId: string }): Promise&lt;NativeExportResult&gt;</code></pre><p>Prompts a native \"save as\" dialog, then streams a subtree (branch) export to the chosen path on disk. This bypasses the in-memory download path, so memory stays bounded regardless of archive size. Progress/success/error are reported over the WebSocket via <code>taskId</code>. Resolves once the dialog is dismissed (<code>cancelled</code>) or the export finishes (<code>saved</code> / <code>error</code>).</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code></td><td><code>{ branchId: string; format: string; title: string; taskId: string }</code><br>The branch to export, the export format (<code>\"html\"</code>, <code>\"markdown\"</code> or <code>\"share\"</code>), the title to suggest as the file name, and the ID of the task that reports progress.</td></tr></tbody></table></figure></td></tr></tbody></table></figure><h2><code>NativeImportApi</code></h2><p>Desktop-native import that reads the user's file <strong>in place</strong> (bounded memory, no temp copy) — the whole point being multi-GB <code>.zip</code> archives, though any importable file is accepted. The renderer never handles a filesystem path: <code>pickFiles</code> runs the OS dialog in the main process and returns opaque capability tokens, which <code>importFromToken</code> redeems. A script can't forge a token or pass a path, so it can never read an arbitrary file.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>pickFiles</code></td><td><pre><code class=\"language-application-typescript\">pickFiles(): Promise&lt;NativeImportPickResult&gt;</code></pre><p>Prompts a native \"open file\" dialog (multi-select, any type) and returns single-use tokens for the chosen files.</p></td></tr><tr><td><code>grantDroppedFiles</code></td><td><pre><code class=\"language-application-typescript\">grantDroppedFiles(files: File[]): Promise&lt;NativeImportPickResult&gt;</code></pre><p>Resolves files the user dropped onto a drop zone to capability tokens, so a drag-and-drop import takes the same in-place (streamed) path as the dialog. The <code>File</code> is the unforgeable capability: the path is obtained via <code>webUtils.getPathForFile</code>, which yields a real path only for a genuinely user-supplied file and an empty string for anything a script constructed — so a script can't smuggle in an arbitrary path. Returns <code>cancelled</code> when no dropped file resolved (e.g. dragged from a browser, not the OS), so the caller falls back to the normal upload route.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>files</code></td><td><code>File[]</code><br>The files of the drop event.</td></tr></tbody></table></figure></td></tr><tr><td><code>importFromToken</code></td><td><pre><code class=\"language-application-typescript\">importFromToken(opts: { token: string; parentNoteId: string; taskId: string; options: NativeImportOptions; last: boolean; format?: string }): Promise&lt;NativeImportResult&gt;</code></pre><p>Imports the file behind a token, with progress/success/error reported over the WebSocket like the HTTP import path.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code></td><td><code>{ token: string; parentNoteId: string; taskId: string; options: NativeImportOptions; last: boolean; format?: string }</code><br>The <code>token</code> to redeem, the <code>parentNoteId</code> to import under, the <code>taskId</code> that reports progress, and the import <code>options</code>. When importing several files in one batch, set <code>last</code> only on the final call so the success toast fires once, after everything is in. <code>format</code> routes the file to a specific importer (e.g. <code>\"obsidian\"</code>), mirroring the HTTP route's format tag.</td></tr></tbody></table></figure></td></tr></tbody></table></figure><h2><code>DialogApi</code></h2><p>Native OS pickers that hand the renderer a location the user chose themselves.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>pickDirectory</code></td><td><pre><code class=\"language-application-typescript\">pickDirectory(opts?: { defaultPath?: string }): Promise&lt;NativeDirectoryPickResult&gt;</code></pre><p>Prompts a native \"select folder\" dialog. The renderer cannot supply the answer: a script can at most pop the dialog, which the user still has to accept before any path comes back.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code><br><em>optional</em></td><td><code>{ defaultPath?: string }</code><br>The directory the dialog starts in, as <code>defaultPath</code>.</td></tr></tbody></table></figure></td></tr><tr><td><code>confirmStartOver</code></td><td><pre><code class=\"language-application-typescript\">confirmStartOver(): Promise&lt;boolean&gt;</code></pre><p>Prompts a native message box before the application restarts into the setup screen, where the user may replace or erase their knowledge base.</p><p>An OS dialog rather than one of the application's own, for the reason the security toggles use one: a note script can reach every dialog the app draws for itself, and this one guards the path to losing everything. It is never suppressible, so there is no \"don't ask again\" here.</p></td></tr></tbody></table></figure><h2><code>RestoreApi</code></h2><p>Choosing a backup to restore from the desktop, where the file is already on the same disk as the database it is going to replace and has no business being uploaded to reach it.</p><p>Only usable during setup: what it puts forward is restored by the ordinary <code>POST /api/setup/restore/start</code>, which refuses once the application is initialized.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>pickBackup</code></td><td><pre><code class=\"language-application-typescript\">pickBackup(): Promise&lt;NativeBackupPickResult&gt;</code></pre><p>Prompts a native \"open file\" dialog for a <code>.db</code> or <code>.tnbackup</code> backup and, if one is chosen, makes it the backup waiting to be restored.</p></td></tr></tbody></table></figure><h2><code>TranscriptionApi</code></h2><p>Meeting transcription, recorded and transcribed on this computer by the main process. The renderer only starts and stops it; the audio never passes through the renderer.</p><figure class=\"table\"><table><thead><tr><th>Member</th><th>Description</th></tr></thead><tbody><tr><td><code>isSupported</code></td><td><pre><code class=\"language-application-typescript\">isSupported(): Promise&lt;boolean&gt;</code></pre><p>Whether this build can transcribe on this computer: <code>false</code> when it carries no speech recognition engine for the platform and processor it runs on.</p></td></tr><tr><td><code>start</code></td><td><pre><code class=\"language-application-typescript\">start(noteId: string): Promise&lt;string&gt;</code></pre><p>Starts recording the microphone and the system audio for a meeting note.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>noteId</code></td><td><code>string</code><br>The meeting note the transcript belongs to.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;string&gt;</code>: An empty string once recording runs, or an error message when it cannot start.</p></td></tr><tr><td><code>stop</code></td><td><pre><code class=\"language-application-typescript\">stop(): Promise&lt;void&gt;</code></pre><p>Stops the recording, once the speech already captured has been transcribed.</p></td></tr><tr><td><code>getState</code></td><td><pre><code class=\"language-application-typescript\">getState(): Promise&lt;TranscriptionState&gt;</code></pre></td></tr><tr><td><code>renameSpeaker</code></td><td><pre><code class=\"language-application-typescript\">renameSpeaker(attachmentId: string, key: string, name: string): Promise&lt;boolean&gt;</code></pre><p>Names a speaker of a transcript attachment, if a running recording writes that transcript. The recording applies it, so no utterance it writes meanwhile is lost.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>attachmentId</code></td><td><code>string</code><br>The transcript attachment.</td></tr><tr><td><code>key</code></td><td><code>string</code><br>The speaker: <code>microphone</code> for the local speaker, <code>system:&lt;n&gt;</code> for an identified speaker of the system audio.</td></tr><tr><td><code>name</code></td><td><code>string</code><br>The name to give, or a blank string to restore the default name.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;boolean&gt;</code>: <code>false</code> when no recording writes <code>attachmentId</code>; it can then be saved whole.</p></td></tr><tr><td><code>getRecordingsDirectory</code></td><td><pre><code class=\"language-application-typescript\">getRecordingsDirectory(): Promise&lt;string&gt;</code></pre><p>Returns the directory that keeps the audio and the transcript as produced of each recording while <code>transcriptionKeepRecordings</code> is on, creating it if needed.</p></td></tr><tr><td><code>onStateChanged</code></td><td><pre><code class=\"language-application-typescript\">onStateChanged(callback: (state: TranscriptionState) =&gt; void): () =&gt; void</code></pre><p>Subscribes to changes of the transcription state, made from any window.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(state: TranscriptionState) =&gt; void</code><br>Receives the new state.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>() =&gt; void</code>: A function that removes the listener.</p></td></tr><tr><td><code>onLevel</code></td><td><pre><code class=\"language-application-typescript\">onLevel(callback: (source: TranscriptSource, level: number) =&gt; void): () =&gt; void</code></pre><p>Subscribes to the audio level of the running recording, about four times a second per source.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(source: TranscriptSource, level: number) =&gt; void</code><br>Receives the source and the RMS, from 0 to 1, of each chunk it delivers.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>() =&gt; void</code>: A function that stops the calls.</p></td></tr></tbody></table></figure><h2>Types</h2><h3><code>ContextMenuParams</code></h3><p>Parameters delivered by the main process to the renderer when the user opens the system context menu (right-click) somewhere inside a web view.</p><p>Mirrors the subset of fields from Electron's <code>Electron.ContextMenuParams</code> that the renderer actually consumes when building its custom context menu.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>x</code></td><td><code>number</code> <br>Horizontal position of the click, in CSS pixels, relative to the web view.</td></tr><tr><td><code>y</code></td><td><code>number</code> <br>Vertical position of the click, in CSS pixels, relative to the web view.</td></tr><tr><td><code>linkURL</code></td><td><code>string</code> <br>URL of the link the user clicked on, or an empty string if not on a link.</td></tr><tr><td><code>linkText</code></td><td><code>string</code> <br>Visible text of the link the user clicked on, or an empty string.</td></tr><tr><td><code>mediaType</code></td><td><code>string</code> <br>Media kind under the cursor (e.g. <code>\"none\"</code>, <code>\"image\"</code>, <code>\"video\"</code>, <code>\"audio\"</code>).</td></tr><tr><td><code>isEditable</code></td><td><code>boolean</code> <br>Whether the element under the cursor is editable (input, textarea, contenteditable).</td></tr><tr><td><code>selectionText</code></td><td><code>string</code> <br>Currently selected text, or an empty string if nothing is selected.</td></tr><tr><td><code>misspelledWord</code></td><td><code>string</code> <br>The misspelled word under the cursor, or an empty string if none.</td></tr><tr><td><code>dictionarySuggestions</code></td><td><code>string[]</code> <br>Spell-check suggestions for <code>misspelledWord</code>, in order of relevance.</td></tr><tr><td><code>editFlags</code></td><td><code>{ canCut: boolean; canCopy: boolean; canPaste: boolean }</code> <br>Hints about which clipboard operations are currently available.</td></tr></tbody></table></figure><h3><code>BackupPassphraseStatus</code></h3><p>What the Options UI needs to know about the stored backup passphrase.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>available</code></td><td><code>boolean</code> <br>Whether the OS offers a keyring to keep the passphrase in. Without one it cannot be stored safely, and since unattended backups cannot ask for it, encryption is unavailable altogether.</td></tr><tr><td><code>set</code></td><td><code>boolean</code> <br>Whether a passphrase is currently stored.</td></tr></tbody></table></figure><h3><code>BackupPassphraseChange</code></h3><p>What became of a request to change the stored backup passphrase.</p><figure class=\"table\"><table><thead><tr><th>Value</th><th>Description</th></tr></thead><tbody><tr><td><code>\"applied\"</code></td><td>The change was confirmed and carried out.</td></tr><tr><td><code>\"cancelled\"</code></td><td>The user declined the OS confirmation, so nothing changed.</td></tr><tr><td><code>\"unavailable\"</code></td><td>There is no keyring on this system to keep a passphrase in.</td></tr></tbody></table></figure><h3><code>OneNoteLoginResult</code></h3><p>Outcome of a <code>OneNoteApi.login</code> attempt.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>connected</code></td><td><code>boolean</code> <br>True if sign-in completed and a Microsoft Graph token was stored.</td></tr><tr><td><code>account</code> <br><em>optional</em></td><td><code>{ name: string; email: string }</code> <br>The connected Microsoft account, present when <code>connected</code> is true.</td></tr><tr><td><code>error</code> <br><em>optional</em></td><td><code>string</code> <br>A human-readable failure reason when <code>connected</code> is false (absent on user cancellation).</td></tr></tbody></table></figure><h3><code>NativeExportResult</code></h3><p>Outcome of a <code>NativeExportApi.exportSubtreeToFile</code> request.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>status</code></td><td><code>\"cancelled\" | \"saved\" | \"error\"</code></td></tr><tr><td><code>filePath</code> <br><em>optional</em></td><td><code>string</code> <br>Absolute path the archive was written to (when <code>status === \"saved\"</code>).</td></tr><tr><td><code>message</code> <br><em>optional</em></td><td><code>string</code> <br>Failure detail (when <code>status === \"error\"</code>).</td></tr></tbody></table></figure><h3><code>NativeImportPickResult</code></h3><p>Outcome of <code>NativeImportApi.pickFiles</code>: capability tokens, never paths.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>status</code></td><td><code>\"cancelled\" | \"selected\"</code></td></tr><tr><td><code>files</code> <br><em>optional</em></td><td><code>NativeImportPickedFile[]</code> <br>The user-chosen files (when <code>status === \"selected\"</code>); one or more, since the dialog allows multi-select.</td></tr></tbody></table></figure><h3><code>NativeImportOptions</code></h3><p>Import flags forwarded to the native importer (mirrors the HTTP route's options; no path).</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>safeImport</code></td><td><code>boolean</code></td></tr><tr><td><code>shrinkImages</code></td><td><code>boolean</code></td></tr><tr><td><code>textImportedAsText</code></td><td><code>boolean</code></td></tr><tr><td><code>codeImportedAsCode</code></td><td><code>boolean</code></td></tr><tr><td><code>spreadsheetImportedAsSpreadsheet</code></td><td><code>boolean</code></td></tr><tr><td><code>explodeArchives</code></td><td><code>boolean</code></td></tr><tr><td><code>replaceUnderscoresWithSpaces</code></td><td><code>boolean</code></td></tr></tbody></table></figure><h3><code>NativeImportResult</code></h3><p>Outcome of <code>NativeImportApi.importFromToken</code>.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>status</code></td><td><code>\"error\" | \"imported\"</code></td></tr><tr><td><code>importedNoteId</code> <br><em>optional</em></td><td><code>string</code> <br>Root note of the import (when <code>status === \"imported\"</code>).</td></tr><tr><td><code>message</code> <br><em>optional</em></td><td><code>string</code> <br>Failure detail (when <code>status === \"error\"</code>).</td></tr></tbody></table></figure><h3><code>NativeDirectoryPickResult</code></h3><p>Outcome of <code>DialogApi.pickDirectory</code>.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>status</code></td><td><code>\"cancelled\" | \"selected\"</code></td></tr><tr><td><code>path</code> <br><em>optional</em></td><td><code>string</code> <br>Absolute path of the chosen directory (when <code>status === \"selected\"</code>).</td></tr></tbody></table></figure><h3><code>NativeBackupPickResult</code></h3><p>Outcome of <code>RestoreApi.pickBackup</code>: what the chosen backup is, never where it is.</p><p>The file itself stays with the main process, which holds it as the one waiting to be restored, so the renderer is given only what the screen has to show and decide with.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>status</code></td><td><code>\"cancelled\" | \"error\" | \"selected\"</code></td></tr><tr><td><code>fileName</code> <br><em>optional</em></td><td><code>string</code> <br>Display name of the chosen backup (when <code>status === \"selected\"</code>).</td></tr><tr><td><code>encrypted</code> <br><em>optional</em></td><td><code>boolean</code> <br>Whether a passphrase has to be asked for before it can be restored.</td></tr><tr><td><code>message</code> <br><em>optional</em></td><td><code>string</code> <br>Failure detail (when <code>status === \"error\"</code>), e.g. setup already being busy.</td></tr></tbody></table></figure><h3><code>TranscriptionState</code></h3><p>What <code>TranscriptionApi</code> reports to every window.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>status</code></td><td><code>\"idle\" | \"starting\" | \"recording\" | \"stopping\"</code> <br>Phase of the meeting transcription; at most one recording runs at a time.</td></tr><tr><td><code>noteId</code></td><td><code>string | null</code> <br>The meeting note the recording belongs to, or <code>null</code> when idle.</td></tr><tr><td><code>pendingSources</code></td><td><code>TranscriptSource[]</code> <br>The sources heard speaking, or whose speech is still being transcribed.</td></tr><tr><td><code>sourceIssues</code> <br><em>optional</em></td><td><code>Partial&lt;Record&lt;TranscriptSource, \"not_captured\" | \"no_audio\" | \"silent\"&gt;&gt;</code> <br>While recording, the sources whose audio is not being transcribed, and why; absent when every source delivers sound. <br>Why a source's audio is not being transcribed: its capture did not start (<code>not_captured</code>), it has delivered no audio for 10 s (<code>no_audio</code>), as when its capture hangs, or it has delivered only digital silence for a while (<code>silent</code>), as from a muted device.</td></tr><tr><td><code>startedAt</code> <br><em>optional</em></td><td><code>number</code> <br>When the recording started, in milliseconds since the epoch: set once it records, kept while it stops, absent otherwise.</td></tr><tr><td><code>error</code> <br><em>optional</em></td><td><code>string</code> <br>A problem to tell the user about, sent once with the state it concerns: the recording ended without being stopped, or its transcript cannot be saved. <code>getState()</code> never returns it.</td></tr></tbody></table></figure><h3><code>TranscriptSource</code></h3><p>Where an utterance was heard: the local speaker's microphone, or everyone else on the system output.</p><pre><code class=\"language-application-typescript\">type TranscriptSource = \"microphone\" | \"system\"</code></pre><h3><code>NativeImportPickedFile</code></h3><p>A single user-chosen file: a capability token (redeemed to import it) and its display name — never a path.</p><figure class=\"table\"><table><thead><tr><th>Property</th><th>Description</th></tr></thead><tbody><tr><td><code>token</code></td><td><code>string</code> <br>Single-use, short-lived grant for the chosen file.</td></tr><tr><td><code>fileName</code></td><td><code>string</code> <br>Display name of the chosen file.</td></tr></tbody></table></figure>",
"_help_ApVHZ8JY5ofC": "<p>Day.js is a date manipulation library that's used by Trilium, but it's also shared with both front-end and back-end scripts. For more information about the library itself, consult the <a href=\"https://day.js.org/en/\">official documentation</a>.</p><h2>How to use</h2><p>The <code>dayjs</code> method is provided directly in the <code>api</code> global:</p><pre><code class=\"language-text-javascript\">const date = api.dayjs();\napi.log(date.format(\"YYYY-MM-DD\"));</code></pre><h2>Plugins</h2><p>Day.js uses a modular, plugin-based architecture. Generally these plugins must be imported, but this process doesn't work inside Trilium scripts due to the use of a bundler.</p><p>Since v0.100.0, the same set of plugins is available for both front-end and back-end scripts.</p><p>The following Day.js plugins are directly integrated into Trilium:</p><ul><li><a href=\"https://day.js.org/docs/en/plugin/advanced-format\">AdvancedFormat</a></li><li><a href=\"https://day.js.org/docs/en/plugin/duration\">Duration</a>, since v0.100.0.</li><li><a href=\"https://day.js.org/docs/en/plugin/is-between\">IsBetween</a></li><li><a href=\"https://day.js.org/docs/en/plugin/iso-week\">IsoWeek</a></li><li><a href=\"https://day.js.org/docs/en/plugin/is-same-or-after\">IsSameOrAfter</a></li><li><a href=\"https://day.js.org/docs/en/plugin/is-same-or-before\">IsSameOrBefore</a></li><li><a href=\"https://day.js.org/docs/en/plugin/quarter-of-year\">QuarterOfYear</a></li><li><a href=\"https://day.js.org/docs/en/plugin/utc\">UTC</a></li></ul><aside class=\"admonition note\"><p>If another Day.js plugin might be needed for scripting purposes, feel free to open a feature request for it. Depending on the size of the plugin and the potential use of it inside the Trilium code base, it has a chance of being integrated.</p></aside>",
"_help_vElnKeDNPSVl": "<p>Both front-end and back-end notes can log messages for debugging.</p><h2>UI logging via <code>api.log</code></h2><figure class=\"image image-style-align-center image_resized\" style=\"width:57.74%;\"><img style=\"aspect-ratio:749/545;\" src=\"{{helpAssets}}/User%20Guide/Scripting/Logging_image.png\" width=\"749\" height=\"545\"></figure><p>The API log feature integrates with the script editor and it displays all the messages logged via <code>api.log</code>. This works for both back-end and front-end scripts.</p><p>The API log panel will appear at the bottom of a note (including in&nbsp;<a class=\"reference-link\" href=\"#root/_help_ZjLYv08Rp3qC\">Quick edit</a>) after executing a script that uses <code>api.log</code>. It can be dismissed temporarily by pressing the close button in the top-right of the panel.</p><p>Apart from strings, an object can be passed as well in which case it will be pretty-formatted if possible (e.g. recursive objects are not supported).</p><h2>Console logging</h2><p>For logs that are not directly visible to the user, the standard <code>console.log</code> can be used as well.</p><ul><li>For front-end scripts, the log will be shown in the Developer Tools (also known as Inspect).</li><li>For back-end scripts, the log will be shown in the server output while running but <strong>will not</strong> be visible in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_bnyigUA2UK7s\">Backend (server) logs</a>.</li></ul>",
"_help_IjZS7iK5EXtb": "<p>The <em>New layout</em> is a series of UI/UX changes that were introduced in v0.101.0 that heavily change both existing UI elements, as well as adding some new ones. The goal of this new layout is to modernize the application and to make it more intuitive but at the same time to reduce clutter.</p><p>Starting with v0.107.0, the old layout has been <strong>completely removed</strong>. This page serves as migration instructions to better understand what changed.</p><h2>Newly introduced features</h2><ul><li>At the bottom of the window there is a new bar called the&nbsp;<a class=\"reference-link\" href=\"#root/_help_AlJ73vBCjWDw\">Status bar</a>. This bar houses multiple items such as the Breadcrumb navigation and information and settings about the current note, such as the <a href=\"#root/_help_veGu4faJErEM\">content language</a> and&nbsp;<a class=\"reference-link\" href=\"#root/_help_zEY4DaJG4YT5\">Attributes</a>.</li><li>When a new&nbsp;<a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>&nbsp;note is created empty, a&nbsp;<a class=\"reference-link\" href=\"#root/_help_m3VlURMSeOrd\">New note type switcher</a>&nbsp;appears under the title making it easy to switch to a different note type, template or collection.</li><li><a class=\"reference-link\" href=\"#root/_help_B5dihXRDksTk\">Note badges</a>&nbsp;appear at the right of the note title and indicate states such as read-only, shared notes as well as corresponding actions (temporarily marking a note as editable, viewing the sharing note, etc.). These replace some of the floating buttons.</li><li><a class=\"reference-link\" href=\"#root/_hidden/_options/_optionsTextNotes\">Text Notes</a>&nbsp;have a new&nbsp;inline title&nbsp;which has a bigger text and display the creation and modification dates which collapses back to a smaller title when scrolling.</li><li>The following sections have been made collapsible and get displayed under the <a href=\"#root/_help_l7pigIGu01K2\">note title</a>:<ul><li><a class=\"reference-link\" href=\"#root/_help_OFXdgB2nNk1F\">Promoted Attributes</a><ul><li>The keyboard shortcut previously used to trigger the promoted attributes ribbon tab (which was no longer working) has been repurposed to toggle the promoted attributes instead.</li></ul></li><li><em>Edited Notes</em> (now renamed to <em>Notes edited on this day</em>), which appears for&nbsp;<a class=\"reference-link\" href=\"#root/_help_l0tKav7yLHGF\">Day Notes</a>&nbsp;is now shown underneath the title.<ul><li>Whether the section is collapsed or not depends on the choice in&nbsp;<a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a>&nbsp;→ Appearance.</li></ul></li><li><em>Search Properties</em>, which appears for the full&nbsp;<a class=\"reference-link\" href=\"#root/_help_eIg8jdvaoNNd\">Search</a>&nbsp;and&nbsp;<a class=\"reference-link\" href=\"#root/_help_m523cpzocqaD\">Saved Search</a>.</li></ul></li><li><a class=\"reference-link\" href=\"#root/_help_Bsm4fyzPJkSc\">Save status indicator</a>&nbsp;which appears in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_B5dihXRDksTk\">Note badges</a>&nbsp;area&nbsp;and indicates when there are unsaved changes.</li></ul><h2>Changing to the existing layout</h2><h3>Removal of the ribbon</h3><p>The most significant change is the removal of the ribbon. All the actions and options from the ribbon were integrated in other places in the application.</p><p>Here's how all the different tabs that were once part of the ribbon are available in the new layout:</p><ul><li>“Formatting toolbar” was relocated to the top of the page.<ul><li>Instead of having one per split, now there is a single formatting toolbar per tab. This allows more space for the toolbar items.</li></ul></li><li>“Owned attributes” and “Inherited attributes” were merged and moved to the status bar region (displayed one above the other).</li><li>“Basic Properties” were integrated in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a>&nbsp;menu.<ul><li>The only exception here is the Language combo box which can now be found in the status bar (top-right of the screen).</li></ul></li><li>“File” and “Image” tabs<ul><li>The buttons were moved to the right of the note title, as dedicated entries in&nbsp;<a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a>.</li><li>The info section has been merged into the <em>Note info</em> section of the status bar.</li></ul></li><li>Edited notes<ul><li>Moved underneath the title, displayed under a collapsible area and the notes are represented as badges/chips.</li><li>Whether the section is expanded or collapsed depends on the <em>Expand “Notes edited on this day” on day notes</em> setting from Options → Appearance → <em>User Interface</em>.</li></ul></li><li>Search definition tab<ul><li>Moved underneath the title under a collapsible area.</li><li>Expanded by default for new searches, collapsed for saved searches.</li></ul></li><li>The Note map is now in the <span class=\"tn-icon bx bx-dots-horizontal-rounded\"></span> Note actions menu.<ul><li>Instead of opening into a panel in the ribbon, the note map now opens in the sidebar, in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_KRlZFoIH0j6p\">Connections tab</a>&nbsp;where it can also be maximized.</li></ul></li><li>“Note info” tab was moved to a small <span class=\"tn-icon bx bx-info-circle\"></span> icon in the status bar.</li><li>“Similar notes” tab<ul><li>Instead of opening into a panel in the ribbon, the similar notes are now shown in the sidebar, in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_KRlZFoIH0j6p\">Connections tab</a>.</li><li><code>similarNotesWidgetDisabled</code> no longer has any effect.</li></ul></li><li>The Collection properties tab were relocated under the note title and grouped into:<ul><li>A combo box to quickly switch between views.</li><li>Individual settings for the current view in a submenu.</li></ul></li><li>Some smaller ribbon tabs were converted to badges that appear near the note title in the breadcrumb section:<ul><li>Original URL indicator for clipped web pages (<code>#pageUrl</code>).</li><li>SQL and script <span class=\"tn-icon bx bx-play\"></span> execute buttons.</li></ul></li></ul><aside class=\"admonition note\"><p>The ribbon keyboard shortcuts (e.g. <code>toggleRibbonTabClassicEditor</code>) have been repurposed and renamed (<em>Focus Formatting Toolbar</em>, <em>Toggle Owned Attributes</em>, <em>Show Note Map</em>, etc.) to work on the new layout, where they will toggle the appropriate panel.</p></aside><h3>Removal of the floating buttons</h3><p>Most of the buttons were relocated to the right of the note title, in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a>&nbsp;area, with the exception of:</p><ul><li>The Edit button is replaced by the <span class=\"tn-icon bx bx-lock-alt\"></span> <em>Read-only</em> badge near the note title, which makes the note temporarily editable when clicked.</li><li><em>Backlinks</em> are now displayed in the sidebar, in the&nbsp;<a class=\"reference-link\" href=\"#root/_help_KRlZFoIH0j6p\">Connections tab</a>.<ul><li>Alternatively, the backlinks count is displayed in the status bar and when clicked the sidebar opens at the right section.</li></ul></li><li>Relation map zoom buttons are now part of the relation map itself.</li><li>Export image to PNG/SVG are now in the Note actions menu, in the <em>Export as image</em> option.</li></ul><h3>Changes to the sidebar</h3><p>The sidebar (also known as the right pane) also received some important changes.</p><p>Most importantly, v0.105.0 splits the sidebar into multiple tabs with additional functionality:</p><ul><li><a class=\"reference-link\" href=\"#root/_help_2dcGDhp9WFKb\">Outline tab</a>, which gathers the table of contents and highlights lists.</li><li><a class=\"reference-link\" href=\"#root/_help_uNtgN0cUKEBc\">Attributes tab</a>, which provides a graphical method of editing labels, relations and (promoted) attribute definitions.</li><li>A dedicated&nbsp;<a class=\"reference-link\" href=\"#root/_help_LrKznOtw9cQD\">AI chat tab</a>.</li><li><a class=\"reference-link\" href=\"#root/_help_KRlZFoIH0j6p\">Connections tab</a>, which groups together the note map, note paths, backlinks and similar notes.</li></ul><p>The previous iteration of the sidebar would appear contextually, depending on whether there are any items to be displayed. This caused occasional content shifts when moving between two panes in a split view. In the new layout, the sidebar acts more like the&nbsp;<a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>&nbsp;pane, remaining visible even if there is nothing to display.</p><p>As such:</p><ul><li>The <em>Table of Contents</em> card in Text Notes options (minimum number of headings) is gone. The &nbsp;shows the table of contents whatever the number of headings.</li><li><code>#toc</code> / <code>#toc=show</code> / <code>#toc=hide</code> no longer have any effect.</li><li><code>#hideHighlightWidget</code> no longer has any effect. The highlight categories are still set globally, from the <span class=\"tn-icon bx bx-cog\"></span> menu of the Highlights list or Text Notes options, but they can't be hidden for a single note.</li></ul><p>In order to toggle the sidebar, there is a new <span class=\"tn-icon bx bx-sidebar bx-flip-horizontal\"></span> button on the top-right side of the screen, near the window buttons (on Windows and Linux).</p><p>Now each section of the sidebar (e.g. “Table of Contents”, “Highlights list”) is individually collapsible and will remember whether it was collapsed.</p><p>Some sidebar items also have their own menu in the title. For example, the highlights filter can be adjusted directly from the <span class=\"tn-icon bx bx-cog\"></span> menu of the Highlights list.&nbsp;</p><p>Custom widgets are still supported. For custom scripts, the <span class=\"tn-icon bx bx-dots-vertical-rounded\"></span> menu allows quick navigation to the corresponding script note.</p>",
diff --git a/docs/User Guide/User Guide/Scripting/Script API/Backend API.md b/docs/User Guide/User Guide/Scripting/Script API/Backend API.md
index 8c0e92816d..7830849803 100644
--- a/docs/User Guide/User Guide/Scripting/Script API/Backend API.md
+++ b/docs/User Guide/User Guide/Scripting/Script API/Backend API.md
@@ -13,11 +13,11 @@ The `api` global available inside **backend** script notes (`application/javascr
<tbody>
<tr>
<td><code>startNote</code><br><em>optional</em></td>
- <td><p><code>ScriptBNote | null</code><br>Note where the script execution started — the entry point of the current script bundle (in C terms, the file containing <code>main()</code>). When a script is spread across multiple code notes (descendant code notes loaded as modules via <code>require()</code>), every note in the bundle shares the same <code>startNote</code>, while <code>currentNote</code> differs per note. Messages from <code>api.log()</code> are grouped under this note. When a frontend script calls <code>api.runOnBackend()</code>, the frontend's <code>startNote</code> is preserved here; since that note may not be resolvable on the backend, this can be null.</p></td>
+ <td><p><code>BNote | null</code><br>Note where the script execution started — the entry point of the current script bundle (in C terms, the file containing <code>main()</code>). When a script is spread across multiple code notes (descendant code notes loaded as modules via <code>require()</code>), every note in the bundle shares the same <code>startNote</code>, while <code>currentNote</code> differs per note. Messages from <code>api.log()</code> are grouped under this note. When a frontend script calls <code>api.runOnBackend()</code>, the frontend's <code>startNote</code> is preserved here; since that note may not be resolvable on the backend, this can be null.</p></td>
</tr>
<tr>
<td><code>currentNote</code></td>
- <td><p><code>ScriptBNote</code><br>Note containing the source code that is currently executing (in C terms, <code>__FILE__</code>). Equal to <code>startNote</code> unless execution has moved into a descendant module note loaded via <code>require()</code>. Don't confuse this with the concept of the active note in the UI.</p></td>
+ <td><p><code>BNote</code><br>Note containing the source code that is currently executing (in C terms, <code>__FILE__</code>). Equal to <code>startNote</code> unless execution has moved into a descendant module note loaded via <code>require()</code>. Don't confuse this with the concept of the active note in the UI.</p></td>
</tr>
<tr>
<td><code>originEntity</code><br><em>optional</em></td>
@@ -25,11 +25,11 @@ The `api` global available inside **backend** script notes (`application/javascr
</tr>
<tr>
<td><code>req</code></td>
- <td><p><code>ScriptRequest</code><br>The HTTP request, present only when the script runs as a custom request handler: a note with the <code>#customRequestHandler</code> label, invoked through a <code>/custom/...</code> URL. It is <code>undefined</code> in every other backend script. The object is Express's own request, so it has more members than <code>ScriptRequest</code> lists.</p></td>
+ <td><p><code>Request</code><br>The HTTP request, present only when the script runs as a custom request handler: a note with the <code>#customRequestHandler</code> label, invoked through a <code>/custom/...</code> URL. It is <code>undefined</code> in every other backend script. The object is Express's own request, so it has more members than <code>Request</code> lists.</p></td>
</tr>
<tr>
<td><code>res</code></td>
- <td><p><code>ScriptResponse</code><br>The HTTP response to write the reply to, such as <code>api.res.status(200).json({ ok: true })</code>. Like <code>req</code>, it is present only in custom request handlers, and is Express's own response.</p></td>
+ <td><p><code>Response</code><br>The HTTP response to write the reply to, such as <code>api.res.status(200).json({ ok: true })</code>. Like <code>req</code>, it is present only in custom request handlers, and is Express's own response.</p></td>
</tr>
<tr>
<td><code>pathParams</code></td>
@@ -37,7 +37,7 @@ The `api` global available inside **backend** script notes (`application/javascr
</tr>
<tr>
<td><code>dayjs</code></td>
- <td><p><code>ScriptDayjs</code><br>day.js library for date manipulation. See <code>https://day.js.org</code> for documentation</p></td>
+ <td><p><code>Dayjs</code><br>day.js library for date manipulation. See <code>https://day.js.org</code> for documentation</p></td>
</tr>
<tr>
<td><code>xml2js</code></td>
@@ -53,15 +53,15 @@ The `api` global available inside **backend** script notes (`application/javascr
</tr>
<tr>
<td><code>getNote</code></td>
- <td><pre><code class="language-application-typescript">getNote(noteId: string): ScriptBNote | null</code></pre><p>Returns a note by its ID, or null.</p></td>
+ <td><pre><code class="language-application-typescript">getNote(noteId: string): BNote | null</code></pre><p>Returns a note by its ID, or null.</p></td>
</tr>
<tr>
<td><code>getBranch</code></td>
- <td><pre><code class="language-application-typescript">getBranch(branchId: string): ScriptBBranch | null</code></pre><p>Returns a branch by its ID, or null.</p></td>
+ <td><pre><code class="language-application-typescript">getBranch(branchId: string): BBranch | null</code></pre><p>Returns a branch by its ID, or null.</p></td>
</tr>
<tr>
<td><code>getAttribute</code></td>
- <td><pre><code class="language-application-typescript">getAttribute(attributeId: string): ScriptAttribute | null</code></pre><p>Returns an attribute by its ID, or null.</p></td>
+ <td><pre><code class="language-application-typescript">getAttribute(attributeId: string): Attribute | null</code></pre><p>Returns an attribute by its ID, or null.</p></td>
</tr>
<tr>
<td><code>getAttachment</code></td>
@@ -89,23 +89,23 @@ The `api` global available inside **backend** script notes (`application/javascr
</tr>
<tr>
<td><code>searchForNotes</code></td>
- <td><pre><code class="language-application-typescript">searchForNotes(query: string, searchParams?: Record&lt;string, unknown&gt;): ScriptBNote[]</code></pre><p>This is a powerful search method - you can search by attributes and their values, e.g.: "#dateModified =* MONTH AND #log". See <code>https://triliumnext.github.io/Docs/Wiki/search.html</code> for full documentation for all options</p></td>
+ <td><pre><code class="language-application-typescript">searchForNotes(query: string, searchParams?: Record&lt;string, unknown&gt;): BNote[]</code></pre><p>This is a powerful search method - you can search by attributes and their values, e.g.: "#dateModified =* MONTH AND #log". See <code>https://triliumnext.github.io/Docs/Wiki/search.html</code> for full documentation for all options</p></td>
</tr>
<tr>
<td><code>searchForNote</code></td>
- <td><pre><code class="language-application-typescript">searchForNote(query: string, searchParams?: Record&lt;string, unknown&gt;): ScriptBNote | null</code></pre><p>This is a powerful search method - you can search by attributes and their values, e.g.: "#dateModified =* MONTH AND #log". See <code>https://triliumnext.github.io/Docs/Wiki/search.html</code> for full documentation for all options</p></td>
+ <td><pre><code class="language-application-typescript">searchForNote(query: string, searchParams?: Record&lt;string, unknown&gt;): BNote | null</code></pre><p>This is a powerful search method - you can search by attributes and their values, e.g.: "#dateModified =* MONTH AND #log". See <code>https://triliumnext.github.io/Docs/Wiki/search.html</code> for full documentation for all options</p></td>
</tr>
<tr>
<td><code>getNotesWithLabel</code></td>
- <td><pre><code class="language-application-typescript">getNotesWithLabel(name: string, value?: string): ScriptBNote[]</code></pre><p>Retrieves notes with given label name &amp; value</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code><br>attribute name</td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>attribute value</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getNotesWithLabel(name: string, value?: string): BNote[]</code></pre><p>Retrieves notes with given label name &amp; value</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code><br>attribute name</td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>attribute value</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getNoteWithLabel</code></td>
- <td><pre><code class="language-application-typescript">getNoteWithLabel(name: string, value?: string): ScriptBNote | null</code></pre><p>Retrieves first note with given label name &amp; value</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code><br>attribute name</td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>attribute value</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getNoteWithLabel(name: string, value?: string): BNote | null</code></pre><p>Retrieves first note with given label name &amp; value</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code><br>attribute name</td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>attribute value</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>ensureNoteIsPresentInParent</code></td>
- <td><pre><code class="language-application-typescript">ensureNoteIsPresentInParent(noteId: string, parentNoteId: string, prefix?: string): { branch: ScriptBBranch | null }</code></pre><p>If there's no branch between note and parent note, create one. Otherwise, do nothing. Returns the new or existing branch.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>noteId</code></td><td><code>string</code></td></tr><tr><td><code>parentNoteId</code></td><td><code>string</code></td></tr><tr><td><code>prefix</code><br><em>optional</em></td><td><code>string</code><br>if branch is created between note and parent note, set this prefix</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">ensureNoteIsPresentInParent(noteId: string, parentNoteId: string, prefix?: string): { branch: BBranch | null }</code></pre><p>If there's no branch between note and parent note, create one. Otherwise, do nothing. Returns the new or existing branch.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>noteId</code></td><td><code>string</code></td></tr><tr><td><code>parentNoteId</code></td><td><code>string</code></td></tr><tr><td><code>prefix</code><br><em>optional</em></td><td><code>string</code><br>if branch is created between note and parent note, set this prefix</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>ensureNoteIsAbsentFromParent</code></td>
@@ -117,15 +117,15 @@ The `api` global available inside **backend** script notes (`application/javascr
</tr>
<tr>
<td><code>createTextNote</code></td>
- <td><pre><code class="language-application-typescript">createTextNote(parentNoteId: string, title: string, content: string): ScriptNoteAndBranch</code></pre><p>Create text note. See also createNewNote() for more options.</p></td>
+ <td><pre><code class="language-application-typescript">createTextNote(parentNoteId: string, title: string, content: string): NoteAndBranch</code></pre><p>Create text note. See also createNewNote() for more options.</p></td>
</tr>
<tr>
<td><code>createDataNote</code></td>
- <td><pre><code class="language-application-typescript">createDataNote(parentNoteId: string, title: string, content: object): ScriptNoteAndBranch</code></pre><p>Create data note - data in this context means object serializable to JSON. Created note will be of type 'code' and JSON MIME type. See also createNewNote() for more options.</p></td>
+ <td><pre><code class="language-application-typescript">createDataNote(parentNoteId: string, title: string, content: object): NoteAndBranch</code></pre><p>Create data note - data in this context means object serializable to JSON. Created note will be of type 'code' and JSON MIME type. See also createNewNote() for more options.</p></td>
</tr>
<tr>
<td><code>createNewNote</code></td>
- <td><pre><code class="language-application-typescript">createNewNote(params: { parentNoteId: string; title: string; content: string | Uint8Array&lt;ArrayBufferLike&gt;; type: string; mime?: string; [key: string]: unknown }): ScriptNoteAndBranch</code></pre><p><strong>Returns</strong> <code>ScriptNoteAndBranch</code>: object contains newly created entities note and branch</p></td>
+ <td><pre><code class="language-application-typescript">createNewNote(params: { parentNoteId: string; title: string; content: string | Uint8Array&lt;ArrayBufferLike&gt;; type: string; mime?: string; [key: string]: unknown }): NoteAndBranch</code></pre><p><strong>Returns</strong> <code>NoteAndBranch</code>: object contains newly created entities note and branch</p></td>
</tr>
<tr>
<td><code>logMessages</code></td>
@@ -141,35 +141,35 @@ The `api` global available inside **backend** script notes (`application/javascr
</tr>
<tr>
<td><code>getRootCalendarNote</code></td>
- <td><pre><code class="language-application-typescript">getRootCalendarNote(): ScriptBNote | null</code></pre><p>Returns root note of the calendar.</p></td>
+ <td><pre><code class="language-application-typescript">getRootCalendarNote(): BNote | null</code></pre><p>Returns root note of the calendar.</p></td>
</tr>
<tr>
<td><code>getDayNote</code></td>
- <td><pre><code class="language-application-typescript">getDayNote(date: string, rootNote?: ScriptBNote): ScriptBNote | null</code></pre><p>Returns day note for given date. If such note doesn't exist, it is created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM-DD format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>ScriptBNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getDayNote(date: string, rootNote?: BNote): BNote | null</code></pre><p>Returns day note for given date. If such note doesn't exist, it is created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM-DD format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>BNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getTodayNote</code></td>
- <td><pre><code class="language-application-typescript">getTodayNote(rootNote?: ScriptBNote): ScriptBNote | null</code></pre><p>Returns today's day note. If such note doesn't exist, it is created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>ScriptBNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getTodayNote(rootNote?: BNote): BNote | null</code></pre><p>Returns today's day note. If such note doesn't exist, it is created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>BNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getWeekFirstDayNote</code></td>
- <td><pre><code class="language-application-typescript">getWeekFirstDayNote(date: string, rootNote?: ScriptBNote): ScriptBNote | null</code></pre><p>Returns note for the first date of the week of the given date.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM-DD format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>ScriptBNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getWeekFirstDayNote(date: string, rootNote?: BNote): BNote | null</code></pre><p>Returns note for the first date of the week of the given date.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM-DD format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>BNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getWeekNote</code></td>
- <td><pre><code class="language-application-typescript">getWeekNote(date: string, rootNote?: ScriptBNote): ScriptBNote | null</code></pre><p>Returns week note for given date. If such a note doesn't exist, it is created.</p><p>If the calendar does not support week notes, this method will return `null`.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM-DD format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>ScriptBNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>ScriptBNote | null</code>: an existing or newly created week note, or <code>null</code> if the calendar does not support week notes.</p></td>
+ <td><pre><code class="language-application-typescript">getWeekNote(date: string, rootNote?: BNote): BNote | null</code></pre><p>Returns week note for given date. If such a note doesn't exist, it is created.</p><p>If the calendar does not support week notes, this method will return `null`.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM-DD format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>BNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>BNote | null</code>: an existing or newly created week note, or <code>null</code> if the calendar does not support week notes.</p></td>
</tr>
<tr>
<td><code>getMonthNote</code></td>
- <td><pre><code class="language-application-typescript">getMonthNote(date: string, rootNote?: ScriptBNote): ScriptBNote | null</code></pre><p>Returns month note for given date. If such a note doesn't exist, it is created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>ScriptBNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getMonthNote(date: string, rootNote?: BNote): BNote | null</code></pre><p>Returns month note for given date. If such a note doesn't exist, it is created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>BNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getQuarterNote</code></td>
- <td><pre><code class="language-application-typescript">getQuarterNote(date: string, rootNote?: ScriptBNote): ScriptBNote | null</code></pre><p>Returns quarter note for given date. If such a note doesn't exist, it is created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>ScriptBNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getQuarterNote(date: string, rootNote?: BNote): BNote | null</code></pre><p>Returns quarter note for given date. If such a note doesn't exist, it is created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>BNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getYearNote</code></td>
- <td><pre><code class="language-application-typescript">getYearNote(year: string, rootNote?: ScriptBNote): ScriptBNote | null</code></pre><p>Returns year note for given year. If such a note doesn't exist, it is created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>year</code></td><td><code>string</code><br>in YYYY format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>ScriptBNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getYearNote(year: string, rootNote?: BNote): BNote | null</code></pre><p>Returns year note for given year. If such a note doesn't exist, it is created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>year</code></td><td><code>string</code><br>in YYYY format</td></tr><tr><td><code>rootNote</code><br><em>optional</em></td><td><code>BNote</code><br>specify calendar root note, normally leave empty to use the default calendar</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>sortNotes</code></td>
@@ -213,7 +213,7 @@ The `api` global available inside **backend** script notes (`application/javascr
</tr>
<tr>
<td><code>createOrUpdateLauncher</code></td>
- <td><pre><code class="language-application-typescript">createOrUpdateLauncher(opts: { id: string; type: "note" | "script" | "customWidget"; title: string; isVisible: boolean; icon: string; keyboardShortcut: string; targetNoteId?: string; scriptNoteId?: string; widgetNoteId?: string }): { note: ScriptBNote }</code></pre><p>Creates a new launcher to the launchbar. If the launcher (id) already exists, it will be updated.</p></td>
+ <td><pre><code class="language-application-typescript">createOrUpdateLauncher(opts: { id: string; type: "note" | "script" | "customWidget"; title: string; isVisible: boolean; icon: string; keyboardShortcut: string; targetNoteId?: string; scriptNoteId?: string; widgetNoteId?: string }): { note: BNote }</code></pre><p>Creates a new launcher to the launchbar. If the launcher (id) already exists, it will be updated.</p></td>
</tr>
<tr>
<td><code>exportSubtreeToZipFile</code></td>
@@ -233,12 +233,12 @@ The `api` global available inside **backend** script notes (`application/javascr
</tr>
<tr>
<td><code>duplicateSubtree</code></td>
- <td><pre><code class="language-application-typescript">duplicateSubtree(origNoteId: string, newParentNoteId: string): ScriptNoteAndBranch</code></pre><p>Enables the complete duplication of the specified original note and all its children into the specified parent note. The new note will be named the same as the original, with (Dup) added to the end of it.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>origNoteId</code></td><td><code>string</code><br>the noteId for the original note to be duplicated</td></tr><tr><td><code>newParentNoteId</code></td><td><code>string</code><br>the noteId for the parent note where the duplication is to be placed.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>ScriptNoteAndBranch</code>: the note and the branch of the newly created note.</p></td>
+ <td><pre><code class="language-application-typescript">duplicateSubtree(origNoteId: string, newParentNoteId: string): NoteAndBranch</code></pre><p>Enables the complete duplication of the specified original note and all its children into the specified parent note. The new note will be named the same as the original, with (Dup) added to the end of it.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>origNoteId</code></td><td><code>string</code><br>the noteId for the original note to be duplicated</td></tr><tr><td><code>newParentNoteId</code></td><td><code>string</code><br>the noteId for the parent note where the duplication is to be placed.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>NoteAndBranch</code>: the note and the branch of the newly created note.</p></td>
</tr>
</tbody>
</table>
-## `ScriptBNote`
+## `BNote`
A note as seen by backend scripts (subset of trilium-core's `BNote`).
@@ -348,15 +348,15 @@ A note as seen by backend scripts (subset of trilium-core's `BNote`).
</tr>
<tr>
<td><code>parents</code></td>
- <td><p><code>ScriptBNote[]</code><br>The parent notes of this note: one per place the note appears in the tree, so a cloned note has several. Parents that are not archived come first. This is the same array <code>getParentNotes()</code> returns; don't modify it.</p></td>
+ <td><p><code>BNote[]</code><br>The parent notes of this note: one per place the note appears in the tree, so a cloned note has several. Parents that are not archived come first. This is the same array <code>getParentNotes()</code> returns; don't modify it.</p></td>
</tr>
<tr>
<td><code>children</code></td>
- <td><p><code>ScriptBNote[]</code><br>The child notes of this note, in their order in the tree. This is the same array <code>getChildNotes()</code> returns; don't modify it.</p></td>
+ <td><p><code>BNote[]</code><br>The child notes of this note, in their order in the tree. This is the same array <code>getChildNotes()</code> returns; don't modify it.</p></td>
</tr>
<tr>
<td><code>parentBranches</code></td>
- <td><p><code>ScriptBBranch[]</code><br>The branches that place this note under each of its parents, in the same order as <code>parents</code>. This is the same array <code>getParentBranches()</code> returns; don't modify it.</p></td>
+ <td><p><code>BBranch[]</code><br>The branches that place this note under each of its parents, in the same order as <code>parents</code>. This is the same array <code>getParentBranches()</code> returns; don't modify it.</p></td>
</tr>
<tr>
<td><code>parentCount</code></td>
@@ -368,39 +368,39 @@ A note as seen by backend scripts (subset of trilium-core's `BNote`).
</tr>
<tr>
<td><code>getParentNotes</code></td>
- <td><pre><code class="language-application-typescript">getParentNotes(): ScriptBNote[]</code></pre><p>Returns the parent notes of this note, one per place the note appears in the tree. Parents that are not archived come first. The result is the <code>parents</code> array itself; don't modify it.</p></td>
+ <td><pre><code class="language-application-typescript">getParentNotes(): BNote[]</code></pre><p>Returns the parent notes of this note, one per place the note appears in the tree. Parents that are not archived come first. The result is the <code>parents</code> array itself; don't modify it.</p></td>
</tr>
<tr>
<td><code>getChildNotes</code></td>
- <td><pre><code class="language-application-typescript">getChildNotes(): ScriptBNote[]</code></pre><p>Returns the child notes of this note, in their order in the tree. The result is the <code>children</code> array itself; don't modify it.</p></td>
+ <td><pre><code class="language-application-typescript">getChildNotes(): BNote[]</code></pre><p>Returns the child notes of this note, in their order in the tree. The result is the <code>children</code> array itself; don't modify it.</p></td>
</tr>
<tr>
<td><code>getVisibleChildNotes</code></td>
- <td><pre><code class="language-application-typescript">getVisibleChildNotes(): ScriptBNote[]</code></pre><p>Returns the child notes that are shown in a shared note's navigation tree, in tree order. It leaves out system notes, whose IDs start with <code>_</code>, and notes with a <code>shareHiddenFromTree</code> label, their own or inherited. Archived notes are included.</p></td>
+ <td><pre><code class="language-application-typescript">getVisibleChildNotes(): BNote[]</code></pre><p>Returns the child notes that are shown in a shared note's navigation tree, in tree order. It leaves out system notes, whose IDs start with <code>_</code>, and notes with a <code>shareHiddenFromTree</code> label, their own or inherited. Archived notes are included.</p></td>
</tr>
<tr>
<td><code>getParentBranches</code></td>
- <td><pre><code class="language-application-typescript">getParentBranches(): ScriptBBranch[]</code></pre><p>Returns the branches that place this note under each of its parents. The result is the <code>parentBranches</code> array itself; don't modify it.</p></td>
+ <td><pre><code class="language-application-typescript">getParentBranches(): BBranch[]</code></pre><p>Returns the branches that place this note under each of its parents. The result is the <code>parentBranches</code> array itself; don't modify it.</p></td>
</tr>
<tr>
<td><code>getChildBranches</code></td>
- <td><pre><code class="language-application-typescript">getChildBranches(): ScriptBBranch[]</code></pre><p>Returns the branches that connect this note to each of its children, in their order in the tree. A branch holds the child's position and prefix.</p></td>
+ <td><pre><code class="language-application-typescript">getChildBranches(): BBranch[]</code></pre><p>Returns the branches that connect this note to each of its children, in their order in the tree. A branch holds the child's position and prefix.</p></td>
</tr>
<tr>
<td><code>getVisibleChildBranches</code></td>
- <td><pre><code class="language-application-typescript">getVisibleChildBranches(): ScriptBBranch[]</code></pre><p>Returns the child branches whose notes are shown in a shared note's navigation tree, in tree order. It leaves out system notes, whose IDs start with <code>_</code>, and notes with a <code>shareHiddenFromTree</code> label, their own or inherited. Archived notes are included.</p></td>
+ <td><pre><code class="language-application-typescript">getVisibleChildBranches(): BBranch[]</code></pre><p>Returns the child branches whose notes are shown in a shared note's navigation tree, in tree order. It leaves out system notes, whose IDs start with <code>_</code>, and notes with a <code>shareHiddenFromTree</code> label, their own or inherited. Archived notes are included.</p></td>
</tr>
<tr>
<td><code>getStrongParentBranches</code></td>
- <td><pre><code class="language-application-typescript">getStrongParentBranches(): ScriptBBranch[]</code></pre><p>Returns the parent branches the user created, leaving out the automatic placements under the shared notes (<code>_share</code>) and the bookmarks (<code>_lbBookmarks</code>). A note whose last such branch is deleted is deleted too.</p></td>
+ <td><pre><code class="language-application-typescript">getStrongParentBranches(): BBranch[]</code></pre><p>Returns the parent branches the user created, leaving out the automatic placements under the shared notes (<code>_share</code>) and the bookmarks (<code>_lbBookmarks</code>). A note whose last such branch is deleted is deleted too.</p></td>
</tr>
<tr>
<td><code>getFilteredChildBranches</code></td>
- <td><pre><code class="language-application-typescript">getFilteredChildBranches(): ScriptBBranch[]</code></pre><p>Returns the same branches as <code>getChildBranches()</code>. Despite its name, it filters nothing: archived and hidden children are included.</p></td>
+ <td><pre><code class="language-application-typescript">getFilteredChildBranches(): BBranch[]</code></pre><p>Returns the same branches as <code>getChildBranches()</code>. Despite its name, it filters nothing: archived and hidden children are included.</p></td>
</tr>
<tr>
<td><code>getBranches</code></td>
- <td><pre><code class="language-application-typescript">getBranches(): ScriptBBranch[]</code></pre><p>Returns the branches that place this note under each of its parents.</p><aside class="admonition warning"><p>Deprecated. Use <code>getParentBranches()</code> instead.</p></aside></td>
+ <td><pre><code class="language-application-typescript">getBranches(): BBranch[]</code></pre><p>Returns the branches that place this note under each of its parents.</p><aside class="admonition warning"><p>Deprecated. Use <code>getParentBranches()</code> instead.</p></aside></td>
</tr>
<tr>
<td><code>hasChildren</code></td>
@@ -412,7 +412,7 @@ A note as seen by backend scripts (subset of trilium-core's `BNote`).
</tr>
<tr>
<td><code>getAncestors</code></td>
- <td><pre><code class="language-application-typescript">getAncestors(): ScriptBNote[]</code></pre><p>Returns every ancestor of the note across all of its paths in the tree, each note once, up to and including the root note. The note itself is not included. The order follows the parents: each parent comes first, followed by its own ancestors.</p></td>
+ <td><pre><code class="language-application-typescript">getAncestors(): BNote[]</code></pre><p>Returns every ancestor of the note across all of its paths in the tree, each note once, up to and including the root note. The note itself is not included. The order follows the parents: each parent comes first, followed by its own ancestors.</p></td>
</tr>
<tr>
<td><code>getAncestorNoteIds</code></td>
@@ -440,19 +440,19 @@ A note as seen by backend scripts (subset of trilium-core's `BNote`).
</tr>
<tr>
<td><code>getSubtree</code></td>
- <td><pre><code class="language-application-typescript">getSubtree(opts?: ScriptSubtreeOpts): { notes: ScriptBNote[]; relationships: ScriptSubtreeRelationship[] }</code></pre><p>Returns the note and all its descendants, each note once, together with every parent-child relationship among them, including those of cloned notes.</p><p><strong>Returns</strong> <code>{ notes: ScriptBNote[]; relationships: ScriptSubtreeRelationship[] }</code>: An object with <code>notes</code>, the notes of the subtree including this note, and <code>relationships</code>, the <code>{ parentNoteId, childNoteId }</code> pairs connecting them.</p></td>
+ <td><pre><code class="language-application-typescript">getSubtree(opts?: SubtreeOpts): { notes: BNote[]; relationships: SubtreeRelationship[] }</code></pre><p>Returns the note and all its descendants, each note once, together with every parent-child relationship among them, including those of cloned notes.</p><p><strong>Returns</strong> <code>{ notes: BNote[]; relationships: SubtreeRelationship[] }</code>: An object with <code>notes</code>, the notes of the subtree including this note, and <code>relationships</code>, the <code>{ parentNoteId, childNoteId }</code> pairs connecting them.</p></td>
</tr>
<tr>
<td><code>getSubtreeNoteIds</code></td>
- <td><pre><code class="language-application-typescript">getSubtreeNoteIds(opts?: ScriptSubtreeOpts): string[]</code></pre><p>Returns the IDs of this note and all its descendants, each once. Takes the same options as <code>getSubtree()</code>.</p></td>
+ <td><pre><code class="language-application-typescript">getSubtreeNoteIds(opts?: SubtreeOpts): string[]</code></pre><p>Returns the IDs of this note and all its descendants, each once. Takes the same options as <code>getSubtree()</code>.</p></td>
</tr>
<tr>
<td><code>getSubtreeNotesIncludingTemplated</code></td>
- <td><pre><code class="language-application-typescript">getSubtreeNotesIncludingTemplated(): ScriptBNote[]</code></pre><p>Returns the notes that this note's inheritable attributes reach: the note itself, its descendants, and every note that uses one of them as a <code>template</code> or <code>inherit</code> relation target, along with that note's descendants. Each note appears once; the hidden subtree (<code>_hidden</code>) is skipped.</p></td>
+ <td><pre><code class="language-application-typescript">getSubtreeNotesIncludingTemplated(): BNote[]</code></pre><p>Returns the notes that this note's inheritable attributes reach: the note itself, its descendants, and every note that uses one of them as a <code>template</code> or <code>inherit</code> relation target, along with that note's descendants. Each note appears once; the hidden subtree (<code>_hidden</code>) is skipped.</p></td>
</tr>
<tr>
<td><code>getInheritingNotes</code></td>
- <td><pre><code class="language-application-typescript">getInheritingNotes(): ScriptBNote[]</code></pre><p>Returns the notes that this note's non-inheritable attributes apply to: the note itself and every note that uses it as a <code>template</code> or <code>inherit</code> relation target. Their descendants are not included.</p></td>
+ <td><pre><code class="language-application-typescript">getInheritingNotes(): BNote[]</code></pre><p>Returns the notes that this note's non-inheritable attributes apply to: the note itself and every note that uses it as a <code>template</code> or <code>inherit</code> relation target. Their descendants are not included.</p></td>
</tr>
<tr>
<td><code>getAllNotePaths</code></td>
@@ -468,7 +468,7 @@ A note as seen by backend scripts (subset of trilium-core's `BNote`).
</tr>
<tr>
<td><code>getSortedNotePathRecords</code></td>
- <td><pre><code class="language-application-typescript">getSortedNotePathRecords(hoistedNoteId?: string): ScriptNotePathRecord[]</code></pre><p>Returns a record for every path from the root note to this note, best path first. Paths within the hoisted note's subtree come first, then paths without archived notes, then paths outside the hidden subtree, then shorter paths.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>hoistedNoteId</code><br><em>optional</em></td><td><code>string</code><br>The ID of the note whose subtree is preferred. Defaults to <code>root</code>.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>ScriptNotePathRecord[]</code>: Records whose <code>notePath</code> holds the note IDs from the root to this note, with flags telling whether the path lies within the hoisted subtree (<code>isInHoistedSubTree</code>), passes through an archived note, the note itself included (<code>isArchived</code>), or lies within the hidden subtree (<code>isHidden</code>).</p></td>
+ <td><pre><code class="language-application-typescript">getSortedNotePathRecords(hoistedNoteId?: string): NotePathRecord[]</code></pre><p>Returns a record for every path from the root note to this note, best path first. Paths within the hoisted note's subtree come first, then paths without archived notes, then paths outside the hidden subtree, then shorter paths.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>hoistedNoteId</code><br><em>optional</em></td><td><code>string</code><br>The ID of the note whose subtree is preferred. Defaults to <code>root</code>.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>NotePathRecord[]</code>: Records whose <code>notePath</code> holds the note IDs from the root to this note, with flags telling whether the path lies within the hoisted subtree (<code>isInHoistedSubTree</code>), passes through an archived note, the note itself included (<code>isArchived</code>), or lies within the hidden subtree (<code>isHidden</code>).</p></td>
</tr>
<tr>
<td><code>areAllNotePathsArchived</code></td>
@@ -476,11 +476,11 @@ A note as seen by backend scripts (subset of trilium-core's `BNote`).
</tr>
<tr>
<td><code>ownedAttributes</code></td>
- <td><p><code>ScriptAttribute[]</code><br>The labels and relations defined directly on this note, without inherited ones.</p></td>
+ <td><p><code>Attribute[]</code><br>The labels and relations defined directly on this note, without inherited ones.</p></td>
</tr>
<tr>
<td><code>targetRelations</code></td>
- <td><p><code>ScriptAttribute[]</code><br>The relations in other notes (or this one) that point to this note. This includes the link relations Trilium creates automatically for links in note content, such as <code>internalLink</code> and <code>imageLink</code>.</p></td>
+ <td><p><code>Attribute[]</code><br>The relations in other notes (or this one) that point to this note. This includes the link relations Trilium creates automatically for links in note content, such as <code>internalLink</code> and <code>imageLink</code>.</p></td>
</tr>
<tr>
<td><code>attributeCount</code></td>
@@ -524,19 +524,19 @@ A note as seen by backend scripts (subset of trilium-core's `BNote`).
</tr>
<tr>
<td><code>getAttributes</code></td>
- <td><pre><code class="language-application-typescript">getAttributes(type?: string, name?: string): ScriptAttribute[]</code></pre><p>Returns the labels and relations of this note, inherited ones included, optionally filtered by type and name. Without a filter, the result is the note's own cached array; don't modify it.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code><br><em>optional</em></td><td><code>string</code><br><code>"label"</code> or <code>"relation"</code>; any other value throws an error.</td></tr><tr><td><code>name</code><br><em>optional</em></td><td><code>string</code><br>The attribute name, without the leading <code>#</code> or <code>~</code>.</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getAttributes(type?: string, name?: string): Attribute[]</code></pre><p>Returns the labels and relations of this note, inherited ones included, optionally filtered by type and name. Without a filter, the result is the note's own cached array; don't modify it.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code><br><em>optional</em></td><td><code>string</code><br><code>"label"</code> or <code>"relation"</code>; any other value throws an error.</td></tr><tr><td><code>name</code><br><em>optional</em></td><td><code>string</code><br>The attribute name, without the leading <code>#</code> or <code>~</code>.</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getOwnedAttributes</code></td>
- <td><pre><code class="language-application-typescript">getOwnedAttributes(type?: string, name?: string): ScriptAttribute[]</code></pre><p>Returns the labels and relations defined directly on this note, optionally filtered by type and name. Without a filter, the result is the <code>ownedAttributes</code> array itself; don't modify it.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code><br><em>optional</em></td><td><code>string</code><br><code>"label"</code> or <code>"relation"</code>; any other value throws an error.</td></tr><tr><td><code>name</code><br><em>optional</em></td><td><code>string</code><br>The attribute name, without the leading <code>#</code> or <code>~</code>.</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getOwnedAttributes(type?: string, name?: string): Attribute[]</code></pre><p>Returns the labels and relations defined directly on this note, optionally filtered by type and name. Without a filter, the result is the <code>ownedAttributes</code> array itself; don't modify it.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code><br><em>optional</em></td><td><code>string</code><br><code>"label"</code> or <code>"relation"</code>; any other value throws an error.</td></tr><tr><td><code>name</code><br><em>optional</em></td><td><code>string</code><br>The attribute name, without the leading <code>#</code> or <code>~</code>.</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getAttribute</code></td>
- <td><pre><code class="language-application-typescript">getAttribute(type: string, name: string): ScriptAttribute | null</code></pre><p>Returns the first attribute of the given type and name, inherited ones included, or <code>null</code> if there is none.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>"label"</code> or <code>"relation"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getAttribute(type: string, name: string): Attribute | null</code></pre><p>Returns the first attribute of the given type and name, inherited ones included, or <code>null</code> if there is none.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>"label"</code> or <code>"relation"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getOwnedAttribute</code></td>
- <td><pre><code class="language-application-typescript">getOwnedAttribute(type: string, name: string, value?: string | null): ScriptAttribute | null</code></pre><p>Returns the first attribute of the given type and name defined directly on this note, or <code>null</code> if there is none. It skips inheritance, so it can be much faster than <code>getAttribute()</code>.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>"label"</code> or <code>"relation"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string | null</code><br>The value to match; when omitted, any value matches.</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getOwnedAttribute(type: string, name: string, value?: string | null): Attribute | null</code></pre><p>Returns the first attribute of the given type and name defined directly on this note, or <code>null</code> if there is none. It skips inheritance, so it can be much faster than <code>getAttribute()</code>.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>"label"</code> or <code>"relation"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string | null</code><br>The value to match; when omitted, any value matches.</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getAttributeValue</code></td>
@@ -548,11 +548,11 @@ A note as seen by backend scripts (subset of trilium-core's `BNote`).
</tr>
<tr>
<td><code>getAttributeById</code></td>
- <td><pre><code class="language-application-typescript">getAttributeById(attributeId: string): ScriptAttribute | undefined</code></pre><p>Returns the attribute of this note with the given ID, inherited ones included, or <code>undefined</code> if there is none.</p></td>
+ <td><pre><code class="language-application-typescript">getAttributeById(attributeId: string): Attribute | undefined</code></pre><p>Returns the attribute of this note with the given ID, inherited ones included, or <code>undefined</code> if there is none.</p></td>
</tr>
<tr>
<td><code>getAttributeCaseInsensitive</code></td>
- <td><pre><code class="language-application-typescript">getAttributeCaseInsensitive(type: string, name: string, value?: string | null): ScriptAttribute | undefined</code></pre><p>Returns the first attribute of the given type whose name, and optionally value, matches regardless of letter case, or <code>undefined</code> if none does. Inherited attributes are included.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>"label"</code> or <code>"relation"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string | null</code><br>The value to match; an empty or omitted value matches any value.</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getAttributeCaseInsensitive(type: string, name: string, value?: string | null): Attribute | undefined</code></pre><p>Returns the first attribute of the given type whose name, and optionally value, matches regardless of letter case, or <code>undefined</code> if none does. Inherited attributes are included.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>"label"</code> or <code>"relation"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string | null</code><br>The value to match; an empty or omitted value matches any value.</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>hasAttribute</code></td>
@@ -564,31 +564,31 @@ A note as seen by backend scripts (subset of trilium-core's `BNote`).
</tr>
<tr>
<td><code>getLabelDefinitions</code></td>
- <td><pre><code class="language-application-typescript">getLabelDefinitions(): ScriptAttribute[]</code></pre><p>Returns the attribute definitions on this note, inherited ones included. Currently returns the same <code>#relation:*</code> definitions as <code>getRelationDefinitions()</code>, not the <code>#label:*</code> ones; to read label definitions, filter <code>getLabels()</code> by names that start with <code>label:</code>.</p></td>
+ <td><pre><code class="language-application-typescript">getLabelDefinitions(): Attribute[]</code></pre><p>Returns the attribute definitions on this note, inherited ones included. Currently returns the same <code>#relation:*</code> definitions as <code>getRelationDefinitions()</code>, not the <code>#label:*</code> ones; to read label definitions, filter <code>getLabels()</code> by names that start with <code>label:</code>.</p></td>
</tr>
<tr>
<td><code>getRelationDefinitions</code></td>
- <td><pre><code class="language-application-typescript">getRelationDefinitions(): ScriptAttribute[]</code></pre><p>Returns the relation definitions on this note, inherited ones included: the <code>#relation:*</code> labels that declare promoted relations, such as <code>#relation:author="promoted,single"</code>.</p></td>
+ <td><pre><code class="language-application-typescript">getRelationDefinitions(): Attribute[]</code></pre><p>Returns the relation definitions on this note, inherited ones included: the <code>#relation:*</code> labels that declare promoted relations, such as <code>#relation:author="promoted,single"</code>.</p></td>
</tr>
<tr>
<td><code>getTargetRelations</code></td>
- <td><pre><code class="language-application-typescript">getTargetRelations(): ScriptAttribute[]</code></pre><p>Returns the relations in other notes (or this one) that point to this note, the automatic link relations included. Same as <code>targetRelations</code>.</p></td>
+ <td><pre><code class="language-application-typescript">getTargetRelations(): Attribute[]</code></pre><p>Returns the relations in other notes (or this one) that point to this note, the automatic link relations included. Same as <code>targetRelations</code>.</p></td>
</tr>
<tr>
<td><code>getLabel</code></td>
- <td><pre><code class="language-application-typescript">getLabel(name: string): ScriptAttribute | null</code></pre><p>Returns the first label with the given name, inherited ones included, or <code>null</code> if there is none. Pass the name without the leading <code>#</code>.</p></td>
+ <td><pre><code class="language-application-typescript">getLabel(name: string): Attribute | null</code></pre><p>Returns the first label with the given name, inherited ones included, or <code>null</code> if there is none. Pass the name without the leading <code>#</code>.</p></td>
</tr>
<tr>
<td><code>getOwnedLabel</code></td>
- <td><pre><code class="language-application-typescript">getOwnedLabel(name: string): ScriptAttribute | null</code></pre><p>Returns the first label with the given name defined directly on this note, or <code>null</code> if there is none.</p></td>
+ <td><pre><code class="language-application-typescript">getOwnedLabel(name: string): Attribute | null</code></pre><p>Returns the first label with the given name defined directly on this note, or <code>null</code> if there is none.</p></td>
</tr>
<tr>
<td><code>getLabels</code></td>
- <td><pre><code class="language-application-typescript">getLabels(name?: string): ScriptAttribute[]</code></pre><p>Returns the labels of this note, inherited ones included. When <code>name</code> is given, only labels with that name are returned.</p></td>
+ <td><pre><code class="language-application-typescript">getLabels(name?: string): Attribute[]</code></pre><p>Returns the labels of this note, inherited ones included. When <code>name</code> is given, only labels with that name are returned.</p></td>
</tr>
<tr>
<td><code>getOwnedLabels</code></td>
- <td><pre><code class="language-application-typescript">getOwnedLabels(name: string): ScriptAttribute[]</code></pre><p>Returns the labels with the given name defined directly on this note.</p></td>
+ <td><pre><code class="language-application-typescript">getOwnedLabels(name: string): Attribute[]</code></pre><p>Returns the labels with the given name defined directly on this note.</p></td>
</tr>
<tr>
<td><code>getLabelValue</code></td>
@@ -624,19 +624,19 @@ A note as seen by backend scripts (subset of trilium-core's `BNote`).
</tr>
<tr>
<td><code>getRelation</code></td>
- <td><pre><code class="language-application-typescript">getRelation(name: string): ScriptAttribute | null</code></pre><p>Returns the first relation with the given name, inherited ones included, or <code>null</code> if there is none. Pass the name without the leading <code>~</code>.</p></td>
+ <td><pre><code class="language-application-typescript">getRelation(name: string): Attribute | null</code></pre><p>Returns the first relation with the given name, inherited ones included, or <code>null</code> if there is none. Pass the name without the leading <code>~</code>.</p></td>
</tr>
<tr>
<td><code>getOwnedRelation</code></td>
- <td><pre><code class="language-application-typescript">getOwnedRelation(name: string): ScriptAttribute | null</code></pre><p>Returns the first relation with the given name defined directly on this note, or <code>null</code> if there is none.</p></td>
+ <td><pre><code class="language-application-typescript">getOwnedRelation(name: string): Attribute | null</code></pre><p>Returns the first relation with the given name defined directly on this note, or <code>null</code> if there is none.</p></td>
</tr>
<tr>
<td><code>getRelations</code></td>
- <td><pre><code class="language-application-typescript">getRelations(name?: string): ScriptAttribute[]</code></pre><p>Returns the relations of this note, inherited ones included. When <code>name</code> is given, only relations with that name are returned.</p></td>
+ <td><pre><code class="language-application-typescript">getRelations(name?: string): Attribute[]</code></pre><p>Returns the relations of this note, inherited ones included. When <code>name</code> is given, only relations with that name are returned.</p></td>
</tr>
<tr>
<td><code>getOwnedRelations</code></td>
- <td><pre><code class="language-application-typescript">getOwnedRelations(name?: string | null): ScriptAttribute[]</code></pre><p>Returns the relations defined directly on this note. When <code>name</code> is given, only relations with that name are returned.</p></td>
+ <td><pre><code class="language-application-typescript">getOwnedRelations(name?: string | null): Attribute[]</code></pre><p>Returns the relations defined directly on this note. When <code>name</code> is given, only relations with that name are returned.</p></td>
</tr>
<tr>
<td><code>getRelationValue</code></td>
@@ -648,7 +648,7 @@ A note as seen by backend scripts (subset of trilium-core's `BNote`).
</tr>
<tr>
<td><code>getRelationTarget</code></td>
- <td><pre><code class="language-application-typescript">getRelationTarget(name: string): ScriptBNote | null</code></pre><p>Returns the note that the first relation with the given name points to, or <code>null</code> if the note has no such relation. Inherited relations are included.</p></td>
+ <td><pre><code class="language-application-typescript">getRelationTarget(name: string): BNote | null</code></pre><p>Returns the note that the first relation with the given name points to, or <code>null</code> if the note has no such relation. Inherited relations are included.</p></td>
</tr>
<tr>
<td><code>hasRelation</code></td>
@@ -660,15 +660,15 @@ A note as seen by backend scripts (subset of trilium-core's `BNote`).
</tr>
<tr>
<td><code>addLabel</code></td>
- <td><pre><code class="language-application-typescript">addLabel(name: string, value?: string, isInheritable?: boolean): ScriptAttribute</code></pre><p>Adds a label to this note, saves it and returns it. It adds a new label even when the note already has one with that name; to change an existing label instead, use <code>setLabel()</code>.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code><br>The label name, without the leading <code>#</code>.</td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The label value. Defaults to an empty string.</td></tr><tr><td><code>isInheritable</code><br><em>optional</em></td><td><code>boolean</code><br>Whether the note's descendants inherit the label. Defaults to <code>false</code>.</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">addLabel(name: string, value?: string, isInheritable?: boolean): Attribute</code></pre><p>Adds a label to this note, saves it and returns it. It adds a new label even when the note already has one with that name; to change an existing label instead, use <code>setLabel()</code>.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code><br>The label name, without the leading <code>#</code>.</td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The label value. Defaults to an empty string.</td></tr><tr><td><code>isInheritable</code><br><em>optional</em></td><td><code>boolean</code><br>Whether the note's descendants inherit the label. Defaults to <code>false</code>.</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>addRelation</code></td>
- <td><pre><code class="language-application-typescript">addRelation(name: string, targetNoteId: string, isInheritable?: boolean): ScriptAttribute</code></pre><p>Adds a relation from this note to another note, saves it and returns it. It adds a new relation even when the note already has one with that name; to change an existing relation instead, use <code>setRelation()</code>.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code><br>The relation name, without the leading <code>~</code>.</td></tr><tr><td><code>targetNoteId</code></td><td><code>string</code></td></tr><tr><td><code>isInheritable</code><br><em>optional</em></td><td><code>boolean</code><br>Whether the note's descendants inherit the relation. Defaults to <code>false</code>.</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">addRelation(name: string, targetNoteId: string, isInheritable?: boolean): Attribute</code></pre><p>Adds a relation from this note to another note, saves it and returns it. It adds a new relation even when the note already has one with that name; to change an existing relation instead, use <code>setRelation()</code>.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>name</code></td><td><code>string</code><br>The relation name, without the leading <code>~</code>.</td></tr><tr><td><code>targetNoteId</code></td><td><code>string</code></td></tr><tr><td><code>isInheritable</code><br><em>optional</em></td><td><code>boolean</code><br>Whether the note's descendants inherit the relation. Defaults to <code>false</code>.</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>addAttribute</code></td>
- <td><pre><code class="language-application-typescript">addAttribute(type: string, name: string, value?: string, isInheritable?: boolean): ScriptAttribute</code></pre><p>Adds a label or relation to this note, saves it and returns it. <code>addLabel()</code> and <code>addRelation()</code> do the same for one type.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>"label"</code> or <code>"relation"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code><br>The attribute name, without the leading <code>#</code> or <code>~</code>.</td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The label's text, or the relation's target note ID. Defaults to an empty string.</td></tr><tr><td><code>isInheritable</code><br><em>optional</em></td><td><code>boolean</code><br>Whether the note's descendants inherit the attribute. Defaults to <code>false</code>.</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">addAttribute(type: string, name: string, value?: string, isInheritable?: boolean): Attribute</code></pre><p>Adds a label or relation to this note, saves it and returns it. <code>addLabel()</code> and <code>addRelation()</code> do the same for one type.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>"label"</code> or <code>"relation"</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code><br>The attribute name, without the leading <code>#</code> or <code>~</code>.</td></tr><tr><td><code>value</code><br><em>optional</em></td><td><code>string</code><br>The label's text, or the relation's target note ID. Defaults to an empty string.</td></tr><tr><td><code>isInheritable</code><br><em>optional</em></td><td><code>boolean</code><br>Whether the note's descendants inherit the attribute. Defaults to <code>false</code>.</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>setLabel</code></td>
@@ -720,35 +720,35 @@ A note as seen by backend scripts (subset of trilium-core's `BNote`).
</tr>
<tr>
<td><code>getRevisions</code></td>
- <td><pre><code class="language-application-typescript">getRevisions(): ScriptBRevision[]</code></pre><p>Returns the saved revisions of this note, oldest first.</p></td>
+ <td><pre><code class="language-application-typescript">getRevisions(): BRevision[]</code></pre><p>Returns the saved revisions of this note, oldest first.</p></td>
</tr>
<tr>
<td><code>saveRevision</code></td>
- <td><pre><code class="language-application-typescript">saveRevision(opts?: { description?: string; source?: string }): ScriptBRevision</code></pre><p>Saves a revision that snapshots the note's current title, content and attachments, and returns it. Afterwards, Trilium erases the oldest revisions beyond the number the revision settings keep.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code><br><em>optional</em></td><td><code>{ description?: string; source?: string }</code><br><code>description</code> names the revision; <code>source</code> records what created it: <code>"auto"</code> (the default), <code>"manual"</code>, <code>"etapi"</code>, <code>"llm"</code> or <code>"restore"</code>.</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">saveRevision(opts?: { description?: string; source?: string }): BRevision</code></pre><p>Saves a revision that snapshots the note's current title, content and attachments, and returns it. Afterwards, Trilium erases the oldest revisions beyond the number the revision settings keep.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code><br><em>optional</em></td><td><code>{ description?: string; source?: string }</code><br><code>description</code> names the revision; <code>source</code> records what created it: <code>"auto"</code> (the default), <code>"manual"</code>, <code>"etapi"</code>, <code>"llm"</code> or <code>"restore"</code>.</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getAttachments</code></td>
- <td><pre><code class="language-application-typescript">getAttachments(): ScriptAttachment[]</code></pre><p>Returns the attachments of this note, ordered by position. Deleted attachments are excluded.</p></td>
+ <td><pre><code class="language-application-typescript">getAttachments(): Attachment[]</code></pre><p>Returns the attachments of this note, ordered by position. Deleted attachments are excluded.</p></td>
</tr>
<tr>
<td><code>getAttachmentById</code></td>
- <td><pre><code class="language-application-typescript">getAttachmentById(attachmentId: string): ScriptAttachment</code></pre><p>Returns the attachment of this note with the given ID. Returns <code>undefined</code> if this note has no such attachment, although the type does not say so.</p></td>
+ <td><pre><code class="language-application-typescript">getAttachmentById(attachmentId: string): Attachment</code></pre><p>Returns the attachment of this note with the given ID. Returns <code>undefined</code> if this note has no such attachment, although the type does not say so.</p></td>
</tr>
<tr>
<td><code>getAttachmentByTitle</code></td>
- <td><pre><code class="language-application-typescript">getAttachmentByTitle(title: string): ScriptAttachment | undefined</code></pre><p>Returns the first attachment of this note whose title matches exactly, or <code>undefined</code> if none does.</p></td>
+ <td><pre><code class="language-application-typescript">getAttachmentByTitle(title: string): Attachment | undefined</code></pre><p>Returns the first attachment of this note whose title matches exactly, or <code>undefined</code> if none does.</p></td>
</tr>
<tr>
<td><code>getAttachmentsByRole</code></td>
- <td><pre><code class="language-application-typescript">getAttachmentsByRole(role: string): ScriptAttachment[]</code></pre><p>Returns the attachments of this note with the given role, such as <code>"image"</code> or <code>"file"</code>, ordered by position.</p></td>
+ <td><pre><code class="language-application-typescript">getAttachmentsByRole(role: string): Attachment[]</code></pre><p>Returns the attachments of this note with the given role, such as <code>"image"</code> or <code>"file"</code>, ordered by position.</p></td>
</tr>
<tr>
<td><code>saveAttachment</code></td>
- <td><pre><code class="language-application-typescript">saveAttachment(attachment: ScriptSaveAttachmentInput, matchBy?: "title" | "attachmentId"): ScriptAttachment</code></pre><p>Saves an attachment of this note and returns it. If an existing attachment matches, only its content is replaced; otherwise a new attachment is created from <code>attachment</code>, protected if the note is. Missing content is saved as an empty string.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>attachment</code></td><td><code>ScriptSaveAttachmentInput</code></td></tr><tr><td><code>matchBy</code><br><em>optional</em></td><td><code>"title" | "attachmentId"</code><br>How to find an existing attachment to update: <code>"attachmentId"</code> (the default) by <code>attachment.attachmentId</code>, which throws an error if no attachment has that ID, or <code>"title"</code> by <code>attachment.title</code> among this note's attachments.</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">saveAttachment(attachment: SaveAttachmentInput, matchBy?: "title" | "attachmentId"): Attachment</code></pre><p>Saves an attachment of this note and returns it. If an existing attachment matches, only its content is replaced; otherwise a new attachment is created from <code>attachment</code>, protected if the note is. Missing content is saved as an empty string.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>attachment</code></td><td><code>SaveAttachmentInput</code></td></tr><tr><td><code>matchBy</code><br><em>optional</em></td><td><code>"title" | "attachmentId"</code><br>How to find an existing attachment to update: <code>"attachmentId"</code> (the default) by <code>attachment.attachmentId</code>, which throws an error if no attachment has that ID, or <code>"title"</code> by <code>attachment.title</code> among this note's attachments.</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>convertToParentAttachment</code></td>
- <td><pre><code class="language-application-typescript">convertToParentAttachment(opts?: Record&lt;string, unknown&gt;): ScriptAttachment | null</code></pre><p>Converts this image note into an image attachment of its parent text note, points the parent's content at the attachment, deletes this note and returns the attachment. Returns <code>null</code> and changes nothing when <code>isEligibleForConversionToAttachment()</code> returns <code>false</code>.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code><br><em>optional</em></td><td><code>Record&lt;string, unknown&gt;</code><br>Pass <code>{ autoConversion: true }</code> to also require that the parent links the image.</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">convertToParentAttachment(opts?: Record&lt;string, unknown&gt;): Attachment | null</code></pre><p>Converts this image note into an image attachment of its parent text note, points the parent's content at the attachment, deletes this note and returns the attachment. Returns <code>null</code> and changes nothing when <code>isEligibleForConversionToAttachment()</code> returns <code>false</code>.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>opts</code><br><em>optional</em></td><td><code>Record&lt;string, unknown&gt;</code><br>Pass <code>{ autoConversion: true }</code> to also require that the parent links the image.</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>isEligibleForConversionToAttachment</code></td>
@@ -768,7 +768,7 @@ A note as seen by backend scripts (subset of trilium-core's `BNote`).
</tr>
<tr>
<td><code>cloneTo</code></td>
- <td><pre><code class="language-application-typescript">cloneTo(parentNoteId: string): ScriptCloneResponse</code></pre><p>Places this note under another parent note as well, keeping its existing placements, and expands the new parent in the note tree. The result does not throw on failure; check <code>success</code>, and read <code>message</code> for why it failed (for example, the note is already in that parent, the target is a search note, or the clone would create a cycle).</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>parentNoteId</code></td><td><code>string</code><br>The ID of the note to clone into.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>ScriptCloneResponse</code>: On success, <code>branchId</code> of the new branch and <code>notePath</code> of the clone.</p></td>
+ <td><pre><code class="language-application-typescript">cloneTo(parentNoteId: string): CloneResponse</code></pre><p>Places this note under another parent note as well, keeping its existing placements, and expands the new parent in the note tree. The result does not throw on failure; check <code>success</code>, and read <code>message</code> for why it failed (for example, the note is already in that parent, the target is a search note, or the clone would create a cycle).</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>parentNoteId</code></td><td><code>string</code><br>The ID of the note to clone into.</td></tr></tbody></table></figure><p><strong>Returns</strong> <code>CloneResponse</code>: On success, <code>branchId</code> of the new branch and <code>notePath</code> of the clone.</p></td>
</tr>
<tr>
<td><code>deleteNote</code></td>
@@ -784,15 +784,15 @@ A note as seen by backend scripts (subset of trilium-core's `BNote`).
</tr>
<tr>
<td><code>searchNotesInSubtree</code></td>
- <td><pre><code class="language-application-typescript">searchNotesInSubtree(searchString: string): ScriptBNote[]</code></pre><p>Returns the notes that match a search query. Despite the name, the search covers the whole tree, not only this note's subtree, and leaves out archived and hidden notes; to limit it to this note's subtree, call <code>api.searchForNotes(query, { ancestorNoteId: note.noteId })</code>.</p></td>
+ <td><pre><code class="language-application-typescript">searchNotesInSubtree(searchString: string): BNote[]</code></pre><p>Returns the notes that match a search query. Despite the name, the search covers the whole tree, not only this note's subtree, and leaves out archived and hidden notes; to limit it to this note's subtree, call <code>api.searchForNotes(query, { ancestorNoteId: note.noteId })</code>.</p></td>
</tr>
<tr>
<td><code>searchNoteInSubtree</code></td>
- <td><pre><code class="language-application-typescript">searchNoteInSubtree(searchString: string): ScriptBNote | null</code></pre><p>Returns the first note that matches a search query, or <code>undefined</code> if none does. Like <code>searchNotesInSubtree()</code>, the search covers the whole tree, not only this note's subtree.</p></td>
+ <td><pre><code class="language-application-typescript">searchNoteInSubtree(searchString: string): BNote | null</code></pre><p>Returns the first note that matches a search query, or <code>undefined</code> if none does. Like <code>searchNotesInSubtree()</code>, the search covers the whole tree, not only this note's subtree.</p></td>
</tr>
<tr>
<td><code>getSearchResultNotes</code></td>
- <td><pre><code class="language-application-typescript">getSearchResultNotes(): ScriptBNote[]</code></pre><p>Runs the saved search of a search note and returns the notes it finds. Returns an empty array for other note types, and when the search fails (the error goes to the backend log).</p></td>
+ <td><pre><code class="language-application-typescript">getSearchResultNotes(): BNote[]</code></pre><p>Runs the saved search of a search note and returns the notes it finds. Returns an empty array for other note types, and when the search fails (the error goes to the backend log).</p></td>
</tr>
<tr>
<td><code>isFolder</code></td>
@@ -857,7 +857,7 @@ A note as seen by backend scripts (subset of trilium-core's `BNote`).
</tbody>
</table>
-## `ScriptRequest`
+## `Request`
Minimal Express `Request` surface available to **custom request handlers** (a subset of Express's `Request` — re-declared here to keep this module self-contained). Only the commonly used members are typed; the real object is a full Express request.
@@ -900,7 +900,7 @@ Minimal Express `Request` surface available to **custom request handlers** (a su
</tbody>
</table>
-## `ScriptResponse`
+## `Response`
Minimal Express `Response` surface available to **custom request handlers** (a subset of Express's `Response`). Write the HTTP response through this object, e.g. `api.res.status(200).json({ ok: true })`.
@@ -914,23 +914,23 @@ Minimal Express `Response` surface available to **custom request handlers** (a s
<tbody>
<tr>
<td><code>status</code></td>
- <td><pre><code class="language-application-typescript">status(code: number): ScriptResponse</code></pre><p>Sets the HTTP status code (chainable).</p></td>
+ <td><pre><code class="language-application-typescript">status(code: number): Response</code></pre><p>Sets the HTTP status code (chainable).</p></td>
</tr>
<tr>
<td><code>send</code></td>
- <td><pre><code class="language-application-typescript">send(body?: unknown): ScriptResponse</code></pre><p>Sends the response body (string, Buffer, object, …) and ends the response.</p></td>
+ <td><pre><code class="language-application-typescript">send(body?: unknown): Response</code></pre><p>Sends the response body (string, Buffer, object, …) and ends the response.</p></td>
</tr>
<tr>
<td><code>json</code></td>
- <td><pre><code class="language-application-typescript">json(body: unknown): ScriptResponse</code></pre><p>Sends a JSON response and ends the response.</p></td>
+ <td><pre><code class="language-application-typescript">json(body: unknown): Response</code></pre><p>Sends a JSON response and ends the response.</p></td>
</tr>
<tr>
<td><code>setHeader</code></td>
- <td><pre><code class="language-application-typescript">setHeader(name: string, value: string | string[]): ScriptResponse</code></pre><p>Sets a response header (chainable).</p></td>
+ <td><pre><code class="language-application-typescript">setHeader(name: string, value: string | string[]): Response</code></pre><p>Sets a response header (chainable).</p></td>
</tr>
<tr>
<td><code>set</code></td>
- <td><pre><code class="language-application-typescript">set(field: string, value?: string): ScriptResponse</code></pre><p>Sets a response header (Express alias of <code>setHeader</code>, chainable).</p></td>
+ <td><pre><code class="language-application-typescript">set(field: string, value?: string): Response</code></pre><p>Sets a response header (Express alias of <code>setHeader</code>, chainable).</p></td>
</tr>
<tr>
<td><code>redirect</code></td>
@@ -943,7 +943,7 @@ Minimal Express `Response` surface available to **custom request handlers** (a s
</tbody>
</table>
-## `ScriptBBranch`
+## `BBranch`
A branch (note→parent placement) as seen by backend scripts (subset of `BBranch`).
@@ -981,16 +981,16 @@ A branch (note→parent placement) as seen by backend scripts (subset of `BBranc
</tr>
<tr>
<td><code>getNote</code></td>
- <td><pre><code class="language-application-typescript">getNote(): ScriptBNote</code></pre><p>Returns the child note this branch places in the tree.</p></td>
+ <td><pre><code class="language-application-typescript">getNote(): BNote</code></pre><p>Returns the child note this branch places in the tree.</p></td>
</tr>
<tr>
<td><code>getParentNote</code></td>
- <td><pre><code class="language-application-typescript">getParentNote(): ScriptBNote | null</code></pre><p>Returns the parent note. The root note's branch has no parent note.</p></td>
+ <td><pre><code class="language-application-typescript">getParentNote(): BNote | null</code></pre><p>Returns the parent note. The root note's branch has no parent note.</p></td>
</tr>
</tbody>
</table>
-## `ScriptBRevision`
+## `BRevision`
A note revision as seen by backend scripts (subset of trilium-core's `BRevision`).
@@ -1045,7 +1045,7 @@ A note revision as seen by backend scripts (subset of trilium-core's `BRevision`
</tbody>
</table>
-## `ScriptDayjsInstance`
+## `DayjsInstance`
A date as day.js wraps it (subset).
@@ -1063,11 +1063,11 @@ A date as day.js wraps it (subset).
</tr>
<tr>
<td><code>add</code></td>
- <td><pre><code class="language-application-typescript">add(value: number, unit: string): ScriptDayjsInstance</code></pre><p>Returns a new date, <code>value</code> units later. The date it is called on stays unchanged.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>number</code></td></tr><tr><td><code>unit</code></td><td><code>string</code><br>The unit, such as <code>"day"</code>, <code>"week"</code>, <code>"month"</code> or <code>"year"</code>.</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">add(value: number, unit: string): DayjsInstance</code></pre><p>Returns a new date, <code>value</code> units later. The date it is called on stays unchanged.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>number</code></td></tr><tr><td><code>unit</code></td><td><code>string</code><br>The unit, such as <code>"day"</code>, <code>"week"</code>, <code>"month"</code> or <code>"year"</code>.</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>subtract</code></td>
- <td><pre><code class="language-application-typescript">subtract(value: number, unit: string): ScriptDayjsInstance</code></pre><p>Returns a new date, <code>value</code> units earlier. The date it is called on stays unchanged.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>number</code></td></tr><tr><td><code>unit</code></td><td><code>string</code><br>The unit, such as <code>"day"</code>, <code>"week"</code>, <code>"month"</code> or <code>"year"</code>.</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">subtract(value: number, unit: string): DayjsInstance</code></pre><p>Returns a new date, <code>value</code> units earlier. The date it is called on stays unchanged.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>number</code></td></tr><tr><td><code>unit</code></td><td><code>string</code><br>The unit, such as <code>"day"</code>, <code>"week"</code>, <code>"month"</code> or <code>"year"</code>.</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>toDate</code></td>
@@ -1078,15 +1078,15 @@ A date as day.js wraps it (subset).
## Types
-### `ScriptDayjs`
+### `Dayjs`
Minimal day.js surface (the real API exposes the full day.js factory).
```typescript
-type ScriptDayjs = (date?: string | number | Date) => ScriptDayjsInstance
+type Dayjs = (date?: string | number | Date) => DayjsInstance
```
-### `ScriptAttribute`
+### `Attribute`
A label or relation attached to a note.
@@ -1099,18 +1099,18 @@ A label or relation attached to a note.
| `isInheritable` | `boolean` <br>Whether the note's descendants inherit the attribute. |
| `isOwned` | `boolean` <br>Not set by Trilium: neither frontend nor backend attributes carry this property, so it reads `undefined`. |
-### `ScriptNoteAndBranch`
+### `NoteAndBranch`
Result of the backend note-creation helpers.
| Property | Description |
| --- | --- |
-| `note` | `ScriptBNote` <br>The new note. For `duplicateSubtree()`, it is the copy of the original note. |
-| `branch` | `ScriptBBranch` <br>The branch that places the new note under its parent. |
+| `note` | `BNote` <br>The new note. For `duplicateSubtree()`, it is the copy of the original note. |
+| `branch` | `BBranch` <br>The branch that places the new note under its parent. |
-### `ScriptSubtreeOpts`
+### `SubtreeOpts`
-Options accepted by the subtree traversal helpers on `ScriptBNote`.
+Options accepted by the subtree traversal helpers on `BNote`.
| Property | Description |
| --- | --- |
@@ -1118,16 +1118,16 @@ Options accepted by the subtree traversal helpers on `ScriptBNote`.
| `includeHidden` <br>_optional_ | `boolean` <br>Whether to descend into the hidden subtree, `_hidden`, which holds Trilium's system notes. Defaults to `false`. |
| `resolveSearch` <br>_optional_ | `boolean` <br>Whether to run each search note and include its results as its children. Defaults to `false`, which includes the search note but none of its results. |
-### `ScriptSubtreeRelationship`
+### `SubtreeRelationship`
-A single parent→child link in a subtree (`ScriptBNote.getSubtree`).
+A single parent→child link in a subtree (`BNote.getSubtree`).
| Property | Description |
| --- | --- |
| `parentNoteId` | `string` <br>The ID of the parent note. With `resolveSearch`, it can be a search note and the child one of its results. |
| `childNoteId` | `string` <br>The ID of the child note. With `includeArchived: false`, it can name an archived note that the list of notes leaves out. |
-### `ScriptNotePathRecord`
+### `NotePathRecord`
One resolved tree path to a note (subset of the client's `NotePathRecord`).
@@ -1139,7 +1139,7 @@ One resolved tree path to a note (subset of the client's `NotePathRecord`).
| `notePath` | `string[]` <br>The note IDs along the path, from `root` to the note itself. |
| `isHidden` | `boolean` <br>Whether the path passes through the hidden subtree, `_hidden`, which holds Trilium's system notes. |
-### `ScriptAttachment`
+### `Attachment`
An attachment as seen by frontend scripts (subset of the client's `FAttachment`).
@@ -1153,9 +1153,9 @@ An attachment as seen by frontend scripts (subset of the client's `FAttachment`)
| `utcDateModified` | `string` <br>The date and time, in UTC, that the attachment was last saved, such as `2026-10-22 12:03:05.123Z`. Replacing the content counts as saving. |
| `contentLength` | `number` <br>The length of the attachment's content. Only some ways of loading an attachment fill it in, such as `getAttachments()`; on the backend, `getAttachmentsByRole()` leaves it `undefined`. |
-### `ScriptSaveAttachmentInput`
+### `SaveAttachmentInput`
-Input accepted by `ScriptBNote.saveAttachment`.
+Input accepted by `BNote.saveAttachment`.
| Property | Description |
| --- | --- |
@@ -1166,9 +1166,9 @@ Input accepted by `ScriptBNote.saveAttachment`.
| `content` <br>_optional_ | `string \| Uint8Array<ArrayBufferLike>` <br>The content of the attachment: a string, or bytes for binary content. Defaults to an empty string. |
| `position` <br>_optional_ | `number` <br>The place of the attachment among the note's attachments, which `getAttachments()` lists by ascending `position`. Used only when a new attachment is created. |
-### `ScriptCloneResponse`
+### `CloneResponse`
-Result of a clone operation (`ScriptBNote.cloneTo`); mirrors `CloneResponse`.
+Result of a clone operation (`BNote.cloneTo`); mirrors `CloneResponse`.
| Property | Description |
| --- | --- |
diff --git a/docs/User Guide/User Guide/Scripting/Script API/Electron API.md b/docs/User Guide/User Guide/Scripting/Script API/Electron API.md
index 5c1e32a430..123566de05 100644
--- a/docs/User Guide/User Guide/Scripting/Script API/Electron API.md
+++ b/docs/User Guide/User Guide/Scripting/Script API/Electron API.md
@@ -3,7 +3,7 @@ The Electron API is the bridge between Trilium's interface and Electron's main p
It is not part of the `api` global of script notes, but frontend scripts running in the desktop application can call it directly. It is `undefined` in the browser and in the standalone build, so guard calls with `if (window.electronApi)`.
-## `ElectronApi`
+## `Api`
The complete surface exposed to the renderer as `window.electronApi` via `contextBridge`. The renderer must access Electron-only functionality through this object — direct `require("electron")` and `@electron/remote` are unavailable because `nodeIntegration` is disabled and `contextIsolation` is enabled.
@@ -11,25 +11,25 @@ The runtime value lives in `apps/desktop/src/preload.ts`; this interface is the
| Property | Description |
| --- | --- |
-| `window` | `ElectronWindowApi` <br>Window chrome, zoom, theme, lifecycle, and main → renderer events. |
-| `clipboard` | `ElectronClipboardApi` <br>System clipboard access beyond what the standard Web Clipboard API offers. |
-| `shell` | `ElectronShellApi` <br>Shell integration — opening URLs, files, and downloads with OS handlers. |
-| `contextMenu` | `ElectronContextMenuApi` <br>Native context-menu plumbing for right-click events on web contents. |
-| `spellcheck` | `ElectronSpellcheckApi` <br>Chromium spell checker controls (dictionary, language list). |
-| `systemIntegration` | `ElectronSystemIntegrationApi` <br>OS integration — system tray and autostart / launch-on-login. |
-| `printing` | `ElectronPrintingApi` <br>Printing and PDF export pipeline. |
-| `navigation` | `ElectronNavigationApi` <br>Read/write access to Chromium's back/forward navigation history. |
-| `ws` | `ElectronWsApi` <br>In-process bridge that replaces the renderer↔server WebSocket. |
-| `security` | `ElectronSecurityApi` <br>Security settings (backend scripting, SQL console) stored outside the DB. |
-| `backupPassphrase` | `ElectronBackupPassphraseApi` <br>Write-only access to the backup passphrase, kept in the OS keyring. |
-| `onenote` | `ElectronOneNoteApi` <br>OneNote importer sign-in via a loopback OAuth redirect (desktop only). |
-| `nativeExport` | `ElectronNativeExportApi` <br>Desktop-native subtree export that streams a `.zip` straight to a file. |
-| `nativeImport` | `ElectronNativeImportApi` <br>Desktop-native large-`.zip` import that reads the user's file in place via a capability token. |
-| `dialog` | `ElectronDialogApi` <br>Native OS pickers that hand the renderer a location the user chose themselves. |
-| `restore` | `ElectronRestoreApi` <br>Choosing a backup to restore during setup, read where it lies rather than uploaded. |
-| `transcription` | `ElectronTranscriptionApi` <br>Meeting transcription: starting and stopping a recording, and following its state. |
-
-## `ElectronWindowApi`
+| `window` | `WindowApi` <br>Window chrome, zoom, theme, lifecycle, and main → renderer events. |
+| `clipboard` | `ClipboardApi` <br>System clipboard access beyond what the standard Web Clipboard API offers. |
+| `shell` | `ShellApi` <br>Shell integration — opening URLs, files, and downloads with OS handlers. |
+| `contextMenu` | `ContextMenuApi` <br>Native context-menu plumbing for right-click events on web contents. |
+| `spellcheck` | `SpellcheckApi` <br>Chromium spell checker controls (dictionary, language list). |
+| `systemIntegration` | `SystemIntegrationApi` <br>OS integration — system tray and autostart / launch-on-login. |
+| `printing` | `PrintingApi` <br>Printing and PDF export pipeline. |
+| `navigation` | `NavigationApi` <br>Read/write access to Chromium's back/forward navigation history. |
+| `ws` | `WsApi` <br>In-process bridge that replaces the renderer↔server WebSocket. |
+| `security` | `SecurityApi` <br>Security settings (backend scripting, SQL console) stored outside the DB. |
+| `backupPassphrase` | `BackupPassphraseApi` <br>Write-only access to the backup passphrase, kept in the OS keyring. |
+| `onenote` | `OneNoteApi` <br>OneNote importer sign-in via a loopback OAuth redirect (desktop only). |
+| `nativeExport` | `NativeExportApi` <br>Desktop-native subtree export that streams a `.zip` straight to a file. |
+| `nativeImport` | `NativeImportApi` <br>Desktop-native large-`.zip` import that reads the user's file in place via a capability token. |
+| `dialog` | `DialogApi` <br>Native OS pickers that hand the renderer a location the user chose themselves. |
+| `restore` | `RestoreApi` <br>Choosing a backup to restore during setup, read where it lies rather than uploaded. |
+| `transcription` | `TranscriptionApi` <br>Meeting transcription: starting and stopping a recording, and following its state. |
+
+## `WindowApi`
Window-level controls: zoom, theme, title bar, full screen, lifecycle, and a handful of main → renderer event subscriptions.
@@ -160,7 +160,7 @@ Window-level controls: zoom, theme, title bar, full screen, lifecycle, and a han
</tbody>
</table>
-## `ElectronClipboardApi`
+## `ClipboardApi`
Renderer access to the system clipboard for cases the standard Web API can't cover.
@@ -187,7 +187,7 @@ Renderer access to the system clipboard for cases the standard Web API can't cov
</tbody>
</table>
-## `ElectronShellApi`
+## `ShellApi`
Wrappers around Electron's `shell` module for interacting with the OS (default browser, default file handler, downloads, etc.).
@@ -228,7 +228,7 @@ Every method here is validated in the main process before dispatch — see `apps
</tbody>
</table>
-## `ElectronContextMenuApi`
+## `ContextMenuApi`
Bridge for the native context menu shown over web contents.
@@ -242,7 +242,7 @@ Bridge for the native context menu shown over web contents.
<tbody>
<tr>
<td><code>onContextMenu</code></td>
- <td><pre><code class="language-application-typescript">onContextMenu(callback: (params: ElectronContextMenuParams) =&gt; void): void</code></pre><p>Subscribes to right-click events forwarded from the main process.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(params: ElectronContextMenuParams) =&gt; void</code><br>Receives where the user clicked and what is under the cursor.</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">onContextMenu(callback: (params: ContextMenuParams) =&gt; void): void</code></pre><p>Subscribes to right-click events forwarded from the main process.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>(params: ContextMenuParams) =&gt; void</code><br>Receives where the user clicked and what is under the cursor.</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>webContentsAction</code></td>
@@ -251,7 +251,7 @@ Bridge for the native context menu shown over web contents.
</tbody>
</table>
-## `ElectronSpellcheckApi`
+## `SpellcheckApi`
Renderer-side access to Chromium's built-in spell checker.
@@ -282,7 +282,7 @@ Renderer-side access to Chromium's built-in spell checker.
</tbody>
</table>
-## `ElectronSystemIntegrationApi`
+## `SystemIntegrationApi`
OS integration controls — system tray and autostart / launch-on-login.
@@ -305,7 +305,7 @@ OS integration controls — system tray and autostart / launch-on-login.
</tbody>
</table>
-## `ElectronPrintingApi`
+## `PrintingApi`
Printing and PDF export flow. Trilium drives Electron's printing pipeline through a small state machine that the main process owns, with progress and results pushed back to the renderer via IPC events.
@@ -360,7 +360,7 @@ Printing and PDF export flow. Trilium drives Electron's printing pipeline throug
</tbody>
</table>
-## `ElectronNavigationApi`
+## `NavigationApi`
Accessors for the underlying Chromium navigation history of the current web contents (back/forward stack), exposed so the renderer can mirror it in custom UI such as the breadcrumb / tab back button.
@@ -415,7 +415,7 @@ Accessors for the underlying Chromium navigation history of the current web cont
</tbody>
</table>
-## `ElectronWsApi`
+## `WsApi`
In-process replacement for the renderer↔server WebSocket. Backed by Chromium IPC instead of a TCP socket — no port is bound and no auth check is needed because the channel is only reachable from the renderer the BrowserWindow owns. Wire format is whatever the server's `MessagingProvider` accepts (currently `WebSocketMessage` / log-error / log-info / ping).
@@ -438,7 +438,7 @@ In-process replacement for the renderer↔server WebSocket. Backed by Chromium I
</tbody>
</table>
-## `ElectronSecurityApi`
+## `SecurityApi`
Security settings that live outside the database (in `data_dir/security.json`) to prevent malicious scripts from modifying them. Changes require a native OS confirmation dialog and an app restart to take effect.
@@ -465,7 +465,7 @@ Security settings that live outside the database (in `data_dir/security.json`) t
</tbody>
</table>
-## `ElectronBackupPassphraseApi`
+## `BackupPassphraseApi`
The backup passphrase, kept encrypted by the OS keyring in a file outside the database (the database is what ends up inside the backup, so a passphrase stored there would ride along inside the very container it protects).
@@ -496,7 +496,7 @@ Both changes are also gated on a native OS confirmation, which a script can requ
</tbody>
</table>
-## `ElectronOneNoteApi`
+## `OneNoteApi`
Desktop-only OneNote importer sign-in, driven from the main process via a loopback OAuth redirect.
@@ -515,7 +515,7 @@ Desktop-only OneNote importer sign-in, driven from the main process via a loopba
</tbody>
</table>
-## `ElectronNativeExportApi`
+## `NativeExportApi`
Desktop-native subtree export that streams a `.zip` straight to a file.
@@ -534,7 +534,7 @@ Desktop-native subtree export that streams a `.zip` straight to a file.
</tbody>
</table>
-## `ElectronNativeImportApi`
+## `NativeImportApi`
Desktop-native import that reads the user's file **in place** (bounded memory, no temp copy) — the whole point being multi-GB `.zip` archives, though any importable file is accepted. The renderer never handles a filesystem path: `pickFiles` runs the OS dialog in the main process and returns opaque capability tokens, which `importFromToken` redeems. A script can't forge a token or pass a path, so it can never read an arbitrary file.
@@ -561,7 +561,7 @@ Desktop-native import that reads the user's file **in place** (bounded memory, n
</tbody>
</table>
-## `ElectronDialogApi`
+## `DialogApi`
Native OS pickers that hand the renderer a location the user chose themselves.
@@ -584,7 +584,7 @@ Native OS pickers that hand the renderer a location the user chose themselves.
</tbody>
</table>
-## `ElectronRestoreApi`
+## `RestoreApi`
Choosing a backup to restore from the desktop, where the file is already on the same disk as the database it is going to replace and has no business being uploaded to reach it.
@@ -605,7 +605,7 @@ Only usable during setup: what it puts forward is restored by the ordinary `POST
</tbody>
</table>
-## `ElectronTranscriptionApi`
+## `TranscriptionApi`
Meeting transcription, recorded and transcribed on this computer by the main process. The renderer only starts and stops it; the audio never passes through the renderer.
@@ -654,7 +654,7 @@ Meeting transcription, recorded and transcribed on this computer by the main pro
## Types
-### `ElectronContextMenuParams`
+### `ContextMenuParams`
Parameters delivered by the main process to the renderer when the user opens the system context menu (right-click) somewhere inside a web view.
@@ -694,7 +694,7 @@ What became of a request to change the stored backup passphrase.
### `OneNoteLoginResult`
-Outcome of a `ElectronOneNoteApi.login` attempt.
+Outcome of a `OneNoteApi.login` attempt.
| Property | Description |
| --- | --- |
@@ -704,7 +704,7 @@ Outcome of a `ElectronOneNoteApi.login` attempt.
### `NativeExportResult`
-Outcome of a `ElectronNativeExportApi.exportSubtreeToFile` request.
+Outcome of a `NativeExportApi.exportSubtreeToFile` request.
| Property | Description |
| --- | --- |
@@ -714,7 +714,7 @@ Outcome of a `ElectronNativeExportApi.exportSubtreeToFile` request.
### `NativeImportPickResult`
-Outcome of `ElectronNativeImportApi.pickFiles`: capability tokens, never paths.
+Outcome of `NativeImportApi.pickFiles`: capability tokens, never paths.
| Property | Description |
| --- | --- |
@@ -737,7 +737,7 @@ Import flags forwarded to the native importer (mirrors the HTTP route's options;
### `NativeImportResult`
-Outcome of `ElectronNativeImportApi.importFromToken`.
+Outcome of `NativeImportApi.importFromToken`.
| Property | Description |
| --- | --- |
@@ -747,7 +747,7 @@ Outcome of `ElectronNativeImportApi.importFromToken`.
### `NativeDirectoryPickResult`
-Outcome of `ElectronDialogApi.pickDirectory`.
+Outcome of `DialogApi.pickDirectory`.
| Property | Description |
| --- | --- |
@@ -756,7 +756,7 @@ Outcome of `ElectronDialogApi.pickDirectory`.
### `NativeBackupPickResult`
-Outcome of `ElectronRestoreApi.pickBackup`: what the chosen backup is, never where it is.
+Outcome of `RestoreApi.pickBackup`: what the chosen backup is, never where it is.
The file itself stays with the main process, which holds it as the one waiting to be restored, so the renderer is given only what the screen has to show and decide with.
@@ -769,7 +769,7 @@ The file itself stays with the main process, which holds it as the one waiting t
### `TranscriptionState`
-What `ElectronTranscriptionApi` reports to every window.
+What `TranscriptionApi` reports to every window.
| Property | Description |
| --- | --- |
diff --git a/docs/User Guide/User Guide/Scripting/Script API/Frontend API.md b/docs/User Guide/User Guide/Scripting/Script API/Frontend API.md
index dc00b5c666..44bb9088a3 100644
--- a/docs/User Guide/User Guide/Scripting/Script API/Frontend API.md
+++ b/docs/User Guide/User Guide/Scripting/Script API/Frontend API.md
@@ -17,11 +17,11 @@ The `api` global available inside **frontend** script notes (`application/javasc
</tr>
<tr>
<td><code>startNote</code></td>
- <td><p><code>ScriptFNote</code><br>Note where the script execution started — the entry point of the current script bundle (in C terms, the file containing <code>main()</code>). When a script is spread across multiple code notes (descendant code notes loaded as modules via <code>require()</code>), every note in the bundle shares the same <code>startNote</code>, while <code>currentNote</code> differs per note. Messages from <code>api.log()</code> are grouped under this note.</p></td>
+ <td><p><code>FNote</code><br>Note where the script execution started — the entry point of the current script bundle (in C terms, the file containing <code>main()</code>). When a script is spread across multiple code notes (descendant code notes loaded as modules via <code>require()</code>), every note in the bundle shares the same <code>startNote</code>, while <code>currentNote</code> differs per note. Messages from <code>api.log()</code> are grouped under this note.</p></td>
</tr>
<tr>
<td><code>currentNote</code></td>
- <td><p><code>ScriptFNote</code><br>Note containing the source code that is currently executing (in C terms, <code>__FILE__</code>). Equal to <code>startNote</code> unless execution has moved into a descendant module note loaded via <code>require()</code>. Don't confuse this with the note open in the UI — use <code>api.getActiveContextNote()</code> for that.</p></td>
+ <td><p><code>FNote</code><br>Note containing the source code that is currently executing (in C terms, <code>__FILE__</code>). Equal to <code>startNote</code> unless execution has moved into a descendant module note loaded via <code>require()</code>. Don't confuse this with the note open in the UI — use <code>api.getActiveContextNote()</code> for that.</p></td>
</tr>
<tr>
<td><code>originEntity</code></td>
@@ -29,7 +29,7 @@ The `api` global available inside **frontend** script notes (`application/javasc
</tr>
<tr>
<td><code>dayjs</code></td>
- <td><p><code>ScriptDayjs</code><br>day.js library for date manipulation. See <code>https://day.js.org</code> for documentation</p></td>
+ <td><p><code>Dayjs</code><br>day.js library for date manipulation. See <code>https://day.js.org</code> for documentation</p></td>
</tr>
<tr>
<td><code>RightPanelWidget</code></td>
@@ -77,19 +77,19 @@ The `api` global available inside **frontend** script notes (`application/javasc
</tr>
<tr>
<td><code>searchForNotes</code></td>
- <td><pre><code class="language-application-typescript">searchForNotes(searchString: string): Promise&lt;ScriptFNote[]&gt;</code></pre><p>This is a powerful search method - you can search by attributes and their values, e.g.: "#dateModified =* MONTH AND #log". See full documentation for all options at: <a href="https://triliumnext.github.io/Docs/Wiki/search.html">https://triliumnext.github.io/Docs/Wiki/search.html</a></p></td>
+ <td><pre><code class="language-application-typescript">searchForNotes(searchString: string): Promise&lt;FNote[]&gt;</code></pre><p>This is a powerful search method - you can search by attributes and their values, e.g.: "#dateModified =* MONTH AND #log". See full documentation for all options at: <a href="https://triliumnext.github.io/Docs/Wiki/search.html">https://triliumnext.github.io/Docs/Wiki/search.html</a></p></td>
</tr>
<tr>
<td><code>searchForNote</code></td>
- <td><pre><code class="language-application-typescript">searchForNote(searchString: string): Promise&lt;ScriptFNote | null&gt;</code></pre><p>This is a powerful search method - you can search by attributes and their values, e.g.: "#dateModified =* MONTH AND #log". See full documentation for all options at: <a href="https://triliumnext.github.io/Docs/Wiki/search.html">https://triliumnext.github.io/Docs/Wiki/search.html</a></p></td>
+ <td><pre><code class="language-application-typescript">searchForNote(searchString: string): Promise&lt;FNote | null&gt;</code></pre><p>This is a powerful search method - you can search by attributes and their values, e.g.: "#dateModified =* MONTH AND #log". See full documentation for all options at: <a href="https://triliumnext.github.io/Docs/Wiki/search.html">https://triliumnext.github.io/Docs/Wiki/search.html</a></p></td>
</tr>
<tr>
<td><code>getNote</code></td>
- <td><pre><code class="language-application-typescript">getNote(noteId: string): Promise&lt;ScriptFNote | null&gt;</code></pre><p>Returns note by given noteId. If note is missing from the cache, it's loaded.</p></td>
+ <td><pre><code class="language-application-typescript">getNote(noteId: string): Promise&lt;FNote | null&gt;</code></pre><p>Returns note by given noteId. If note is missing from the cache, it's loaded.</p></td>
</tr>
<tr>
<td><code>getNotes</code></td>
- <td><pre><code class="language-application-typescript">getNotes(noteIds: string[], silentNotFoundError?: boolean): Promise&lt;ScriptFNote[]&gt;</code></pre><p>Returns list of notes. If note is missing from the cache, it's loaded.</p><p>This is often used to bulk-fill the cache with notes which would have to be picked one by one otherwise (by e.g. createLink())</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>noteIds</code></td><td><code>string[]</code></td></tr><tr><td><code>silentNotFoundError</code><br><em>optional</em></td><td><code>boolean</code><br>don't report error if the note is not found</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getNotes(noteIds: string[], silentNotFoundError?: boolean): Promise&lt;FNote[]&gt;</code></pre><p>Returns list of notes. If note is missing from the cache, it's loaded.</p><p>This is often used to bulk-fill the cache with notes which would have to be picked one by one otherwise (by e.g. createLink())</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>noteIds</code></td><td><code>string[]</code></td></tr><tr><td><code>silentNotFoundError</code><br><em>optional</em></td><td><code>boolean</code><br>don't report error if the note is not found</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>reloadNotes</code></td>
@@ -97,7 +97,7 @@ The `api` global available inside **frontend** script notes (`application/javasc
</tr>
<tr>
<td><code>createNote</code></td>
- <td><pre><code class="language-application-typescript">createNote(parentNotePath: string, opts?: ScriptCreateNoteOpts): Promise&lt;{ note: ScriptFNote | null; branch: ScriptFBranch | undefined }&gt;</code></pre><p>Creates a new note as a child of the given parent, entirely on the frontend — no backend scripting required (unlike <code>api.runOnBackend(() =&gt; api.createTextNote(...))</code>). By default the new note is activated in the current tab with its title focused for editing; pass <code>{ activate: false }</code> to create it silently.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>parentNotePath</code></td><td><code>string</code><br>note path (or noteId) of the parent under which to create the note</td></tr><tr><td><code>opts</code><br><em>optional</em></td><td><code>ScriptCreateNoteOpts</code><br>creation options — e.g. <code>{ title, content, type, mime, activate }</code></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;{ note: ScriptFNote | null; branch: ScriptFBranch | undefined }&gt;</code>: the created note and its branch, resolved from the frontend cache</p></td>
+ <td><pre><code class="language-application-typescript">createNote(parentNotePath: string, opts?: CreateNoteOpts): Promise&lt;{ note: FNote | null; branch: FBranch | undefined }&gt;</code></pre><p>Creates a new note as a child of the given parent, entirely on the frontend — no backend scripting required (unlike <code>api.runOnBackend(() =&gt; api.createTextNote(...))</code>). By default the new note is activated in the current tab with its title focused for editing; pass <code>{ activate: false }</code> to create it silently.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>parentNotePath</code></td><td><code>string</code><br>note path (or noteId) of the parent under which to create the note</td></tr><tr><td><code>opts</code><br><em>optional</em></td><td><code>CreateNoteOpts</code><br>creation options — e.g. <code>{ title, content, type, mime, activate }</code></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise&lt;{ note: FNote | null; branch: FBranch | undefined }&gt;</code>: the created note and its branch, resolved from the frontend cache</p></td>
</tr>
<tr>
<td><code>getInstanceName</code></td>
@@ -109,23 +109,23 @@ The `api` global available inside **frontend** script notes (`application/javasc
</tr>
<tr>
<td><code>getActiveContextNote</code></td>
- <td><pre><code class="language-application-typescript">getActiveContextNote(): ScriptFNote</code></pre><p><strong>Returns</strong> <code>ScriptFNote</code>: active note (loaded into center pane)</p></td>
+ <td><pre><code class="language-application-typescript">getActiveContextNote(): FNote</code></pre><p><strong>Returns</strong> <code>FNote</code>: active note (loaded into center pane)</p></td>
</tr>
<tr>
<td><code>getActiveContext</code></td>
- <td><pre><code class="language-application-typescript">getActiveContext(): ScriptNoteContext</code></pre><p>Obtains the currently active/focused split in the current tab.</p><p>Note that this method does not return the note context of the "Quick edit" panel, it will return the note context behind it.</p></td>
+ <td><pre><code class="language-application-typescript">getActiveContext(): NoteContext</code></pre><p>Obtains the currently active/focused split in the current tab.</p><p>Note that this method does not return the note context of the "Quick edit" panel, it will return the note context behind it.</p></td>
</tr>
<tr>
<td><code>getActiveMainContext</code></td>
- <td><pre><code class="language-application-typescript">getActiveMainContext(): ScriptNoteContext</code></pre><p>Obtains the main context of the current tab. This is the left-most split.</p><p>Note that this method does not return the note context of the "Quick edit" panel, it will return the note context behind it.</p></td>
+ <td><pre><code class="language-application-typescript">getActiveMainContext(): NoteContext</code></pre><p>Obtains the main context of the current tab. This is the left-most split.</p><p>Note that this method does not return the note context of the "Quick edit" panel, it will return the note context behind it.</p></td>
</tr>
<tr>
<td><code>getNoteContexts</code></td>
- <td><pre><code class="language-application-typescript">getNoteContexts(): ScriptNoteContext[]</code></pre><p><strong>Returns</strong> <code>ScriptNoteContext[]</code>: returns all note contexts (splits) in all tabs</p></td>
+ <td><pre><code class="language-application-typescript">getNoteContexts(): NoteContext[]</code></pre><p><strong>Returns</strong> <code>NoteContext[]</code>: returns all note contexts (splits) in all tabs</p></td>
</tr>
<tr>
<td><code>getMainNoteContexts</code></td>
- <td><pre><code class="language-application-typescript">getMainNoteContexts(): ScriptNoteContext[]</code></pre><p><strong>Returns</strong> <code>ScriptNoteContext[]</code>: returns all main contexts representing tabs</p></td>
+ <td><pre><code class="language-application-typescript">getMainNoteContexts(): NoteContext[]</code></pre><p><strong>Returns</strong> <code>NoteContext[]</code>: returns all main contexts representing tabs</p></td>
</tr>
<tr>
<td><code>getActiveContextTextEditor</code></td>
@@ -201,31 +201,31 @@ The `api` global available inside **frontend** script notes (`application/javasc
</tr>
<tr>
<td><code>getTodayNote</code></td>
- <td><pre><code class="language-application-typescript">getTodayNote(): Promise&lt;ScriptFNote&gt;</code></pre><p>Returns date-note for today. If it doesn't exist, it is automatically created.</p></td>
+ <td><pre><code class="language-application-typescript">getTodayNote(): Promise&lt;FNote&gt;</code></pre><p>Returns date-note for today. If it doesn't exist, it is automatically created.</p></td>
</tr>
<tr>
<td><code>getDayNote</code></td>
- <td><pre><code class="language-application-typescript">getDayNote(date: string): Promise&lt;ScriptFNote&gt;</code></pre><p>Returns day note for a given date. If it doesn't exist, it is automatically created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>e.g. "2019-04-29"</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getDayNote(date: string): Promise&lt;FNote&gt;</code></pre><p>Returns day note for a given date. If it doesn't exist, it is automatically created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>e.g. "2019-04-29"</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getWeekFirstDayNote</code></td>
- <td><pre><code class="language-application-typescript">getWeekFirstDayNote(date: string): Promise&lt;ScriptFNote&gt;</code></pre><p>Returns day note for the first date of the week of the given date. If it doesn't exist, it is automatically created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>e.g. "2019-04-29"</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getWeekFirstDayNote(date: string): Promise&lt;FNote&gt;</code></pre><p>Returns day note for the first date of the week of the given date. If it doesn't exist, it is automatically created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>e.g. "2019-04-29"</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getWeekNote</code></td>
- <td><pre><code class="language-application-typescript">getWeekNote(date: string): Promise&lt;ScriptFNote&gt;</code></pre><p>Returns week note for given date. If such a note doesn't exist, it is automatically created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM-DD format</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getWeekNote(date: string): Promise&lt;FNote&gt;</code></pre><p>Returns week note for given date. If such a note doesn't exist, it is automatically created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM-DD format</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getMonthNote</code></td>
- <td><pre><code class="language-application-typescript">getMonthNote(month: string): Promise&lt;ScriptFNote&gt;</code></pre><p>Returns month-note. If it doesn't exist, it is automatically created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>month</code></td><td><code>string</code><br>e.g. "2019-04"</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getMonthNote(month: string): Promise&lt;FNote&gt;</code></pre><p>Returns month-note. If it doesn't exist, it is automatically created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>month</code></td><td><code>string</code><br>e.g. "2019-04"</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getQuarterNote</code></td>
- <td><pre><code class="language-application-typescript">getQuarterNote(date: string): Promise&lt;ScriptFNote&gt;</code></pre><p>Returns quarter note for given date. If such a note doesn't exist, it is automatically created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM format</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getQuarterNote(date: string): Promise&lt;FNote&gt;</code></pre><p>Returns quarter note for given date. If such a note doesn't exist, it is automatically created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>date</code></td><td><code>string</code><br>in YYYY-MM format</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getYearNote</code></td>
- <td><pre><code class="language-application-typescript">getYearNote(year: string): Promise&lt;ScriptFNote&gt;</code></pre><p>Returns year-note. If it doesn't exist, it is automatically created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>year</code></td><td><code>string</code><br>e.g. "2019"</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getYearNote(year: string): Promise&lt;FNote&gt;</code></pre><p>Returns year-note. If it doesn't exist, it is automatically created.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>year</code></td><td><code>string</code><br>e.g. "2019"</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>setHoistedNoteId</code></td>
@@ -290,7 +290,7 @@ The `api` global available inside **frontend** script notes (`application/javasc
</tbody>
</table>
-## `ScriptFNote`
+## `FNote`
A note as seen by frontend scripts (subset of the client's `FNote`).
@@ -348,11 +348,11 @@ A note as seen by frontend scripts (subset of the client's `FNote`).
</tr>
<tr>
<td><code>getParentNotes</code></td>
- <td><pre><code class="language-application-typescript">getParentNotes(): ScriptFNote[]</code></pre><p>Returns the parent notes that the client has already loaded. A parent that is not loaded is skipped, and a search note that shows this note in its results counts as a parent.</p></td>
+ <td><pre><code class="language-application-typescript">getParentNotes(): FNote[]</code></pre><p>Returns the parent notes that the client has already loaded. A parent that is not loaded is skipped, and a search note that shows this note in its results counts as a parent.</p></td>
</tr>
<tr>
<td><code>getChildNotes</code></td>
- <td><pre><code class="language-application-typescript">getChildNotes(): Promise&lt;ScriptFNote[]&gt;</code></pre><p>Loads any missing child notes from the server, then returns all child notes in tree order. Archived children are included.</p></td>
+ <td><pre><code class="language-application-typescript">getChildNotes(): Promise&lt;FNote[]&gt;</code></pre><p>Loads any missing child notes from the server, then returns all child notes in tree order. Archived children are included.</p></td>
</tr>
<tr>
<td><code>getParentNoteIds</code></td>
@@ -368,7 +368,7 @@ A note as seen by frontend scripts (subset of the client's `FNote`).
</tr>
<tr>
<td><code>getSubtreeNotes</code></td>
- <td><pre><code class="language-application-typescript">getSubtreeNotes(): Promise&lt;ScriptFNote[]&gt;</code></pre><p>Returns all descendants of the note, loading missing ones from the server one level at a time. An archived note and everything below it are left out, and the note itself is not included.</p></td>
+ <td><pre><code class="language-application-typescript">getSubtreeNotes(): Promise&lt;FNote[]&gt;</code></pre><p>Returns all descendants of the note, loading missing ones from the server one level at a time. An archived note and everything below it are left out, and the note itself is not included.</p></td>
</tr>
<tr>
<td><code>getSubtreeNoteIds</code></td>
@@ -396,19 +396,19 @@ A note as seen by frontend scripts (subset of the client's `FNote`).
</tr>
<tr>
<td><code>getParentBranches</code></td>
- <td><pre><code class="language-application-typescript">getParentBranches(): ScriptFBranch[]</code></pre><p>Returns the branches that place this note under each of its parents. A branch the client has not loaded is skipped.</p></td>
+ <td><pre><code class="language-application-typescript">getParentBranches(): FBranch[]</code></pre><p>Returns the branches that place this note under each of its parents. A branch the client has not loaded is skipped.</p></td>
</tr>
<tr>
<td><code>getChildBranches</code></td>
- <td><pre><code class="language-application-typescript">getChildBranches(): ScriptFBranch[]</code></pre><p>Returns the branches to this note's children, in tree order. A branch the client has not loaded is skipped.</p></td>
+ <td><pre><code class="language-application-typescript">getChildBranches(): FBranch[]</code></pre><p>Returns the branches to this note's children, in tree order. A branch the client has not loaded is skipped.</p></td>
</tr>
<tr>
<td><code>getBranches</code></td>
- <td><pre><code class="language-application-typescript">getBranches(): ScriptFBranch[]</code></pre><p>Returns the branches that place the note under its parents.</p><aside class="admonition warning"><p>Deprecated. Use <code>getParentBranches()</code> instead.</p></aside></td>
+ <td><pre><code class="language-application-typescript">getBranches(): FBranch[]</code></pre><p>Returns the branches that place the note under its parents.</p><aside class="admonition warning"><p>Deprecated. Use <code>getParentBranches()</code> instead.</p></aside></td>
</tr>
<tr>
<td><code>getFilteredChildBranches</code></td>
- <td><pre><code class="language-application-typescript">getFilteredChildBranches(): ScriptFBranch[]</code></pre><p>Returns the same branches as <code>getChildBranches()</code>. Despite the name, archived children are not filtered out.</p></td>
+ <td><pre><code class="language-application-typescript">getFilteredChildBranches(): FBranch[]</code></pre><p>Returns the same branches as <code>getChildBranches()</code>. Despite the name, archived children are not filtered out.</p></td>
</tr>
<tr>
<td><code>getAllNotePaths</code></td>
@@ -424,23 +424,23 @@ A note as seen by frontend scripts (subset of the client's `FNote`).
</tr>
<tr>
<td><code>getSortedNotePathRecords</code></td>
- <td><pre><code class="language-application-typescript">getSortedNotePathRecords(hoistedNoteId?: string, activeNotePath?: string | null): ScriptNotePathRecord[]</code></pre><p>Returns every path from the root to this note, best first. Paths inside the hoisted note come first, then paths that do not pass through an archived note or the hidden subtree, then paths that share the most with <code>activeNotePath</code>, then shorter paths. Paths through search notes are left out, and only parents the client has loaded are followed.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>hoistedNoteId</code><br><em>optional</em></td><td><code>string</code><br>the ID of the hoisted note. Defaults to <code>root</code>.</td></tr><tr><td><code>activeNotePath</code><br><em>optional</em></td><td><code>string | null</code><br>a note path such as <code>root/abc123/def456</code>, used to prefer paths close to it.</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getSortedNotePathRecords(hoistedNoteId?: string, activeNotePath?: string | null): NotePathRecord[]</code></pre><p>Returns every path from the root to this note, best first. Paths inside the hoisted note come first, then paths that do not pass through an archived note or the hidden subtree, then paths that share the most with <code>activeNotePath</code>, then shorter paths. Paths through search notes are left out, and only parents the client has loaded are followed.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>hoistedNoteId</code><br><em>optional</em></td><td><code>string</code><br>the ID of the hoisted note. Defaults to <code>root</code>.</td></tr><tr><td><code>activeNotePath</code><br><em>optional</em></td><td><code>string | null</code><br>a note path such as <code>root/abc123/def456</code>, used to prefer paths close to it.</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getAttributes</code></td>
- <td><pre><code class="language-application-typescript">getAttributes(type?: string, name?: string): ScriptAttribute[]</code></pre><p>Returns the note's attributes, including inherited ones, optionally only those of the given type and name. The note's own attributes come first, then the ones inherited from its parents, then the ones from its templates.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code><br><em>optional</em></td><td><code>string</code><br><code>label</code> or <code>relation</code>; any other value throws an error.</td></tr><tr><td><code>name</code><br><em>optional</em></td><td><code>string</code><br>The attribute name, without the <code>#</code> or <code>~</code> prefix.</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getAttributes(type?: string, name?: string): Attribute[]</code></pre><p>Returns the note's attributes, including inherited ones, optionally only those of the given type and name. The note's own attributes come first, then the ones inherited from its parents, then the ones from its templates.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code><br><em>optional</em></td><td><code>string</code><br><code>label</code> or <code>relation</code>; any other value throws an error.</td></tr><tr><td><code>name</code><br><em>optional</em></td><td><code>string</code><br>The attribute name, without the <code>#</code> or <code>~</code> prefix.</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getOwnedAttributes</code></td>
- <td><pre><code class="language-application-typescript">getOwnedAttributes(type?: string, name?: string): ScriptAttribute[]</code></pre><p>Returns the note's own attributes, without inherited ones, optionally only those of the given type and name.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code><br><em>optional</em></td><td><code>string</code><br><code>label</code> or <code>relation</code>; any other value throws an error.</td></tr><tr><td><code>name</code><br><em>optional</em></td><td><code>string</code><br>The attribute name, without the <code>#</code> or <code>~</code> prefix.</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getOwnedAttributes(type?: string, name?: string): Attribute[]</code></pre><p>Returns the note's own attributes, without inherited ones, optionally only those of the given type and name.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code><br><em>optional</em></td><td><code>string</code><br><code>label</code> or <code>relation</code>; any other value throws an error.</td></tr><tr><td><code>name</code><br><em>optional</em></td><td><code>string</code><br>The attribute name, without the <code>#</code> or <code>~</code> prefix.</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getAttribute</code></td>
- <td><pre><code class="language-application-typescript">getAttribute(type: string, name: string): ScriptAttribute | null</code></pre><p>Returns the first attribute of the given type and name, including inherited ones, or <code>undefined</code> if the note has none.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getAttribute(type: string, name: string): Attribute | null</code></pre><p>Returns the first attribute of the given type and name, including inherited ones, or <code>undefined</code> if the note has none.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getOwnedAttribute</code></td>
- <td><pre><code class="language-application-typescript">getOwnedAttribute(type: string, name: string): ScriptAttribute | null</code></pre><p>Returns the first of the note's own attributes with the given type and name, or <code>undefined</code> if the note has none.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">getOwnedAttribute(type: string, name: string): Attribute | null</code></pre><p>Returns the first of the note's own attributes with the given type and name, or <code>undefined</code> if the note has none.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>type</code></td><td><code>string</code><br><code>label</code> or <code>relation</code>.</td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>getAttributeValue</code></td>
@@ -460,27 +460,27 @@ A note as seen by frontend scripts (subset of the client's `FNote`).
</tr>
<tr>
<td><code>getAttributeDefinitions</code></td>
- <td><pre><code class="language-application-typescript">getAttributeDefinitions(): ScriptAttribute[]</code></pre><p>Returns the attribute definitions that apply to the note, at most one per defined name. When the note gets a definition from several places, such as its own, an ancestor's and a template's, the nearest one wins, in the order <code>getAttributes()</code> lists them.</p></td>
+ <td><pre><code class="language-application-typescript">getAttributeDefinitions(): Attribute[]</code></pre><p>Returns the attribute definitions that apply to the note, at most one per defined name. When the note gets a definition from several places, such as its own, an ancestor's and a template's, the nearest one wins, in the order <code>getAttributes()</code> lists them.</p></td>
</tr>
<tr>
<td><code>getPromotedDefinitionAttributes</code></td>
- <td><pre><code class="language-application-typescript">getPromotedDefinitionAttributes(): ScriptAttribute[]</code></pre><p>Returns the attribute definitions that are marked as promoted, at most one per name, grouped by the note that owns them and ordered by position. Returns an empty array if the note has a truthy <code>hidePromotedAttributes</code> label.</p></td>
+ <td><pre><code class="language-application-typescript">getPromotedDefinitionAttributes(): Attribute[]</code></pre><p>Returns the attribute definitions that are marked as promoted, at most one per name, grouped by the note that owns them and ordered by position. Returns an empty array if the note has a truthy <code>hidePromotedAttributes</code> label.</p></td>
</tr>
<tr>
<td><code>getLabels</code></td>
- <td><pre><code class="language-application-typescript">getLabels(name?: string): ScriptAttribute[]</code></pre><p>Returns the note's labels, including inherited ones, optionally only those with <code>name</code>.</p></td>
+ <td><pre><code class="language-application-typescript">getLabels(name?: string): Attribute[]</code></pre><p>Returns the note's labels, including inherited ones, optionally only those with <code>name</code>.</p></td>
</tr>
<tr>
<td><code>getOwnedLabels</code></td>
- <td><pre><code class="language-application-typescript">getOwnedLabels(name?: string): ScriptAttribute[]</code></pre><p>Returns the note's own labels, without inherited ones, optionally only those with <code>name</code>.</p></td>
+ <td><pre><code class="language-application-typescript">getOwnedLabels(name?: string): Attribute[]</code></pre><p>Returns the note's own labels, without inherited ones, optionally only those with <code>name</code>.</p></td>
</tr>
<tr>
<td><code>getLabel</code></td>
- <td><pre><code class="language-application-typescript">getLabel(name: string): ScriptAttribute | null</code></pre><p>Returns the first label with the given name, including inherited ones, or <code>undefined</code> if the note has none.</p></td>
+ <td><pre><code class="language-application-typescript">getLabel(name: string): Attribute | null</code></pre><p>Returns the first label with the given name, including inherited ones, or <code>undefined</code> if the note has none.</p></td>
</tr>
<tr>
<td><code>getOwnedLabel</code></td>
- <td><pre><code class="language-application-typescript">getOwnedLabel(name: string): ScriptAttribute | null</code></pre><p>Returns the first of the note's own labels with the given name, or <code>undefined</code> if the note has none.</p></td>
+ <td><pre><code class="language-application-typescript">getOwnedLabel(name: string): Attribute | null</code></pre><p>Returns the first of the note's own labels with the given name, or <code>undefined</code> if the note has none.</p></td>
</tr>
<tr>
<td><code>getLabelValue</code></td>
@@ -508,19 +508,19 @@ A note as seen by frontend scripts (subset of the client's `FNote`).
</tr>
<tr>
<td><code>getRelations</code></td>
- <td><pre><code class="language-application-typescript">getRelations(name?: string): ScriptAttribute[]</code></pre><p>Returns the note's relations, including inherited ones, optionally only those with <code>name</code>.</p></td>
+ <td><pre><code class="language-application-typescript">getRelations(name?: string): Attribute[]</code></pre><p>Returns the note's relations, including inherited ones, optionally only those with <code>name</code>.</p></td>
</tr>
<tr>
<td><code>getOwnedRelations</code></td>
- <td><pre><code class="language-application-typescript">getOwnedRelations(name: string): ScriptAttribute[]</code></pre><p>Returns the note's own relations, without inherited ones, optionally only those with <code>name</code>.</p></td>
+ <td><pre><code class="language-application-typescript">getOwnedRelations(name: string): Attribute[]</code></pre><p>Returns the note's own relations, without inherited ones, optionally only those with <code>name</code>.</p></td>
</tr>
<tr>
<td><code>getRelation</code></td>
- <td><pre><code class="language-application-typescript">getRelation(name: string): ScriptAttribute | null</code></pre><p>Returns the first relation with the given name, including inherited ones, or <code>undefined</code> if the note has none.</p></td>
+ <td><pre><code class="language-application-typescript">getRelation(name: string): Attribute | null</code></pre><p>Returns the first relation with the given name, including inherited ones, or <code>undefined</code> if the note has none.</p></td>
</tr>
<tr>
<td><code>getOwnedRelation</code></td>
- <td><pre><code class="language-application-typescript">getOwnedRelation(name: string): ScriptAttribute | null</code></pre><p>Returns the first of the note's own relations with the given name, or <code>undefined</code> if the note has none.</p></td>
+ <td><pre><code class="language-application-typescript">getOwnedRelation(name: string): Attribute | null</code></pre><p>Returns the first of the note's own relations with the given name, or <code>undefined</code> if the note has none.</p></td>
</tr>
<tr>
<td><code>getRelationValue</code></td>
@@ -544,19 +544,19 @@ A note as seen by frontend scripts (subset of the client's `FNote`).
</tr>
<tr>
<td><code>getRelationTarget</code></td>
- <td><pre><code class="language-application-typescript">getRelationTarget(name: string): Promise&lt;ScriptFNote | null&gt;</code></pre><p>Returns the target note of the first relation with the given name, including inherited ones. Returns <code>null</code> if the note has no such relation, the relation has no target, or the target note does not exist.</p></td>
+ <td><pre><code class="language-application-typescript">getRelationTarget(name: string): Promise&lt;FNote | null&gt;</code></pre><p>Returns the target note of the first relation with the given name, including inherited ones. Returns <code>null</code> if the note has no such relation, the relation has no target, or the target note does not exist.</p></td>
</tr>
<tr>
<td><code>getRelationTargets</code></td>
- <td><pre><code class="language-application-typescript">getRelationTargets(name: string): Promise&lt;(ScriptFNote | null)[]&gt;</code></pre><p>Returns the target notes of the note's relations with the given name, including inherited ones, in the order of the relations. A relation whose target is missing gives <code>null</code>.</p></td>
+ <td><pre><code class="language-application-typescript">getRelationTargets(name: string): Promise&lt;(FNote | null)[]&gt;</code></pre><p>Returns the target notes of the note's relations with the given name, including inherited ones, in the order of the relations. A relation whose target is missing gives <code>null</code>.</p></td>
</tr>
<tr>
<td><code>getTargetRelations</code></td>
- <td><pre><code class="language-application-typescript">getTargetRelations(): ScriptAttribute[]</code></pre><p>Returns the relations, owned by any note, that point at this note.</p></td>
+ <td><pre><code class="language-application-typescript">getTargetRelations(): Attribute[]</code></pre><p>Returns the relations, owned by any note, that point at this note.</p></td>
</tr>
<tr>
<td><code>getTargetRelationSourceNotes</code></td>
- <td><pre><code class="language-application-typescript">getTargetRelationSourceNotes(): Promise&lt;ScriptFNote[]&gt;</code></pre><p>Returns the notes that own a relation pointing at this note.</p></td>
+ <td><pre><code class="language-application-typescript">getTargetRelationSourceNotes(): Promise&lt;FNote[]&gt;</code></pre><p>Returns the notes that own a relation pointing at this note.</p></td>
</tr>
<tr>
<td><code>getContent</code></td>
@@ -568,35 +568,35 @@ A note as seen by frontend scripts (subset of the client's `FNote`).
</tr>
<tr>
<td><code>getBlob</code></td>
- <td><pre><code class="language-application-typescript">getBlob(): Promise&lt;ScriptBlob | null&gt;</code></pre><p>Fetches the note's content together with its blob ID, length and modification date. Resolves to <code>null</code> if the request fails.</p></td>
+ <td><pre><code class="language-application-typescript">getBlob(): Promise&lt;Blob | null&gt;</code></pre><p>Fetches the note's content together with its blob ID, length and modification date. Resolves to <code>null</code> if the request fails.</p></td>
</tr>
<tr>
<td><code>getNoteComplement</code></td>
- <td><pre><code class="language-application-typescript">getNoteComplement(): Promise&lt;ScriptBlob | null&gt;</code></pre><p>Returns the blob that holds the note's content.</p><aside class="admonition warning"><p>Deprecated. Use <code>getBlob()</code> instead.</p></aside></td>
+ <td><pre><code class="language-application-typescript">getNoteComplement(): Promise&lt;Blob | null&gt;</code></pre><p>Returns the blob that holds the note's content.</p><aside class="admonition warning"><p>Deprecated. Use <code>getBlob()</code> instead.</p></aside></td>
</tr>
<tr>
<td><code>getMetadata</code></td>
- <td><pre><code class="language-application-typescript">getMetadata(): Promise&lt;ScriptNoteMetadata&gt;</code></pre><p>Returns the note's creation and modification dates, which it requests from the server.</p></td>
+ <td><pre><code class="language-application-typescript">getMetadata(): Promise&lt;NoteMetadata&gt;</code></pre><p>Returns the note's creation and modification dates, which it requests from the server.</p></td>
</tr>
<tr>
<td><code>attachments</code></td>
- <td><p><code>ScriptAttachment[] | null</code><br>The note's attachments, or <code>null</code> until <code>getAttachments()</code> loads them. Use <code>getAttachments()</code> instead of reading this property.</p></td>
+ <td><p><code>Attachment[] | null</code><br>The note's attachments, or <code>null</code> until <code>getAttachments()</code> loads them. Use <code>getAttachments()</code> instead of reading this property.</p></td>
</tr>
<tr>
<td><code>getAttachments</code></td>
- <td><pre><code class="language-application-typescript">getAttachments(): Promise&lt;ScriptAttachment[]&gt;</code></pre><p>Returns the note's attachments. The first call loads them from the server, and later calls reuse that list.</p></td>
+ <td><pre><code class="language-application-typescript">getAttachments(): Promise&lt;Attachment[]&gt;</code></pre><p>Returns the note's attachments. The first call loads them from the server, and later calls reuse that list.</p></td>
</tr>
<tr>
<td><code>getAttachmentsByRole</code></td>
- <td><pre><code class="language-application-typescript">getAttachmentsByRole(role: string): Promise&lt;ScriptAttachment[]&gt;</code></pre><p>Returns the note's attachments with the given role, such as <code>image</code> or <code>file</code>.</p></td>
+ <td><pre><code class="language-application-typescript">getAttachmentsByRole(role: string): Promise&lt;Attachment[]&gt;</code></pre><p>Returns the note's attachments with the given role, such as <code>image</code> or <code>file</code>.</p></td>
</tr>
<tr>
<td><code>getAttachmentById</code></td>
- <td><pre><code class="language-application-typescript">getAttachmentById(attachmentId: string): Promise&lt;ScriptAttachment | undefined&gt;</code></pre><p>Returns the note's attachment with the given ID, or <code>undefined</code> if this note has no such attachment.</p></td>
+ <td><pre><code class="language-application-typescript">getAttachmentById(attachmentId: string): Promise&lt;Attachment | undefined&gt;</code></pre><p>Returns the note's attachment with the given ID, or <code>undefined</code> if this note has no such attachment.</p></td>
</tr>
<tr>
<td><code>getNotesToInheritAttributesFrom</code></td>
- <td><pre><code class="language-application-typescript">getNotesToInheritAttributesFrom(): ScriptFNote[]</code></pre><p>Returns the target notes of this note's <code>~template</code> and <code>~inherit</code> relations, inherited relations included. A target note that the client has not loaded appears as <code>undefined</code>.</p></td>
+ <td><pre><code class="language-application-typescript">getNotesToInheritAttributesFrom(): FNote[]</code></pre><p>Returns the target notes of this note's <code>~template</code> and <code>~inherit</code> relations, inherited relations included. A target note that the client has not loaded appears as <code>undefined</code>.</p></td>
</tr>
<tr>
<td><code>getIcon</code></td>
@@ -791,15 +791,15 @@ Instance shape of `RightPanelWidget` (subset) — a widget shown in the right si
</tr>
<tr>
<td><code>note</code></td>
- <td><p><code>ScriptFNote | null</code><br>The note currently shown in this widget's context.</p></td>
+ <td><p><code>FNote | null</code><br>The note currently shown in this widget's context.</p></td>
</tr>
<tr>
<td><code>noteContext</code><br><em>optional</em></td>
- <td><p><code>ScriptNoteContext</code><br>The note context (split) this widget is attached to.</p></td>
+ <td><p><code>NoteContext</code><br>The note context (split) this widget is attached to.</p></td>
</tr>
<tr>
<td><code>refreshWithNote</code></td>
- <td><pre><code class="language-application-typescript">refreshWithNote(note: ScriptFNote | null | undefined): void | Promise&lt;void&gt;</code></pre><p>Updates the widget for the note in its context. Override it to refresh the widget's content; it runs when that note changes and on <code>refresh()</code>, as long as <code>isEnabled()</code> returns <code>true</code>.</p></td>
+ <td><pre><code class="language-application-typescript">refreshWithNote(note: FNote | null | undefined): void | Promise&lt;void&gt;</code></pre><p>Updates the widget for the note in its context. Override it to refresh the widget's content; it runs when that note changes and on <code>refresh()</code>, as long as <code>isEnabled()</code> returns <code>true</code>.</p></td>
</tr>
<tr>
<td><code>refresh</code></td>
@@ -866,15 +866,15 @@ Instance shape of `NoteContextAwareWidget` (subset) — reacts to the active not
</tr>
<tr>
<td><code>note</code></td>
- <td><p><code>ScriptFNote | null</code><br>The note currently shown in this widget's context.</p></td>
+ <td><p><code>FNote | null</code><br>The note currently shown in this widget's context.</p></td>
</tr>
<tr>
<td><code>noteContext</code><br><em>optional</em></td>
- <td><p><code>ScriptNoteContext</code><br>The note context (split) this widget is attached to.</p></td>
+ <td><p><code>NoteContext</code><br>The note context (split) this widget is attached to.</p></td>
</tr>
<tr>
<td><code>refreshWithNote</code></td>
- <td><pre><code class="language-application-typescript">refreshWithNote(note: ScriptFNote | null | undefined): void | Promise&lt;void&gt;</code></pre><p>Updates the widget for the note in its context. Override it to refresh the widget's content; it runs when that note changes and on <code>refresh()</code>, as long as <code>isEnabled()</code> returns <code>true</code>.</p></td>
+ <td><pre><code class="language-application-typescript">refreshWithNote(note: FNote | null | undefined): void | Promise&lt;void&gt;</code></pre><p>Updates the widget for the note in its context. Override it to refresh the widget's content; it runs when that note changes and on <code>refresh()</code>, as long as <code>isEnabled()</code> returns <code>true</code>.</p></td>
</tr>
<tr>
<td><code>refresh</code></td>
@@ -934,7 +934,7 @@ Instance shape of `BasicWidget` (subset) — the base for custom frontend widget
</tbody>
</table>
-## `ScriptFBranch`
+## `FBranch`
A branch (parent↔child link) as seen by frontend scripts (subset of `FBranch`).
@@ -972,15 +972,15 @@ A branch (parent↔child link) as seen by frontend scripts (subset of `FBranch`)
</tr>
<tr>
<td><code>getNote</code></td>
- <td><pre><code class="language-application-typescript">getNote(): Promise&lt;ScriptFNote | null&gt;</code></pre><p>Returns the child note, loading it from the server if the frontend cache does not hold it yet. Resolves to <code>null</code> if the note does not exist.</p></td>
+ <td><pre><code class="language-application-typescript">getNote(): Promise&lt;FNote | null&gt;</code></pre><p>Returns the child note, loading it from the server if the frontend cache does not hold it yet. Resolves to <code>null</code> if the note does not exist.</p></td>
</tr>
<tr>
<td><code>getNoteFromCache</code></td>
- <td><pre><code class="language-application-typescript">getNoteFromCache(): ScriptFNote | undefined</code></pre><p>Returns the child note from the frontend cache, without contacting the server. Returns <code>undefined</code> if the note is not loaded yet.</p></td>
+ <td><pre><code class="language-application-typescript">getNoteFromCache(): FNote | undefined</code></pre><p>Returns the child note from the frontend cache, without contacting the server. Returns <code>undefined</code> if the note is not loaded yet.</p></td>
</tr>
<tr>
<td><code>getParentNote</code></td>
- <td><pre><code class="language-application-typescript">getParentNote(): Promise&lt;ScriptFNote | null&gt;</code></pre><p>Returns the parent note, loading it from the server if the frontend cache does not hold it yet. Resolves to <code>null</code> if the note does not exist.</p></td>
+ <td><pre><code class="language-application-typescript">getParentNote(): Promise&lt;FNote | null&gt;</code></pre><p>Returns the parent note, loading it from the server if the frontend cache does not hold it yet. Resolves to <code>null</code> if the note does not exist.</p></td>
</tr>
<tr>
<td><code>isTopLevel</code></td>
@@ -989,7 +989,7 @@ A branch (parent↔child link) as seen by frontend scripts (subset of `FBranch`)
</tbody>
</table>
-## `ScriptNoteContext`
+## `NoteContext`
A split/tab context as seen by frontend scripts (subset of `NoteContext`).
@@ -1007,7 +1007,7 @@ A split/tab context as seen by frontend scripts (subset of `NoteContext`).
</tr>
<tr>
<td><code>note</code></td>
- <td><p><code>ScriptFNote | null</code><br>The note this context shows, or <code>null</code> if the context is empty.</p></td>
+ <td><p><code>FNote | null</code><br>The note this context shows, or <code>null</code> if the context is empty.</p></td>
</tr>
<tr>
<td><code>notePath</code></td>
@@ -1024,7 +1024,7 @@ A split/tab context as seen by frontend scripts (subset of `NoteContext`).
</tbody>
</table>
-## `ScriptDayjsInstance`
+## `DayjsInstance`
A date as day.js wraps it (subset).
@@ -1042,11 +1042,11 @@ A date as day.js wraps it (subset).
</tr>
<tr>
<td><code>add</code></td>
- <td><pre><code class="language-application-typescript">add(value: number, unit: string): ScriptDayjsInstance</code></pre><p>Returns a new date, <code>value</code> units later. The date it is called on stays unchanged.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>number</code></td></tr><tr><td><code>unit</code></td><td><code>string</code><br>The unit, such as <code>"day"</code>, <code>"week"</code>, <code>"month"</code> or <code>"year"</code>.</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">add(value: number, unit: string): DayjsInstance</code></pre><p>Returns a new date, <code>value</code> units later. The date it is called on stays unchanged.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>number</code></td></tr><tr><td><code>unit</code></td><td><code>string</code><br>The unit, such as <code>"day"</code>, <code>"week"</code>, <code>"month"</code> or <code>"year"</code>.</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>subtract</code></td>
- <td><pre><code class="language-application-typescript">subtract(value: number, unit: string): ScriptDayjsInstance</code></pre><p>Returns a new date, <code>value</code> units earlier. The date it is called on stays unchanged.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>number</code></td></tr><tr><td><code>unit</code></td><td><code>string</code><br>The unit, such as <code>"day"</code>, <code>"week"</code>, <code>"month"</code> or <code>"year"</code>.</td></tr></tbody></table></figure></td>
+ <td><pre><code class="language-application-typescript">subtract(value: number, unit: string): DayjsInstance</code></pre><p>Returns a new date, <code>value</code> units earlier. The date it is called on stays unchanged.</p><figure class="table"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>value</code></td><td><code>number</code></td></tr><tr><td><code>unit</code></td><td><code>string</code><br>The unit, such as <code>"day"</code>, <code>"week"</code>, <code>"month"</code> or <code>"year"</code>.</td></tr></tbody></table></figure></td>
</tr>
<tr>
<td><code>toDate</code></td>
@@ -1057,12 +1057,12 @@ A date as day.js wraps it (subset).
## Types
-### `ScriptDayjs`
+### `Dayjs`
Minimal day.js surface (the real API exposes the full day.js factory).
```typescript
-type ScriptDayjs = (date?: string | number | Date) => ScriptDayjsInstance
+type Dayjs = (date?: string | number | Date) => DayjsInstance
```
### `WidgetClass`
@@ -1079,7 +1079,7 @@ type WidgetClass = (...args: unknown[]) => T
type Func = (...args: unknown[]) => unknown | string
```
-### `ScriptCreateNoteOpts`
+### `CreateNoteOpts`
Options accepted by `FrontendApi.createNote`.
@@ -1095,7 +1095,7 @@ Options accepted by `FrontendApi.createNote`.
| `focus` <br>_optional_ | `"title" \| "content"` <br>Which part of the activated note to focus. Defaults to "title". |
| `target` <br>_optional_ | `string` <br>Where to place the note relative to the parent/target: "into" (default) or "after". |
| `targetBranchId` <br>_optional_ | `string` <br>Branch ID used together with `target: "after"`. |
-| `attributes` <br>_optional_ | `ScriptCreateAttribute[]` <br>Attributes to set atomically on creation. |
+| `attributes` <br>_optional_ | `CreateAttribute[]` <br>Attributes to set atomically on creation. |
### `PickerItem`
@@ -1118,7 +1118,7 @@ A run of picker items under a heading of their own.
| `groupHeader` | `string` <br>The heading shown above the group's items. An empty string shows the items without a heading. |
| `items` | `PickerItem[]` <br>The items in the group, in the order the picker shows them. |
-### `ScriptNotePathRecord`
+### `NotePathRecord`
One resolved tree path to a note (subset of the client's `NotePathRecord`).
@@ -1130,7 +1130,7 @@ One resolved tree path to a note (subset of the client's `NotePathRecord`).
| `notePath` | `string[]` <br>The note IDs along the path, from `root` to the note itself. |
| `isHidden` | `boolean` <br>Whether the path passes through the hidden subtree, `_hidden`, which holds Trilium's system notes. |
-### `ScriptAttribute`
+### `Attribute`
A label or relation attached to a note.
@@ -1143,7 +1143,7 @@ A label or relation attached to a note.
| `isInheritable` | `boolean` <br>Whether the note's descendants inherit the attribute. |
| `isOwned` | `boolean` <br>Not set by Trilium: neither frontend nor backend attributes carry this property, so it reads `undefined`. |
-### `ScriptBlob`
+### `Blob`
A note's binary/text content blob (subset of the client's `FBlob`).
@@ -1155,9 +1155,9 @@ A note's binary/text content blob (subset of the client's `FBlob`).
| `dateModified` | `string` <br>The local date and time this content was first stored, with the UTC offset, such as `2026-10-22 14:03:05.123+0200`. A blob never changes, so new content gets a new blob. |
| `utcDateModified` | `string` <br>The date and time, in UTC, that this content was first stored, such as `2026-10-22 12:03:05.123Z`. |
-### `ScriptNoteMetadata`
+### `NoteMetadata`
-Creation/modification timestamps returned by `ScriptFNote.getMetadata`.
+Creation/modification timestamps returned by `FNote.getMetadata`.
| Property | Description |
| --- | --- |
@@ -1166,7 +1166,7 @@ Creation/modification timestamps returned by `ScriptFNote.getMetadata`.
| `dateModified` | `string` <br>The local date and time the note was last modified, with the UTC offset, such as `2026-10-22 14:03:05.123+0200`. A change to the note's content counts as a modification. |
| `utcDateModified` | `string` <br>The date and time, in UTC, that the note was last modified, such as `2026-10-22 12:03:05.123Z`. A change to the note's content counts as a modification. |
-### `ScriptAttachment`
+### `Attachment`
An attachment as seen by frontend scripts (subset of the client's `FAttachment`).
@@ -1180,9 +1180,9 @@ An attachment as seen by frontend scripts (subset of the client's `FAttachment`)
| `utcDateModified` | `string` <br>The date and time, in UTC, that the attachment was last saved, such as `2026-10-22 12:03:05.123Z`. Replacing the content counts as saving. |
| `contentLength` | `number` <br>The length of the attachment's content. Only some ways of loading an attachment fill it in, such as `getAttachments()`; on the backend, `getAttachmentsByRole()` leaves it `undefined`. |
-### `ScriptCreateAttribute`
+### `CreateAttribute`
-An attribute to create together with a note (see `ScriptCreateNoteOpts.attributes`).
+An attribute to create together with a note (see `CreateNoteOpts.attributes`).
| Property | Description |
| --- | --- |
diff --git a/edit-docs-config.yaml b/edit-docs-config.yaml
index 22e116f377..7c0e5c4439 100644
--- a/edit-docs-config.yaml
+++ b/edit-docs-config.yaml
@@ -19,14 +19,17 @@ noteMappings:
entryPoint: "packages/commons/src/lib/electron_api_interface.ts"
tsconfig: "packages/commons/tsconfig.lib.json"
root: "ElectronApi"
+ stripPrefixes: [ "Electron" ]
- noteId: "MEtfsqa5VwNi" # Scripting › Script API › Backend API
entryPoint: "packages/commons/src/lib/script_api.ts"
tsconfig: "packages/commons/tsconfig.lib.json"
root: "BackendApi"
+ stripPrefixes: [ "Script" ]
- noteId: "Q2z6av6JZVWm" # Scripting › Script API › Frontend API
entryPoint: "packages/commons/src/lib/script_api.ts"
tsconfig: "packages/commons/tsconfig.lib.json"
root: "FrontendApi"
+ stripPrefixes: [ "Script" ]
- rootNoteId: "jdjRLhLV3TtI"
path: "docs/Developer Guide"