Electron API

The Electron API is the bridge between Trilium's interface and Electron's main process, exposed as the global window.electronApi in the desktop application.

It is not part of the api global of script notes, but frontend scripts running in the desktop application can call it directly. It is undefined in the browser and in the standalone build, so guard calls with if (window.electronApi).

Api

The complete surface exposed to the renderer as window.electronApi via contextBridge. The renderer must access Electron-only functionality through this object — direct require("electron") and @electron/remote are unavailable because nodeIntegration is disabled and contextIsolation is enabled.

The runtime value lives in apps/desktop/src/preload.ts; this interface is the contract both the preload script (satisfies ElectronApi) and the client (window.electronApi) share.

PropertyDescription
windowWindowApi
Window chrome, zoom, theme, lifecycle, and main → renderer events.
clipboardClipboardApi
System clipboard access beyond what the standard Web Clipboard API offers.
shellShellApi
Shell integration — opening URLs, files, and downloads with OS handlers.
contextMenuContextMenuApi
Native context-menu plumbing for right-click events on web contents.
spellcheckSpellcheckApi
Chromium spell checker controls (dictionary, language list).
systemIntegrationSystemIntegrationApi
OS integration — system tray and autostart / launch-on-login.
printingPrintingApi
Printing and PDF export pipeline.
navigationNavigationApi
Read/write access to Chromium's back/forward navigation history.
wsWsApi
In-process bridge that replaces the renderer↔server WebSocket.
securitySecurityApi
Security settings (backend scripting, SQL console) stored outside the DB.
backupPassphraseBackupPassphraseApi
Write-only access to the backup passphrase, kept in the OS keyring.
backupLocationBackupLocationApi
The backup folder, which only the main process stores.
onenoteOneNoteApi
OneNote importer sign-in via a loopback OAuth redirect (desktop only).
nativeExportNativeExportApi
Desktop-native subtree export that streams a .zip straight to a file.
nativeImportNativeImportApi
Desktop-native large-.zip import that reads the user's file in place via a capability token.
dialogDialogApi
Native OS pickers that hand the renderer a location the user chose themselves.
restoreRestoreApi
Choosing a backup to restore during setup, read where it lies rather than uploaded.
transcriptionTranscriptionApi
Meeting transcription: starting and stopping a recording, and following its state.

WindowApi

Window-level controls: zoom, theme, title bar, full screen, lifecycle, and a handful of main → renderer event subscriptions.

MemberDescription
setZoomFactor
setZoomFactor(factor: number): void

Sets the page zoom factor for the current window.

ParameterDescription
factornumber
1.0 is 100%; e.g. 1.2 zooms to 120%.
getZoomFactor
getZoomFactor(): number

Returns the current page zoom factor (1.0 = 100%).

setNativeThemeSource
setNativeThemeSource(source: "system" | "light" | "dark"): void

Overrides the operating system's reported color scheme for this app.

ParameterDescription
source"system" | "light" | "dark"
The color scheme to report, or "system" to follow the OS setting.
setTitleBarOverlay
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.

ParameterDescription
options{ color: string; symbolColor: string; height?: number }
The overlay's background color, the color of the button symbols, and the overlay's height.
setWindowButtonPosition
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.

ParameterDescription
position{ x: number; y: number }
The offset of the buttons from the window's top-left corner.
onEnterFullScreen
onEnterFullScreen(callback: () => void): void

Registers a callback fired whenever the window enters full-screen mode.

onLeaveFullScreen
onLeaveFullScreen(callback: () => void): void

Registers a callback fired whenever the window leaves full-screen mode.

isFullScreen
isFullScreen(): boolean

Synchronously returns whether the window is currently in full-screen mode.

setFullScreen
setFullScreen(enabled: boolean): void

Enters or leaves full-screen mode.

ParameterDescription
enabledboolean
true to enter full-screen mode, false to leave it.
minimizeWindow
minimizeWindow(): void

Minimizes the current window to the taskbar / dock.

maximizeWindow
maximizeWindow(): void

Maximizes the current window to fill the available screen area.

unmaximizeWindow
unmaximizeWindow(): void

Restores the window from a maximized state to its previous size.

isMaximized
isMaximized(): boolean

Synchronously returns whether the window is currently maximized.

closeWindow
closeWindow(): void

Closes the current window.

isAlwaysOnTop
isAlwaysOnTop(): boolean

Synchronously returns whether the window is pinned above all others.

