Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
docs(scripting): list the Electron API's members in tables
Elian Dorana945d5153e22
diff --git a/apps/server/src/assets/help/help_content.json b/apps/server/src/assets/help/help_content.jsonindex 7c776d244e..07db193a03 100644--- a/apps/server/src/assets/help/help_content.json+++ b/apps/server/src/assets/help/help_content.json@@ -275,7 +275,7 @@"_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 <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 <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 <a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a> and more complicated scripts, it's generally useful to split the code into multiple <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> notes.</p><p>When a script is run, the sub-children of the script being run (or the <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) => a + b;\nmodule.exports.subtract = (a, b) => 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 <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: <a class=\"reference-link\" href=\"#root/_help_Q2z6av6JZVWm\">Frontend API</a></li><li>One for the back-end scripts: <a class=\"reference-link\" href=\"{{helpAssets}}/User%20Guide/Scripting/Script%20API/Backend%20API.dat\">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_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><h3><code>setZoomFactor</code></h3><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><h3><code>getZoomFactor</code></h3><pre><code class=\"language-application-typescript\">getZoomFactor(): number</code></pre><p>Returns the current page zoom factor (<code>1.0</code> = 100%).</p><p><strong>Returns</strong> <code>number</code></p><h3><code>setNativeThemeSource</code></h3><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. Use <code>\"system\"</code> to follow the OS setting.</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></td></tr></tbody></table></figure><h3><code>setTitleBarOverlay</code></h3><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></td></tr></tbody></table></figure><h3><code>setWindowButtonPosition</code></h3><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></td></tr></tbody></table></figure><h3><code>onEnterFullScreen</code></h3><pre><code class=\"language-application-typescript\">onEnterFullScreen(callback: () => void): void</code></pre><p>Registers a callback fired whenever the window enters full-screen mode.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>() => void</code></td></tr></tbody></table></figure><h3><code>onLeaveFullScreen</code></h3><pre><code class=\"language-application-typescript\">onLeaveFullScreen(callback: () => void): void</code></pre><p>Registers a callback fired whenever the window leaves full-screen mode.</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>() => void</code></td></tr></tbody></table></figure><h3><code>isFullScreen</code></h3><pre><code class=\"language-application-typescript\">isFullScreen(): boolean</code></pre><p>Synchronously returns whether the window is currently in full-screen mode.</p><p><strong>Returns</strong> <code>boolean</code></p><h3><code>setFullScreen</code></h3><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></td></tr></tbody></table></figure><h3><code>minimizeWindow</code></h3><pre><code class=\"language-application-typescript\">minimizeWindow(): void</code></pre><p>Minimizes the current window to the taskbar / dock.</p><h3><code>maximizeWindow</code></h3><pre><code class=\"language-application-typescript\">maximizeWindow(): void</code></pre><p>Maximizes the current window to fill the available screen area.</p><h3><code>unmaximizeWindow</code></h3><pre><code class=\"language-application-typescript\">unmaximizeWindow(): void</code></pre><p>Restores the window from a maximized state to its previous size.</p><h3><code>isMaximized</code></h3><pre><code class=\"language-application-typescript\">isMaximized(): boolean</code></pre><p>Synchronously returns whether the window is currently maximized.</p><p><strong>Returns</strong> <code>boolean</code></p><h3><code>closeWindow</code></h3><pre><code class=\"language-application-typescript\">closeWindow(): void</code></pre><p>Closes the current window.</p><h3><code>isAlwaysOnTop</code></h3><pre><code class=\"language-application-typescript\">isAlwaysOnTop(): boolean</code></pre><p>Synchronously returns whether the window is pinned above all others.</p><p><strong>Returns</strong> <code>boolean</code></p><h3><code>setAlwaysOnTop</code></h3><pre><code class=\"language-application-typescript\">setAlwaysOnTop(enabled: boolean): void</code></pre><p>Toggles the always-on-top (pinned) state of the window.</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></tbody></table></figure><h3><code>toggleDevTools</code></h3><pre><code class=\"language-application-typescript\">toggleDevTools(): void</code></pre><p>Opens or closes Chromium DevTools for the current window.</p><h3><code>isDevToolsDocked</code></h3><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><p><strong>Returns</strong> <code>boolean</code></p><h3><code>setBackgroundMaterial</code></h3><pre><code class=\"language-application-typescript\">setBackgroundMaterial(material: string): void</code></pre><p>Sets the Windows 11 backdrop material (e.g. <code>\"mica\"</code>, <code>\"acrylic\"</code>, <code>\"tabbed\"</code>, <code>\"none\"</code>) 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></td></tr></tbody></table></figure><h3><code>setVibrancy</code></h3><pre><code class=\"language-application-typescript\">setVibrancy(vibrancy: string): void</code></pre><p>Sets the macOS vibrancy effect (e.g. <code>\"sidebar\"</code>, <code>\"under-window\"</code>, <code>\"fullscreen-ui\"</code>) 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></td></tr></tbody></table></figure><h3><code>reloadAllWindows</code></h3><pre><code class=\"language-application-typescript\">reloadAllWindows(): void</code></pre><p>Triggers a hard reload of every open Trilium window.</p><h3><code>restartApp</code></h3><pre><code class=\"language-application-typescript\">restartApp(): void</code></pre><p>Quits the app and immediately relaunches it.</p><h3><code>toggleAllWindows</code></h3><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><h3><code>clearCache</code></h3><pre><code class=\"language-application-typescript\">clearCache(): Promise<void></code></pre><p>Clears the underlying Chromium HTTP cache. Resolves once the cache is empty.</p><p><strong>Returns</strong> <code>Promise<void></code></p><h3><code>showWindow</code></h3><pre><code class=\"language-application-typescript\">showWindow(): void</code></pre><p>Brings the main window to the foreground, restoring it if minimized.</p><h3><code>reportStartupMetric</code></h3><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></td></tr></tbody></table></figure><h3><code>onGlobalShortcut</code></h3><pre><code class=\"language-application-typescript\">onGlobalShortcut(callback: (actionName: string) => void): void</code></pre><p>Subscribes to globally registered keyboard shortcuts. The callback receives the logical action name (not the keystroke).</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) => void</code></td></tr></tbody></table></figure><h3><code>onOpenInSameTab</code></h3><pre><code class=\"language-application-typescript\">onOpenInSameTab(callback: (noteId: string) => 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) => void</code></td></tr></tbody></table></figure><h3><code>onDevToolsDockChanged</code></h3><pre><code class=\"language-application-typescript\">onDevToolsDockChanged(callback: (docked: boolean) => void): void</code></pre><p>Subscribes to changes of the DevTools docking state. <code>docked</code> is <code>true</code> only while DevTools is attached to this window — where Chromium disables the native window material (Mica / vibrancy) — and <code>false</code> when it is closed or in a separate 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>(docked: boolean) => void</code></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><h3><code>copyImageToClipboard</code></h3><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></td></tr></tbody></table></figure><h3><code>readText</code></h3><pre><code class=\"language-application-typescript\">readText(): Promise<string></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><p><strong>Returns</strong> <code>Promise<string></code></p><h3><code>readHTML</code></h3><pre><code class=\"language-application-typescript\">readHTML(): Promise<string></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><p><strong>Returns</strong> <code>Promise<string></code></p><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><h3><code>openExternal</code></h3><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></td></tr></tbody></table></figure><h3><code>openPath</code></h3><pre><code class=\"language-application-typescript\">openPath(path: string): Promise<string></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></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise<string></code>: An empty string on success, or an error message on failure.</p><h3><code>showItemInFolder</code></h3><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></td></tr></tbody></table></figure><h3><code>openFileUrl</code></h3><pre><code class=\"language-application-typescript\">openFileUrl(fileUrl: string): Promise<string></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></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise<string></code>: An empty string on success, or an error message on failure.</p><h3><code>downloadURL</code></h3><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></td></tr></tbody></table></figure><h3><code>openCustom</code></h3><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></td></tr></tbody></table></figure><h2><code>ElectronContextMenuApi</code></h2><p>Bridge for the native context menu shown over web contents.</p><h3><code>onContextMenu</code></h3><pre><code class=\"language-application-typescript\">onContextMenu(callback: (params: ElectronContextMenuParams) => 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) => void</code></td></tr></tbody></table></figure><h3><code>webContentsAction</code></h3><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. <code>\"insertText\"</code> requires the <code>text</code> argument; the other actions ignore it.</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></td></tr><tr><td><code>text</code> <br><em>optional</em></td><td><code>string</code></td></tr></tbody></table></figure><h2><code>ElectronSpellcheckApi</code></h2><p>Renderer-side access to Chromium's built-in spell checker.</p><h3><code>addWordToDictionary</code></h3><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><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>word</code></td><td><code>string</code></td></tr></tbody></table></figure><h3><code>getAvailableSpellCheckerLanguages</code></h3><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><p><strong>Returns</strong> <code>string[]</code></p><h3><code>setSpellCheckerLanguages</code></h3><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></td></tr></tbody></table></figure><h3><code>setSpellCheckerEnabled</code></h3><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></td></tr></tbody></table></figure><h2><code>ElectronSystemIntegrationApi</code></h2><p>OS integration controls — system tray and autostart / launch-on-login.</p><h3><code>reloadTray</code></h3><pre><code class=\"language-application-typescript\">reloadTray(): void</code></pre><p>Rebuilds the tray icon and menu — call after changing tray-related settings.</p><h3><code>reapplyLaunchOnStartup</code></h3><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><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><h3><code>sendPrintProgress</code></h3><pre><code class=\"language-application-typescript\">sendPrintProgress(progress: number): void</code></pre><p>Reports rendering progress (<code>0..100</code>) 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></td></tr></tbody></table></figure><h3><code>onPrintProgress</code></h3><pre><code class=\"language-application-typescript\">onPrintProgress(callback: (data: { progress: number; action: string }) => void): void</code></pre><p>Subscribes to progress updates emitted by the main process during a print or PDF export run. <code>action</code> describes the current stage (e.g. <code>\"rendering\"</code>).</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 }) => void</code></td></tr></tbody></table></figure><h3><code>onPrintDone</code></h3><pre><code class=\"language-application-typescript\">onPrintDone(callback: (printReport: unknown, liveJobId?: number) => void): void</code></pre><p>Subscribes to the \"print finished\" event, fired once the OS print job is dispatched. <code>liveJobId</code> names the live print the job ended, for a job that printed the app window itself.</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) => void</code></td></tr></tbody></table></figure><h3><code>removePrintListeners</code></h3><pre><code class=\"language-application-typescript\">removePrintListeners(): void</code></pre><p>Removes all listeners registered via <code>onPrintProgress</code> and <code>onPrintDone</code>.</p><h3><code>getPrinters</code></h3><pre><code class=\"language-application-typescript\">getPrinters(): Promise<unknown[]></code></pre><p>Returns the list of printers known to the OS.</p><p><strong>Returns</strong> <code>Promise<unknown[]></code></p><h3><code>exportAsPdfPreview</code></h3><pre><code class=\"language-application-typescript\">exportAsPdfPreview(opts: Record<string, unknown>): 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<string, unknown></code></td></tr></tbody></table></figure><h3><code>onExportAsPdfPreviewResult</code></h3><pre><code class=\"language-application-typescript\">onExportAsPdfPreviewResult(callback: (result: { buffer?: Uint8Array<ArrayBufferLike>; error?: string; requestId?: number }) => 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<ArrayBufferLike>; error?: string; requestId?: number }) => void</code></td></tr></tbody></table></figure><h3><code>removeExportAsPdfPreviewResultListener</code></h3><pre><code class=\"language-application-typescript\">removeExportAsPdfPreviewResultListener(): void</code></pre><p>Removes the listener registered via <code>onExportAsPdfPreviewResult</code>.</p><h3><code>savePdf</code></h3><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. <code>title</code> is used as the suggested filename.</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></td></tr></tbody></table></figure><h3><code>printFromPreview</code></h3><pre><code class=\"language-application-typescript\">printFromPreview(opts: Record<string, unknown>): 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<string, unknown></code></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><h3><code>clearNavigationHistory</code></h3><pre><code class=\"language-application-typescript\">clearNavigationHistory(): void</code></pre><p>Clears the entire back/forward navigation history.</p><h3><code>navigationCanGoBack</code></h3><pre><code class=\"language-application-typescript\">navigationCanGoBack(): boolean</code></pre><p>Synchronously returns whether a back navigation is possible.</p><p><strong>Returns</strong> <code>boolean</code></p><h3><code>navigationCanGoForward</code></h3><pre><code class=\"language-application-typescript\">navigationCanGoForward(): boolean</code></pre><p>Synchronously returns whether a forward navigation is possible.</p><p><strong>Returns</strong> <code>boolean</code></p><h3><code>navigationGetAllEntries</code></h3><pre><code class=\"language-application-typescript\">navigationGetAllEntries(): { url: string; title: string }[]</code></pre><p>Returns every entry in the navigation history, oldest first.</p><p><strong>Returns</strong> <code>{ url: string; title: string }[]</code></p><h3><code>navigationGetActiveIndex</code></h3><pre><code class=\"language-application-typescript\">navigationGetActiveIndex(): number</code></pre><p>Returns the index of the currently active entry inside <code>navigationGetAllEntries</code>.</p><p><strong>Returns</strong> <code>number</code></p><h3><code>navigationLength</code></h3><pre><code class=\"language-application-typescript\">navigationLength(): number</code></pre><p>Returns the total number of entries in the navigation history.</p><p><strong>Returns</strong> <code>number</code></p><h3><code>navigationGoToIndex</code></h3><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></td></tr></tbody></table></figure><h3><code>onDidNavigate</code></h3><pre><code class=\"language-application-typescript\">onDidNavigate(callback: () => void): void</code></pre><p>Subscribes to top-level navigation events (URL changes that load a new document).</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>() => void</code></td></tr></tbody></table></figure><h3><code>onDidNavigateInPage</code></h3><pre><code class=\"language-application-typescript\">onDidNavigateInPage(callback: () => void): void</code></pre><p>Subscribes to in-page navigation events (hash changes, <code>history.pushState</code>).</p><figure class=\"table\"><table><thead><tr><th>Parameter</th><th>Description</th></tr></thead><tbody><tr><td><code>callback</code></td><td><code>() => void</code></td></tr></tbody></table></figure><h3><code>removeDidNavigateListeners</code></h3><pre><code class=\"language-application-typescript\">removeDidNavigateListeners(): void</code></pre><p>Removes all listeners registered via <code>onDidNavigate</code> and <code>onDidNavigateInPage</code>.</p><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><h3><code>send</code></h3><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></td></tr></tbody></table></figure><h3><code>onMessage</code></h3><pre><code class=\"language-application-typescript\">onMessage(callback: (message: unknown) => void): () => void</code></pre><p>Subscribes to messages pushed from the main process. Returns an unsubscribe function — call it when the listener is no longer needed (e.g. when a BrowserWindow is unloaded) to avoid leaking handlers.</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) => void</code></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>() => void</code></p><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><h3><code>setLanAccessEnabled</code></h3><pre><code class=\"language-application-typescript\">setLanAccessEnabled(enabled: boolean): Promise<boolean></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></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise<boolean></code></p><h3><code>setBackendScriptingEnabled</code></h3><pre><code class=\"language-application-typescript\">setBackendScriptingEnabled(enabled: boolean): Promise<boolean></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></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise<boolean></code></p><h3><code>setSqlConsoleEnabled</code></h3><pre><code class=\"language-application-typescript\">setSqlConsoleEnabled(enabled: boolean): Promise<boolean></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></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise<boolean></code></p><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><h3><code>getStatus</code></h3><pre><code class=\"language-application-typescript\">getStatus(): Promise<BackupPassphraseStatus></code></pre><p>Whether a passphrase can be stored on this system, and whether one already is.</p><p><strong>Returns</strong> <code>Promise<BackupPassphraseStatus></code></p><h3><code>set</code></h3><pre><code class=\"language-application-typescript\">set(passphrase: string): Promise<BackupPassphraseChange></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></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise<BackupPassphraseChange></code></p><h3><code>clear</code></h3><pre><code class=\"language-application-typescript\">clear(): Promise<BackupPassphraseChange></code></pre><p>Forgets the stored passphrase. Existing backups keep the passphrase they were written with.</p><p><strong>Returns</strong> <code>Promise<BackupPassphraseChange></code></p><h2><code>ElectronOneNoteApi</code></h2><p>Desktop-only OneNote importer sign-in, driven from the main process via a loopback OAuth redirect.</p><h3><code>login</code></h3><pre><code class=\"language-application-typescript\">login(): Promise<OneNoteLoginResult></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><p><strong>Returns</strong> <code>Promise<OneNoteLoginResult></code></p><h2><code>ElectronNativeExportApi</code></h2><p>Desktop-native subtree export that streams a <code>.zip</code> straight to a file.</p><h3><code>exportSubtreeToFile</code></h3><pre><code class=\"language-application-typescript\">exportSubtreeToFile(opts: { branchId: string; format: string; title: string; taskId: string }): Promise<NativeExportResult></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></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise<NativeExportResult></code></p><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><h3><code>pickFiles</code></h3><pre><code class=\"language-application-typescript\">pickFiles(): Promise<NativeImportPickResult></code></pre><p>Prompts a native \"open file\" dialog (multi-select, any type) and returns single-use tokens for the chosen files.</p><p><strong>Returns</strong> <code>Promise<NativeImportPickResult></code></p><h3><code>grantDroppedFiles</code></h3><pre><code class=\"language-application-typescript\">grantDroppedFiles(files: File[]): Promise<NativeImportPickResult></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></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise<NativeImportPickResult></code></p><h3><code>importFromToken</code></h3><pre><code class=\"language-application-typescript\">importFromToken(opts: { token: string; parentNoteId: string; taskId: string; options: NativeImportOptions; last: boolean; format?: string }): Promise<NativeImportResult></code></pre><p>Imports the file behind <code>token</code> into <code>parentNoteId</code>. Progress/success/error are reported over the WebSocket via <code>taskId</code>, matching the HTTP import path. 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. \"obsidian\"), mirroring the HTTP route's format tag.</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></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise<NativeImportResult></code></p><h2><code>ElectronDialogApi</code></h2><p>Native OS pickers that hand the renderer a location the user chose themselves.</p><h3><code>pickDirectory</code></h3><pre><code class=\"language-application-typescript\">pickDirectory(opts?: { defaultPath?: string }): Promise<NativeDirectoryPickResult></code></pre><p>Prompts a native \"select folder\" dialog, starting at <code>defaultPath</code> when it is given. 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></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise<NativeDirectoryPickResult></code></p><h3><code>confirmStartOver</code></h3><pre><code class=\"language-application-typescript\">confirmStartOver(): Promise<boolean></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><p><strong>Returns</strong> <code>Promise<boolean></code></p><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><h3><code>pickBackup</code></h3><pre><code class=\"language-application-typescript\">pickBackup(): Promise<NativeBackupPickResult></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><p><strong>Returns</strong> <code>Promise<NativeBackupPickResult></code></p><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><h3><code>isSupported</code></h3><pre><code class=\"language-application-typescript\">isSupported(): Promise<boolean></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><p><strong>Returns</strong> <code>Promise<boolean></code></p><h3><code>start</code></h3><pre><code class=\"language-application-typescript\">start(noteId: string): Promise<string></code></pre><p>Starts recording the microphone and the system audio for the meeting note <code>noteId</code>.</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></tbody></table></figure><p><strong>Returns</strong> <code>Promise<string></code>: An empty string once recording runs, or an error message when it cannot start.</p><h3><code>stop</code></h3><pre><code class=\"language-application-typescript\">stop(): Promise<void></code></pre><p>Stops the recording, once the speech already captured has been transcribed.</p><p><strong>Returns</strong> <code>Promise<void></code></p><h3><code>getState</code></h3><pre><code class=\"language-application-typescript\">getState(): Promise<TranscriptionState></code></pre><p><strong>Returns</strong> <code>Promise<TranscriptionState></code></p><h3><code>renameSpeaker</code></h3><pre><code class=\"language-application-typescript\">renameSpeaker(attachmentId: string, key: string, name: string): Promise<boolean></code></pre><p>Names a speaker of the transcript attachment <code>attachmentId</code>, or restores the default name when <code>name</code> is blank, 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></td></tr><tr><td><code>key</code></td><td><code>string</code></td></tr><tr><td><code>name</code></td><td><code>string</code></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>Promise<boolean></code>: <code>false</code> when no recording writes <code>attachmentId</code>; it can then be saved whole.</p><h3><code>getRecordingsDirectory</code></h3><pre><code class=\"language-application-typescript\">getRecordingsDirectory(): Promise<string></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><p><strong>Returns</strong> <code>Promise<string></code></p><h3><code>onStateChanged</code></h3><pre><code class=\"language-application-typescript\">onStateChanged(callback: (state: TranscriptionState) => void): () => void</code></pre><p>Calls <code>callback</code> every time the state changes, in 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) => void</code></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>() => void</code>: A function that removes the listener.</p><h3><code>onLevel</code></h3><pre><code class=\"language-application-typescript\">onLevel(callback: (source: TranscriptSource, level: number) => void): () => void</code></pre><p>Calls <code>callback</code> with the RMS, from 0 to 1, of every chunk a source of the running recording delivers, 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) => void</code></td></tr></tbody></table></figure><p><strong>Returns</strong> <code>() => void</code>: A function that stops the calls.</p><h2><code>ElectronContextMenuParams</code></h2><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><h2><code>BackupPassphraseStatus</code></h2><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><h2><code>BackupPassphraseChange</code></h2><p>What became of a request to change the stored backup passphrase.</p><pre><code class=\"language-application-typescript\">type BackupPassphraseChange = \"applied\" | \"cancelled\" | \"unavailable\"</code></pre><h2><code>OneNoteLoginResult</code></h2><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><h2><code>NativeExportResult</code></h2><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><h2><code>NativeImportPickResult</code></h2><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><h2><code>NativeImportOptions</code></h2><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><h2><code>NativeImportResult</code></h2><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><h2><code>NativeDirectoryPickResult</code></h2><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><h2><code>NativeBackupPickResult</code></h2><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><h2><code>TranscriptionState</code></h2><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>TranscriptionStatus</code></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<Record<TranscriptSource, TranscriptSourceIssue>></code> <br>While recording, the sources whose audio is not being transcribed, and why; absent when every source delivers sound.</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><h2><code>NativeImportPickedFile</code></h2><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><h2><code>TranscriptionStatus</code></h2><p>Phase of the meeting transcription; at most one recording runs at a time.</p><pre><code class=\"language-application-typescript\">type TranscriptionStatus = \"idle\" | \"starting\" | \"recording\" | \"stopping\"</code></pre><h2><code>TranscriptSourceIssue</code></h2><p>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.</p><pre><code class=\"language-application-typescript\">type TranscriptSourceIssue = \"not_captured\" | \"no_audio\" | \"silent\"</code></pre><h2><code>RendererStartupMetric</code></h2><p>Startup milestones the renderer may report to the main process for startup timing instrumentation (see <code>apps/desktop/src/services/startup_metrics.ts</code>).</p><ul><li><code>client-full-render</code> — the client finished its initial render: the layout widgets are attached to the DOM, the froca note cache is loaded, and a frame of the rendered layout has been painted.</li></ul><pre><code class=\"language-application-typescript\">type RendererStartupMetric = \"client-full-render\"</code></pre>",+ "_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. Use <code>\"system\"</code> to follow the OS setting.</p></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></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></td></tr><tr><td><code>onEnterFullScreen</code></td><td><pre><code class=\"language-application-typescript\">onEnterFullScreen(callback: () => 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: () => 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></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>Toggles the always-on-top (pinned) state of the window.</p></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 (e.g. <code>\"mica\"</code>, <code>\"acrylic\"</code>, <code>\"tabbed\"</code>, <code>\"none\"</code>) applied behind the window contents. No-op on other platforms.</p></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 (e.g. <code>\"sidebar\"</code>, <code>\"under-window\"</code>, <code>\"fullscreen-ui\"</code>) applied behind the window contents. No-op on other platforms.</p></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<void></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></td></tr><tr><td><code>onGlobalShortcut</code></td><td><pre><code class=\"language-application-typescript\">onGlobalShortcut(callback: (actionName: string) => void): void</code></pre><p>Subscribes to globally registered keyboard shortcuts. The callback receives the logical action name (not the keystroke).</p></td></tr><tr><td><code>onOpenInSameTab</code></td><td><pre><code class=\"language-application-typescript\">onOpenInSameTab(callback: (noteId: string) => 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></td></tr><tr><td><code>onDevToolsDockChanged</code></td><td><pre><code class=\"language-application-typescript\">onDevToolsDockChanged(callback: (docked: boolean) => void): void</code></pre><p>Subscribes to changes of the DevTools docking state. <code>docked</code> is <code>true</code> only while DevTools is attached to this window — where Chromium disables the native window material (Mica / vibrancy) — and <code>false</code> when it is closed or in a separate window.</p></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></td></tr><tr><td><code>readText</code></td><td><pre><code class=\"language-application-typescript\">readText(): Promise<string></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<string></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></td></tr><tr><td><code>openPath</code></td><td><pre><code class=\"language-application-typescript\">openPath(path: string): Promise<string></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><p><strong>Returns</strong> <code>Promise<string></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></td></tr><tr><td><code>openFileUrl</code></td><td><pre><code class=\"language-application-typescript\">openFileUrl(fileUrl: string): Promise<string></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><p><strong>Returns</strong> <code>Promise<string></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></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></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) => void): void</code></pre><p>Subscribes to right-click events forwarded from the main process.</p></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. <code>\"insertText\"</code> requires the <code>text</code> argument; the other actions ignore it.</p></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></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></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 (<code>0..100</code>) from the renderer to the main process.</p></td></tr><tr><td><code>onPrintProgress</code></td><td><pre><code class=\"language-application-typescript\">onPrintProgress(callback: (data: { progress: number; action: string }) => void): void</code></pre><p>Subscribes to progress updates emitted by the main process during a print or PDF export run. <code>action</code> describes the current stage (e.g. <code>\"rendering\"</code>).</p></td></tr><tr><td><code>onPrintDone</code></td><td><pre><code class=\"language-application-typescript\">onPrintDone(callback: (printReport: unknown, liveJobId?: number) => void): void</code></pre><p>Subscribes to the \"print finished\" event, fired once the OS print job is dispatched. <code>liveJobId</code> names the live print the job ended, for a job that printed the app window itself.</p></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<unknown[]></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<string, unknown>): 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></td></tr><tr><td><code>onExportAsPdfPreviewResult</code></td><td><pre><code class=\"language-application-typescript\">onExportAsPdfPreviewResult(callback: (result: { buffer?: Uint8Array<ArrayBufferLike>; error?: string; requestId?: number }) => void): void</code></pre><p>Subscribes to the result of an <code>exportAsPdfPreview</code> call.</p></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. <code>title</code> is used as the suggested filename.</p></td></tr><tr><td><code>printFromPreview</code></td><td><pre><code class=\"language-application-typescript\">printFromPreview(opts: Record<string, unknown>): void</code></pre><p>Sends the previewed PDF to the OS print dialog with the given options.</p></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></td></tr><tr><td><code>onDidNavigate</code></td><td><pre><code class=\"language-application-typescript\">onDidNavigate(callback: () => 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: () => 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></td></tr><tr><td><code>onMessage</code></td><td><pre><code class=\"language-application-typescript\">onMessage(callback: (message: unknown) => void): () => void</code></pre><p>Subscribes to messages pushed from the main process. Returns 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<boolean></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></td></tr><tr><td><code>setBackendScriptingEnabled</code></td><td><pre><code class=\"language-application-typescript\">setBackendScriptingEnabled(enabled: boolean): Promise<boolean></code></pre><p>Requests backend script execution be turned on or off.</p></td></tr><tr><td><code>setSqlConsoleEnabled</code></td><td><pre><code class=\"language-application-typescript\">setSqlConsoleEnabled(enabled: boolean): Promise<boolean></code></pre><p>Requests the SQL console be turned on or off.</p></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<BackupPassphraseStatus></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<BackupPassphraseChange></code></pre><p>Stores a passphrase, replacing any existing one, once the user has confirmed it.</p></td></tr><tr><td><code>clear</code></td><td><pre><code class=\"language-application-typescript\">clear(): Promise<BackupPassphraseChange></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<OneNoteLoginResult></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<NativeExportResult></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></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<NativeImportPickResult></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<NativeImportPickResult></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></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<NativeImportResult></code></pre><p>Imports the file behind <code>token</code> into <code>parentNoteId</code>. Progress/success/error are reported over the WebSocket via <code>taskId</code>, matching the HTTP import path. 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. \"obsidian\"), mirroring the HTTP route's format tag.</p></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<NativeDirectoryPickResult></code></pre><p>Prompts a native \"select folder\" dialog, starting at <code>defaultPath</code> when it is given. 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></td></tr><tr><td><code>confirmStartOver</code></td><td><pre><code class=\"language-application-typescript\">confirmStartOver(): Promise<boolean></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<NativeBackupPickResult></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<boolean></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<string></code></pre><p>Starts recording the microphone and the system audio for the meeting note <code>noteId</code>.</p><p><strong>Returns</strong> <code>Promise<string></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<void></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<TranscriptionState></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<boolean></code></pre><p>Names a speaker of the transcript attachment <code>attachmentId</code>, or restores the default name when <code>name</code> is blank, if a running recording writes that transcript. The recording applies it, so no utterance it writes meanwhile is lost.</p><p><strong>Returns</strong> <code>Promise<boolean></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<string></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) => void): () => void</code></pre><p>Calls <code>callback</code> every time the state changes, in any window.</p><p><strong>Returns</strong> <code>() => 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) => void): () => void</code></pre><p>Calls <code>callback</code> with the RMS, from 0 to 1, of every chunk a source of the running recording delivers, about four times a second per source.</p><p><strong>Returns</strong> <code>() => void</code>: A function that stops the calls.</p></td></tr></tbody></table></figure><h2><code>ElectronContextMenuParams</code></h2><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><h2><code>BackupPassphraseStatus</code></h2><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><h2><code>BackupPassphraseChange</code></h2><p>What became of a request to change the stored backup passphrase.</p><pre><code class=\"language-application-typescript\">type BackupPassphraseChange = \"applied\" | \"cancelled\" | \"unavailable\"</code></pre><h2><code>OneNoteLoginResult</code></h2><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><h2><code>NativeExportResult</code></h2><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><h2><code>NativeImportPickResult</code></h2><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><h2><code>NativeImportOptions</code></h2><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><h2><code>NativeImportResult</code></h2><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><h2><code>NativeDirectoryPickResult</code></h2><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><h2><code>NativeBackupPickResult</code></h2><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><h2><code>TranscriptionState</code></h2><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>TranscriptionStatus</code></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<Record<TranscriptSource, TranscriptSourceIssue>></code> <br>While recording, the sources whose audio is not being transcribed, and why; absent when every source delivers sound.</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><h2><code>NativeImportPickedFile</code></h2><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><h2><code>TranscriptionStatus</code></h2><p>Phase of the meeting transcription; at most one recording runs at a time.</p><pre><code class=\"language-application-typescript\">type TranscriptionStatus = \"idle\" | \"starting\" | \"recording\" | \"stopping\"</code></pre><h2><code>TranscriptSourceIssue</code></h2><p>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.</p><pre><code class=\"language-application-typescript\">type TranscriptSourceIssue = \"not_captured\" | \"no_audio\" | \"silent\"</code></pre><h2><code>RendererStartupMetric</code></h2><p>Startup milestones the renderer may report to the main process for startup timing instrumentation (see <code>apps/desktop/src/services/startup_metrics.ts</code>).</p><ul><li><code>client-full-render</code> — the client finished its initial render: the layout widgets are attached to the DOM, the froca note cache is loaded, and a frame of the rendered layout has been painted.</li></ul><pre><code class=\"language-application-typescript\">type RendererStartupMetric = \"client-full-render\"</code></pre>","_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 <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 <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 <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 <a class=\"reference-link\" href=\"#root/_help_zEY4DaJG4YT5\">Attributes</a>.</li><li>When a new <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> note is created empty, a <a class=\"reference-link\" href=\"#root/_help_m3VlURMSeOrd\">New note type switcher</a> 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> 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> have a new inline title 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 <a class=\"reference-link\" href=\"#root/_help_l0tKav7yLHGF\">Day Notes</a> is now shown underneath the title.<ul><li>Whether the section is collapsed or not depends on the choice in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → Appearance.</li></ul></li><li><em>Search Properties</em>, which appears for the full <a class=\"reference-link\" href=\"#root/_help_eIg8jdvaoNNd\">Search</a> and <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> which appears in the <a class=\"reference-link\" href=\"#root/_help_B5dihXRDksTk\">Note badges</a> area 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 <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> 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 <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 <a class=\"reference-link\" href=\"#root/_help_KRlZFoIH0j6p\">Connections tab</a> 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 <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 <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> 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 <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 <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 <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> 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 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. </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/Electron API.md b/docs/User Guide/User Guide/Scripting/Script API/Electron API.mdindex 32b8fe73ab..b77d9b7549 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@@ -33,834 +33,437 @@ The runtime value lives in `apps/desktop/src/preload.ts`; this interface is theWindow-level controls: zoom, theme, title bar, full screen, lifecycle, and a handful of main → renderer event subscriptions.-### `setZoomFactor`+<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. Use <code>"system"</code> to follow the OS setting.</p></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></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></td>+ </tr>+ <tr>+ <td><code>onEnterFullScreen</code></td>+ <td><pre><code class="language-application-typescript">onEnterFullScreen(callback: () => 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: () => 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></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>Toggles the always-on-top (pinned) state of the window.</p></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 (e.g. <code>"mica"</code>, <code>"acrylic"</code>, <code>"tabbed"</code>, <code>"none"</code>) applied behind the window contents. No-op on other platforms.</p></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 (e.g. <code>"sidebar"</code>, <code>"under-window"</code>, <code>"fullscreen-ui"</code>) applied behind the window contents. No-op on other platforms.</p></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<void></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></td>+ </tr>+ <tr>+ <td><code>onGlobalShortcut</code></td>+ <td><pre><code class="language-application-typescript">onGlobalShortcut(callback: (actionName: string) => void): void</code></pre><p>Subscribes to globally registered keyboard shortcuts. The callback receives the logical action name (not the keystroke).</p></td>+ </tr>+ <tr>+ <td><code>onOpenInSameTab</code></td>+ <td><pre><code class="language-application-typescript">onOpenInSameTab(callback: (noteId: string) => 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></td>+ </tr>+ <tr>+ <td><code>onDevToolsDockChanged</code></td>+ <td><pre><code class="language-application-typescript">onDevToolsDockChanged(callback: (docked: boolean) => void): void</code></pre><p>Subscribes to changes of the DevTools docking state. <code>docked</code> is <code>true</code> only while DevTools is attached to this window — where Chromium disables the native window material (Mica / vibrancy) — and <code>false</code> when it is closed or in a separate window.</p></td>+ </tr>+ </tbody>+</table>-```typescript-setZoomFactor(factor: number): void-```--Sets the page zoom factor for the current window.--| Parameter | Description |-| --- | --- |-| `factor` | `number` <br>`1.0` is 100%; e.g. `1.2` zooms to 120%. |--### `getZoomFactor`--```typescript-getZoomFactor(): number-```--Returns the current page zoom factor (`1.0` = 100%).--**Returns** `number`--### `setNativeThemeSource`--```typescript-setNativeThemeSource(source: "system" | "light" | "dark"): void-```--Overrides the operating system's reported color scheme for this app. Use `"system"` to follow the OS setting.--| Parameter | Description |-| --- | --- |-| `source` | `"system" \| "light" \| "dark"` |--### `setTitleBarOverlay`--```typescript-setTitleBarOverlay(options: { color: string; symbolColor: string; height?: number }): void-```--Customizes the Windows and Linux native title bar overlay (the area containing the minimize / maximize / close buttons). `height` 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 `setWindowButtonPosition`.--| Parameter | Description |-| --- | --- |-| `options` | `{ color: string; symbolColor: string; height?: number }` |--### `setWindowButtonPosition`--```typescript-setWindowButtonPosition(position: { x: number; y: number }): void-```--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.--| Parameter | Description |-| --- | --- |-| `position` | `{ x: number; y: number }` |--### `onEnterFullScreen`--```typescript-onEnterFullScreen(callback: () => void): void-```--Registers a callback fired whenever the window enters full-screen mode.--| Parameter | Description |-| --- | --- |-| `callback` | `() => void` |--### `onLeaveFullScreen`--```typescript-onLeaveFullScreen(callback: () => void): void-```--Registers a callback fired whenever the window leaves full-screen mode.--| Parameter | Description |-| --- | --- |-| `callback` | `() => void` |--### `isFullScreen`--```typescript-isFullScreen(): boolean-```--Synchronously returns whether the window is currently in full-screen mode.--**Returns** `boolean`--### `setFullScreen`--```typescript-setFullScreen(enabled: boolean): void-```--Enters or leaves full-screen mode.--| Parameter | Description |-| --- | --- |-| `enabled` | `boolean` |--### `minimizeWindow`--```typescript-minimizeWindow(): void-```--Minimizes the current window to the taskbar / dock.--### `maximizeWindow`--```typescript-maximizeWindow(): void-```--Maximizes the current window to fill the available screen area.--### `unmaximizeWindow`--```typescript-unmaximizeWindow(): void-```--Restores the window from a maximized state to its previous size.--### `isMaximized`--```typescript-isMaximized(): boolean-```--Synchronously returns whether the window is currently maximized.--**Returns** `boolean`--### `closeWindow`--```typescript-closeWindow(): void-```--Closes the current window.--### `isAlwaysOnTop`--```typescript-isAlwaysOnTop(): boolean-```--Synchronously returns whether the window is pinned above all others.--**Returns** `boolean`--### `setAlwaysOnTop`--```typescript-setAlwaysOnTop(enabled: boolean): void-```--Toggles the always-on-top (pinned) state of the window.--| Parameter | Description |-| --- | --- |-| `enabled` | `boolean` |--### `toggleDevTools`--```typescript-toggleDevTools(): void-```--Opens or closes Chromium DevTools for the current window.--### `isDevToolsDocked`--```typescript-isDevToolsDocked(): boolean-```--Synchronously returns whether DevTools is currently open and docked into this window (as opposed to detached into a separate window).--**Returns** `boolean`--### `setBackgroundMaterial`--```typescript-setBackgroundMaterial(material: string): void-```--Sets the Windows 11 backdrop material (e.g. `"mica"`, `"acrylic"`, `"tabbed"`, `"none"`) applied behind the window contents. No-op on other platforms.--| Parameter | Description |-| --- | --- |-| `material` | `string` |--### `setVibrancy`--```typescript-setVibrancy(vibrancy: string): void-```--Sets the macOS vibrancy effect (e.g. `"sidebar"`, `"under-window"`, `"fullscreen-ui"`) applied behind the window contents. No-op on other platforms.--| Parameter | Description |-| --- | --- |-| `vibrancy` | `string` |--### `reloadAllWindows`--```typescript-reloadAllWindows(): void-```--Triggers a hard reload of every open Trilium window.--### `restartApp`--```typescript-restartApp(): void-```--Quits the app and immediately relaunches it.--### `toggleAllWindows`--```typescript-toggleAllWindows(): void-```--Shows all hidden windows or hides all visible ones — used by the "show/hide app" global shortcut and tray menu entry.--### `clearCache`--```typescript-clearCache(): Promise<void>-```--Clears the underlying Chromium HTTP cache. Resolves once the cache is empty.--**Returns** `Promise<void>`--### `showWindow`--```typescript-showWindow(): void-```--Brings the main window to the foreground, restoring it if minimized.--### `reportStartupMetric`--```typescript-reportStartupMetric(metric: "client-full-render"): void-```--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.--| Parameter | Description |-| --- | --- |-| `metric` | `"client-full-render"` |--### `onGlobalShortcut`--```typescript-onGlobalShortcut(callback: (actionName: string) => void): void-```--Subscribes to globally registered keyboard shortcuts. The callback receives the logical action name (not the keystroke).--| Parameter | Description |-| --- | --- |-| `callback` | `(actionName: string) => void` |--### `onOpenInSameTab`--```typescript-onOpenInSameTab(callback: (noteId: string) => void): void-```--Subscribes to "open note in active tab" requests originating from outside the renderer (e.g. tray menu, deep links).--| Parameter | Description |-| --- | --- |-| `callback` | `(noteId: string) => void` |--### `onDevToolsDockChanged`--```typescript-onDevToolsDockChanged(callback: (docked: boolean) => void): void-```--Subscribes to changes of the DevTools docking state. `docked` is `true` only while DevTools is attached to this window — where Chromium disables the native window material (Mica / vibrancy) — and `false` when it is closed or in a separate window.--| Parameter | Description |-| --- | --- |-| `callback` | `(docked: boolean) => void` |--## `ElectronClipboardApi`--Renderer access to the system clipboard for cases the standard Web API can't cover.--### `copyImageToClipboard`--```typescript-copyImageToClipboard(buffer: Uint8Array): void-```--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.--| Parameter | Description |-| --- | --- |-| `buffer` | `Uint8Array` |--### `readText`--```typescript-readText(): Promise<string>-```--Reads plain text from the system clipboard via the main-process `electron.clipboard`. Used instead of `navigator.clipboard.readText()` so the renderer's deny-by-default permission policy does not have to grant the sensitive `clipboard-read` permission to the whole session.--**Returns** `Promise<string>`--### `readHTML`--```typescript-readHTML(): Promise<string>-```--Reads the HTML flavor of the system clipboard, the same way as `readText`. Empty when the clipboard has no HTML.--**Returns** `Promise<string>`--## `ElectronShellApi`--Wrappers around Electron's `shell` module for interacting with the OS (default browser, default file handler, downloads, etc.).--Every method here is validated in the main process before dispatch — see `apps/server/src/services/shell_validators.ts`. The renderer is treated as untrusted: invalid input throws on the main side rather than being silently passed through to `electron.shell` / `WebContents`.--### `openExternal`--```typescript-openExternal(url: string): void-```--Opens a URL in the user's default external browser via `electron.shell.openExternal`.--**Security:** the scheme is matched against the allowlist in `SHELL_OPEN_EXTERNAL_PROTOCOLS` (commons). Blocked schemes include `file:`, `data:`, `smb:`, `ldap:`, `ldaps:`, `jar:`, and `view-source:` — they cover Follina-class RCE primitives (`ms-msdt:`, `search-ms:`), NTLM credential theft, and Java loader vectors. URLs that fail to parse are rejected outright.--| Parameter | Description |-| --- | --- |-| `url` | `string` |--### `openPath`--```typescript-openPath(path: string): Promise<string>-```--Opens a local path with its default OS handler.--**Security:** 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.--| Parameter | Description |-| --- | --- |-| `path` | `string` |--**Returns** `Promise<string>`: An empty string on success, or an error message on failure.--### `showItemInFolder`--```typescript-showItemInFolder(path: string): void-```--Shows a local file in the OS file manager, with the file itself selected, via `electron.shell.showItemInFolder`. For pointing at a file the user is not meant to open — the database, whose reader is Trilium itself.--**Security:** the same sandbox as `openPath`, with the database file added as a root of its own, since `TRILIUM_DOCUMENT_PATH` 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.--Nothing is reported back: the OS is asked to bring a window forward, and whether it did is not something Electron answers.--| Parameter | Description |-| --- | --- |-| `path` | `string` |--### `openFileUrl`--```typescript-openFileUrl(fileUrl: string): Promise<string>-```--Opens a `file://` URL with its default OS handler. Exists as a separate channel from `openExternal` because neither Electron API opens every target correctly on Windows: `shell.openExternal` mishandles Unicode characters in `file:` URLs, while `shell.openPath` opens a directory with the Explorer-specific `explore` verb, bypassing the user's file manager. The main process picks between them per target.--**Security:** the URL must use the `file:` scheme and must have an empty hostname. UNC paths (`file://attacker.example/share/x`) are explicitly blocked because Windows would otherwise resolve them to `\\attacker.example\share\x` and leak the user's NTLM hash via SMB authentication. Drive-letter-as-host malformations like `file://C:/path` are normalized to `file:///C:/path` before parsing.--Note: unlike `openPath`, the resolved path is NOT confined to the Trilium data / tmp directories — this channel handles user-clicked `file://` links inside note content, which routinely reference arbitrary locations on disk (`file:///C:/Users/me/Documents/contract.pdf` and similar). Equivalent to a browser following a `file:` link the user clicked. Treat clicks on attacker-influenced note content accordingly.--| Parameter | Description |-| --- | --- |-| `fileUrl` | `string` |--**Returns** `Promise<string>`: An empty string on success, or an error message on failure.--### `downloadURL`--```typescript-downloadURL(url: string): void-```--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.--**Security:** locked to the renderer's own origin. The scheme, hostname, and port must all match the running app's origin (`http://localhost:PORT` for the dev server, or the custom `trilium-app://app/` protocol for packaged Electron). Cross-origin downloads, hostless URLs (`data:`, `blob:`, `about:`, plain `file:///`), 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.--| Parameter | Description |-| --- | --- |-| `url` | `string` |--### `openCustom`--```typescript-openCustom(filePath: string): void-```--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.--**Security:** 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 `saveToTmpDir`; anything else (the data dir itself, paths elsewhere on disk, null bytes, empty strings) is rejected.--| Parameter | Description |-| --- | --- |-| `filePath` | `string` |--## `ElectronContextMenuApi`--Bridge for the native context menu shown over web contents.--### `onContextMenu`--```typescript-onContextMenu(callback: (params: ElectronContextMenuParams) => void): void-```--Subscribes to right-click events forwarded from the main process.--| Parameter | Description |-| --- | --- |-| `callback` | `(params: ElectronContextMenuParams) => void` |--### `webContentsAction`--```typescript-webContentsAction(action: "cut" | "copy" | "paste" | "pasteAndMatchStyle" | "insertText", text?: string): void-```--Executes a clipboard / text-input action on the focused web contents. `"insertText"` requires the `text` argument; the other actions ignore it.--| Parameter | Description |-| --- | --- |-| `action` | `"cut" \| "copy" \| "paste" \| "pasteAndMatchStyle" \| "insertText"` |-| `text` <br>_optional_ | `string` |--## `ElectronSpellcheckApi`--Renderer-side access to Chromium's built-in spell checker.--### `addWordToDictionary`--```typescript-addWordToDictionary(word: string): void-```--Adds a word to the user's personal dictionary so it is no longer flagged.--| Parameter | Description |-| --- | --- |-| `word` | `string` |--### `getAvailableSpellCheckerLanguages`--```typescript-getAvailableSpellCheckerLanguages(): string[]-```--Returns the BCP-47 language tags Chromium can spell-check on this platform.--**Returns** `string[]`--### `setSpellCheckerLanguages`--```typescript-setSpellCheckerLanguages(languageCodes: string[]): void-```--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.--| Parameter | Description |-| --- | --- |-| `languageCodes` | `string[]` |--### `setSpellCheckerEnabled`--```typescript-setSpellCheckerEnabled(enabled: boolean): void-```--Enables or disables the built-in spell checker on every open window's session immediately, without an application restart.--| Parameter | Description |-| --- | --- |-| `enabled` | `boolean` |--## `ElectronSystemIntegrationApi`--OS integration controls — system tray and autostart / launch-on-login.--### `reloadTray`--```typescript-reloadTray(): void-```--Rebuilds the tray icon and menu — call after changing tray-related settings.--### `reapplyLaunchOnStartup`--```typescript-reapplyLaunchOnStartup(): void-```--Re-applies the OS autostart entry after the `launchOnStartup` / `hideOnAutoStart` options change.--## `ElectronPrintingApi`--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.--### `sendPrintProgress`--```typescript-sendPrintProgress(progress: number): void-```--Reports rendering progress (`0..100`) from the renderer to the main process.--| Parameter | Description |-| --- | --- |-| `progress` | `number` |--### `onPrintProgress`--```typescript-onPrintProgress(callback: (data: { progress: number; action: string }) => void): void-```--Subscribes to progress updates emitted by the main process during a print or PDF export run. `action` describes the current stage (e.g. `"rendering"`).--| Parameter | Description |-| --- | --- |-| `callback` | `(data: { progress: number; action: string }) => void` |--### `onPrintDone`--```typescript-onPrintDone(callback: (printReport: unknown, liveJobId?: number) => void): void-```--Subscribes to the "print finished" event, fired once the OS print job is dispatched. `liveJobId` names the live print the job ended, for a job that printed the app window itself.--| Parameter | Description |-| --- | --- |-| `callback` | `(printReport: unknown, liveJobId?: number) => void` |--### `removePrintListeners`--```typescript-removePrintListeners(): void-```--Removes all listeners registered via `onPrintProgress` and `onPrintDone`.--### `getPrinters`--```typescript-getPrinters(): Promise<unknown[]>-```--Returns the list of printers known to the OS.--**Returns** `Promise<unknown[]>`--### `exportAsPdfPreview`+## `ElectronClipboardApi`-```typescript-exportAsPdfPreview(opts: Record<string, unknown>): void-```+Renderer access to the system clipboard for cases the standard Web API can't cover.-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 `onExportAsPdfPreviewResult`.+<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></td>+ </tr>+ <tr>+ <td><code>readText</code></td>+ <td><pre><code class="language-application-typescript">readText(): Promise<string></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<string></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>-| Parameter | Description |-| --- | --- |-| `opts` | `Record<string, unknown>` |+## `ElectronShellApi`-### `onExportAsPdfPreviewResult`+Wrappers around Electron's `shell` module for interacting with the OS (default browser, default file handler, downloads, etc.).-```typescript-onExportAsPdfPreviewResult(callback: (result: { buffer?: Uint8Array<ArrayBufferLike>; error?: string; requestId?: number }) => void): void-```+Every method here is validated in the main process before dispatch — see `apps/server/src/services/shell_validators.ts`. The renderer is treated as untrusted: invalid input throws on the main side rather than being silently passed through to `electron.shell` / `WebContents`.-Subscribes to the result of an `exportAsPdfPreview` call.+<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></td>+ </tr>+ <tr>+ <td><code>openPath</code></td>+ <td><pre><code class="language-application-typescript">openPath(path: string): Promise<string></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><p><strong>Returns</strong> <code>Promise<string></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></td>+ </tr>+ <tr>+ <td><code>openFileUrl</code></td>+ <td><pre><code class="language-application-typescript">openFileUrl(fileUrl: string): Promise<string></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><p><strong>Returns</strong> <code>Promise<string></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></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></td>+ </tr>+ </tbody>+</table>-| Parameter | Description |-| --- | --- |-| `callback` | `(result: { buffer?: Uint8Array<ArrayBufferLike>; error?: string; requestId?: number }) => void` |+## `ElectronContextMenuApi`-### `removeExportAsPdfPreviewResultListener`+Bridge for the native context menu shown over web contents.-```typescript-removeExportAsPdfPreviewResultListener(): void-```+<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) => void): void</code></pre><p>Subscribes to right-click events forwarded from the main process.</p></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. <code>"insertText"</code> requires the <code>text</code> argument; the other actions ignore it.</p></td>+ </tr>+ </tbody>+</table>-Removes the listener registered via `onExportAsPdfPreviewResult`.+## `ElectronSpellcheckApi`-### `savePdf`+Renderer-side access to Chromium's built-in spell checker.-```typescript-savePdf(data: { title: string; buffer: Uint8Array }): void-```+<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></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></td>+ </tr>+ </tbody>+</table>-Persists a previously generated PDF buffer to disk via the native save dialog. `title` is used as the suggested filename.+## `ElectronSystemIntegrationApi`-| Parameter | Description |-| --- | --- |-| `data` | `{ title: string; buffer: Uint8Array }` |+OS integration controls — system tray and autostart / launch-on-login.-### `printFromPreview`+<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>-```typescript-printFromPreview(opts: Record<string, unknown>): void-```+## `ElectronPrintingApi`-Sends the previewed PDF to the OS print dialog with the given options.+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.-| Parameter | Description |-| --- | --- |-| `opts` | `Record<string, unknown>` |+<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 (<code>0..100</code>) from the renderer to the main process.</p></td>+ </tr>+ <tr>+ <td><code>onPrintProgress</code></td>+ <td><pre><code class="language-application-typescript">onPrintProgress(callback: (data: { progress: number; action: string }) => void): void</code></pre><p>Subscribes to progress updates emitted by the main process during a print or PDF export run. <code>action</code> describes the current stage (e.g. <code>"rendering"</code>).</p></td>+ </tr>+ <tr>+ <td><code>onPrintDone</code></td>+ <td><pre><code class="language-application-typescript">onPrintDone(callback: (printReport: unknown, liveJobId?: number) => void): void</code></pre><p>Subscribes to the "print finished" event, fired once the OS print job is dispatched. <code>liveJobId</code> names the live print the job ended, for a job that printed the app window itself.</p></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<unknown[]></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<string, unknown>): 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></td>+ </tr>+ <tr>+ <td><code>onExportAsPdfPreviewResult</code></td>+ <td><pre><code class="language-application-typescript">onExportAsPdfPreviewResult(callback: (result: { buffer?: Uint8Array<ArrayBufferLike>; error?: string; requestId?: number }) => void): void</code></pre><p>Subscribes to the result of an <code>exportAsPdfPreview</code> call.</p></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. <code>title</code> is used as the suggested filename.</p></td>+ </tr>+ <tr>+ <td><code>printFromPreview</code></td>+ <td><pre><code class="language-application-typescript">printFromPreview(opts: Record<string, unknown>): void</code></pre><p>Sends the previewed PDF to the OS print dialog with the given options.</p></td>+ </tr>+ </tbody>+</table>## `ElectronNavigationApi`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.-### `clearNavigationHistory`--```typescript-clearNavigationHistory(): void-```--Clears the entire back/forward navigation history.--### `navigationCanGoBack`--```typescript-navigationCanGoBack(): boolean-```--Synchronously returns whether a back navigation is possible.--**Returns** `boolean`--### `navigationCanGoForward`--```typescript-navigationCanGoForward(): boolean-```--Synchronously returns whether a forward navigation is possible.--**Returns** `boolean`--### `navigationGetAllEntries`--```typescript-navigationGetAllEntries(): { url: string; title: string }[]-```--Returns every entry in the navigation history, oldest first.--**Returns** `{ url: string; title: string }[]`--### `navigationGetActiveIndex`--```typescript-navigationGetActiveIndex(): number-```--Returns the index of the currently active entry inside `navigationGetAllEntries`.--**Returns** `number`--### `navigationLength`--```typescript-navigationLength(): number-```--Returns the total number of entries in the navigation history.--**Returns** `number`--### `navigationGoToIndex`--```typescript-navigationGoToIndex(index: number): void-```--Navigates to the entry at the given index in the history stack.--| Parameter | Description |-| --- | --- |-| `index` | `number` |--### `onDidNavigate`--```typescript-onDidNavigate(callback: () => void): void-```--Subscribes to top-level navigation events (URL changes that load a new document).--| Parameter | Description |-| --- | --- |-| `callback` | `() => void` |--### `onDidNavigateInPage`--```typescript-onDidNavigateInPage(callback: () => void): void-```--Subscribes to in-page navigation events (hash changes, `history.pushState`).--| Parameter | Description |-| --- | --- |-| `callback` | `() => void` |--### `removeDidNavigateListeners`--```typescript-removeDidNavigateListeners(): void-```--Removes all listeners registered via `onDidNavigate` and `onDidNavigateInPage`.+<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></td>+ </tr>+ <tr>+ <td><code>onDidNavigate</code></td>+ <td><pre><code class="language-application-typescript">onDidNavigate(callback: () => 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: () => 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>## `ElectronWsApi`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).-### `send`--```typescript-send(message: unknown): void-```--Sends a message from the renderer to the main-process messaging hub.--| Parameter | Description |-| --- | --- |-| `message` | `unknown` |--### `onMessage`--```typescript-onMessage(callback: (message: unknown) => void): () => void-```--Subscribes to messages pushed from the main process. Returns an unsubscribe function — call it when the listener is no longer needed (e.g. when a BrowserWindow is unloaded) to avoid leaking handlers.--| Parameter | Description |-| --- | --- |-| `callback` | `(message: unknown) => void` |--**Returns** `() => void`+<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></td>+ </tr>+ <tr>+ <td><code>onMessage</code></td>+ <td><pre><code class="language-application-typescript">onMessage(callback: (message: unknown) => void): () => void</code></pre><p>Subscribes to messages pushed from the main process. Returns 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>## `ElectronSecurityApi`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.-### `setLanAccessEnabled`--```typescript-setLanAccessEnabled(enabled: boolean): Promise<boolean>-```--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.--| Parameter | Description |-| --- | --- |-| `enabled` | `boolean` |--**Returns** `Promise<boolean>`--### `setBackendScriptingEnabled`--```typescript-setBackendScriptingEnabled(enabled: boolean): Promise<boolean>-```--Requests backend script execution be turned on or off.--| Parameter | Description |-| --- | --- |-| `enabled` | `boolean` |--**Returns** `Promise<boolean>`--### `setSqlConsoleEnabled`--```typescript-setSqlConsoleEnabled(enabled: boolean): Promise<boolean>-```--Requests the SQL console be turned on or off.--| Parameter | Description |-| --- | --- |-| `enabled` | `boolean` |--**Returns** `Promise<boolean>`+<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<boolean></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></td>+ </tr>+ <tr>+ <td><code>setBackendScriptingEnabled</code></td>+ <td><pre><code class="language-application-typescript">setBackendScriptingEnabled(enabled: boolean): Promise<boolean></code></pre><p>Requests backend script execution be turned on or off.</p></td>+ </tr>+ <tr>+ <td><code>setSqlConsoleEnabled</code></td>+ <td><pre><code class="language-application-typescript">setSqlConsoleEnabled(enabled: boolean): Promise<boolean></code></pre><p>Requests the SQL console be turned on or off.</p></td>+ </tr>+ </tbody>+</table>## `ElectronBackupPassphraseApi`@@ -870,143 +473,116 @@ Deliberately write-only: there is no way to read the passphrase back, so a frontBoth 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.-### `getStatus`--```typescript-getStatus(): Promise<BackupPassphraseStatus>-```--Whether a passphrase can be stored on this system, and whether one already is.--**Returns** `Promise<BackupPassphraseStatus>`--### `set`--```typescript-set(passphrase: string): Promise<BackupPassphraseChange>-```--Stores a passphrase, replacing any existing one, once the user has confirmed it.--| Parameter | Description |-| --- | --- |-| `passphrase` | `string` |--**Returns** `Promise<BackupPassphraseChange>`--### `clear`--```typescript-clear(): Promise<BackupPassphraseChange>-```--Forgets the stored passphrase. Existing backups keep the passphrase they were written with.--**Returns** `Promise<BackupPassphraseChange>`+<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<BackupPassphraseStatus></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<BackupPassphraseChange></code></pre><p>Stores a passphrase, replacing any existing one, once the user has confirmed it.</p></td>+ </tr>+ <tr>+ <td><code>clear</code></td>+ <td><pre><code class="language-application-typescript">clear(): Promise<BackupPassphraseChange></code></pre><p>Forgets the stored passphrase. Existing backups keep the passphrase they were written with.</p></td>+ </tr>+ </tbody>+</table>## `ElectronOneNoteApi`Desktop-only OneNote importer sign-in, driven from the main process via a loopback OAuth redirect.-### `login`--```typescript-login(): Promise<OneNoteLoginResult>-```--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 `connected: false` on failure/timeout).--**Returns** `Promise<OneNoteLoginResult>`+<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<OneNoteLoginResult></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>## `ElectronNativeExportApi`Desktop-native subtree export that streams a `.zip` straight to a file.-### `exportSubtreeToFile`--```typescript-exportSubtreeToFile(opts: { branchId: string; format: string; title: string; taskId: string }): Promise<NativeExportResult>-```--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 `taskId`. Resolves once the dialog is dismissed (`cancelled`) or the export finishes (`saved` / `error`).--| Parameter | Description |-| --- | --- |-| `opts` | `{ branchId: string; format: string; title: string; taskId: string }` |--**Returns** `Promise<NativeExportResult>`+<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<NativeExportResult></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></td>+ </tr>+ </tbody>+</table>## `ElectronNativeImportApi`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.-### `pickFiles`--```typescript-pickFiles(): Promise<NativeImportPickResult>-```--Prompts a native "open file" dialog (multi-select, any type) and returns single-use tokens for the chosen files.--**Returns** `Promise<NativeImportPickResult>`--### `grantDroppedFiles`--```typescript-grantDroppedFiles(files: File[]): Promise<NativeImportPickResult>-```--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 `File` is the unforgeable capability: the path is obtained via `webUtils.getPathForFile`, 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 `cancelled` when no dropped file resolved (e.g. dragged from a browser, not the OS), so the caller falls back to the normal upload route.--| Parameter | Description |-| --- | --- |-| `files` | `File[]` |--**Returns** `Promise<NativeImportPickResult>`--### `importFromToken`--```typescript-importFromToken(opts: { token: string; parentNoteId: string; taskId: string; options: NativeImportOptions; last: boolean; format?: string }): Promise<NativeImportResult>-```--Imports the file behind `token` into `parentNoteId`. Progress/success/error are reported over the WebSocket via `taskId`, matching the HTTP import path. When importing several files in one batch, set `last` only on the final call so the success toast fires once, after everything is in. `format` routes the file to a specific importer (e.g. "obsidian"), mirroring the HTTP route's format tag.--| Parameter | Description |-| --- | --- |-| `opts` | `{ token: string; parentNoteId: string; taskId: string; options: NativeImportOptions; last: boolean; format?: string }` |--**Returns** `Promise<NativeImportResult>`+<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<NativeImportPickResult></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<NativeImportPickResult></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></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<NativeImportResult></code></pre><p>Imports the file behind <code>token</code> into <code>parentNoteId</code>. Progress/success/error are reported over the WebSocket via <code>taskId</code>, matching the HTTP import path. 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. "obsidian"), mirroring the HTTP route's format tag.</p></td>+ </tr>+ </tbody>+</table>## `ElectronDialogApi`Native OS pickers that hand the renderer a location the user chose themselves.-### `pickDirectory`--```typescript-pickDirectory(opts?: { defaultPath?: string }): Promise<NativeDirectoryPickResult>-```--Prompts a native "select folder" dialog, starting at `defaultPath` when it is given. 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.--| Parameter | Description |-| --- | --- |-| `opts` <br>_optional_ | `{ defaultPath?: string }` |--**Returns** `Promise<NativeDirectoryPickResult>`--### `confirmStartOver`--```typescript-confirmStartOver(): Promise<boolean>-```--Prompts a native message box before the application restarts into the setup screen, where the user may replace or erase their knowledge base.--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.--**Returns** `Promise<boolean>`+<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<NativeDirectoryPickResult></code></pre><p>Prompts a native "select folder" dialog, starting at <code>defaultPath</code> when it is given. 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></td>+ </tr>+ <tr>+ <td><code>confirmStartOver</code></td>+ <td><pre><code class="language-application-typescript">confirmStartOver(): Promise<boolean></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>## `ElectronRestoreApi`@@ -1014,115 +590,67 @@ Choosing a backup to restore from the desktop, where the file is already on theOnly usable during setup: what it puts forward is restored by the ordinary `POST /api/setup/restore/start`, which refuses once the application is initialized.-### `pickBackup`--```typescript-pickBackup(): Promise<NativeBackupPickResult>-```--Prompts a native "open file" dialog for a `.db` or `.tnbackup` backup and, if one is chosen, makes it the backup waiting to be restored.--**Returns** `Promise<NativeBackupPickResult>`+<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<NativeBackupPickResult></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>## `ElectronTranscriptionApi`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.-### `isSupported`--```typescript-isSupported(): Promise<boolean>-```--Whether this build can transcribe on this computer: `false` when it carries no speech recognition engine for the platform and processor it runs on.--**Returns** `Promise<boolean>`--### `start`--```typescript-start(noteId: string): Promise<string>-```--Starts recording the microphone and the system audio for the meeting note `noteId`.--| Parameter | Description |-| --- | --- |-| `noteId` | `string` |--**Returns** `Promise<string>`: An empty string once recording runs, or an error message when it cannot start.--### `stop`--```typescript-stop(): Promise<void>-```--Stops the recording, once the speech already captured has been transcribed.--**Returns** `Promise<void>`--### `getState`--```typescript-getState(): Promise<TranscriptionState>-```--**Returns** `Promise<TranscriptionState>`--### `renameSpeaker`--```typescript-renameSpeaker(attachmentId: string, key: string, name: string): Promise<boolean>-```--Names a speaker of the transcript attachment `attachmentId`, or restores the default name when `name` is blank, if a running recording writes that transcript. The recording applies it, so no utterance it writes meanwhile is lost.--| Parameter | Description |-| --- | --- |-| `attachmentId` | `string` |-| `key` | `string` |-| `name` | `string` |--**Returns** `Promise<boolean>`: `false` when no recording writes `attachmentId`; it can then be saved whole.--### `getRecordingsDirectory`--```typescript-getRecordingsDirectory(): Promise<string>-```--Returns the directory that keeps the audio and the transcript as produced of each recording while `transcriptionKeepRecordings` is on, creating it if needed.--**Returns** `Promise<string>`--### `onStateChanged`--```typescript-onStateChanged(callback: (state: TranscriptionState) => void): () => void-```--Calls `callback` every time the state changes, in any window.--| Parameter | Description |-| --- | --- |-| `callback` | `(state: TranscriptionState) => void` |--**Returns** `() => void`: A function that removes the listener.--### `onLevel`--```typescript-onLevel(callback: (source: TranscriptSource, level: number) => void): () => void-```--Calls `callback` with the RMS, from 0 to 1, of every chunk a source of the running recording delivers, about four times a second per source.--| Parameter | Description |-| --- | --- |-| `callback` | `(source: TranscriptSource, level: number) => void` |--**Returns** `() => void`: A function that stops the calls.+<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<boolean></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<string></code></pre><p>Starts recording the microphone and the system audio for the meeting note <code>noteId</code>.</p><p><strong>Returns</strong> <code>Promise<string></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<void></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<TranscriptionState></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<boolean></code></pre><p>Names a speaker of the transcript attachment <code>attachmentId</code>, or restores the default name when <code>name</code> is blank, if a running recording writes that transcript. The recording applies it, so no utterance it writes meanwhile is lost.</p><p><strong>Returns</strong> <code>Promise<boolean></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<string></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) => void): () => void</code></pre><p>Calls <code>callback</code> every time the state changes, in any window.</p><p><strong>Returns</strong> <code>() => 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) => void): () => void</code></pre><p>Calls <code>callback</code> with the RMS, from 0 to 1, of every chunk a source of the running recording delivers, about four times a second per source.</p><p><strong>Returns</strong> <code>() => void</code>: A function that stops the calls.</p></td>+ </tr>+ </tbody>+</table>## `ElectronContextMenuParams`