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
feat(export): export virtual notes as a working copy of their content
Elian Doranccb9b6e329c1
diff --git a/apps/client/src/menus/tree_context_menu.spec.ts b/apps/client/src/menus/tree_context_menu.spec.tsindex ca1edf9d82..c1ee118aa4 100644--- a/apps/client/src/menus/tree_context_menu.spec.ts+++ b/apps/client/src/menus/tree_context_menu.spec.ts@@ -85,6 +85,33 @@ describe("buildTreeContextMenuItems", () => {});});+describe("buildTreeContextMenuItems on system notes", () => {+ async function enabledState(parentId: string, childId: string) {+ vi.spyOn(noteTypesService, "loadNoteTypeData")+ .mockResolvedValue({ builtInTemplateNotes: [], userTemplateNotes: [], newTemplates: new Set() });+ buildNote({ id: parentId, title: "Parent", children: [ { id: childId, title: "Child" } ] });+ const child = froca.notes[childId];+ const [ branch ] = child?.getParentBranches() ?? [];+ if (!child || !branch) throw new Error("expected the child and its branch");++ const items = await buildTreeContextMenuItems({+ note: child, branch, notePath: `${parentId}/${childId}`, component: {} as Component+ });+ const find = (command: TreeCommandNames) => items.find((item) => "command" in item && item.command === command);+ const enabled = (command: TreeCommandNames) => {+ const item = find(command);+ if (!item || "kind" in item) throw new Error(`expected a ${command} row`);+ return item.enabled;+ };+ return { exportNote: enabled("exportNote"), importIntoNote: enabled("importIntoNote") };+ }++ it("exports a help page, which cannot be imported into, and neither for an options page", async () => {+ expect(await enabledState("_helpParent", "_helpPage")).toStrictEqual({ exportNote: true, importIntoNote: false });+ expect(await enabledState("_optionsParent", "_optionsPage")).toStrictEqual({ exportNote: false, importIntoNote: false });+ });+});+describe("getDuplicateItems", () => {it("offers the note-only copy as soon as one of the notes has children", () => {const leaf = buildNote({ title: "Leaf" });diff --git a/apps/client/src/menus/tree_context_menu.ts b/apps/client/src/menus/tree_context_menu.tsindex a5ea0d7a84..ef335520f3 100644--- a/apps/client/src/menus/tree_context_menu.ts+++ b/apps/client/src/menus/tree_context_menu.ts@@ -125,7 +125,8 @@ export async function buildTreeContextMenuItems(ctx: TreeContextMenuContext): Prconst notSearch = note.type !== "search";const hasSubtreeHidden = note.isLabelTruthy("subtreeHidden") ?? false;- const notOptionsOrHelp = !note.noteId.startsWith("_options") && !note.noteId.startsWith("_help");+ const notOptions = !note.noteId.startsWith("_options");+ const notOptionsOrHelp = notOptions && !note.noteId.startsWith("_help");const parentNotSearch = !parentNote || parentNote.type !== "search";const insertNoteAfterEnabled = isNotRoot && !isHoisted && parentNotSearch;@@ -302,7 +303,7 @@ export async function buildTreeContextMenuItems(ctx: TreeContextMenuContext): Pr{ title: t("tree-context-menu.import-into-note"), command: "importIntoNote", uiIcon: "bx bx-import", enabled: notSearch && noSelectedNotes && notOptionsOrHelp },- { title: t("tree-context-menu.export"), command: "exportNote", uiIcon: "bx bx-export", enabled: notSearch && noSelectedNotes && notOptionsOrHelp },+ { title: t("tree-context-menu.export"), command: "exportNote", uiIcon: "bx bx-export", enabled: notSearch && noSelectedNotes && notOptions },{ kind: "separator" },diff --git a/apps/client/src/widgets/layout/NoteActions.spec.tsx b/apps/client/src/widgets/layout/NoteActions.spec.tsxindex cf698021ba..48e3917929 100644--- a/apps/client/src/widgets/layout/NoteActions.spec.tsx+++ b/apps/client/src/widgets/layout/NoteActions.spec.tsx@@ -183,6 +183,33 @@ describe("NoteContextMenu", () => {expect(await isPrintEnabled(buildNote({ title: "Disabled", type: "render", "~disabled:renderNote": script.noteId }))).toBe(false);});+ it("offers to export a help page, but not an options page", async () => {+ const isExportEnabled = async (note: FNote) => {+ const noteContext = new NoteContext("ntx-export");+ noteContext.noteId = note.noteId;+ noteContext.viewScope = { viewMode: "default" };+ render((+ <ParentComponent.Provider value={new Component()}>+ <NoteContextContext.Provider value={noteContext}>+ <NoteContextMenu note={note} noteContext={noteContext} />+ </NoteContextContext.Provider>+ </ParentComponent.Provider>+ ), host);+ host.querySelector<HTMLButtonElement>("button")?.click();+ const exportItem = await vi.waitFor(() => {+ const item = document.querySelector<HTMLElement>(".tn-popup li.dropdown-item:has(.bx-export)");+ expect(item).toBeTruthy();+ return item;+ });+ const enabled = !exportItem?.classList.contains("disabled");+ render(null, host);+ return enabled;+ };++ expect(await isExportEnabled(buildNote({ id: "_helpExportPage", title: "Help page" }))).toBe(true);+ expect(await isExportEnabled(buildNote({ id: "_optionsExportPage", title: "Options page" }))).toBe(false);+ });+it("opens on the Basic Properties shortcut only for its own note context", async () => {const note = buildNote({ title: "Text", type: "text", content: "<p>Hi</p>" });const noteContext = new NoteContext("ntx-split-2");diff --git a/apps/client/src/widgets/layout/NoteActions.tsx b/apps/client/src/widgets/layout/NoteActions.tsxindex 09bc321e7c..e98e08dd8f 100644--- a/apps/client/src/widgets/layout/NoteActions.tsx+++ b/apps/client/src/widgets/layout/NoteActions.tsx@@ -149,7 +149,7 @@ export function NoteContextMenu({ note, noteContext, itemsAtStart, itemsNearNotedisabled={isInOptionsOrHelp || note.type === "search"}command={() => parentComponent?.triggerCommand("showImportDialog", { noteId: note.noteId })} /><CommandItem icon="bx bx-export" text={t("note_actions.export_note")}- disabled={isInOptionsOrHelp || note.noteId === "_backendLog"}+ disabled={note.noteId.startsWith("_options") || note.noteId === "_backendLog"}command={() => noteContext?.notePath && parentComponent?.triggerCommand("showExportDialog", {notePath: noteContext.notePath,defaultType: "single"diff --git a/apps/server/spec/in_app_help.spec.ts b/apps/server/spec/in_app_help.spec.tsindex 2114ac570b..11bdf15317 100644--- a/apps/server/spec/in_app_help.spec.ts+++ b/apps/server/spec/in_app_help.spec.ts@@ -6,6 +6,7 @@ import { getContext } from "@triliumnext/core/src/services/context.js";import { HELP_ASSET_TOKEN, initInAppHelp } from "@triliumnext/core/src/services/in_app_help.js";import { helpTools } from "@triliumnext/core/src/services/llm/tools/help_tools.js";import searchService from "@triliumnext/core/src/services/search/services/search.js";+import { getVirtualNoteAssets } from "@triliumnext/core/src/services/virtual_notes.js";import fs from "fs";import path from "path";import { beforeAll, describe, expect, it } from "vitest";@@ -38,8 +39,7 @@ describe("in-app help (shipped artifacts)", () => {});it("serves the content of every page that ships one, through becca and the blob route", () => {- // Text and code notes carry a page of their own; folders and web views do not.- const pages = flatten(meta).filter((item) => item.type === "text" || item.type === "code");+ const pages = contentPages(meta);expect(pages.length).toBeGreaterThan(0);for (const page of pages) {@@ -58,14 +58,14 @@ describe("in-app help (shipped artifacts)", () => {const assetRoot = path.resolve(__dirname, "../../../docs/User Guide");const missing: string[] = [];- for (const page of flatten(meta).filter((item) => item.source)) {+ for (const page of contentPages(meta)) {const html = String(becca.getNoteOrThrow(page.id).getContent());expect(html, `page ${page.id} still carries an unsubstituted asset placeholder`).not.toContain(HELP_ASSET_TOKEN);for (const match of html.matchAll(/(?:src|href)="([^"]*\/help\/[^"]*)"/g)) {const relative = decodeURIComponent(match[1].split("/help/")[1]);if (!fs.existsSync(path.join(assetRoot, relative))) {- missing.push(`${page.source} -> ${relative}`);+ missing.push(`${page.title} -> ${relative}`);}}}@@ -73,6 +73,23 @@ describe("in-app help (shipped artifacts)", () => {expect(missing).toEqual([]);});+ it("can read every picture and file an export of the guide carries", async () => {+ const unreadable: string[] = [];+ let assetCount = 0;++ for (const page of contentPages(meta)) {+ for (const asset of getVirtualNoteAssets(page.id)) {+ assetCount++;+ if (await asset.getContent() === null) {+ unreadable.push(`${page.id} -> ${asset.url}`);+ }+ }+ }++ expect(assetCount).toBeGreaterThan(0);+ expect(unreadable).toEqual([]);+ });+it("is searchable by its content, but only when the search asks for hidden notes", () => {// A phrase from the body of a page, not from any title.const query = "docker compose";@@ -107,6 +124,11 @@ describe("in-app help (shipped artifacts)", () => {});});+/** Text and code notes carry a page of their own; folders and web views do not. */+function contentPages(items: HelpMetaItem[]) {+ return flatten(items).filter((item) => item.type === "text" || item.type === "code");+}+function flatten(items: HelpMetaItem[], out: HelpMetaItem[] = []): HelpMetaItem[] {for (const item of items) {out.push(item);diff --git a/apps/server/src/assets/help/help_content.json b/apps/server/src/assets/help/help_content.jsonindex c60c319390..0a9a661469 100644--- a/apps/server/src/assets/help/help_content.json+++ b/apps/server/src/assets/help/help_content.json@@ -44,7 +44,7 @@"_help_wyaGBBQrl4i3": "<figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:328/45;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree/1_Hiding%20the%20subtree_image.png\" width=\"328\" height=\"45\"><figcaption>An example of a collection with a relatively large number of children that are hidden from the tree.</figcaption></figure><p>The tree works well when the notes are structured in a hierarchy so that the number of items stays small. When a note has a large number of notes (in the order of thousands or tens of thousands), two problems arise:</p><ul><li>Navigating between notes becomes cumbersome and the tree itself gets cluttered with a large amount of notes.</li><li>The large amount of notes can slow down the application considerably.</li></ul><p>Since v0.102.0, Trilium allows the tree to hide the child notes of particular notes. This works for both <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a> and normal notes.</p><h2>Interaction</h2><p>When the subtree of a note is hidden, there are a few subtle changes:</p><ul><li>To indicate that the subtree is hidden, the note will not have an expand button and it will display the number of children to the right.</li><li>It's not possible to add a new note directly from the tree.<ul><li>For <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a>, it's best to use the built-in mechanism to create notes (for example by creating a new point on a geo-map, or by adding a new row in a table).</li><li>For normal notes, it's still possible to create children via other means such as using the <a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a> system.</li></ul></li><li>Notes can be dragged from outside the note, case in which they will be cloned into it.<ul><li>Instead of switching to the child notes that were copied, the parent note is highlighted instead.</li><li>A notification will indicate this behavior.</li></ul></li><li>Similarly, features such as cut/copy and then paste into the note will also work.</li></ul><h2>Spotlighting</h2><figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:322/83;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree/Hiding%20the%20subtree_image.png\" width=\"322\" height=\"83\"></figure><p>Even if the subtree of a note is hidden, if a child note manages to become active, it will still appear inside the tree in a special state called <em>spotlighted</em>.</p><p>During this state, the note remains under its normal hierarchy, so that its easy to tell its location. In addition, this means that:</p><ul><li>The note position is clearly visible when using the <a class=\"reference-link\" href=\"#root/_help_eIg8jdvaoNNd\">Search</a>.</li><li>The note can still be operated on from the tree, such as adding a <a class=\"reference-link\" href=\"#root/_help_TBwsyfadTA18\">Branch prefix</a> or moving it outside the collection.</li></ul><p>The note appears in italics to indicate its temporary display. When switching to another note, the spotlighted note will disappear.</p><aside class=\"admonition note\"><p>Only one note can be highlighted at the time. When working with multiple notes such as dragging them into the collection, no note will be spotlighted. This is intentional to avoid displaying a partial state of the subtree.</p></aside><h2>Working with collections</h2><p>For large collections, it can be helpful to hide their child notes for performance reasons or de-cluttering the tree.</p><p>To toggle this behavior:</p><ul><li>Open the collection and in <a class=\"reference-link\" href=\"#root/_help_CssoWBu8I7jF\">Collection Properties</a>, look for <em>Hide child notes in tree</em>.</li><li>Right click the collection note in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> and select <em>Advanced</em> → <em>Show subtree</em>.</li></ul><h2>Working with normal notes</h2><p>It's possible to hide the subtree for normal notes as well, not just collections. To do so, right click the note in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> and select <em>Advanced</em> → <em>Hide subtree.</em></p>","_help_3seOhtN8uLIY": "<figure class=\"image image-style-align-center\"><img style=\"aspect-ratio:1119/43;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Tabs_image.png\" width=\"1119\" height=\"43\"></figure><p>In Trilium, tabs allow easy switching between notes.</p><h2>Layout</h2><p>Depending on the <a class=\"reference-link\" href=\"#root/_help_x0JgW8UqGXvq\">Vertical and horizontal layout</a>:</p><ul><li>For the vertical layout, the tabs will be placed at the top but to the right of the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>.</li><li>For the horizontal layout, the tabs will be placed at the top in full-width, above the <a href=\"#root/_help_oPVyFC7WL2Lp\">note tree</a>, allowing for more tabs to be comfortably displayed.</li></ul><h2>Interaction</h2><ul><li>To create a new tab, press the <span class=\"tn-icon bx bx-plus\"></span> button that is to the right of the last tab.</li><li>To close a tab, press the corresponding <span class=\"tn-icon bx bx-x\"></span> button.</li><li>For multitasking, tabs can be used alongside <a class=\"reference-link\" href=\"#root/_help_luNhaphA37EO\">Split View</a>. Each tab can have one or more notes, displayed horizontally.</li><li>Tabs can be reordered by drag-and-dropping it into a new position.</li><li>An existing tab can be displayed in a new window by dragging the tab upwards or downwards. It is not possible to combine tabs back into another window.</li></ul><h2>Keyboard interaction</h2><p>Since tabs are a commonly used feature, there are multiple keyboard shortcuts that can be used:</p><ul><li><kbd>Ctrl</kbd>+<kbd>T</kbd> to open a new tab.</li><li><kbd>Ctrl</kbd>+<kbd>W</kbd> to close the current tab.</li><li><kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>T</kbd> to reopen the last closed tab.</li><li><kbd>Ctrl</kbd>+<kbd>Tab</kbd> and <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Tab</kbd> to go to the next or previous tab.</li><li><kbd>Ctrl</kbd>+<kbd>1</kbd>, <kbd>Ctrl</kbd>+<kbd>2</kbd>, up to <kbd>Ctrl</kbd>+<kbd>9</kbd> to activate the first, second and up to ninth tab.</li><li>There is also a shortcut to go to the last tab, but it is not assigned a key by default.</li></ul><h2>Mobile</h2><figure class=\"image image-style-align-right image_resized\" style=\"width:34.12%;\"><img style=\"aspect-ratio:1242/2688;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Tabs_IMG_1767.PNG\" width=\"1242\" height=\"2688\"></figure><p>Tabs are also supported on the <a class=\"reference-link\" href=\"#root/_help_RDslemsQ6gCp\">Mobile Frontend</a>.</p><p>Since v0.102.0, the tabs are displayed by pressing the dedicated tab switcher button in the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>. In this view the tabs are laid out on a grid with a preview of the note content.</p><p>The context menu button at the top-right of the popup allows creating a new tab, reopening the last closed tab and closing all the tabs.</p><p><a class=\"reference-link\" href=\"#root/_help_luNhaphA37EO\">Split View</a>s are also indicated in the tab switcher, with two titles displayed in a tab.</p><aside class=\"admonition note\"><p>Versions prior to v0.102.0 also supported tabs, but they were displayed directly above the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>. The decision to use a more mobile-like tab switcher was taken because the original tab bar could not support many tabs at once and the new design better aligns with how mobile applications handle tabs.</p></aside>","_help_xYmIYSP6wE3F": "<h2>Position of the Launch bar</h2><p>On desktop, depending on the layout selected, the launcher bar will either be on the left side of the screen with buttons displayed vertically or at the top of the screen. See <a class=\"reference-link\" href=\"#root/_help_x0JgW8UqGXvq\">Vertical and horizontal layout</a> for more information.</p><p>On mobile, the launch bar will always be at the bottom.</p><p>If there are too many items in the launch bar to fit the screen, it will become scrollable.</p><h2>Terminology</h2><ul><li><strong>Launcher</strong>: a button that can be (or is) displayed on the launch bar.</li><li><strong>Available Launcher</strong>: a launcher that is not displayed on the launch bar, but can be added.</li><li><strong>Visible Launcher</strong>: a launcher that is currently displayed on the launch bar.</li></ul><h2>Configuring the desktop Launch bar</h2><p>There are two ways to configure the launch bar:</p><ul><li>Right click in the empty space between launchers on the launch bar and select <em>Configure Launchbar…</em></li><li>Click on the <a class=\"reference-link\" href=\"#root/_help_x3i7MxGccDuM\">Global menu</a> and select <em>Configure Launchbar</em>.</li></ul><p>This will open a new tab with the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> listing the launchers.</p><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Launch%20Bar_image.jpg\"></p><p>Expanding <em>Available Launchers</em> section will show the list of launchers that are not displayed on the launch bar. The <em>Visible Launchers</em> will show the ones that are currently displayed.</p><h2>Configuring the mobile launch bar</h2><p>The launch bar on mobile uses a different configuration from the desktop one. The reasoning is that not all desktop icons are available on mobile, and fewer icons fit on a mobile screen.</p><p>To configure the launch bar on mobile, go to <a class=\"reference-link\" href=\"#root/_help_x3i7MxGccDuM\">Global menu</a> and select <em>Configure Launchbar</em>.</p><p>The configure the mobile launch bar while on the desktop (especially useful to configure more complicated launchers such as scripts or custom widgets), go to <a class=\"reference-link\" href=\"#root/_help_x3i7MxGccDuM\">Global menu</a> → Advanced → Show Hidden Subtree and look for the <em>Mobile Launch Bar</em> section. While in the hidden subtree, it's also possible to drag launchers between the <em>Mobile Launch Bar</em> and (Desktop) <em>Launch Bar</em> sections.</p><h3>Adding/removing and reordering launchers</h3><p>To display a new launcher in the launch bar, first look for it in the <em>Available Launchers</em> section. Then right click it and select <em>Move to visible launchers</em>. It is also possible to drag and drop the item manually.</p><p>Similarly, to remove it from the launch bar, simply look for it in <em>Visible Launchers</em> then right click it and select <em>Move to available launchers</em> or use drag-and-drop.</p><p>Drag-and-drop the items in the tree in order to change their order. See <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> for more interaction options, including using keyboard shortcuts.</p><h2>Customizing the launcher</h2><ul><li>The icon of a launcher can be changed just like a normal note. See <a href=\"#root/_help_p9kXRFAkwN4o\">note icons</a> for more information.</li><li>The title of the launcher can also be changed.</li></ul><h3>Resetting</h3><p>Resetting allows restoring the original configuration of Trilium for the launcher bar, or for a portion of it. Simply right click a launcher (or even the entire <em>Launch Bar</em> section) and select <em>Reset</em> to bring it back to the original state.</p><h3>Creating new launchers / types of launchers</h3><p>Right click either the <em>Available launchers</em> or <em>Visible launchers</em> sections and select one of the options:</p><ol><li><p><strong>Note Launcher</strong><br>A note launcher will simply navigate to a specified note.</p><ol><li>Set the <code>target</code> promoted attribute to the note to navigate to.</li><li>Optionally, set <code>hoistedNote</code> to hoist a particular note. See <a class=\"reference-link\" href=\"#root/_help_OR8WJ7Iz9K4U\">Note Hoisting</a> for more information.</li><li>Optionally, set a <code>keyboardShortcut</code> to trigger the launcher.</li></ol></li><li><p><strong>Script Launcher</strong><br>An advanced launcher which will run a script upon pressing. See <a class=\"reference-link\" href=\"#root/_help_CdNpE2pqjmI6\">Scripting</a> for more information.</p><ol><li>Set <code>script</code> to point to the desired script to run.</li><li>Optionally, set a <code>keyboardShortcut</code> to trigger the launcher.</li></ol></li><li><p><strong>Custom Widget</strong></p><p>Allows defining a custom widget to be rendered inside the launcher. See <a class=\"reference-link\" href=\"#root/_help_SynTBQiBsdYJ\">Widget Basics</a> for more information.</p></li><li><p><strong>Spacers</strong><br>Launchers that create some distance between other launchers for better visual distinction.</p></li></ol><p>Launchers are configured via predefined <a class=\"reference-link\" href=\"#root/_help_OFXdgB2nNk1F\">Promoted Attributes</a>.</p>",- "_help_8YBEPzcpUgxw": "<figure class=\"image image-style-align-right image_resized\" style=\"width:25.95%;\"><img style=\"aspect-ratio:402/988;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Note%20menu_image.png\" width=\"402\" height=\"988\"></figure><p>The note menu contains various actions and configurations for the current note. It can be found in the <a class=\"reference-link\" href=\"#root/_help_1P8QXI5edXNd\">Note buttons</a> area (to the right of the <a class=\"reference-link\" href=\"#root/_help_l7pigIGu01K2\">Title</a>).</p><p>Every split has a note menu of its own, which acts on the note displayed in that split. Entries that don't apply to the current note are still listed but grayed out, while entries that only exist for some notes (described in <em>Note-specific entries</em>) appear only on those notes.</p><h2>Navigating the note</h2><ul><li><span class=\"tn-icon bx bx-search\"></span> <em>Search in note</em> opens the <a class=\"reference-link\" href=\"#root/_help_McngOG2jbUWX\">Search in note</a> bar, to find and replace text inside the current note. On the desktop application, the same bar opens with <kbd>Ctrl</kbd>+<kbd>F</kbd>.<ul><li>It is available on <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>, <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a>, <a class=\"reference-link\" href=\"#root/_help_gBbsAeiuUxI5\">Mind Map</a> and <a class=\"reference-link\" href=\"#root/_help_GWHEkY4I4OE3\">Spreadsheets</a> notes, <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a>, PDF files, and any note displayed as <a class=\"reference-link\" href=\"#root/_help_4FahAwuGTAwC\">Note source</a>.</li></ul></li><li><span class=\"tn-icon bx bx-paperclip\"></span> <em>Note attachments</em> switches the note to the list of its <a class=\"reference-link\" href=\"#root/_help_0vhv7lsOLy82\">Attachments</a>, where they can be uploaded, opened, downloaded, renamed or deleted.</li><li><span class=\"tn-icon bx bxs-network-chart\"></span> <em>Note map</em> opens the <a class=\"reference-link\" href=\"#root/_help_KRlZFoIH0j6p\">Connections tab</a> of the <a class=\"reference-link\" href=\"#root/_help_RnaPdbciOfeq\">Right Sidebar</a>, which shows the <a class=\"reference-link\" href=\"#root/_help_BCkXAVs63Ttv\">Note Map (Link map, Tree map)</a> centered on the current note.</li></ul><h2>Note properties</h2><p>The toggles in this section take effect immediately:</p><ul><li><span class=\"tn-icon bx bx-share-alt\"></span> <em>Shared</em> publishes the note via <a class=\"reference-link\" href=\"#root/_help_R9pX4DGra2Vt\">Sharing</a>, by cloning it into the <em>Shared Notes</em> tree.<ul><li>Turning it off removes the clone from that tree. If the note exists only as a shared note, Trilium asks for confirmation, since unsharing it deletes it.</li><li>The toggle is unavailable on the root note, on the <em>Shared Notes</em> note itself, and on system notes.</li></ul></li><li><span class=\"tn-icon bx bx-lock-alt\"></span> <em>Protect the note</em> encrypts the note, turning it into one of the <a class=\"reference-link\" href=\"#root/_help_bwg0e8ewQMak\">Protected Notes</a>. If no protected session is active, Trilium asks for the password first. Only the current note is affected, not its children.</li><li><span class=\"tn-icon bx bx-bookmark\"></span> <em>Bookmark</em> adds the note to the <a class=\"reference-link\" href=\"#root/_help_u3YFHC9tQlpm\">Bookmarks</a> that are displayed in the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>, or removes it from them.</li><li><span class=\"tn-icon bx bx-copy-alt\"></span> <em>Template</em> marks the note as one of the <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a> (by adding the <code>#template</code> label), which makes it available when creating a new note.</li><li><span class=\"tn-icon bx bx-expand-horizontal\"></span> <em>Full width</em> lets the note use the whole width of the window instead of the limit set in <a class=\"reference-link\" href=\"#root/_help_t596jLvPrqkS\">Content width</a> by adding the <code>#fullContentWidth</code> label. It is not listed for note types that are always displayed at full width.</li></ul><p>The two submenus in this section:</p><ul><li><span class=\"tn-icon bx bx-file\"></span> <em>Note type</em> changes the type of the note to any of the <a class=\"reference-link\" href=\"#root/_help_KSZ04uQ2D1St\">Note Types</a>; the current one is checked. If the note already has content, Trilium asks for confirmation first, since the content generally doesn't carry over. <a class=\"reference-link\" href=\"#root/_help_jludwdW7N4hg\">Converting between note types</a>.<ul><li>For a <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> note, the language is chosen in the <a class=\"reference-link\" href=\"#root/_help_AlJ73vBCjWDw\">Status bar</a> instead.</li></ul></li><li><span class=\"tn-icon bx bx-edit-alt\"></span> <em>Editable</em> controls when the note opens as read-only (see <a class=\"reference-link\" href=\"#root/_help_CoFPLs3dRlXc\">Read-Only Notes</a>):<ul><li><em>Auto</em> (the default): the note is editable, unless it is long enough to be opened as read-only automatically.</li><li><em>Read-only</em>: the note always opens as read-only, but can still be edited after pressing <em>Edit note</em>.</li><li><em>Always Editable</em>: the note is always editable, regardless of its length.</li></ul></li></ul><h2>Importing, exporting and printing</h2><ul><li><span class=\"tn-icon bx bx-import\"></span> <em>Import files</em> opens the import dialog, which imports files as children of the current note. See <a class=\"reference-link\" href=\"#root/_help_mHbBMPDPkVV5\">Import & Export</a>. It is unavailable on <a class=\"reference-link\" href=\"#root/_help_m523cpzocqaD\">Saved Search</a> notes.</li><li><span class=\"tn-icon bx bx-export\"></span> <em>Export note</em> opens the export dialog with <em>Only this note</em> selected; select <em>This note & all descendants</em> there to export the whole subtree.</li><li><span class=\"tn-icon bx bx-printer\"></span><em>Print note…</em> prints the note. On the desktop application this entry reads <em>Print/export to PDF…</em> and can also save the note as a PDF file. See <a class=\"reference-link\" href=\"#root/_help_NRnIZmSMc5sj\">Printing & Exporting as PDF</a>, including which note types and collections can be printed.</li></ul><p>Some note types add their own export formats right below <em>Export note</em>:</p><ul><li><span class=\"tn-icon bx bxs-file-image\"></span><em>Export as image</em>, on <a class=\"reference-link\" href=\"#root/_help_s1aBHPd79XYj\">Mermaid Diagrams</a> and <a class=\"reference-link\" href=\"#root/_help_gBbsAeiuUxI5\">Mind Map</a> notes, downloads the diagram as <em>PNG (raster)</em> or <em>SVG (vector)</em>.</li><li><span class=\"tn-icon bx bxs-spreadsheet\"></span><em>Export to Excel (.xlsx)</em> and <em>Export to CSV (.csv)</em>, on <a class=\"reference-link\" href=\"#root/_help_GWHEkY4I4OE3\">Spreadsheets</a>, download the spreadsheet in those formats.</li></ul><h2>Revisions</h2><p>These entries manage the <a class=\"reference-link\" href=\"#root/_help_vZWERwf8U3nx\">Note Revisions</a> of the note:</p><ul><li><span class=\"tn-icon bx bx-history\"></span><em>Note revisions…</em> opens the revisions dialog, where previous versions can be previewed, compared with the current one, downloaded or restored.</li><li><span class=\"tn-icon bx bx-save\"></span><em>Save revision</em> saves a revision of the note right away, instead of waiting for the next automatic snapshot.</li><li><span class=\"tn-icon bx bx-purchase-tag\"></span><em>Save named revision…</em> also saves a revision right away, but first asks for a short description of the changes, which is shown in the revisions dialog.</li></ul><h2>Note-specific entries</h2><p>The following entries only appear on some notes:</p><ul><li><span class=\"tn-icon bx bx-pencil\"></span><em>Edit note</em> appears at the top of the menu when the note is currently read-only. It enables editing until the note is closed.</li><li><span class=\"tn-icon bx bx-align-justify\"></span><em>Word wrap</em> appears at the top of the menu on <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> notes, and sets whether long lines wrap in this note:<ul><li><em>Auto</em> (the default) follows <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Code Notes</em> → <em>Wrap lines in code notes</em>.</li><li><em>On</em> and <em>Off</em> override it for this note only, by setting the <code>#wrapLines</code> label.</li></ul></li><li><span class=\"tn-icon bx bx-paperclip\"></span><em>Convert into attachment</em> appears on an image note that has no children and a single parent which is a <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> note. After a confirmation, it turns the image into an attachment of its parent note and opens it there. See <a class=\"reference-link\" href=\"#root/_help_0vhv7lsOLy82\">Attachments</a>.</li><li><span class=\"tn-icon bx bx-extension\"></span><em>Re-render note</em> appears on a <a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a>, and runs its script again to refresh the output.</li><li><span class=\"tn-icon bx bx-cog\"></span><em>Board properties</em> appears on a <a class=\"reference-link\" href=\"#root/_help_CtBQqbwXDx1w\">Kanban Board</a>, and configures its columns, card attributes and card templates.</li><li><span class=\"tn-icon bx bx-cog\"></span><em>Calendar properties</em> appears on a <a class=\"reference-link\" href=\"#root/_help_xWbu3jpNWapp\">Calendar</a> that creates events, and configures its event templates.</li><li><span class=\"tn-icon bx bx-cog\"></span><em>Geo map properties</em> appears on a <a class=\"reference-link\" href=\"#root/_help_81SGnPGMk7Xc\">Geo Map</a>, and configures its map settings and the image of an <a href=\"#root/_help_ZRDXGc0nAIh4\">image map</a>.</li><li><span class=\"tn-icon bx bx-cog\"></span><em>Table properties</em> appears on a <a class=\"reference-link\" href=\"#root/_help_2FvYrpmOXm29\">Table</a>, and configures which notes it shows.</li></ul><h2>Advanced</h2><p>The <span class=\"tn-icon bx bx-wrench\"></span><em>Advanced</em> submenu groups the actions that are needed less often:</p><ul><li><p><span class=\"tn-icon bx bx-file-find\"></span><em>Open note externally</em> (desktop application only) saves the note to a temporary file and opens it in the application that the operating system associates with it. Trilium watches the file, and offers to upload the modified version back into the note. It is unavailable on <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a> and <a class=\"reference-link\" href=\"#root/_help_m523cpzocqaD\">Saved Search</a> notes.</p></li><li><p><span class=\"tn-icon bx bx-customize\"></span><em>Open note custom</em> (desktop application only, Windows and Linux) works like <em>Open note externally</em>, but lets you pick the application to open the file with.</p></li><li><p><span class=\"tn-icon bx bx-code\"></span><em>Note source</em> shows the <a class=\"reference-link\" href=\"#root/_help_4FahAwuGTAwC\">Note source</a>, the content of the note exactly as it is stored.</p></li><li><p><span class=\"tn-icon bx bxl-markdown\"></span><em>Convert to Markdown Note</em> (on text notes) and <em>Convert to Text Note</em> (on Markdown notes) switch the note between rich text and Markdown. After a confirmation, Trilium saves a revision and converts the content; the revision allows going back if some formatting was lost. See <a class=\"reference-link\" href=\"#root/_help_jludwdW7N4hg\">Converting between note types</a>.</p></li><li><p><span class=\"tn-icon bx bx-collapse-alt\"></span><em>Compress images</em> opens a dialog that reduces the size of the images in the note. It lists the images found and how much space they take, and offers to:</p><ul><li>Resize the images larger than a chosen size.</li><li>Keep, or compress, JPEG images.</li><li>Keep, optimize, or convert to JPEG the PNG images.</li><li><em>Process child notes as well</em>, to include the images of the notes beneath this one.</li></ul><p>Compressing cannot be undone. Images can also be compressed automatically on upload, see <a class=\"reference-link\" href=\"#root/_help_mT0HEkOsz6i1\">Images</a>.</p></li><li><p><span class=\"tn-icon bx bx-text\"></span><em>View OCR text</em> (on image and file notes) shows the text extracted from the note via <a class=\"reference-link\" href=\"#root/_help_TiQbQDgP8L5t\">Text Extraction (OCR)</a>. If the note has not been processed yet, the dialog offers to <em>Process OCR</em>.</p></li><li><p><span class=\"tn-icon bx bx-world\"></span><em>Open note on server</em> (desktop application only, listed when <a class=\"reference-link\" href=\"#root/_help_cbkrhQjrkKrh\">Synchronization</a> is configured) opens the same note on the sync server, in the web browser.</p></li></ul><h2>Deleting the note</h2><p><span class=\"tn-icon bx bx-trash\"></span><em>Delete note</em> opens the deletion dialog for the current note and its subtree. The dialog lists the notes that will be deleted and the relations that will be broken, and offers to:</p><ul><li>Also delete the other clones of the note, if it is cloned elsewhere. Otherwise, only the current placement is removed and the note stays in its other locations. See <a class=\"reference-link\" href=\"#root/_help_IakOLONlIfGI\">Cloning Notes</a>.</li><li><em>Erase permanently</em> instead of the usual soft deletion. This cannot be undone.</li></ul><p>Notes deleted without erasing can be brought back, see <a class=\"reference-link\" href=\"#root/_help_5Ct4MAJTS4tQ\">Restoring Deleted Notes</a>.</p><h2>Limitations</h2><ul><li>The note menu is not available on launchers.</li><li>On the notes of <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> and of the in-app help, most entries are grayed out, since these notes cannot be imported into, exported, deleted or have revisions.</li><li>The <a href=\"#note-properties\">Note properties</a> section is only listed when the note itself is displayed, not its <a class=\"reference-link\" href=\"#root/_help_0vhv7lsOLy82\">Attachments</a> or its <a class=\"reference-link\" href=\"#root/_help_4FahAwuGTAwC\">Note source</a>.</li><li>In <a class=\"reference-link\" href=\"#root/_help_ZjLYv08Rp3qC\">Quick edit</a>, <em>Search in note</em>, <em>Note map</em>, <em>Full width</em> and <em>Convert into attachment</em> are not listed.</li></ul><h2>Mobile support</h2><p>On the <a class=\"reference-link\" href=\"#root/_help_RDslemsQ6gCp\">Mobile Frontend</a>, the note menu opens as a sheet from the bottom of the screen. Besides the entries above, it contains the items that the desktop layout places elsewhere:</p><ul><li><em>Backlinks</em> and <em>Note paths</em>, at the top, which open the <a class=\"reference-link\" href=\"#root/_help_wfGXLmm7x27z\">Backlinks</a> and the other locations of the note.</li><li>The custom buttons of the note type (such as <span class=\"tn-icon bx bx-download\"></span><em>Download</em> on a <a class=\"reference-link\" href=\"#root/_help_W8vYD3Q1zjCR\">File</a>).</li><li><em>Insert child note</em>, which creates a note under the current one.</li><li><em>Create new split</em> and <em>Close this pane</em>, to manage the <a class=\"reference-link\" href=\"#root/_help_luNhaphA37EO\">Split View</a>.</li><li><em>Note attributes</em>, which opens the attributes of the note.</li><li>On <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes, the content language (see <a class=\"reference-link\" href=\"#root/_help_veGu4faJErEM\">Content language & Right-to-left support</a>); on <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> notes, the language of the code.</li><li><em>Note info</em> and <a class=\"reference-link\" href=\"#root/_help_xWtq5NUHOwql\">Similar Notes</a>.</li><li><em>Note map</em> opens the map in a popup instead of the right sidebar.</li></ul>",+ "_help_8YBEPzcpUgxw": "<figure class=\"image image-style-align-right image_resized\" style=\"width:25.95%;\"><img style=\"aspect-ratio:402/988;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Note%20menu_image.png\" width=\"402\" height=\"988\"></figure><p>The note menu contains various actions and configurations for the current note. It can be found in the <a class=\"reference-link\" href=\"#root/_help_1P8QXI5edXNd\">Note buttons</a> area (to the right of the <a class=\"reference-link\" href=\"#root/_help_l7pigIGu01K2\">Title</a>).</p><p>Every split has a note menu of its own, which acts on the note displayed in that split. Entries that don't apply to the current note are still listed but grayed out, while entries that only exist for some notes (described in <em>Note-specific entries</em>) appear only on those notes.</p><h2>Navigating the note</h2><ul><li><span class=\"tn-icon bx bx-search\"></span> <em>Search in note</em> opens the <a class=\"reference-link\" href=\"#root/_help_McngOG2jbUWX\">Search in note</a> bar, to find and replace text inside the current note. On the desktop application, the same bar opens with <kbd>Ctrl</kbd>+<kbd>F</kbd>.<ul><li>It is available on <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>, <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a>, <a class=\"reference-link\" href=\"#root/_help_gBbsAeiuUxI5\">Mind Map</a> and <a class=\"reference-link\" href=\"#root/_help_GWHEkY4I4OE3\">Spreadsheets</a> notes, <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a>, PDF files, and any note displayed as <a class=\"reference-link\" href=\"#root/_help_4FahAwuGTAwC\">Note source</a>.</li></ul></li><li><span class=\"tn-icon bx bx-paperclip\"></span> <em>Note attachments</em> switches the note to the list of its <a class=\"reference-link\" href=\"#root/_help_0vhv7lsOLy82\">Attachments</a>, where they can be uploaded, opened, downloaded, renamed or deleted.</li><li><span class=\"tn-icon bx bxs-network-chart\"></span> <em>Note map</em> opens the <a class=\"reference-link\" href=\"#root/_help_KRlZFoIH0j6p\">Connections tab</a> of the <a class=\"reference-link\" href=\"#root/_help_RnaPdbciOfeq\">Right Sidebar</a>, which shows the <a class=\"reference-link\" href=\"#root/_help_BCkXAVs63Ttv\">Note Map (Link map, Tree map)</a> centered on the current note.</li></ul><h2>Note properties</h2><p>The toggles in this section take effect immediately:</p><ul><li><span class=\"tn-icon bx bx-share-alt\"></span> <em>Shared</em> publishes the note via <a class=\"reference-link\" href=\"#root/_help_R9pX4DGra2Vt\">Sharing</a>, by cloning it into the <em>Shared Notes</em> tree.<ul><li>Turning it off removes the clone from that tree. If the note exists only as a shared note, Trilium asks for confirmation, since unsharing it deletes it.</li><li>The toggle is unavailable on the root note, on the <em>Shared Notes</em> note itself, and on system notes.</li></ul></li><li><span class=\"tn-icon bx bx-lock-alt\"></span> <em>Protect the note</em> encrypts the note, turning it into one of the <a class=\"reference-link\" href=\"#root/_help_bwg0e8ewQMak\">Protected Notes</a>. If no protected session is active, Trilium asks for the password first. Only the current note is affected, not its children.</li><li><span class=\"tn-icon bx bx-bookmark\"></span> <em>Bookmark</em> adds the note to the <a class=\"reference-link\" href=\"#root/_help_u3YFHC9tQlpm\">Bookmarks</a> that are displayed in the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>, or removes it from them.</li><li><span class=\"tn-icon bx bx-copy-alt\"></span> <em>Template</em> marks the note as one of the <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a> (by adding the <code>#template</code> label), which makes it available when creating a new note.</li><li><span class=\"tn-icon bx bx-expand-horizontal\"></span> <em>Full width</em> lets the note use the whole width of the window instead of the limit set in <a class=\"reference-link\" href=\"#root/_help_t596jLvPrqkS\">Content width</a> by adding the <code>#fullContentWidth</code> label. It is not listed for note types that are always displayed at full width.</li></ul><p>The two submenus in this section:</p><ul><li><span class=\"tn-icon bx bx-file\"></span> <em>Note type</em> changes the type of the note to any of the <a class=\"reference-link\" href=\"#root/_help_KSZ04uQ2D1St\">Note Types</a>; the current one is checked. If the note already has content, Trilium asks for confirmation first, since the content generally doesn't carry over. <a class=\"reference-link\" href=\"#root/_help_jludwdW7N4hg\">Converting between note types</a>.<ul><li>For a <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> note, the language is chosen in the <a class=\"reference-link\" href=\"#root/_help_AlJ73vBCjWDw\">Status bar</a> instead.</li></ul></li><li><span class=\"tn-icon bx bx-edit-alt\"></span> <em>Editable</em> controls when the note opens as read-only (see <a class=\"reference-link\" href=\"#root/_help_CoFPLs3dRlXc\">Read-Only Notes</a>):<ul><li><em>Auto</em> (the default): the note is editable, unless it is long enough to be opened as read-only automatically.</li><li><em>Read-only</em>: the note always opens as read-only, but can still be edited after pressing <em>Edit note</em>.</li><li><em>Always Editable</em>: the note is always editable, regardless of its length.</li></ul></li></ul><h2>Importing, exporting and printing</h2><ul><li><span class=\"tn-icon bx bx-import\"></span> <em>Import files</em> opens the import dialog, which imports files as children of the current note. See <a class=\"reference-link\" href=\"#root/_help_mHbBMPDPkVV5\">Import & Export</a>. It is unavailable on <a class=\"reference-link\" href=\"#root/_help_m523cpzocqaD\">Saved Search</a> notes.</li><li><span class=\"tn-icon bx bx-export\"></span> <em>Export note</em> opens the export dialog with <em>Only this note</em> selected; select <em>This note & all descendants</em> there to export the whole subtree.</li><li><span class=\"tn-icon bx bx-printer\"></span><em>Print note…</em> prints the note. On the desktop application this entry reads <em>Print/export to PDF…</em> and can also save the note as a PDF file. See <a class=\"reference-link\" href=\"#root/_help_NRnIZmSMc5sj\">Printing & Exporting as PDF</a>, including which note types and collections can be printed.</li></ul><p>Some note types add their own export formats right below <em>Export note</em>:</p><ul><li><span class=\"tn-icon bx bxs-file-image\"></span><em>Export as image</em>, on <a class=\"reference-link\" href=\"#root/_help_s1aBHPd79XYj\">Mermaid Diagrams</a> and <a class=\"reference-link\" href=\"#root/_help_gBbsAeiuUxI5\">Mind Map</a> notes, downloads the diagram as <em>PNG (raster)</em> or <em>SVG (vector)</em>.</li><li><span class=\"tn-icon bx bxs-spreadsheet\"></span><em>Export to Excel (.xlsx)</em> and <em>Export to CSV (.csv)</em>, on <a class=\"reference-link\" href=\"#root/_help_GWHEkY4I4OE3\">Spreadsheets</a>, download the spreadsheet in those formats.</li></ul><h2>Revisions</h2><p>These entries manage the <a class=\"reference-link\" href=\"#root/_help_vZWERwf8U3nx\">Note Revisions</a> of the note:</p><ul><li><span class=\"tn-icon bx bx-history\"></span><em>Note revisions…</em> opens the revisions dialog, where previous versions can be previewed, compared with the current one, downloaded or restored.</li><li><span class=\"tn-icon bx bx-save\"></span><em>Save revision</em> saves a revision of the note right away, instead of waiting for the next automatic snapshot.</li><li><span class=\"tn-icon bx bx-purchase-tag\"></span><em>Save named revision…</em> also saves a revision right away, but first asks for a short description of the changes, which is shown in the revisions dialog.</li></ul><h2>Note-specific entries</h2><p>The following entries only appear on some notes:</p><ul><li><span class=\"tn-icon bx bx-pencil\"></span><em>Edit note</em> appears at the top of the menu when the note is currently read-only. It enables editing until the note is closed.</li><li><span class=\"tn-icon bx bx-align-justify\"></span><em>Word wrap</em> appears at the top of the menu on <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> notes, and sets whether long lines wrap in this note:<ul><li><em>Auto</em> (the default) follows <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Code Notes</em> → <em>Wrap lines in code notes</em>.</li><li><em>On</em> and <em>Off</em> override it for this note only, by setting the <code>#wrapLines</code> label.</li></ul></li><li><span class=\"tn-icon bx bx-paperclip\"></span><em>Convert into attachment</em> appears on an image note that has no children and a single parent which is a <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> note. After a confirmation, it turns the image into an attachment of its parent note and opens it there. See <a class=\"reference-link\" href=\"#root/_help_0vhv7lsOLy82\">Attachments</a>.</li><li><span class=\"tn-icon bx bx-extension\"></span><em>Re-render note</em> appears on a <a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a>, and runs its script again to refresh the output.</li><li><span class=\"tn-icon bx bx-cog\"></span><em>Board properties</em> appears on a <a class=\"reference-link\" href=\"#root/_help_CtBQqbwXDx1w\">Kanban Board</a>, and configures its columns, card attributes and card templates.</li><li><span class=\"tn-icon bx bx-cog\"></span><em>Calendar properties</em> appears on a <a class=\"reference-link\" href=\"#root/_help_xWbu3jpNWapp\">Calendar</a> that creates events, and configures its event templates.</li><li><span class=\"tn-icon bx bx-cog\"></span><em>Geo map properties</em> appears on a <a class=\"reference-link\" href=\"#root/_help_81SGnPGMk7Xc\">Geo Map</a>, and configures its map settings and the image of an <a href=\"#root/_help_ZRDXGc0nAIh4\">image map</a>.</li><li><span class=\"tn-icon bx bx-cog\"></span><em>Table properties</em> appears on a <a class=\"reference-link\" href=\"#root/_help_2FvYrpmOXm29\">Table</a>, and configures which notes it shows.</li></ul><h2>Advanced</h2><p>The <span class=\"tn-icon bx bx-wrench\"></span><em>Advanced</em> submenu groups the actions that are needed less often:</p><ul><li><p><span class=\"tn-icon bx bx-file-find\"></span><em>Open note externally</em> (desktop application only) saves the note to a temporary file and opens it in the application that the operating system associates with it. Trilium watches the file, and offers to upload the modified version back into the note. It is unavailable on <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a> and <a class=\"reference-link\" href=\"#root/_help_m523cpzocqaD\">Saved Search</a> notes.</p></li><li><p><span class=\"tn-icon bx bx-customize\"></span><em>Open note custom</em> (desktop application only, Windows and Linux) works like <em>Open note externally</em>, but lets you pick the application to open the file with.</p></li><li><p><span class=\"tn-icon bx bx-code\"></span><em>Note source</em> shows the <a class=\"reference-link\" href=\"#root/_help_4FahAwuGTAwC\">Note source</a>, the content of the note exactly as it is stored.</p></li><li><p><span class=\"tn-icon bx bxl-markdown\"></span><em>Convert to Markdown Note</em> (on text notes) and <em>Convert to Text Note</em> (on Markdown notes) switch the note between rich text and Markdown. After a confirmation, Trilium saves a revision and converts the content; the revision allows going back if some formatting was lost. See <a class=\"reference-link\" href=\"#root/_help_jludwdW7N4hg\">Converting between note types</a>.</p></li><li><p><span class=\"tn-icon bx bx-collapse-alt\"></span><em>Compress images</em> opens a dialog that reduces the size of the images in the note. It lists the images found and how much space they take, and offers to:</p><ul><li>Resize the images larger than a chosen size.</li><li>Keep, or compress, JPEG images.</li><li>Keep, optimize, or convert to JPEG the PNG images.</li><li><em>Process child notes as well</em>, to include the images of the notes beneath this one.</li></ul><p>Compressing cannot be undone. Images can also be compressed automatically on upload, see <a class=\"reference-link\" href=\"#root/_help_mT0HEkOsz6i1\">Images</a>.</p></li><li><p><span class=\"tn-icon bx bx-text\"></span><em>View OCR text</em> (on image and file notes) shows the text extracted from the note via <a class=\"reference-link\" href=\"#root/_help_TiQbQDgP8L5t\">Text Extraction (OCR)</a>. If the note has not been processed yet, the dialog offers to <em>Process OCR</em>.</p></li><li><p><span class=\"tn-icon bx bx-world\"></span><em>Open note on server</em> (desktop application only, listed when <a class=\"reference-link\" href=\"#root/_help_cbkrhQjrkKrh\">Synchronization</a> is configured) opens the same note on the sync server, in the web browser.</p></li></ul><h2>Deleting the note</h2><p><span class=\"tn-icon bx bx-trash\"></span><em>Delete note</em> opens the deletion dialog for the current note and its subtree. The dialog lists the notes that will be deleted and the relations that will be broken, and offers to:</p><ul><li>Also delete the other clones of the note, if it is cloned elsewhere. Otherwise, only the current placement is removed and the note stays in its other locations. See <a class=\"reference-link\" href=\"#root/_help_IakOLONlIfGI\">Cloning Notes</a>.</li><li><em>Erase permanently</em> instead of the usual soft deletion. This cannot be undone.</li></ul><p>Notes deleted without erasing can be brought back, see <a class=\"reference-link\" href=\"#root/_help_5Ct4MAJTS4tQ\">Restoring Deleted Notes</a>.</p><h2>Limitations</h2><ul><li>The note menu is not available on launchers.</li><li>On the notes of <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> and of the in-app help, most entries are grayed out, since these notes cannot be imported into, deleted or have revisions. Of the two, only the in-app help can be exported, see <a class=\"reference-link\" href=\"#root/_help_mHbBMPDPkVV5\">Import & Export</a>.</li><li>The <a href=\"#note-properties\">Note properties</a> section is only listed when the note itself is displayed, not its <a class=\"reference-link\" href=\"#root/_help_0vhv7lsOLy82\">Attachments</a> or its <a class=\"reference-link\" href=\"#root/_help_4FahAwuGTAwC\">Note source</a>.</li><li>In <a class=\"reference-link\" href=\"#root/_help_ZjLYv08Rp3qC\">Quick edit</a>, <em>Search in note</em>, <em>Note map</em>, <em>Full width</em> and <em>Convert into attachment</em> are not listed.</li></ul><h2>Mobile support</h2><p>On the <a class=\"reference-link\" href=\"#root/_help_RDslemsQ6gCp\">Mobile Frontend</a>, the note menu opens as a sheet from the bottom of the screen. Besides the entries above, it contains the items that the desktop layout places elsewhere:</p><ul><li><em>Backlinks</em> and <em>Note paths</em>, at the top, which open the <a class=\"reference-link\" href=\"#root/_help_wfGXLmm7x27z\">Backlinks</a> and the other locations of the note.</li><li>The custom buttons of the note type (such as <span class=\"tn-icon bx bx-download\"></span><em>Download</em> on a <a class=\"reference-link\" href=\"#root/_help_W8vYD3Q1zjCR\">File</a>).</li><li><em>Insert child note</em>, which creates a note under the current one.</li><li><em>Create new split</em> and <em>Close this pane</em>, to manage the <a class=\"reference-link\" href=\"#root/_help_luNhaphA37EO\">Split View</a>.</li><li><em>Note attributes</em>, which opens the attributes of the note.</li><li>On <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes, the content language (see <a class=\"reference-link\" href=\"#root/_help_veGu4faJErEM\">Content language & Right-to-left support</a>); on <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> notes, the language of the code.</li><li><em>Note info</em> and <a class=\"reference-link\" href=\"#root/_help_xWtq5NUHOwql\">Similar Notes</a>.</li><li><em>Note map</em> opens the map in a popup instead of the right sidebar.</li></ul>","_help_1P8QXI5edXNd": "<p>The note buttons is an area at the top-right of a note with a few buttons:</p><ul><li>The <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> which offers commands for the note or its subtree, such as import, export, viewing the <a href=\"#root/_help_4FahAwuGTAwC\">Note source code</a> or <a href=\"#root/_help_0vhv7lsOLy82\">Attachments</a>.</li><li><a class=\"reference-link\" href=\"#root/_help_luNhaphA37EO\">Split View</a> controls<ul><li><span class=\"tn-icon bx bx-dock-right\"></span> to open a new split</li><li><span class=\"tn-icon bx bx-chevron-right\"></span>/<span class=\"tn-icon bx bx-chevron-left\"></span> to move the pane around</li><li><span class=\"tn-icon bx bx-x\"></span> to close the pane.</li></ul></li><li>On some note types such as <a class=\"reference-link\" href=\"#root/_help_W8vYD3Q1zjCR\">File</a> and images, there are dedicated buttons (e.g. <span class=\"tn-icon bx bx-download\"></span> to download the file locally).</li></ul>","_help_4TIF1oA4VQRO": "<figure class=\"image image-style-align-center\"><img style=\"aspect-ratio:1189/709;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Options_image.png\" width=\"1189\" height=\"709\"></figure><p>The Options section allows the configuration of the TriliumNext client and server.</p><h2>Entering options</h2><p>The Options can be accessed via:</p><ul><li>The <a href=\"#root/_help_x3i7MxGccDuM\">Global menu</a>, by selecting the <em>Options</em> item.</li><li>The <span class=\"tn-icon bx bx-cog\"></span> button in the <a href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a> which can optionally be hidden if not desirable.</li><li>Optionally, a keyboard shortcut can be defined, but it is not assigned by default.</li><li>By clicking on this link: <a class=\"reference-link\" href=\"#root/_hidden/_options\">Options</a>.</li></ul><p>Once in the options section, simply select one of the option categories using the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>.</p><h2>Exiting options</h2><p>When entering the options, they are opened in a new <a href=\"#root/_help_3seOhtN8uLIY\">tab</a>. To close them, simply close the tab.</p><h2>Options when using sync</h2><p>When using <a class=\"reference-link\" href=\"#root/_help_cbkrhQjrkKrh\">Synchronization</a>, some of the options will be kept in sync across all the devices while others can be changed independently.</p><p>Generally, the options that relate to appearance are intentionally kept not synced in order to allow per-client customization (layout orientation, theme, vertical/horizontal layout, code block themes).</p>","_help_luNhaphA37EO": "<p>In Trilium, is possible to work with two or more notes side-by-side.</p><figure class=\"image image-style-align-center\"><img style=\"aspect-ratio:1398/1015;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Split%20View_2_Split%20View_image.png\" width=\"1398\" height=\"1015\"></figure><h2>Interactions</h2><ul><li>Press the <span class=\"tn-icon bx bx-dock-right\"></span> button to the right of a note's title to open a new split to the right of it.<ul><li>It is possible to have as many splits as desired, simply press again the button.</li><li>Only horizontal splits are possible, vertical or drag & dropping is not supported.</li></ul></li><li>When at least one split is open, press the <span class=\"tn-icon bx bx-x\"></span> button next to it to close it.</li><li>Use the <span class=\"tn-icon bx bx-chevron-right\"></span> or the <span class=\"tn-icon bx bx-chevron-left\"></span> button to move around the splits.</li><li>Creating, closing and moving a split can also be triggered from a <a href=\"#root/_help_A9Oc6YKKc65v\">keyboard shortcut</a> (<em>Create New Split</em>, <em>Close Active Split</em>, <em>Move Split Left</em> and <em>Move Split Right</em>, all unassigned by default) or through the <a href=\"#root/_help_F1r9QtzQLZqm\">command palette</a>.</li><li>The focus can be moved from one split to the one next to it with the <em>Focus Split to the Left</em> and <em>Focus Split to the Right</em> actions, which stop at either end of the tab instead of continuing into the next tab. They are unassigned by default as well.</li><li>Each <a href=\"#root/_help_3seOhtN8uLIY\">tab</a> has its own split view configuration (e.g. one tab can have two notes in a split view, whereas the others are one-note views).<ul><li>The tab's title will indicate all the note titles, in the order of the splits from the left to right and separated by a bullet symbol.</li><li>The tab's icon will indicate the icon of the last active split, which will be automatically focused when clicking on the tab.</li></ul></li></ul><h2>Splits and the note tree & hoisting</h2><p>Clicking on the content of a split will focus that split. While focused, the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> will also indicate the note that is being edited.</p><p>It is possible for each of the splits to have their own <a class=\"reference-link\" href=\"#root/_help_OR8WJ7Iz9K4U\">Note Hoisting</a>.</p><p>When a new split is created, it will share the same note hoisting as the previous one. An easy solution to this is to simply hoist the notes after the split is created.</p><p>This is generally quite useful for reorganizing notes from one place to the other, by hoisting the old place in the first split and hoisting the new place to the second one. This will allow easy cut and paste without the tree jumping around from switching between notes.</p><h2>Mobile support</h2><p>Since v0.100.0, it's possible to have a split view on the mobile view as well, with the following differences from the desktop version of the split:</p><ul><li>On smartphones, the split views are laid out vertically (one on the top and one on the bottom), instead of horizontally as on the desktop.</li><li>There can be only one split open per tab.</li><li>It's not possible to resize the two split panes.</li><li>When the keyboard is opened, the active note will be “maximized”, thus allowing for more space even when a split is open. When the keyboard is closed, the splits become equal in size again.</li></ul><p>Interaction:</p><ul><li>To create a new split, click the three dots button on the right of the note title and select <em>Create new split</em>.<ul><li>This option will only be available if there is no split already open in the current tab.</li></ul></li><li>To close a split, click the three dots button on the right of the note title and select <em>Close this pane</em>.<ul><li>Note that this option will only be available on the second note in the split (the one at the bottom on smartphones, the one on the right on tablets).</li></ul></li><li>When long-pressing a link, a contextual menu will show up with an option to <em>Open note in a new split</em>.<ul><li>If there's already a split, the option will replace the existing split instead.</li></ul></li></ul>",@@ -97,7 +97,7 @@"_help_VbjZvtUek0Ln": "<p>These are user-created themes which were made publicly available:</p><h2>Legacy Themes</h2><p>These themes may or may not be compatible with the latest versions of TriliumNext and are based on the original/legacy theme.</p><figure class=\"table\"><table><thead><tr><th>Theme</th><th>Author</th></tr></thead><tbody><tr><td><a href=\"https://github.com/tobealive/trilium-midnight-theme\">Midnight</a></td><td><a href=\"https://github.com/tobealive\">tobealive</a></td></tr><tr><td><a href=\"https://github.com/tobealive/trilum-eote-theme\">EOTE</a></td><td><a href=\"https://github.com/tobealive\">tobealive</a></td></tr><tr><td><a href=\"https://github.com/Abourass/TriliumThemes\">Trilium Themes</a></td><td><a href=\"https://github.com/Abourass\">Abourass</a></td></tr><tr><td><a href=\"https://github.com/ZMonk91/Material-Dark-Trilium\">MaterialDark</a></td><td><a href=\"https://github.com/ZMonk91\">ZMonk91</a></td></tr><tr><td><a href=\"https://github.com/jaroet/trilium-theme-lightslategray\">lightslategray</a></td><td><a href=\"https://github.com/jaroet\">jaroet</a></td></tr><tr><td><a href=\"https://github.com/raphwriter/trilium-theme-melon\">melon-4</a></td><td><a href=\"https://github.com/raphwriter\">raphwriter</a></td></tr><tr><td><a href=\"https://github.com/Engr-AllanG/trilium-themes\">Neon_Dark</a></td><td><a href=\"https://github.com/Engr-AllanG\">Engr-AllanG</a></td></tr><tr><td><a href=\"https://github.com/Engr-AllanG/trilium-themes\">Coder_Dark</a></td><td><a href=\"https://github.com/Engr-AllanG\">Engr-AllanG</a></td></tr><tr><td><a href=\"https://github.com/idelem/trilium-theme-velvet\">velvet</a></td><td><a href=\"https://github.com/idelem\">idelem</a></td></tr><tr><td><a href=\"https://github.com/SADAVA/trilium-notes-theme-dark-plus\">Dark Plus</a></td><td><a href=\"https://github.com/SADAVA\">SADAVA</a></td></tr><tr><td><a href=\"https://github.com/WKSu/trilium-solarized-theme\">Solarized</a></td><td><a href=\"https://github.com/WKSu\">WKSu</a></td></tr><tr><td><a href=\"https://github.com/en3r0/Trilium-Nord-Theme\">Nord</a></td><td><a href=\"https://github.com/en3r0\">en3r0</a></td></tr><tr><td><a href=\"https://github.com/AllanZyne/trilium-bear-theme\">Bear Note Light</a></td><td><a href=\"https://github.com/AllanZyne\">AllanZyne</a></td></tr><tr><td><a href=\"https://github.com/AllanZyne/trilium-bear-theme\">Bear Note Dark</a></td><td><a href=\"https://github.com/AllanZyne\">AllanZyne</a></td></tr><tr><td><a href=\"https://github.com/Sebiann/miku-hatsune-trilium-theme\">Miku Hatsune</a></td><td><a href=\"https://github.com/Sebiann\">Sebiann</a></td></tr><tr><td><a href=\"https://github.com/cwilliams5/Midnight-Trilium-Dark-Mode\">Midnight</a></td><td><a href=\"https://github.com/cwilliams5\">cwilliams5</a></td></tr><tr><td><a href=\"https://github.com/SiriusXT/trilium-theme-blue\">Blue</a> (light)</td><td><a href=\"https://github.com/SiriusXT\">SiriusXT</a></td></tr><tr><td><a href=\"https://github.com/SiriusXT/trilium-theme-blue\">Blue</a> (dark)</td><td><a href=\"https://github.com/SiriusXT\">SiriusXT</a></td></tr></tbody></table></figure><aside class=\"admonition tip\"><p>If you would like to add your theme to this gallery, write a new post in <a href=\"https://github.com/TriliumNext/Trilium/discussions/categories/show-and-tell\">👐 Show and tell</a>.</p></aside>","_help_gOKqSJgXLcIj": "<figure class=\"image image-style-align-right image_resized\" style=\"width:45.14%;\"><img style=\"aspect-ratio:854/649;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Themes/Icon%20Packs_image.png\" width=\"854\" height=\"649\"></figure><p>By default, Trilium comes with a set of icons called Boxicons v2. Since v0.102.0, custom icon packs allow a wider selection of icons for notes.</p><p>Icon packs are specific to Trilium, so they must either be created from scratch (see below) or imported from a ZIP file from a third-party developer.</p><h2>Sample icon packs</h2><p>The Trilium team maintains a few icon packs that are not shipped with Trilium. These icon packs can be found on the official website on the <a href=\"https://triliumnotes.org/resources\">Resources page</a>.</p><h2>Importing an existing icon pack</h2><aside class=\"admonition note\"><p><strong>Icon packs are third-party content</strong></p><p>Apart from the <a href=\"https://triliumnotes.org/resources\">sample icon packs</a>, the Trilium maintainers are not responsible for keeping icon packs up to date. If you have an issue with a specific icon pack, then the issue must be reported to the third-party developer responsible for it, not the Trilium team.</p></aside><p>To import an icon pack:</p><ol><li>Ideally, create a dedicated spot in your note tree where to place the icon packs.</li><li>Right click the note where to put it and select <em>Import into note</em>.</li><li>Uncheck <em>Safe import</em>.</li><li>Select <em>Import</em>.</li><li><a href=\"#root/_help_s8alTXmpFR61\">Refresh the application</a>.</li></ol><aside class=\"admonition warning\"><p>Since <em>Safe import</em> is disabled, make sure you trust the source as it could contain dangerous third-party scripts. One good way to check if the icon pack is safe is to manually extract the .zip and inspect the file contents. Icon packs should only contain a font file and a JSON file. Other files (especially scripts) are to be considered harmful.</p></aside><h2>Creating an icon pack</h2><p>Creating an icon pack requires some scripting knowledge outside Trilium in order to generate the list of icons. For information, see <a class=\"reference-link\" href=\"#root/_help_g1mlRoU8CsqC\">Creating an icon pack</a>.</p><h2>Using an icon from an icon pack</h2><p>After <a href=\"#root/_help_s8alTXmpFR61\">refreshing the application</a>, the icon pack should be enabled by default. To test this, simply select an existing note or create a new one and try to change the note icon.</p><p>There should be a <em>Filter</em> button to the right of the search bar in the icon list. Clicking it allows filtering by icon pack and the newly imported icon pack should be displayed there.</p><aside class=\"admonition note\"><p>If the icon pack is missing from that list, then most likely there's something wrong with it.</p><ul><li>Try checking the <a class=\"reference-link\" href=\"#root/_help_bnyigUA2UK7s\">Backend (server) logs</a> for clues and make sure that the icon pack has the <code>#iconPack</code> <a href=\"#root/_help_HI6GBBIduIgv\">label</a> with a value assigned to it (a prefix).</li><li>Icon packs that are <a href=\"#root/_help_bwg0e8ewQMak\">protected</a> are ignored.</li></ul></aside><h2>Integration with the share and export functionality</h2><p>Custom icon packs are also supported by the <a class=\"reference-link\" href=\"#root/_help_R9pX4DGra2Vt\">Sharing</a> feature, where they will be shown in the note tree. However, in order for an icon pack to be visible to the share function, the icon pack note must also be shared.</p><p>If you are using a custom share theme, make sure it supports the <code>iconPackCss</code>, otherwise icons will not show up. Check the original share template source code for reference.</p><p>Custom icon packs will also be preserved when <a class=\"reference-link\" href=\"#root/_help_ycBFjKrrwE9p\">Exporting static HTML for web publishing</a>. In this case, there's no requirement to make the icon pack shared.</p><h2>What happens if I remove an icon pack</h2><p>If an icon pack is removed or disabled (by removing or altering its <code>#iconPack</code> label), all the notes that use this icon pack will show in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> with no icon. This won't cause any issues apart from looking strange.</p><p>The solution is to replace the icons with some else, try using <a class=\"reference-link\" href=\"#root/_help_eIg8jdvaoNNd\">Search</a> which supports bulk actions, to identify the notes with the now deleted icon pack (by looking for the prefix) and changing or removing their <code>iconClass</code>.</p>","_help_w4rMEhJsALlA": "<h2>Using different fonts</h2><p>Trilium comes by default with its own font (<em>Inter</em>), but the font can be adjusted in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Appearance</em>, by checking <em>Use different fonts</em> in the <em>Fonts</em> section.</p><p>The font can be personalized for the following areas of the application:</p><ul><li>Interface text, for most of the UI (menus, toolbars, dialogs).</li><li><a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>.</li><li>Document text, for the actual content of the notes (especially for <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes).</li><li>Monospace text, e.g. for <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> notes and <a class=\"reference-link\" href=\"#root/_help_QxEyIjRBizuC\">Code blocks</a>.</li></ul><p>Each area also has its own <em>Size</em>. The note tree and document sizes are relative to the interface size, so changing the interface size moves them along with it.</p><p>The list of fonts contains the following items:</p><ul><li><strong>Generic fonts</strong><ul><li><em>Theme defined</em> which uses the font that is embedded with the current <a href=\"#root/_help_Wy267RK4M69c\">theme</a>. For example on the default modern theme, the font is <em>Inter</em>. This does not require the font to be installed.</li><li><em>System default</em> which uses a combination of fonts that works best for the <a href=\"#root/_help_poXkQfguuA0U\">desktop app</a>. For example on Windows it will use <em>Segoe UI</em>.</li><li>Generic font selections for fonts with serifs (e.g. <em>Times New Roman</em>-like), no serifs and monospace.</li></ul></li><li><strong>Web fonts</strong> which appear on the <a class=\"reference-link\" href=\"#root/_help_WOcw2SLH6tbX\">Server Installation</a>, which is a predefined list of fonts and grouped into Sans-serif, serif, monospace and handwriting. The fonts that are not supported by your system (i.e. not installed) are not displayed.</li><li><strong>System fonts</strong> which appear on the <a class=\"reference-link\" href=\"#root/_help_poXkQfguuA0U\">Desktop Installation</a>. Unlike the server fonts which are predefined, the system fonts are listed from your operating system.</li><li><strong>Custom fonts</strong>, allowing any font to be used provided it's imported into Trilium. See the section below for more information.</li></ul><p>Font changes take effect after a reload; the section offers a <em>Reload to apply changes</em> button once something has been changed.</p><h2>Custom fonts</h2><p>A font file imported into Trilium can be used by the application itself, without writing any CSS.</p><h3>Adding a font</h3><ol><li>Import the font file, by dragging it into the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> or through <em>Import into note</em>. TrueType (<code>.ttf</code>), OpenType (<code>.otf</code>) and Web Open Font Format (<code>.woff</code>, <code>.woff2</code>) files are recognized; the note takes the font's name without its extension and is marked with a font icon (an “A” icon).</li><li>Select the resulting note where a preview of a font will be displayed: a specimen line to type your own text into, a slider for its size, a preview in multiple sizes, and the Latin character set.</li><li>Turn on <em>In font picker</em> above the specimen.</li><li>In <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Appearance</em> → <em>Fonts</em>, the font is now offered under <em>Custom fonts</em>, ahead of the built-in families, and can be set for any of the four areas.</li></ol><aside class=\"admonition note\"><p>Embedded OpenType (<code>.eot</code>) files and TrueType collections (<code>.ttc</code>) cannot be drawn by the browser, so they are treated as ordinary files: no preview, and no entry in the picker.</p></aside><h3>How custom fonts behave</h3><ul><li>Each entry is named after its note, so renaming the note renames the entry. The setting refers to the note itself rather than to its name, and keeps working across a rename.</li><li>The font file is an ordinary note, so <a class=\"reference-link\" href=\"#root/_help_cbkrhQjrkKrh\">Synchronization</a> carries it to your other devices. The choice of font is not synced: appearance settings are deliberately kept per-device, so on another device the font is already there and only needs to be selected again.</li><li>A font kept in a <a href=\"#root/_help_bwg0e8ewQMak\">protected note</a> can only be previewed and used while the protected session is open.</li></ul><p>For theme authors, a font can also be embedded in a theme's CSS through <a class=\"reference-link\" href=\"#root/_help_d3fAXQ2diepH\">Custom Resource Providers</a>, which is the route to take when the font should come with the theme rather than be chosen in the settings.</p><h3>Downloading from Google Fonts</h3><p>A large selection of fonts can be easily retrieved from Google Fonts, as follows:</p><ol><li>Go to <a href=\"https://fonts.google.com\">https://fonts.google.com</a>.</li><li>Search for a desired font.</li><li>Press <em>Get font</em> in the top right.</li><li>Check that the list of fonts on the left side corresponds to your selection.</li><li>Press <em>Download all</em>.</li><li>In the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>, create a note where to store the new fonts.</li><li>In the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>, drag-and-drop the .zip file directly onto the newly created note and follow the steps from the previous section.</li></ol><h2>Programming ligatures</h2><p>Some fonts support programming ligatures, which will turn character combinations such as <code>!=</code> into <code>≠</code> or <code>-></code> as <code>→</code> in <a class=\"reference-link\" href=\"#root/_help_QxEyIjRBizuC\">Code blocks</a> and <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> notes.</p><p>These are only a display affordance, so copying the text is not affected. Regardless, this feature can be disabled in Trilium by unchecking <em>Programming ligatures</em> in the font settings.</p>",- "_help_mHbBMPDPkVV5": "<p>To import a note:</p><ul><li>The easiest way to import is to simply drag & drop a file or an archive into the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>.<ul><li>This will automatically detect some formats such as <a class=\"reference-link\" href=\"#root/_help_iWD7wiIuMtgV\">Obsidian</a>.</li><li><em>Safe import</em> is automatically on to prevent accidental running of foreign scripts.</li></ul></li><li>To configure an import, there is a dedicated dialog which can be accessed from either <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> → <em>Import into note</em> or <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> → <em>Import into note</em>.<ul><li>This feature allows for dedicated importers for others apps such as <a class=\"reference-link\" href=\"#root/_help_iWD7wiIuMtgV\">Obsidian</a> or <a class=\"reference-link\" href=\"#root/_help_GnhlmrATVqcH\">Microsoft OneNote</a>.</li><li><em>Safe import</em> as well as other options can be configured from the collapsed <em>Options</em> section at the bottom.</li></ul></li></ul><p>To export a note, right click the note in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> and select <em>Export</em>. Similarly, in <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> there is a <em>Export note</em> option.</p><h2>Supported formats</h2><p>Trilium natively supports the following formats for both import and export.</p><ul><li>HTML:<ul><li>This is the main format used by Trilium, where standard tags are used to represent basic formatting and layout (e.g. <code><strong></code>, <code><table></code>, <code><pre></code>).</li><li>Note that HTML is not a standardized format so some more specific features such as admonitions or <a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a> might not be supported by other applications.</li><li>The notes can also be exported as <a href=\"#root/_help_ycBFjKrrwE9p\">static HTML that can be used for web publishing</a>.</li></ul></li><li><a class=\"reference-link\" href=\"#root/_help_Oau6X9rCuegd\">Markdown</a><ul><li>Most of the formatting is preserved, see <a class=\"reference-link\" href=\"#root/_help_rJ9grSgoExl9\">Supported syntax</a>.</li></ul></li><li>OPML (Outliner Interchange Format)<ul><li>Supports both OPML v1.0 for plain text and v2.0 with HTML support.</li></ul></li></ul><p>To import from other applications such as OneNote, Notion and others, see <a class=\"reference-link\" href=\"#root/_help_ckZ2uNWQmVeX\">Importing data from other applications</a>.</p><h2>Maximum import size</h2><p>Versions prior to v0.104.0 had an upload limit of 250 MiB that could be bypassed via a <code>TRILIUM_NO_UPLOAD_LIMIT</code> environment variable; with v0.104.0 this limit was removed.</p><p>Nevertheless, there is still a limit for the maximum size of a <strong>single item</strong> (whether it's a <a class=\"reference-link\" href=\"#root/_help_W8vYD3Q1zjCR\">File</a>, an <a class=\"reference-link\" href=\"#root/_help_0vhv7lsOLy82\">Attachments</a> or even a <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> note). The limit is approximately 374 MiB and it's determined by the <a class=\"reference-link\" href=\"#root/_help_cbkrhQjrkKrh\">Synchronization</a> protocol. Attempts to import such large files will be refused.</p><p>During large imports or exports, memory consumption might spike but it will remain somewhere around the 2 gigabyte mark. Tested with a 2.4 GB database with ~21k notes.</p><aside class=\"admonition important\"><p>For the <a class=\"reference-link\" href=\"#root/_help_poXkQfguuA0U\">Desktop Installation</a>, there are two distinct import mechanisms:</p><ul><li>A quick import, from the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>.</li><li>The import dialog (via right click in the note tree → <em>Import into note</em> or from <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a>).</li></ul><p>When dealing with large files (multi-gigabyte), prefer using the import dialog as it has a special mechanism which makes sure that the file is read directly from disk rather than uploaded again.</p></aside><h2>Exporting the root note</h2><p>The root note is the top-most note. Exporting it behaves just like any other note: right click on it in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> and select <em>Export</em>.</p><p>Starting with v0.104.0, when a root note is imported, it will be imported as a child of your existing root note. This behavior makes sure that the import cannot change or overwrite your existing notes.</p><p>You can easily move the notes onto the root using the tree's <a class=\"reference-link\" href=\"#root/_help_yTjUdsOi4CIE\">Multiple selection</a> and delete the redundant root note.</p><figure class=\"table\"><table><thead><tr><th scope=\"col\">Before</th><th scope=\"col\">After</th></tr></thead><tbody><tr><td><ul><li>root<ul><li>one</li><li>two</li></ul></li></ul></td><td><ul><li>root (existing)<ul><li>root (from import)<ul><li>one</li><li>two</li></ul></li></ul></li></ul></td></tr></tbody></table></figure><aside class=\"admonition tip\"><p>Instead of exporting full ZIPs (including the root note), consider using <a href=\"#root/_help_ODY7qQn5m2FT\">backups</a> instead. Backups always contain the entire structure, as well as additional information a ZIP export does not have: maintains note IDs, contains the options/tokens and handle <a class=\"reference-link\" href=\"#root/_help_bwg0e8ewQMak\">Protected Notes</a> better.</p></aside>",+ "_help_mHbBMPDPkVV5": "<p>To import a note:</p><ul><li>The easiest way to import is to simply drag & drop a file or an archive into the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>.<ul><li>This will automatically detect some formats such as <a class=\"reference-link\" href=\"#root/_help_iWD7wiIuMtgV\">Obsidian</a>.</li><li><em>Safe import</em> is automatically on to prevent accidental running of foreign scripts.</li></ul></li><li>To configure an import, there is a dedicated dialog which can be accessed from either <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> → <em>Import into note</em> or <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> → <em>Import into note</em>.<ul><li>This feature allows for dedicated importers for others apps such as <a class=\"reference-link\" href=\"#root/_help_iWD7wiIuMtgV\">Obsidian</a> or <a class=\"reference-link\" href=\"#root/_help_GnhlmrATVqcH\">Microsoft OneNote</a>.</li><li><em>Safe import</em> as well as other options can be configured from the collapsed <em>Options</em> section at the bottom.</li></ul></li></ul><p>To export a note, right click the note in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> and select <em>Export</em>. Similarly, in <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> there is a <em>Export note</em> option.</p><h2>Supported formats</h2><p>Trilium natively supports the following formats for both import and export.</p><ul><li>HTML:<ul><li>This is the main format used by Trilium, where standard tags are used to represent basic formatting and layout (e.g. <code><strong></code>, <code><table></code>, <code><pre></code>).</li><li>Note that HTML is not a standardized format so some more specific features such as admonitions or <a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a> might not be supported by other applications.</li><li>The notes can also be exported as <a href=\"#root/_help_ycBFjKrrwE9p\">static HTML that can be used for web publishing</a>.</li></ul></li><li><a class=\"reference-link\" href=\"#root/_help_Oau6X9rCuegd\">Markdown</a><ul><li>Most of the formatting is preserved, see <a class=\"reference-link\" href=\"#root/_help_rJ9grSgoExl9\">Supported syntax</a>.</li></ul></li><li>OPML (Outliner Interchange Format)<ul><li>Supports both OPML v1.0 for plain text and v2.0 with HTML support.</li></ul></li></ul><p>To import from other applications such as OneNote, Notion and others, see <a class=\"reference-link\" href=\"#root/_help_ckZ2uNWQmVeX\">Importing data from other applications</a>.</p><h2>Maximum import size</h2><p>Versions prior to v0.104.0 had an upload limit of 250 MiB that could be bypassed via a <code>TRILIUM_NO_UPLOAD_LIMIT</code> environment variable; with v0.104.0 this limit was removed.</p><p>Nevertheless, there is still a limit for the maximum size of a <strong>single item</strong> (whether it's a <a class=\"reference-link\" href=\"#root/_help_W8vYD3Q1zjCR\">File</a>, an <a class=\"reference-link\" href=\"#root/_help_0vhv7lsOLy82\">Attachments</a> or even a <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> note). The limit is approximately 374 MiB and it's determined by the <a class=\"reference-link\" href=\"#root/_help_cbkrhQjrkKrh\">Synchronization</a> protocol. Attempts to import such large files will be refused.</p><p>During large imports or exports, memory consumption might spike but it will remain somewhere around the 2 gigabyte mark. Tested with a 2.4 GB database with ~21k notes.</p><aside class=\"admonition important\"><p>For the <a class=\"reference-link\" href=\"#root/_help_poXkQfguuA0U\">Desktop Installation</a>, there are two distinct import mechanisms:</p><ul><li>A quick import, from the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>.</li><li>The import dialog (via right click in the note tree → <em>Import into note</em> or from <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a>).</li></ul><p>When dealing with large files (multi-gigabyte), prefer using the import dialog as it has a special mechanism which makes sure that the file is read directly from disk rather than uploaded again.</p></aside><h2>Exporting the root note</h2><p>The root note is the top-most note. Exporting it behaves just like any other note: right click on it in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> and select <em>Export</em>.</p><p>Starting with v0.104.0, when a root note is imported, it will be imported as a child of your existing root note. This behavior makes sure that the import cannot change or overwrite your existing notes.</p><p>You can easily move the notes onto the root using the tree's <a class=\"reference-link\" href=\"#root/_help_yTjUdsOi4CIE\">Multiple selection</a> and delete the redundant root note.</p><figure class=\"table\"><table><thead><tr><th scope=\"col\">Before</th><th scope=\"col\">After</th></tr></thead><tbody><tr><td><ul><li>root<ul><li>one</li><li>two</li></ul></li></ul></td><td><ul><li>root (existing)<ul><li>root (from import)<ul><li>one</li><li>two</li></ul></li></ul></li></ul></td></tr></tbody></table></figure><aside class=\"admonition tip\"><p>Instead of exporting full ZIPs (including the root note), consider using <a href=\"#root/_help_ODY7qQn5m2FT\">backups</a> instead. Backups always contain the entire structure, as well as additional information a ZIP export does not have: maintains note IDs, contains the options/tokens and handle <a class=\"reference-link\" href=\"#root/_help_bwg0e8ewQMak\">Protected Notes</a> better.</p></aside><h2>Exporting the User Guide</h2><p>The in-app User Guide can be exported like any other note: right click one of its pages or chapters in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> and select <em>Export</em>, or use <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> → <em>Export note</em>.</p><ul><li>Exporting a chapter with <em>This note & all descendants</em> writes the pictures and files of each page as its attachments. Importing that archive creates an ordinary copy that you can edit, with its pictures and the links between its pages working.</li><li>Exporting a single page with <em>Only this note</em> embeds its pictures in the exported file.</li></ul>","_help_Oau6X9rCuegd": "<p>Trilium supports Markdown for both import and export, while trying to keep compatibility as high as possible.</p><h2>Import</h2><h3>Clipboard import</h3><p>If you want to import just a chunk of markdown from clipboard, you can do it from editor block menu:</p><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Import%20%26%20Export/Markdown_markdown-inline-import.gif\"></p><h3>File import</h3><p>You can also import Markdown files from files:</p><ul><li>single markdown file (with .md extension)</li><li>whole tree of markdown files (packaged into <a href=\"https://en.wikipedia.org/wiki/Tar_(computing)\">.zip</a> archive)<ul><li>Markdown files need to be packaged into ZIP archive because browser can't read directories, only single files.</li><li>You can use e.g. <a href=\"https://www.7-zip.org\">7-zip</a> to package directory of markdown files into the ZIP file</li></ul></li></ul><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Import%20%26%20Export/Markdown_markdown-file-import.gif\"></p><h2>Export</h2><h3>Subtree export</h3><p>You can export whole subtree to ZIP archive which will have directory structured modelled after subtree structure:</p><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Import%20%26%20Export/Markdown_markdown-export-subtree.gif\"></p><h3>Single note export</h3><p>If you want to export just single note without its subtree, you can do it from Note actions menu:</p><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Import%20%26%20Export/Markdown_markdown-export-note.gif\"></p><h3>Exporting protected notes</h3><p>If you want to export protected notes, enter a protected session first! This will export the notes in an unencrypted form, so if you reimport into Trilium, make sure to re-protect these notes.</p><h2>Supported syntax</h2><p>See the dedicated page: <a class=\"reference-link\" href=\"#root/_help_rJ9grSgoExl9\">Supported syntax</a></p>","_help_rJ9grSgoExl9": "<p><a href=\"https://github.github.com/gfm/\">GitHub-Flavored Markdown</a> is the main syntax that Trilium is following.</p><h2>Images</h2><p>When exporting, images are usually kept in the basic Markdown syntax but will use the HTML syntax if the image has a custom width. Figures are always embedded as HTML.</p><h2>Tables</h2><p>Simple tables are supported with the Markdown syntax. If the table is too complex or contains elements that would render as HTML, the table is also rendered as HTML.</p><h2>Links</h2><p>Standard Markdown links are supported.</p><p>Trilium internal links (that mirror a note's title and display its icon) are embedded as HTML in order to preserve the information on import.</p><h2>Math equations</h2><p>Both inline and display equations are supported, using the <code>$</code> and <code>$$</code> syntaxes.</p><h2>Admonitions</h2><p>The Markdown syntax for admonitions as supported by Trilium is the one that GitHub uses, which is as follows:</p><pre><code class=\"language-text-x-trilium-auto\">> [!NOTE]\n> This is a note.\n\n> [!TIP]\n> This is a tip.\n\n> [!IMPORTANT]\n> This is a very important information.\n\n> [!CAUTION]\n> This is a caution.</code></pre><p>There are currently no plans of supporting alternative admonition syntaxes such as <code>!!! note</code>.</p><h2>Tabs</h2><p>Tabs use the syntax of <a href=\"https://squidfunk.github.io/mkdocs-material/reference/content-tabs/\">Material for MkDocs</a>: each tab starts with a <code>=== \"Title\"</code> line, followed by its content indented by four spaces. Consecutive tabs form one tabs block, and <code>===!</code> starts a new block right after another one:</p><pre><code class=\"language-text-x-trilium-auto\">=== \"Windows\"\n\n Run the **installer**.\n\n=== \"Linux\"\n\n Use the package.\n\n===! \"Another block\"\n\n This tab starts a separate tabs block.</code></pre><p>Tabs can be nested by indenting the inner tabs inside the content of a tab. A tab title is plain text, so its formatting is not kept on export. For how tabs blocks work in a text note, see <a class=\"reference-link\" href=\"#root/_help_EK2ckIZ74tbT\">Content tabs</a>.</p><h2>Wikilinks</h2><p>Basic support for wikilinks has been added in v0.96.0:</p><ul><li><code>[[foo/bar]]</code> will look for the <code>bar.md</code> file in the <code>foo</code> directory and turn it into an internal link.</li><li><code>![[foo/baz.png]]</code> will look for the <code>baz.png</code> file in the <code>foo</code> directory and turn it into an image.</li></ul><p>This feature is import-only, which means that it will turn wikilinks into Trilium-compatible syntax, but it will not export Trilium Notes into Markdown files with this syntax.</p><aside class=\"admonition important\"><p>The path to pages in wikilinks is resolved relatively to the <em>import root</em> and not the current directory of the note. This is to be inline with other platforms that use wikilinks such as SilverBullet.</p><p>The root path of the import is determined as follows:</p><ul><li>If there is a single directory within the archive at root level, then that directory is considered the root.</li><li>If there are multiple files & directories at root level, then the archive root (containing all of these items) is considered the root.</li></ul></aside><h2>Highlights</h2><p>Background highlights are supported in two ways:</p><ul><li><p>The Markdown <code>==</code> extension which is supported by other Markdown-based applications such as Obsidian:</p><pre><code class=\"language-text-x-trilium-auto\">==highlighted==</code></pre></li><li><p>The canonical HTML representation of highlights, as supported by Trilium:</p><pre><code class=\"language-text-html\"><span style=\"background-color:hsl(0,0%,100%);\">Highlighted</span></code></pre></li></ul><p>When the yellow highlight is used, import/export prefers the <code>==</code> syntax whereas the canonical HTML reprepresentation is used otherwise.</p>","_help_ckZ2uNWQmVeX": "<p>Starting with version v0.104.0, Trilium's importer was expanded to application-specific imports. Unlike the standard HTML or <a class=\"reference-link\" href=\"#root/_help_Oau6X9rCuegd\">Markdown</a> import/export, these importers are tailored to support the features and note structure of a particular application.</p><h2>Supported applications</h2><ul><li><a class=\"reference-link\" href=\"#root/_help_GnhlmrATVqcH\">Microsoft OneNote</a>, by connecting to your account using Microsoft Graph.</li><li><a class=\"reference-link\" href=\"#root/_help_Y5mKeJ6dsCld\">Notion</a>, via a ZIP export.</li><li><a class=\"reference-link\" href=\"#root/_help_nhQVuO4zvIxi\">Google Keep</a>, via a ZIP export from <em>Google Takeout</em> (Keep has no dedicated export mechanism).</li><li><a class=\"reference-link\" href=\"#root/_help_syuSEKf2rUGr\">Evernote</a>, via an ENEX export.</li><li><a class=\"reference-link\" href=\"#root/_help_83zmPBJRgfnW\">Anytype</a>, via a JSON export.</li><li><a class=\"reference-link\" href=\"#root/_help_iWD7wiIuMtgV\">Obsidian</a>, via a ZIP of the vault.</li></ul><h2>Importing data from another application</h2><p>To import from an application, there are two ways to access the import dialog:</p><ul><li>In the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>, right click on a note and select <em>Import into note</em>.</li><li>In the <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a>, select <em>Import files</em>.</li></ul><p>A list of supported applications will appear at the top, each with their own configuration. Simply click one and proceed with the on-screen instructions.</p><h2>Acknowledgement</h2><ul><li>Trilium's importer is inspired by Obsidian's <a href=\"https://github.com/obsidianmd/obsidian-importer\">Importer plugin</a> (licensed under the MIT license), for example regarding the OneNote connection process or the Notion ID management.</li></ul>",diff --git a/apps/server/src/in_app_help_provider.spec.ts b/apps/server/src/in_app_help_provider.spec.tsindex 7d8bc25a0f..44b8baee9b 100644--- a/apps/server/src/in_app_help_provider.spec.ts+++ b/apps/server/src/in_app_help_provider.spec.ts@@ -1,9 +1,10 @@import fs from "fs";+import path from "path";import { afterEach, describe, expect, it, vi } from "vitest";// in_app_help_provider is loaded during boot (setup.ts), so vi.mock can't// intercept "fs" — spy on the real (shared) fs.readFileSync instead.-import NodejsInAppHelpProvider from "./in_app_help_provider.js";+import NodejsInAppHelpProvider, { getHelpAssetDir } from "./in_app_help_provider.js";afterEach(() => vi.restoreAllMocks());@@ -43,4 +44,19 @@ describe("NodejsInAppHelpProvider", () => {expect(provider.getHelpHiddenSubtreeData()).toEqual([]);expect(warnSpy).toHaveBeenCalled();});++ it("reads a help asset by its path, and nothing outside the asset directory", async () => {+ const provider = new NodejsInAppHelpProvider();+ const inside = path.join(getHelpAssetDir(), "User Guide", "pic.png");+ const readFile = vi.spyOn(fs.promises, "readFile").mockResolvedValue(Buffer.from([ 1, 2 ]));++ expect(await provider.getHelpAsset("User Guide/pic.png")).toEqual(Buffer.from([ 1, 2 ]));+ expect(path.resolve(String(readFile.mock.calls[0][0]))).toBe(path.resolve(inside));++ expect(await provider.getHelpAsset("../../secret.txt")).toBeNull();+ expect(readFile).toHaveBeenCalledTimes(1);++ readFile.mockRejectedValue(new Error("ENOENT"));+ expect(await provider.getHelpAsset("User Guide/missing.png")).toBeNull();+ });});diff --git a/apps/server/src/in_app_help_provider.ts b/apps/server/src/in_app_help_provider.tsindex 21354a2a5f..a1638b106e 100644--- a/apps/server/src/in_app_help_provider.ts+++ b/apps/server/src/in_app_help_provider.ts@@ -5,6 +5,7 @@ import path from "path";import { assetUrlFragment } from "./services/asset_path.js";import { RESOURCE_DIR } from "./services/resource_dir.js";+import { isDev } from "./services/utils.js";/*** Serves the in-app help from the two artifacts `edit-docs` builds out of `docs/User Guide`:@@ -39,6 +40,31 @@ export default class NodejsInAppHelpProvider extends InAppHelpProvider {getHelpAssetBase(): string {return `${assetUrlFragment}/help`;}++ async getHelpAsset(assetPath: string): Promise<Uint8Array | null> {+ const root = path.resolve(getHelpAssetDir());+ const filePath = path.resolve(root, assetPath);+ if (!filePath.startsWith(root + path.sep)) {+ return null;+ }++ try {+ return await fs.promises.readFile(filePath);+ } catch {+ return null;+ }+ }+}++/**+ * Where the in-app help's images and attachments live: the Markdown export in a source checkout,+ * the copy the build makes (see `copyServerAssets()`) in a packaged one.+ */+export function getHelpAssetDir() {+ if (isDev) {+ return path.join(RESOURCE_DIR, "..", "..", "..", "..", "docs", "User Guide");+ }+ return path.join(RESOURCE_DIR, "help");}function readHelpFile<T>(fileName: string): T | null {diff --git a/apps/server/src/routes/assets.ts b/apps/server/src/routes/assets.tsindex aa1c12827b..45e7e73699 100644--- a/apps/server/src/routes/assets.ts+++ b/apps/server/src/routes/assets.ts@@ -4,6 +4,7 @@ import { existsSync } from "fs";import path from "path";import type serveStatic from "serve-static";+import { getHelpAssetDir } from "../in_app_help_provider.js";import { assetUrlFragment } from "../services/asset_path.js";import auth from "../services/auth.js";import port from "../services/port.js";@@ -117,7 +118,7 @@ async function register(app: express.Application) {// Images and attachments of the in-app help. They are not committed under the server's assets// — the User Guide owns them — so in a source checkout they are served straight out of docs/,// while a packaged build copies them in (see scripts/build.ts).- app.use(`/${assetUrlFragment}/help`, persistentCacheStatic(getHelpAssetDir(srcRoot, resourceDir)));+ app.use(`/${assetUrlFragment}/help`, persistentCacheStatic(getHelpAssetDir()));// `vX` is a version-independent alias so custom themes and scripts can reference built-in assets// without naming a version they would have to bump on every upgrade. It serves the same files as// the versioned routes above, but without `maxAge`: the URL no longer changes between releases,@@ -127,17 +128,6 @@ async function register(app: express.Application) {app.use(`/assets/vX/images`, express.static(path.join(resourceDir, "assets", "images"), STATIC_OPTIONS));}-/**- * Where the in-app help's assets live: the markdown export in a source checkout, the copy the- * build makes in a packaged one.- */-function getHelpAssetDir(srcRoot: string, resourceDir: string) {- if (isDev) {- return path.join(srcRoot, "..", "..", "docs", "User Guide");- }- return path.join(resourceDir, "assets", "help");-}-/** The fixed files of the share theme that every shared page loads. */const SHARE_THEME_ENTRIES = [ "scripts.js", "tree.js", "scripts.css" ];diff --git a/apps/standalone/src/lightweight/in_app_help_provider.spec.ts b/apps/standalone/src/lightweight/in_app_help_provider.spec.tsindex 313851ae11..69ea47a828 100644--- a/apps/standalone/src/lightweight/in_app_help_provider.spec.ts+++ b/apps/standalone/src/lightweight/in_app_help_provider.spec.ts@@ -39,6 +39,21 @@ describe("StandaloneInAppHelpProvider", () => {warn.mockRestore();});+ it("fetches a help asset from the copy the build makes, encoding each path segment", async () => {+ const provider = new StandaloneInAppHelpProvider();+ const fetchSpy = vi.spyOn(globalThis, "fetch")+ .mockResolvedValueOnce(new Response(new Uint8Array([ 1, 2 ]), { status: 200 }))+ .mockResolvedValueOnce(new Response("", { status: 404 }))+ .mockRejectedValueOnce(new Error("offline"));++ expect(await provider.getHelpAsset("User Guide/My pic.png")).toEqual(new Uint8Array([ 1, 2 ]));+ expect(fetchSpy).toHaveBeenCalledWith("/server-assets/help/User%20Guide/My%20pic.png");+ expect(await provider.getHelpAsset("User Guide/missing.png")).toBeNull();+ expect(await provider.getHelpAsset("User Guide/any.png")).toBeNull();++ fetchSpy.mockRestore();+ });+it("points assets at the copy the build makes", () => {expect(new StandaloneInAppHelpProvider().getHelpAssetBase()).toBe("server-assets/help");});diff --git a/apps/standalone/src/lightweight/in_app_help_provider.ts b/apps/standalone/src/lightweight/in_app_help_provider.tsindex 8a9a8cedc5..17d26d2653 100644--- a/apps/standalone/src/lightweight/in_app_help_provider.ts+++ b/apps/standalone/src/lightweight/in_app_help_provider.ts@@ -31,6 +31,16 @@ export default class StandaloneInAppHelpProvider extends InAppHelpProvider {return HELP_ASSETS;}+ async getHelpAsset(assetPath: string): Promise<Uint8Array | null> {+ const url = `/${HELP_ASSETS}/${assetPath.split("/").map(encodeURIComponent).join("/")}`;+ try {+ const response = await fetch(url);+ return response.ok ? new Uint8Array(await response.arrayBuffer()) : null;+ } catch {+ return null;+ }+ }+/*** Loads the page content. Failing costs the pages their bodies while the tree, the titles and* the navigation keep working, so it is logged rather than allowed to fail startup.diff --git a/docs/User Guide/User Guide/Basic Concepts and Features/Import & Export.md b/docs/User Guide/User Guide/Basic Concepts and Features/Import & Export.mdindex cefccb255a..6459bc0ddf 100644--- a/docs/User Guide/User Guide/Basic Concepts and Features/Import & Export.md+++ b/docs/User Guide/User Guide/Basic Concepts and Features/Import & Export.md@@ -65,4 +65,11 @@ You can easily move the notes onto the root using the tree's <a class="referenc</table>> [!TIP]-> Instead of exporting full ZIPs (including the root note), consider using [backups](../Installation%20%26%20Setup/Backup.md) instead. Backups always contain the entire structure, as well as additional information a ZIP export does not have: maintains note IDs, contains the options/tokens and handle <a class="reference-link" href="Notes/Protected%20Notes.md">Protected Notes</a> better.\ No newline at end of file+> Instead of exporting full ZIPs (including the root note), consider using [backups](../Installation%20%26%20Setup/Backup.md) instead. Backups always contain the entire structure, as well as additional information a ZIP export does not have: maintains note IDs, contains the options/tokens and handle <a class="reference-link" href="Notes/Protected%20Notes.md">Protected Notes</a> better.++## Exporting the User Guide++The in-app User Guide can be exported like any other note: right click one of its pages or chapters in the <a class="reference-link" href="UI%20Elements/Note%20Tree.md">Note Tree</a> and select _Export_, or use <a class="reference-link" href="UI%20Elements/Note%20menu.md">Note menu</a> → _Export note_.++* Exporting a chapter with _This note & all descendants_ writes the pictures and files of each page as its attachments. Importing that archive creates an ordinary copy that you can edit, with its pictures and the links between its pages working.+* Exporting a single page with _Only this note_ embeds its pictures in the exported file.\ No newline at end of filediff --git a/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.md b/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.mdindex 6654f8da1b..28568f1f3e 100644--- a/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.md+++ b/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note menu.md@@ -98,7 +98,7 @@ Notes deleted without erasing can be brought back, see <a class="reference-link## Limitations* The note menu is not available on launchers.-* On the notes of <a class="reference-link" href="Options.md">Options</a> and of the in-app help, most entries are grayed out, since these notes cannot be imported into, exported, deleted or have revisions.+* On the notes of <a class="reference-link" href="Options.md">Options</a> and of the in-app help, most entries are grayed out, since these notes cannot be imported into, deleted or have revisions. Of the two, only the in-app help can be exported, see <a class="reference-link" href="../Import%20%26%20Export.md">Import & Export</a>.* The [Note properties](#note-properties) section is only listed when the note itself is displayed, not its <a class="reference-link" href="../Notes/Attachments.md">Attachments</a> or its <a class="reference-link" href="../../Advanced%20Usage/Note%20source.md">Note source</a>.* In <a class="reference-link" href="../Navigation/Quick%20edit.md">Quick edit</a>, _Search in note_, _Note map_, _Full width_ and _Convert into attachment_ are not listed.diff --git a/packages/trilium-core/src/becca/becca_loader.ts b/packages/trilium-core/src/becca/becca_loader.tsindex 58d186da04..d1f860b83e 100644--- a/packages/trilium-core/src/becca/becca_loader.ts+++ b/packages/trilium-core/src/becca/becca_loader.ts@@ -14,6 +14,7 @@ import BNote from "./entities/bnote.js";import BOption from "./entities/boption.js";import { getSql } from "../services/sql";import { getContext } from "../services/context.js";+import dateUtils from "../services/utils/date.js";import { getVirtualNoteProviders, type VirtualNoteProvider, type VirtualSubtreeItem } from "../services/virtual_notes.js";export const beccaLoaded = new Promise<void>(async (res, rej) => {@@ -172,7 +173,11 @@ function injectVirtualItem(provider: VirtualNoteProvider, parentNoteId: string,title: item.title,type: item.type,mime: item.mime ?? "",- isProtected: false+ isProtected: false,+ dateCreated: dateUtils.localNowDateTime(),+ dateModified: dateUtils.localNowDateTime(),+ utcDateCreated: dateUtils.utcNowDateTime(),+ utcDateModified: dateUtils.utcNowDateTime()};if (note) {diff --git a/packages/trilium-core/src/routes/api/export.ts b/packages/trilium-core/src/routes/api/export.tsindex e380ab9f63..8224872849 100644--- a/packages/trilium-core/src/routes/api/export.ts+++ b/packages/trilium-core/src/routes/api/export.ts@@ -30,7 +30,7 @@ async function exportBranch(req: Request<{ branchId: string; type: string; formaif (format !== "html" && format !== "markdown") {throw new ValidationError("Invalid export type.");}- singleExportService.exportSingleNote(taskContext, branch, format, res);+ await singleExportService.exportSingleNote(taskContext, branch, format, res);} else if (format === "opml") {opmlExportService.exportToOpml(taskContext, branch, res);} else {diff --git a/packages/trilium-core/src/services/export/single.spec.ts b/packages/trilium-core/src/services/export/single.spec.tsindex 0c3f0ae829..b32fe8dd7b 100644--- a/packages/trilium-core/src/services/export/single.spec.ts+++ b/packages/trilium-core/src/services/export/single.spec.ts@@ -8,6 +8,7 @@ import type BNote from "../../becca/entities/bnote.js";import type { ExportFormat } from "../../meta.js";import TaskContext from "../task_context.js";import { buildNote } from "../../test/becca_easy_mocking.js";+import { registerVirtualNoteProvider, unregisterVirtualNoteProvider } from "../virtual_notes.js";import singleExportService, { mapByNoteType } from "./single.js";describe("Note type mappings", () => {@@ -254,24 +255,56 @@ describe("exportSingleNote", () => {return { result: singleExportService.exportSingleNote(taskContext, branch, format as ExportFormat, res), res };}- it("writes the mapped payload and download headers for a supported note", () => {+ it("writes the mapped payload and download headers for a supported note", async () => {const note = buildNote({ type: "code", mime: "text/x-markdown", title: "script" });vi.spyOn(note, "getContent").mockReturnValue("# hi");- const { res } = exportNote(note, "html");+ const { result, res } = exportNote(note, "html");+ await result;expect(res.setHeader).toHaveBeenCalledWith("Content-Disposition", expect.stringContaining("script.md"));expect(res.setHeader).toHaveBeenCalledWith("Content-Type", "text/x-markdown; charset=UTF-8");expect(res.send).toHaveBeenCalledWith("# hi");});- it("throws a ValidationError for note types and formats it cannot export", () => {+ it("inlines the pictures and files of a virtual note, which exist only behind its provider", async () => {+ registerVirtualNoteProvider({+ namespace: "_vsingle",+ parentNoteId: "_hidden",+ getSubtree: () => [],+ getAssets: () => [+ { id: "a1", url: "assets/v1/vsingle/pic.png", title: "pic.png", mime: "image/png", getContent: async () => new Uint8Array([ 1, 2, 3 ]) },+ { id: "a2", url: "assets/v1/vsingle/data.dat", title: "data.dat", mime: "application/octet-stream", getContent: async () => new Uint8Array([ 4, 5 ]) },+ { id: "a3", url: "assets/v1/vsingle/gone.png", title: "gone.png", mime: "image/png", getContent: async () => null }+ ]+ });++ try {+ const note = buildNote({+ id: "_vsinglePage", type: "text", title: "Page",+ content: `<img src="assets/v1/vsingle/pic.png"><a href="assets/v1/vsingle/data.dat">data</a><img src="assets/v1/vsingle/gone.png">`+ });+ note.isVirtual = true;++ const { result, res } = exportNote(note, "html");+ await result;++ const payload = String(vi.mocked(res.send).mock.calls[0][0]);+ expect(payload).toContain(`src="data:image/png;base64,AQID"`);+ expect(payload).toContain(`href="data:application/octet-stream;base64,BAU=" download="data.dat"`);+ expect(payload).toContain(`src="assets/v1/vsingle/gone.png"`);+ } finally {+ unregisterVirtualNoteProvider("_vsingle");+ }+ });++ it("throws a ValidationError for note types and formats it cannot export", async () => {// A returned [status, body] tuple used to be dropped on the floor by the route, leaving the// request unanswered; throwing an HttpError is what actually reaches the client.for (const type of ["image", "file"] as const) {const note = buildNote({ type, title: "Binary" });- expect(() => exportNote(note, "html")).toThrow(+ await expect(exportNote(note, "html").result).rejects.toThrow(expect.objectContaining({name: "ValidationError",statusCode: 400,@@ -280,7 +313,7 @@ describe("exportSingleNote", () => {);}- expect(() => exportNote(buildNote({ type: "text", title: "Texty" }), "pdf")).toThrow(+ await expect(exportNote(buildNote({ type: "text", title: "Texty" }), "pdf").result).rejects.toThrow(expect.objectContaining({ name: "ValidationError", statusCode: 400, message: "Unrecognized format 'pdf'" }));});diff --git a/packages/trilium-core/src/services/export/single.ts b/packages/trilium-core/src/services/export/single.tsindex 9804007a08..d6586738ca 100644--- a/packages/trilium-core/src/services/export/single.ts+++ b/packages/trilium-core/src/services/export/single.ts@@ -14,8 +14,9 @@ import mdService from "./markdown.js";import { stripListItemIds } from "./strip_list_item_ids.js";import { ExportFormat } from "../../meta.js";import { encodeBase64 } from "../utils/binary.js";+import { getVirtualNoteAssets, type VirtualNoteAsset } from "../virtual_notes.js";-function exportSingleNote(taskContext: TaskContext<"export">, branch: BBranch, format: ExportFormat, res: Response) {+async function exportSingleNote(taskContext: TaskContext<"export">, branch: BBranch, format: ExportFormat, res: Response) {const note = branch.getNote();// These are thrown rather than returned: the export route writes straight to `res` and has no@@ -30,7 +31,12 @@ function exportSingleNote(taskContext: TaskContext<"export">, branch: BBranch, fthrow new ValidationError(`Unrecognized format '${format}'`);}- const { payload, extension, mime } = mapByNoteType(note, note.getContent(), format);+ let content = note.getContent();+ if (note.isVirtual && typeof content === "string") {+ content = await inlineVirtualAssets(content, getVirtualNoteAssets(note.noteId));+ }++ const { payload, extension, mime } = mapByNoteType(note, content, format);const fileName = `${note.title}.${extension}`;res.setHeader("Content-Disposition", getContentDisposition(fileName));@@ -174,6 +180,26 @@ function inlineAttachments(content: string) {return content;}+/**+ * Replaces the URLs a virtual note's content points at with `data:` URIs, since those files exist+ * only behind the note's provider. An asset that cannot be read keeps its URL.+ */+async function inlineVirtualAssets(content: string, assets: VirtualNoteAsset[]) {+ for (const asset of assets) {+ const bytes = await asset.getContent();+ if (!bytes) {+ continue;+ }++ const dataUri = `data:${asset.mime};base64,${encodeBase64(bytes)}`;+ content = content+ .replaceAll(`src="${asset.url}"`, `src="${dataUri}"`)+ .replaceAll(`href="${asset.url}"`, `href="${dataUri}" download="${escapeHtml(asset.title)}"`);+ }++ return content;+}+export default {exportSingleNote};diff --git a/packages/trilium-core/src/services/export/zip.spec.ts b/packages/trilium-core/src/services/export/zip.spec.tsindex eafb4806c1..affcc3cfd8 100644--- a/packages/trilium-core/src/services/export/zip.spec.ts+++ b/packages/trilium-core/src/services/export/zip.spec.ts@@ -7,6 +7,7 @@ import { afterAll, beforeAll, describe, expect, it } from "vitest";import { isLocalPreviewImageSrc } from "@triliumnext/commons";import becca from "../../becca/becca.js";+import becca_loader from "../../becca/becca_loader.js";import type BBranch from "../../becca/entities/bbranch.js";import type BNote from "../../becca/entities/bnote.js";import type { ExportFormat, NoteMetaFile } from "../../meta.js";@@ -14,6 +15,7 @@ import { getContext } from "../context.js";import noteService from "../notes.js";import sql_init from "../sql_init.js";import { decodeUtf8 } from "../utils/binary.js";+import { registerVirtualNoteProvider, unregisterVirtualNoteProvider } from "../virtual_notes.js";import type { ZipArchive, ZipArchiveEntryOptions, ZipProvider } from "../zip_provider.js";import { getZipProvider, initZipProvider } from "../zip_provider.js";import zip, { shouldStoreUncompressed } from "./zip.js";@@ -553,6 +555,80 @@ describe.skipIf(isBrowserRuntime)("zip export (real DB)", () => {}});+ it("exports a virtual subtree as a copy that imports with its pictures, files and links", async () => {+ const picture = new Uint8Array([ 0x89, 0x50, 0x4e, 0x47, 1, 2, 3 ]);+ const file = new Uint8Array([ 7, 8, 9 ]);+ registerVirtualNoteProvider({+ namespace: "_vzip",+ parentNoteId: "_hidden",+ getSubtree: () => [{+ id: "_vzipGuide", title: "Guide", type: "book",+ attributes: [{ type: "label", name: "readOnly", value: "", isInheritable: true }],+ children: [+ { id: "_vzipPage", title: "Page", type: "text" },+ { id: "_vzipOther", title: "Other", type: "text" }+ ]+ }],+ getContent: (noteId) => (noteId === "_vzipPage"+ ? `<p><img src="assets/v1/vzip/My%20picture.png"></p>`+ + `<p><a href="assets/v1/vzip/data.dat">data</a></p>`+ + `<p><a class="reference-link" href="#root/_vzipOther">Other</a></p>`+ : "<p>other</p>"),+ getAssets: (noteId) => (noteId === "_vzipPage"+ ? [+ { id: "_vzipPage_a1", url: "assets/v1/vzip/My%20picture.png", title: "My picture.png", mime: "image/png", getContent: async () => picture },+ { id: "_vzipPage_a2", url: "assets/v1/vzip/data.dat", title: "data.dat", mime: "application/octet-stream", getContent: async () => file }+ ]+ : [])+ });++ try {+ getContext().init(() => becca_loader.load());+ const taskContext = (await import("../task_context.js")).default;+ const importZip = (await import("../import/zip.js")).default;++ for (const format of [ "html", "markdown" ] as const) {+ const { buffer, entries } = await exportSubtree(becca.getBranchOrThrow("_hidden__vzipGuide"), format);+ const guideMeta = parseMeta(entries).files[0];+ const pageMeta = guideMeta.children?.find((child) => child.noteId === "_vzipPage");+ const attachmentFile = (title: string) => pageMeta?.attachments?.find((a) => a.title === title)?.dataFileName;+ expect(new Uint8Array(entries[`Guide/${attachmentFile("My picture.png")}`]), format).toEqual(picture);+ expect(new Uint8Array(entries[`Guide/${attachmentFile("data.dat")}`]), format).toEqual(file);++ const pageFile = entries[`Guide/${pageMeta?.dataFileName}`].toString("utf-8");+ expect(pageFile, format).not.toContain("assets/v1/vzip");+ // Markdown percent-encodes the file name; HTML writes it as it is.+ const pictureFile = String(attachmentFile("My picture.png"));+ expect([ pictureFile, encodeURIComponent(pictureFile) ].some((name) => pageFile.includes(name)), format).toBe(true);++ const guide = await getContext().init(async () => await importZip.importZip(+ new taskContext("no-progress-reporting", "importNotes", {}),+ buffer,+ becca.getNoteOrThrow("root")+ ));++ const [ page, other ] = [ "Page", "Other" ].map((title) => guide.getChildNotes().find((n) => n.title === title));+ expect(guide.isVirtual || page?.isVirtual, format).toBeFalsy();+ const pictureCopy = page?.getAttachments().find((a) => a.title === "My picture.png");+ const fileCopy = page?.getAttachments().find((a) => a.title === "data.dat");+ expect(new Uint8Array(pictureCopy?.getContent() as Uint8Array), format).toEqual(picture);+ expect(new Uint8Array(fileCopy?.getContent() as Uint8Array), format).toEqual(file);++ const content = page?.getContent().toString();+ expect(content, format).toContain(`src="api/attachments/${pictureCopy?.attachmentId}/image/`);+ expect(content, format).toContain(`attachmentId=${fileCopy?.attachmentId}`);+ expect(content, format).toContain(`href="#root/${other?.noteId}"`);++ // The copy is the user's own: it saves like any other note.+ getContext().init(() => page?.setContent("<p>edited</p>"));+ expect(page?.getContent(), format).toBe("<p>edited</p>");+ }+ } finally {+ unregisterVirtualNoteProvider("_vzip");+ getContext().init(() => becca_loader.load());+ }+ });+it("pipes the archive to the response before appending any content", async () => {// Memory efficiency: the archive must start streaming to the response// before note/attachment content is appended, so blobs drain to thediff --git a/packages/trilium-core/src/services/export/zip.ts b/packages/trilium-core/src/services/export/zip.tsindex bea1a4a3f5..bc93d8899c 100644--- a/packages/trilium-core/src/services/export/zip.ts+++ b/packages/trilium-core/src/services/export/zip.ts@@ -22,6 +22,7 @@ import { extname } from "../utils/path";import { truncateUtf8Bytes } from "../utils/binary";import { rewriteMarkdownContentLinks, isMarkdownCodeNote } from "./rewrite_links.js";import { stripListItemIds } from "./strip_list_item_ids.js";+import { getVirtualNoteAssets, referenceAssetsAsAttachments, type VirtualNoteAsset } from "../virtual_notes.js";// Most filesystems cap a single path component at 255 bytes; keep exported file names within that.const MAX_FILENAME_BYTES = 255;@@ -42,6 +43,8 @@ async function exportToZip(taskContext: TaskContext<"export">, branch: BBranch,const noteIdToMeta: Record<string, NoteMeta> = {};/** The file holding the content of an image or file note in a share export, beside its page. */const noteIdToRawFileName: Record<string, string> = {};+ /** The files a virtual note's content links to, exported as attachments of that note. */+ const noteIdToVirtualAssets: Record<string, VirtualNoteAsset[]> = {};async function buildProvider() {const providerData: ZipExportProviderData = {@@ -217,6 +220,21 @@ async function exportToZip(taskContext: TaskContext<"export">, branch: BBranch,return attMeta;});+ if (note.isVirtual) {+ const assets = getVirtualNoteAssets(note.noteId);+ noteIdToVirtualAssets[note.noteId] = assets;+ for (const [index, asset] of assets.entries()) {+ meta.attachments.push({+ attachmentId: asset.id,+ title: asset.title,+ role: asset.mime.startsWith("image/") ? "image" : "file",+ mime: asset.mime,+ position: (index + 1) * 10,+ dataFileName: getDataFileName(null, asset.mime, `${baseFileName}_${asset.title}`, existingFileNames)+ });+ }+ }+if (childBranches.length > 0) {meta.dirFileName = getUniqueFilename(existingFileNames, baseFileName);meta.children = [];@@ -366,6 +384,10 @@ async function exportToZip(taskContext: TaskContext<"export">, branch: BBranch,content = stripListItemIds(content);}+ if (note?.isVirtual && typeof content === "string") {+ content = referenceAssetsAsAttachments(note.noteId, content, noteIdToVirtualAssets[note.noteId] ?? []);+ }+content = provider.prepareContent(title, content, noteMeta, note, branch);// Rewrite markdown-style links for code notes with markdown MIME.@@ -437,11 +459,17 @@ async function exportToZip(taskContext: TaskContext<"export">, branch: BBranch,continue;}- const attachment = note.getAttachmentById(attachmentMeta.attachmentId);+ const asset = noteIdToVirtualAssets[note.noteId]?.find((a) => a.id === attachmentMeta.attachmentId);// getContent() already returns a string or a Uint8Array; the binary// case can be appended as-is (the zip provider handles the Buffer// conversion), so avoid an extra full copy of the blob here.- const content = attachment.getContent();+ const content = asset+ ? await asset.getContent()+ : note.getAttachmentById(attachmentMeta.attachmentId).getContent();+ if (content === null) {+ log.info(`Could not read asset '${attachmentMeta.title}' of virtual note '${note.noteId}', leaving it out of the export.`);+ continue;+ }archive.append(content, {name: filePathPrefix + attachmentMeta.dataFileName,diff --git a/packages/trilium-core/src/services/in_app_help.spec.ts b/packages/trilium-core/src/services/in_app_help.spec.tsindex 9e69f6c7e1..5d9557574e 100644--- a/packages/trilium-core/src/services/in_app_help.spec.ts+++ b/packages/trilium-core/src/services/in_app_help.spec.ts@@ -6,7 +6,7 @@ import { load } from "../becca/becca_loader.js";import blobService from "./blob.js";import { getContext } from "./context.js";import { getHelpHiddenSubtreeData, HELP_ASSET_TOKEN, InAppHelpProvider, initInAppHelp } from "./in_app_help.js";-import { getVirtualNoteProvider } from "./virtual_notes.js";+import { getVirtualNoteAssets, getVirtualNoteProvider } from "./virtual_notes.js";/** Minimal concrete provider standing in for the platform-specific implementations. */class TestHelpProvider extends InAppHelpProvider {@@ -25,6 +25,13 @@ class TestHelpProvider extends InAppHelpProvider {getHelpAssetBase(): string {return this.assetBase;}++ readAssets: string[] = [];++ async getHelpAsset(assetPath: string): Promise<Uint8Array | null> {+ this.readAssets.push(assetPath);+ return new Uint8Array([ assetPath.length ]);+ }}function reloadBecca() {@@ -106,6 +113,31 @@ describe("in_app_help", () => {.toBe(`<img src="assets/v1.2.3/help/User%20Guide/pic.png">`);});+ it("declares each picture and file a page references, at the URL its content carries", async () => {+ const page = `<img src="${HELP_ASSET_TOKEN}/User%20Guide/My%20pic.png">`+ + `<a href="${HELP_ASSET_TOKEN}/User%20Guide/api.dat">API</a>`+ + `<img src="${HELP_ASSET_TOKEN}/User%20Guide/My%20pic.png">`+ + `<a href="https://example.com/x.png">elsewhere</a>`;+ const provider = new TestHelpProvider(+ [{ id: "_helpPage", title: "Page", type: "text" }],+ { _helpPage: page },+ "assets/v1.2.3/help"+ );+ initInAppHelp(provider);+ reloadBecca();++ const assets = getVirtualNoteAssets("_helpPage");+ expect(assets.map(({ id, url, title, mime }) => ({ id, url, title, mime }))).toEqual([+ { id: "_helpPage_a1", url: "assets/v1.2.3/help/User%20Guide/My%20pic.png", title: "My pic.png", mime: "image/png" },+ { id: "_helpPage_a2", url: "assets/v1.2.3/help/User%20Guide/api.dat", title: "api.dat", mime: "application/octet-stream" }+ ]);+ const content = String(becca.getNoteOrThrow("_helpPage").getContent());+ expect(assets.every((asset) => content.includes(`"${asset.url}"`))).toBe(true);++ await assets[0].getContent();+ expect(provider.readAssets).toEqual([ "User Guide/My pic.png" ]);+ });+it("makes every help page read-only through an inheritable label on the root", () => {initInAppHelp(new TestHelpProvider([{ id: "_helpPage", title: "Page", type: "text" }]));reloadBecca();diff --git a/packages/trilium-core/src/services/in_app_help.ts b/packages/trilium-core/src/services/in_app_help.tsindex 73dad7a9e7..e0906f7d9c 100644--- a/packages/trilium-core/src/services/in_app_help.ts+++ b/packages/trilium-core/src/services/in_app_help.ts@@ -1,7 +1,13 @@import type { HelpBundle, HiddenSubtreeItem } from "@triliumnext/commons";import { t } from "i18next";+import mimeTypes from "mime-types";-import { registerVirtualNoteProvider, unregisterVirtualNoteProvider, type VirtualSubtreeItem } from "./virtual_notes.js";+import {+ registerVirtualNoteProvider,+ unregisterVirtualNoteProvider,+ type VirtualNoteAsset,+ type VirtualSubtreeItem+} from "./virtual_notes.js";/*** Platform-specific source of the in-app help (User Guide), both its tree and the rendered content@@ -29,6 +35,12 @@ export abstract class InAppHelpProvider {* custom protocol.*/abstract getHelpAssetBase(): string;++ /**+ * Reads one of the guide's images or attachments, by its path from the export root as the+ * pages reference it (percent-decoded). Resolves to `null` when the file cannot be read.+ */+ abstract getHelpAsset(assetPath: string): Promise<Uint8Array | null>;}/**@@ -77,10 +89,35 @@ export function initInAppHelp(p: InAppHelpProvider) {getContent(noteId: string) {const page = provider?.getHelpContent()[noteId];return page?.replaceAll(HELP_ASSET_TOKEN, provider?.getHelpAssetBase() ?? "");- }+ },+ getAssets: (noteId) => getHelpPageAssets(p, noteId)});}export function getHelpHiddenSubtreeData(): HiddenSubtreeItem[] {return provider?.getHelpHiddenSubtreeData() ?? [];}++/** The images and attachments one help page references, in the order they first appear. */+function getHelpPageAssets(p: InAppHelpProvider, noteId: string): VirtualNoteAsset[] {+ const page = p.getHelpContent()[noteId] ?? "";+ const prefix = `${HELP_ASSET_TOKEN}/`;+ const encodedPaths = new Set<string>();+ for (const [ , url ] of page.matchAll(/(?:src|href)="([^"]*)"/g)) {+ if (url.startsWith(prefix)) {+ encodedPaths.add(url.slice(prefix.length));+ }+ }++ return [ ...encodedPaths ].map((encodedPath, index) => {+ const assetPath = decodeURIComponent(encodedPath);+ const title = assetPath.split("/").pop() ?? assetPath;+ return {+ id: `${noteId}_a${index + 1}`,+ url: `${p.getHelpAssetBase()}/${encodedPath}`,+ title,+ mime: mimeTypes.lookup(title) || "application/octet-stream",+ getContent: () => p.getHelpAsset(assetPath)+ };+ });+}diff --git a/packages/trilium-core/src/services/virtual_notes.ts b/packages/trilium-core/src/services/virtual_notes.tsindex 97bb445ce7..94c964797d 100644--- a/packages/trilium-core/src/services/virtual_notes.ts+++ b/packages/trilium-core/src/services/virtual_notes.ts@@ -44,12 +44,27 @@ export interface VirtualNoteProvider {getSubtree(): VirtualSubtreeItem[];/**- * Optional note content lookup, for providers whose notes carry content (e.g. file-system- * mounts). When absent — or when it returns `null`/`undefined` — the content is `""`.- * The in-app help does not use this: help pages are `doc` notes whose HTML the client- * fetches directly from bundled assets.+ * Content of a virtual note. When absent, or when it returns `null` or `undefined`, the+ * content is `""`.*/getContent?(noteId: string): string | Uint8Array | null | undefined;++ /**+ * Files that the note's content references by URL (pictures, downloads). An export carries+ * them as attachments of the note, so the exported copy works without the provider.+ */+ getAssets?(noteId: string): VirtualNoteAsset[];+}++export interface VirtualNoteAsset {+ /** Stands in for an attachment ID in an export, so it uses only `[a-zA-Z0-9_]`. */+ id: string;+ /** The URL exactly as `getContent()` writes it into the note. */+ url: string;+ title: string;+ mime: string;+ /** Resolves to `null` when the file cannot be read; the export then leaves it out. */+ getContent(): Promise<Uint8Array | null>;}export interface VirtualSubtreeItem {@@ -124,3 +139,26 @@ export function getVirtualNoteProvider(noteId: string): VirtualNoteProvider | nuexport function getVirtualNoteContent(noteId: string): string | Uint8Array {return getVirtualNoteProvider(noteId)?.getContent?.(noteId) ?? "";}++/** Assets of a virtual note, delegated to its provider; empty when the provider has none. */+export function getVirtualNoteAssets(noteId: string): VirtualNoteAsset[] {+ return getVirtualNoteProvider(noteId)?.getAssets?.(noteId) ?? [];+}++/**+ * Rewrites the asset URLs in a virtual note's HTML into the references a persisted note uses for+ * its attachments: `api/attachments/<id>/image/<title>` for a picture, an attachment link for any+ * other file. The export rewrites those references to the exported files.+ */+export function referenceAssetsAsAttachments(noteId: string, content: string, assets: VirtualNoteAsset[]) {+ for (const asset of assets) {+ const attachmentLink = `#root/${noteId}?viewMode=attachments&attachmentId=${asset.id}`;+ if (asset.mime.startsWith("image/")) {+ content = content.replaceAll(`src="${asset.url}"`,+ `src="api/attachments/${asset.id}/image/${encodeURIComponent(asset.title)}"`);+ }+ content = content.replaceAll(`href="${asset.url}"`, `href="${attachmentLink}"`);+ }++ return content;+}