setAlwaysOnTop
setAlwaysOnTop(enabled: boolean): void

Pins the window above all others, or unpins it.

ParameterDescription
enabledboolean
true to pin the window, false to unpin it.
toggleDevTools
toggleDevTools(): void

Opens or closes Chromium DevTools for the current window.

isDevToolsDocked
isDevToolsDocked(): boolean

Synchronously returns whether DevTools is currently open and docked into this window (as opposed to detached into a separate window).

reloadAllWindows
reloadAllWindows(): void

Triggers a hard reload of every open Trilium window.

restartApp
restartApp(): void

Quits the app and immediately relaunches it.

toggleAllWindows
toggleAllWindows(): void

Shows all hidden windows or hides all visible ones — used by the "show/hide app" global shortcut and tray menu entry.

clearCache
clearCache(): Promise<void>

Clears the underlying Chromium HTTP cache. Resolves once the cache is empty.

showWindow
showWindow(): void

Brings the main window to the foreground, restoring it if minimized.

releaseFirstPaint
releaseFirstPaint(): void

Lets the window paint for the first time. The main process holds the first paint of a starting main or extra window, and with it the reveal of the window, until the client has rendered its interface, so that the window never shows a half-built one. No-op for other windows and once released.

reportStartupMetric
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.

ParameterDescription
metric"client-full-render"
The milestone the renderer reached.
onGlobalShortcut
onGlobalShortcut(callback: (actionName: string) => void): void

Subscribes to globally registered keyboard shortcuts.

ParameterDescription
callback(actionName: string) => void
Receives the name of the action the shortcut triggers, not the keystroke.
onOpenInSameTab
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).

ParameterDescription
callback(noteId: string) => void
Receives the ID of the note to open.
onDevToolsDockChanged
onDevToolsDockChanged(callback: (docked: boolean) => void): void

Subscribes to changes of the DevTools docking state. While DevTools is docked, Chromium disables the native window material (Mica / vibrancy).

ParameterDescription
callback(docked: boolean) => void
Receives true while DevTools is attached to this window, and false when it is closed or in a separate window.

ClipboardApi

Renderer access to the system clipboard for cases the standard Web API can't cover.

MemberDescription
copyImageToClipboard
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.

ParameterDescription
bufferUint8Array
The PNG-encoded image.
readText
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.

readHTML
readHTML(): Promise<string>

Reads the HTML flavor of the system clipboard, the same way as readText. Empty when the clipboard has no HTML.

ShellApi

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.

MemberDescription
openExternal
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.

ParameterDescription
urlstring
The URL to open.
openPath
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, and so is a file whose extension makes the OS run it as a program (.exe, .bat, .ps1, .lnk, .hta, .app, .command, .desktop, an extension in PATHEXT, …): the file was written from a note, which chose its name and content.

ParameterDescription
pathstring
A file in the Trilium data or tmp directory.

Returns Promise<string>: An empty string on success, or an error message on failure.

showItemInFolder
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.

ParameterDescription
pathstring
A file in the Trilium data or tmp directory, or the database file.
openFileUrl
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. A target that would run as a program — an executable extension as refused by openPath, or outside Windows a file with an execute bit — opens only after the user confirms it in a native dialog that defaults to Cancel. One such dialog is shown at a time; a cancel resolves to an empty string.

ParameterDescription
fileUrlstring
A file: URL with an empty hostname.

Returns Promise<string>: An empty string on success, or an error message on failure.

downloadURL
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.

ParameterDescription
urlstring
A URL on the app's own origin.
openCustom
openCustom(filePath: string): Promise<boolean>

Shows the operating system's application chooser for a file: the "Open with" dialog on Windows, the desktop portal's chooser on Linux, and on macOS a picker of the applications in /Applications, which then opens the file in the one chosen. It never falls back to the default application, since "Open externally" already does that.

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.

ParameterDescription
filePathstring
A file in Trilium's tmp directory, as written by saveToTmpDir.

Returns Promise<boolean>: true once the chooser is shown; false if the path is rejected or no chooser is available on this platform.

ContextMenuApi

Bridge for the native context menu shown over web contents.

MemberDescription
onContextMenu
onContextMenu(callback: (params: ContextMenuParams) => void): void

Subscribes to right-click events forwarded from the main process.

ParameterDescription
callback(params: ContextMenuParams) => void
Receives where the user clicked and what is under the cursor.
webContentsAction
webContentsAction(action: "cut" | "copy" | "paste" | "pasteAndMatchStyle" | "insertText", text?: string): void

Executes a clipboard / text-input action on the focused web contents.

ParameterDescription
action"cut" | "copy" | "paste" | "pasteAndMatchStyle" | "insertText"
The action to execute.
text
optional
string
The text to insert. "insertText" requires it; the other actions ignore it.

SpellcheckApi

Renderer-side access to Chromium's built-in spell checker.

MemberDescription
addWordToDictionary
addWordToDictionary(word: string): void

Adds a word to the user's personal dictionary so it is no longer flagged.

getAvailableSpellCheckerLanguages
getAvailableSpellCheckerLanguages(): string[]

Returns the BCP-47 language tags Chromium can spell-check on this platform.

setSpellCheckerLanguages
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.

ParameterDescription
languageCodesstring[]
Language tags returned by getAvailableSpellCheckerLanguages.
setSpellCheckerEnabled
setSpellCheckerEnabled(enabled: boolean): void

Enables or disables the built-in spell checker on every open window's session immediately, without an application restart.

ParameterDescription
enabledboolean
true to enable the spell checker, false to disable it.

SystemIntegrationApi

OS integration controls — system tray and autostart / launch-on-login.

MemberDescription
reloadTray
reloadTray(): void

Rebuilds the tray icon and menu — call after changing tray-related settings.

reapplyLaunchOnStartup
reapplyLaunchOnStartup(): void

Re-applies the OS autostart entry after the launchOnStartup / hideOnAutoStart options change.

PrintingApi

Printing and PDF export flow. Trilium drives Electron's printing pipeline through a small state machine that the main process owns, with progress and results pushed back to the renderer via IPC events.

MemberDescription
sendPrintProgress
sendPrintProgress(progress: number): void

Reports rendering progress from the renderer to the main process.

ParameterDescription
progressnumber
The percentage rendered, from 0 to 100.
onPrintProgress
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.

ParameterDescription
callback(data: { progress: number; action: string }) => void
Receives the percentage done and the current stage, such as "rendering".
onPrintDone
onPrintDone(callback: (printReport: unknown, liveJobId?: number) => void): void

Subscribes to the "print finished" event, fired once the OS print job is dispatched.

ParameterDescription
callback(printReport: unknown, liveJobId?: number) => void
Receives the main process's report on the job, or an error with a message, and, for a job that printed the app window itself, the ID of the live print the job ended.
removePrintListeners
removePrintListeners(): void

Removes all listeners registered via onPrintProgress and onPrintDone.

getPrinters
getPrinters(): Promise<unknown[]>

Returns the list of printers known to the OS.

exportAsPdfPreview
exportAsPdfPreview(opts: Record<string, unknown>): void

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.

ParameterDescription
optsRecord<string, unknown>
The note path, the page size, orientation, scale, margins and page ranges, and a requestId the result echoes back.
onExportAsPdfPreviewResult
onExportAsPdfPreviewResult(callback: (result: { buffer?: Uint8Array<ArrayBufferLike>; error?: string; requestId?: number }) => void): void

Subscribes to the result of an exportAsPdfPreview call.

ParameterDescription
callback(result: { buffer?: Uint8Array<ArrayBufferLike>; error?: string; requestId?: number }) => void
Receives the PDF bytes or an error message, and the requestId of the call the result answers.
removeExportAsPdfPreviewResultListener
removeExportAsPdfPreviewResultListener(): void

Removes the listener registered via onExportAsPdfPreviewResult.

savePdf
savePdf(data: { title: string; buffer: Uint8Array }): void

Persists a previously generated PDF buffer to disk via the native save dialog.

ParameterDescription
data{ title: string; buffer: Uint8Array }
The PDF bytes, and the title to suggest as the file name.
printFromPreview
printFromPreview(opts: Record<string, unknown>): void

Sends the previewed PDF to the OS print dialog with the given options.

ParameterDescription
optsRecord<string, unknown>
The options of exportAsPdfPreview, plus silent to print without the dialog and deviceName to choose the printer.

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.

MemberDescription
clearNavigationHistory
clearNavigationHistory(): void

Clears the entire back/forward navigation history.

navigationCanGoBack
navigationCanGoBack(): boolean

Synchronously returns whether a back navigation is possible.

navigationCanGoForward
navigationCanGoForward(): boolean

Synchronously returns whether a forward navigation is possible.

navigationGetAllEntries
navigationGetAllEntries(): { url: string; title: string }[]

Returns every entry in the navigation history, oldest first.

navigationGetActiveIndex
navigationGetActiveIndex(): number

Returns the index of the currently active entry inside navigationGetAllEntries.

navigationLength
navigationLength(): number

Returns the total number of entries in the navigation history.

navigationGoToIndex
navigationGoToIndex(index: number): void

Navigates to the entry at the given index in the history stack.

ParameterDescription
indexnumber
An index into navigationGetAllEntries.
onDidNavigate
onDidNavigate(callback: () => void): void

Subscribes to top-level navigation events (URL changes that load a new document).

onDidNavigateInPage
onDidNavigateInPage(callback: () => void): void

Subscribes to in-page navigation events (hash changes, history.pushState).

removeDidNavigateListeners
removeDidNavigateListeners(): void

Removes all listeners registered via onDidNavigate and onDidNavigateInPage.

WsApi

In-process replacement for the renderer↔server WebSocket. Backed by Chromium IPC instead of a TCP socket — no port is bound and no auth check is needed because the channel is only reachable from the renderer the BrowserWindow owns. Wire format is whatever the server's MessagingProvider accepts (currently WebSocketMessage / log-error / log-info / ping).

MemberDescription
send
send(message: unknown): void

Sends a message from the renderer to the main-process messaging hub.

ParameterDescription
messageunknown
A message the server's MessagingProvider accepts.
onMessage
onMessage(callback: (message: unknown) => void): () => void

Subscribes to messages pushed from the main process.

ParameterDescription
callback(message: unknown) => void
Receives each message.

Returns () => void: An unsubscribe function. Call it when the listener is no longer needed (e.g. when a BrowserWindow is unloaded) to avoid leaking handlers.

SecurityApi

Security settings that live outside the database (in data_dir/security.json) to prevent malicious scripts from modifying them. Changes require a native OS confirmation dialog and an app restart to take effect.

MemberDescription
setLanAccessEnabled
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.

ParameterDescription
enabledboolean
true to listen on all interfaces, false to listen on loopback only.

Returns Promise<boolean>: true once the user agreed and the change was written.

setBackendScriptingEnabled
setBackendScriptingEnabled(enabled: boolean): Promise<boolean>

Requests backend script execution be turned on or off.

ParameterDescription
enabledboolean
true to allow backend scripts to run, false to block them.
setSqlConsoleEnabled
setSqlConsoleEnabled(enabled: boolean): Promise<boolean>

Requests the SQL console be turned on or off.

ParameterDescription
enabledboolean
true to enable the SQL console, false to disable it.

BackupPassphraseApi

The backup passphrase, kept encrypted by the OS keyring in a file outside the database (the database is what ends up inside the backup, so a passphrase stored there would ride along inside the very container it protects).

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.

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.

MemberDescription
getStatus
getStatus(): Promise<BackupPassphraseStatus>

Whether a passphrase can be stored on this system, and whether one already is.

set
set(passphrase: string): Promise<BackupPassphraseChange>

Stores a passphrase, replacing any existing one, once the user has confirmed it.

ParameterDescription
passphrasestring
The passphrase to encrypt later backups with.
clear
clear(): Promise<BackupPassphraseChange>

Forgets the stored passphrase. Existing backups keep the passphrase they were written with.

BackupLocationApi

The folder that backups are written to. The main process stores it from the folder that the user accepts in the OS dialog, and the options API does not write it, so a frontend script cannot choose where backups go or which folder the backup download reads.

MemberDescription
choose
choose(): Promise<NativeDirectoryPickResult>

Prompts the native folder picker at the current backup folder and, once the user accepts a folder, writes later backups there.

reset
reset(): Promise<void>

Writes later backups to the default folder again.

OneNoteApi

Desktop-only OneNote importer sign-in, driven from the main process via a loopback OAuth redirect.

MemberDescription
login
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).

NativeExportApi

Desktop-native subtree export that streams a .zip straight to a file.

MemberDescription
exportSubtreeToFile
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).

ParameterDescription
opts{ branchId: string; format: string; title: string; taskId: string }
The branch to export, the export format ("html", "markdown" or "share"), the title to suggest as the file name, and the ID of the task that reports progress.

NativeImportApi

Desktop-native import that reads the user's file in place (bounded memory, no temp copy) — the whole point being multi-GB .zip archives, though any importable file is accepted. The renderer never handles a filesystem path: pickFiles runs the OS dialog in the main process and returns opaque capability tokens, which importFromToken redeems. A script can't forge a token or pass a path, so it can never read an arbitrary file.

MemberDescription
pickFiles
pickFiles(): Promise<NativeImportPickResult>

Prompts a native "open file" dialog (multi-select, any type) and returns single-use tokens for the chosen files.

grantDroppedFiles
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.

ParameterDescription
filesFile[]
The files of the drop event.
importFromToken
importFromToken(opts: { token: string; parentNoteId: string; taskId: string; options: NativeImportOptions; last: boolean; format?: string }): Promise<NativeImportResult>

Imports the file behind a token, with progress/success/error reported over the WebSocket like the HTTP import path.

ParameterDescription
opts{ token: string; parentNoteId: string; taskId: string; options: NativeImportOptions; last: boolean; format?: string }
The token to redeem, the parentNoteId to import under, the taskId that reports progress, and the import options. 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.

DialogApi

Native OS pickers that hand the renderer a location the user chose themselves.

MemberDescription
pickDirectory
pickDirectory(opts?: { defaultPath?: string }): Promise<NativeDirectoryPickResult>

Prompts a native "select folder" dialog. The renderer cannot supply the answer: a script can at most pop the dialog, which the user still has to accept before any path comes back.

ParameterDescription
opts
optional
{ defaultPath?: string }
The directory the dialog starts in, as defaultPath.
confirmStartOver
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.

RestoreApi

Choosing a backup to restore from the desktop, where the file is already on the same disk as the database it is going to replace and has no business being uploaded to reach it.

Only usable during setup: what it puts forward is restored by the ordinary POST /api/setup/restore/start, which refuses once the application is initialized.

MemberDescription
pickBackup
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.

TranscriptionApi

Meeting transcription, recorded and transcribed on this computer by the main process. The renderer only starts and stops it; the audio never passes through the renderer.

MemberDescription
isSupported
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.

start
start(noteId: string): Promise<string>

Starts recording the microphone and the system audio for a meeting note.

ParameterDescription
noteIdstring
The meeting note the transcript belongs to.

Returns Promise<string>: An empty string once recording runs, or an error message when it cannot start.

stop
stop(): Promise<void>

Stops the recording, once the speech already captured has been transcribed.

getState
getState(): Promise<TranscriptionState>
renameSpeaker
renameSpeaker(attachmentId: string, key: string, name: string): Promise<boolean>

Names a speaker of a transcript attachment, if a running recording writes that transcript. The recording applies it, so no utterance it writes meanwhile is lost.

ParameterDescription
attachmentIdstring
The transcript attachment.
keystring
The speaker: microphone for the local speaker, system:<n> for an identified speaker of the system audio.
namestring
The name to give, or a blank string to restore the default name.

Returns Promise<boolean>: false when no recording writes attachmentId; it can then be saved whole.

getRecordingsDirectory
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.

onStateChanged
onStateChanged(callback: (state: TranscriptionState) => void): () => void

Subscribes to changes of the transcription state, made from any window.

ParameterDescription
callback(state: TranscriptionState) => void
Receives the new state.

Returns () => void: A function that removes the listener.

onLevel
onLevel(callback: (source: TranscriptSource, level: number) => void): () => void

Subscribes to the audio level of the running recording, about four times a second per source.

ParameterDescription
callback(source: TranscriptSource, level: number) => void
Receives the source and the RMS, from 0 to 1, of each chunk it delivers.

Returns () => void: A function that stops the calls.

Types

ContextMenuParams

Parameters delivered by the main process to the renderer when the user opens the system context menu (right-click) somewhere inside a web view.

Mirrors the subset of fields from Electron's Electron.ContextMenuParams that the renderer actually consumes when building its custom context menu.

PropertyDescription
xnumber
Horizontal position of the click, in CSS pixels, relative to the web view.
ynumber
Vertical position of the click, in CSS pixels, relative to the web view.
linkURLstring
URL of the link the user clicked on, or an empty string if not on a link.
linkTextstring
Visible text of the link the user clicked on, or an empty string.
mediaTypestring
Media kind under the cursor (e.g. "none", "image", "video", "audio").
isEditableboolean
Whether the element under the cursor is editable (input, textarea, contenteditable).
selectionTextstring
Currently selected text, or an empty string if nothing is selected.
misspelledWordstring
The misspelled word under the cursor, or an empty string if none.
dictionarySuggestionsstring[]
Spell-check suggestions for misspelledWord, in order of relevance.
editFlags{ canCut: boolean; canCopy: boolean; canPaste: boolean }
Hints about which clipboard operations are currently available.

BackupPassphraseStatus

What the Options UI needs to know about the stored backup passphrase.

PropertyDescription
availableboolean
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.
setboolean
Whether a passphrase is currently stored.

BackupPassphraseChange

What became of a request to change the stored backup passphrase.

ValueDescription
"applied"The change was confirmed and carried out.
"cancelled"The user declined the OS confirmation, so nothing changed.
"unavailable"There is no keyring on this system to keep a passphrase in.

NativeDirectoryPickResult

Outcome of DialogApi.pickDirectory and BackupLocationApi.choose.

PropertyDescription
status"cancelled" | "selected"
path
optional
string
Absolute path of the chosen directory (when status === "selected").

OneNoteLoginResult

Outcome of a OneNoteApi.login attempt.

PropertyDescription
connectedboolean
True if sign-in completed and a Microsoft Graph token was stored.
account
optional
{ name: string; email: string }
The connected Microsoft account, present when connected is true.
error
optional
string
A human-readable failure reason when connected is false (absent on user cancellation).

NativeExportResult

Outcome of a NativeExportApi.exportSubtreeToFile request.

PropertyDescription
status"cancelled" | "saved" | "error"
filePath
optional
string
Absolute path the archive was written to (when status === "saved").
message
optional
string
Failure detail (when status === "error").

NativeImportPickResult

Outcome of NativeImportApi.pickFiles: capability tokens, never paths.

PropertyDescription
status"cancelled" | "selected"
files
optional
NativeImportPickedFile[]
The user-chosen files (when status === "selected"); one or more, since the dialog allows multi-select.

NativeImportOptions

Import flags forwarded to the native importer (mirrors the HTTP route's options; no path).

PropertyDescription
safeImportboolean
shrinkImagesboolean
textImportedAsTextboolean
codeImportedAsCodeboolean
spreadsheetImportedAsSpreadsheetboolean
drawingImportedAsHandwritingboolean
explodeArchivesboolean
replaceUnderscoresWithSpacesboolean

NativeImportResult

Outcome of NativeImportApi.importFromToken.

PropertyDescription
status"error" | "imported"
importedNoteId
optional
string
Root note of the import (when status === "imported").
message
optional
string
Failure detail (when status === "error").

NativeBackupPickResult

Outcome of RestoreApi.pickBackup: what the chosen backup is, never where it is.

The file itself stays with the main process, which holds it as the one waiting to be restored, so the renderer is given only what the screen has to show and decide with.

PropertyDescription
status"cancelled" | "error" | "selected"
fileName
optional
string
Display name of the chosen backup (when status === "selected").
encrypted
optional
boolean
Whether a passphrase has to be asked for before it can be restored.
message
optional
string
Failure detail (when status === "error"), e.g. setup already being busy.

TranscriptionState

What TranscriptionApi reports to every window.

PropertyDescription
status"idle" | "starting" | "recording" | "stopping"
Phase of the meeting transcription; at most one recording runs at a time.
noteIdstring | null
The meeting note the recording belongs to, or null when idle.
pendingSourcesTranscriptSource[]
The sources heard speaking, or whose speech is still being transcribed.
sourceIssues
optional
Partial<Record<TranscriptSource, "not_captured" | "no_audio" | "silent">>
While recording, the sources whose audio is not being transcribed, and why; absent when every source delivers sound.
Why a source's audio is not being transcribed: its capture did not start (not_captured), it has delivered no audio for 10 s (no_audio), as when its capture hangs, or it has delivered only digital silence for a while (silent), as from a muted device.
startedAt
optional
number
When the recording started, in milliseconds since the epoch: set once it records, kept while it stops, absent otherwise.
error
optional
string
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. getState() never returns it.

TranscriptSource

Where an utterance was heard: the local speaker's microphone, or everyone else on the system output.

type TranscriptSource = "microphone" | "system"

NativeImportPickedFile

A single user-chosen file: a capability token (redeemed to import it) and its display name — never a path.

PropertyDescription
tokenstring
Single-use, short-lived grant for the chosen file.
fileNamestring
Display name of the chosen file.