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
client/code notes: switch to CodeMirror's own highlighter for code note previews
Adorian Doran6288cdb9b803
diff --git a/apps/client/src/services/code_note_preview.spec.ts b/apps/client/src/services/code_note_preview.spec.tsnew file mode 100644index 0000000000..0d34213161--- /dev/null+++ b/apps/client/src/services/code_note_preview.spec.ts@@ -0,0 +1,115 @@+import { afterEach, describe, expect, it, vi } from "vitest";++import { buildNote } from "../test/easy-froca.js";++type PreviewModule = typeof import("./code_note_preview.js");+type CodeMirrorPreviewModule = typeof import("@triliumnext/codemirror/src/code_preview.js");++const CODE = "const a = 1;\nlet b = 2;";+const DEVICE = window.glob.device;++describe("renderCodeNotePreview", () => {+ afterEach(() => {+ window.glob.device = DEVICE;+ for (const style of document.head.querySelectorAll("style")) style.remove();+ });++ it("colors the preview with the light and dark themes, each scoped to its scheme", async () => {+ const { renderCodeNotePreview } = await freshModule({ codeNoteThemeMatchesApp: "true" });+ const pre = await renderCodeNotePreview(CODE, "text/javascript");++ expect({ ...pre.dataset }).toEqual({+ codeThemeL: "vs-code-light", codeThemeD: "vs-code-dark"+ });+ expect(pre.querySelectorAll(".code-preview-line").length).toBe(2);+ expect(pre.querySelector(".code-preview-line span")?.className).toMatch(/^l\d+ d\d+$/);+ const styles = [ ...document.head.querySelectorAll("style") ].map((s) => s.textContent);+ expect(styles.map((css) => css?.split(" .code-preview")[0])).toEqual([+ ":where(body:not(.dark-theme))", ":where(body.dark-theme)"+ ]);++ // A second preview reuses the CSS, and the HTML of the same content.+ const again = await renderCodeNotePreview(CODE, "text/javascript");+ expect(again).not.toBe(pre);+ expect(again.outerHTML).toBe(pre.outerHTML);+ expect(document.head.querySelectorAll("style").length).toBe(2);+ });++ it("uses the one theme unless they follow the app, and the light theme to print", async () => {+ const { renderCodeNotePreview } = await freshModule({ codeNoteThemeMatchesApp: "false" });++ const single = await renderCodeNotePreview(CODE, "text/javascript");+ expect({ ...single.dataset }).toEqual({ codeThemeT: "monokai" });++ window.glob.device = "print";+ const printed = await renderCodeNotePreview(CODE, "text/javascript");+ expect({ ...printed.dataset }).toEqual({ codeThemeT: "vs-code-light" });+ expect(document.head.querySelector("style")?.textContent)+ .toMatch(/^\.code-preview\[data-code-theme-t="monokai"\]/);+ });++ it("falls back to the default style for a theme that is not a built-in one", async () => {+ const { renderCodeNotePreview } = await freshModule({+ codeNoteThemeMatchesApp: "false", codeNoteTheme: "custom"+ });+ const pre = await renderCodeNotePreview(CODE, "text/javascript");+ expect({ ...pre.dataset }).toEqual({ codeThemeT: "default" });+ });++ it("wraps the lines by the `#wrapLines` label of the note, else by the option", async () => {+ const { renderCodeNotePreview } = await freshModule({ codeLineWrapEnabled: "true" });+ const isWrapped = async (note?: Parameters<PreviewModule["renderCodeNotePreview"]>[2]) =>+ (await renderCodeNotePreview(CODE, "text/javascript", note))+ .classList.contains("code-preview-wrap");++ expect(await isWrapped()).toBe(true);+ expect(await isWrapped(buildNote({ title: "Off", "#wrapLines": "false" }))).toBe(false);+ expect(await isWrapped(buildNote({ title: "On", "#wrapLines": "" }))).toBe(true);+ });++ it("shows code too long to highlight plain, still numbered", async () => {+ const { renderCodeNotePreview } = await freshModule({});+ const long = Array.from({ length: 600 }, () => "let a = 1;").join("\n");+ const pre = await renderCodeNotePreview(long, "text/javascript");++ expect(pre.querySelectorAll(".code-preview-line").length).toBe(600);+ expect(pre.querySelectorAll(".code-preview-line span").length).toBe(0);+ expect(pre.getAttribute("style")).toBe("--code-preview-digits: 3");+ });++ it("renders the same content once, until 256 others push it out", async () => {+ const renderCodePreview = vi.fn();+ vi.doMock("@triliumnext/codemirror/src/code_preview.js", async (importOriginal) => {+ const original = await importOriginal<CodeMirrorPreviewModule>();+ renderCodePreview.mockImplementation(original.renderCodePreview);+ return { ...original, renderCodePreview };+ });+ try {+ const { renderCodeNotePreview } = await freshModule({});+ for (let index = 0; index <= 256; index++) {+ await renderCodeNotePreview(`a = ${index}`, "text/plain");+ }+ await renderCodeNotePreview("a = 256", "text/plain");+ expect(renderCodePreview).toHaveBeenCalledTimes(257);+ await renderCodeNotePreview("a = 0", "text/plain");+ expect(renderCodePreview).toHaveBeenCalledTimes(258);+ } finally {+ vi.doUnmock("@triliumnext/codemirror/src/code_preview.js");+ }+ });+});++/** Loads the module again, so its caches start empty, with `values` over the default options. */+async function freshModule(values: Record<string, string>): Promise<PreviewModule> {+ vi.resetModules();+ const options = (await import("./options.js")).default;+ options.load({+ codeNoteThemeMatchesApp: "true",+ codeNoteTheme: "default:monokai",+ codeNoteThemeLight: "default:vs-code-light",+ codeNoteThemeDark: "default:vs-code-dark",+ codeLineWrapEnabled: "false",+ ...values+ });+ return import("./code_note_preview.js");+}diff --git a/apps/client/src/services/code_note_preview.ts b/apps/client/src/services/code_note_preview.tsnew file mode 100644index 0000000000..a35d8132e2--- /dev/null+++ b/apps/client/src/services/code_note_preview.ts@@ -0,0 +1,96 @@+import "@triliumnext/codemirror/src/code_preview.css";++import {+ buildCodePreviewCss, loadPreviewLanguage, loadPreviewTheme, type PreviewThemeSlot,+ renderCodePreview+} from "@triliumnext/codemirror/src/code_preview.js";+import { type OptionNames, shouldSyntaxHighlight } from "@triliumnext/commons";++import type FNote from "../entities/fnote.js";+import { CODE_THEME_DEFAULT_PREFIX } from "../widgets/type_widgets/constants.js";+import options from "./options.js";++interface ThemeChoice {+ /** The option with the ID of the theme. */+ option: OptionNames;+ key: string;+ /** The selector the CSS of the theme is nested under. */+ scope?: string;+}++const CACHE_MAX = 256;++const cache = new Map<string, string>();+const mountedThemes = new Set<string>();++/**+ * Renders `content` as CodeMirror shows it in a code note: in the colors of the code note themes,+ * with line numbers.+ *+ * @param note the note whose `#wrapLines` label sets the line wrapping, over the option.+ */+export async function renderCodeNotePreview(content: string, mime: string, note?: FNote | null) {+ const [ themes, language ] = await Promise.all([+ Promise.all(getThemeChoices().map(loadSlot)),+ shouldSyntaxHighlight(content) ? loadPreviewLanguage(mime) : null+ ]);+ const isWrapped = isLineWrapped(note);+ const cacheKey = [+ ...themes.map(({ theme, key }) => `${key}:${theme.id}`), mime, isWrapped, content+ ].join("\0");++ let html = cache.get(cacheKey);+ if (html === undefined) {+ html = renderCodePreview(content, { themes, language, isWrapped });+ remember(cacheKey, html);+ }++ const template = document.createElement("template");+ template.innerHTML = html;+ return template.content.firstElementChild as HTMLElement;+}++/** The light and dark themes when they follow the app, else the one theme. Print is light. */+function getThemeChoices(): ThemeChoice[] {+ if (glob.device === "print") {+ return [ { option: "codeNoteThemeLight", key: "t" } ];+ }+ if (options.is("codeNoteThemeMatchesApp")) {+ return [+ { option: "codeNoteThemeLight", key: "l", scope: ":where(body:not(.dark-theme))" },+ { option: "codeNoteThemeDark", key: "d", scope: ":where(body.dark-theme)" }+ ];+ }+ return [ { option: "codeNoteTheme", key: "t" } ];+}++/** Loads the theme of `choice`, and adds its CSS to the page the first time. */+async function loadSlot({ option, key, scope }: ThemeChoice): Promise<PreviewThemeSlot> {+ const value = options.get(option) ?? "";+ const id = value.startsWith(CODE_THEME_DEFAULT_PREFIX)+ ? value.slice(CODE_THEME_DEFAULT_PREFIX.length)+ : value;+ const slot = { theme: await loadPreviewTheme(id), key };++ const mountKey = `${key}:${slot.theme.id}`;+ if (!mountedThemes.has(mountKey)) {+ mountedThemes.add(mountKey);+ const style = document.createElement("style");+ style.textContent = buildCodePreviewCss(slot, scope);+ document.head.append(style);+ }+ return slot;+}++function isLineWrapped(note: FNote | null | undefined) {+ const label = note?.getLabelValue("wrapLines");+ return label == null ? options.is("codeLineWrapEnabled") : label !== "false";+}++function remember(key: string, html: string) {+ if (cache.size >= CACHE_MAX) {+ const oldest = cache.keys().next().value;+ if (oldest !== undefined) cache.delete(oldest);+ }+ cache.set(key, html);+}diff --git a/apps/client/src/services/content_renderer.spec.ts b/apps/client/src/services/content_renderer.spec.tsindex 9da9c30f17..6446a2621e 100644--- a/apps/client/src/services/content_renderer.spec.ts+++ b/apps/client/src/services/content_renderer.spec.ts@@ -27,9 +27,11 @@ const renderServiceRender = vi.fn(async (...args: any[]) => {});vi.mock("./render.js", () => ({ default: { render: (...args: any[]) => renderServiceRender(...args) } }));-const applySingleBlockSyntaxHighlight = vi.fn(async (..._args: any[]) => {});-vi.mock("./syntax_highlight.js", () => ({- applySingleBlockSyntaxHighlight: (...args: any[]) => applySingleBlockSyntaxHighlight(...args)+const renderCodeNotePreview = vi.fn(async (content: string, _mime: string, _note?: unknown) => (+ $("<pre>").append($("<code>").text(content))[0]+));+vi.mock("./code_note_preview.js", () => ({+ renderCodeNotePreview: (...args: [ string, string, unknown ]) => renderCodeNotePreview(...args)}));const setupContextMenu = vi.fn((..._args: any[]) => {});@@ -356,7 +358,8 @@ describe("getRenderedContent code rendering", () => {const { type, $renderedContent } = await getRenderedContent(note);expect(type).toBe("code");expect($renderedContent.find("pre > code").text()).toBe('{\n "a": 1\n}');- expect(applySingleBlockSyntaxHighlight).toHaveBeenCalledOnce();+ expect(renderCodeNotePreview.mock.calls)+ .toEqual([ [ '{\n "a": 1\n}', "application/json", note ] ]);});it("leaves invalid JSON untouched", async () => {@@ -397,7 +400,7 @@ describe("getRenderedContent editable code", () => {});expect((await getRenderedContent(largeSource)).type).toBe("file");expect(large.getBlob).not.toHaveBeenCalled();- expect(applySingleBlockSyntaxHighlight).not.toHaveBeenCalled();+ expect(renderCodeNotePreview).not.toHaveBeenCalled();});it("renders an attached code file as code, highlighted by the language of its name", async () => {@@ -417,8 +420,8 @@ describe("getRenderedContent editable code", () => {attachment.getBlob = (async () => ({ content: "" })) as any;await getRenderedContent(attachment);}- expect(applySingleBlockSyntaxHighlight.mock.calls.map(([ , mime ]) => mime)).toEqual([- "text-x-python", "text-javascript", "application-typescript", "text-plain"+ expect(renderCodeNotePreview.mock.calls.map(([ , mime ]) => mime)).toEqual([+ "text/x-python", "text/javascript", "application/typescript", "text/plain"]);});@@ -533,14 +536,14 @@ describe("getRenderedContent editable code", () => {att.getBlob = (async () => ({ content: "echo 1" })) as any;await getRenderedContent(att, { codeLanguage: "text/x-sh" });- expect(applySingleBlockSyntaxHighlight.mock.lastCall?.[1]).toBe("text-x-sh");+ expect(renderCodeNotePreview.mock.lastCall?.[1]).toBe("text/x-sh");await getRenderedContent(att, {codeLanguage: "text/x-sh", interactive: true, attachmentEditor: buildEditor()});const props = codeEmbedComponent.mock.lastCall?.[0];expect([ props.mime, props.codeLanguage ]).toEqual([ "text/x-python", "text/x-sh" ]);- expect(applySingleBlockSyntaxHighlight.mock.lastCall?.[1]).toBe("text-x-sh");+ expect(renderCodeNotePreview.mock.lastCall?.[1]).toBe("text/x-sh");});it("mounts TextEmbed for an interactive text note, with a preview to render again", async () => {diff --git a/apps/client/src/services/content_renderer.ts b/apps/client/src/services/content_renderer.tsindex a4951eb08f..a4da6e614e 100644--- a/apps/client/src/services/content_renderer.ts+++ b/apps/client/src/services/content_renderer.ts@@ -9,7 +9,6 @@ import {isAcceptedImageMime,isImageAttachmentRole,isMarkdownMime,- normalizeMimeTypeForCKEditor,type TextRepresentationResponse} from "@triliumnext/commons";import DOMPurify from "dompurify";@@ -35,7 +34,6 @@ import { waitForPendingRenders } from "./pending_renders.js";import protectedSessionService from "./protected_session.js";import protectedSessionHolder from "./protected_session_holder.js";import server from "./server.js";-import { applySingleBlockSyntaxHighlight } from "./syntax_highlight.js";import { getErrorMessage } from "./utils.js";let idCounter = 1;@@ -481,7 +479,8 @@ async function renderCode(const content = editor?.getUnsavedContent() ?? (await entity.getBlob())?.content ?? "";const mime = getCodeMime(entity);const { codeLanguage } = options;- const preview = await renderCodePreview(content, codeLanguage ?? mime);+ const note = entity instanceof FNote ? entity : null;+ const preview = await renderCodePreview(content, codeLanguage ?? mime, note);if (!editor) {$renderedContent.append(preview);@@ -500,8 +499,12 @@ async function renderCode($renderedContent.append($container);}-/** The highlighted content of a code note or file, with JSON indented. */-export async function renderCodePreview(content: string, mime: string) {+/**+ * The highlighted content of a code note or file, with JSON indented.+ *+ * @param note the note whose `#wrapLines` label sets the line wrapping.+ */+export async function renderCodePreview(content: string, mime: string, note?: FNote | null) {if (mime === "application/json") {try {content = JSON.stringify(JSON.parse(content), null, 4);@@ -510,11 +513,8 @@ export async function renderCodePreview(content: string, mime: string) {}}- const $codeBlock = $("<code>");- $codeBlock.text(content);- const $pre = $("<pre>").append($codeBlock);- await applySingleBlockSyntaxHighlight($codeBlock, normalizeMimeTypeForCKEditor(mime));- return $pre[0];+ const { renderCodeNotePreview } = await import("./code_note_preview.js");+ return renderCodeNotePreview(content, mime, note);}/**diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.cssindex 70297dcab6..ab7e55d51f 100644--- a/apps/client/src/stylesheets/style.css+++ b/apps/client/src/stylesheets/style.css@@ -400,6 +400,11 @@ button kbd {font-family: var(--monospace-font-family) !important;}+:root pre.code-preview > .code-preview-content {+ font-family: var(--monospace-font-family);+ font-size: var(--monospace-font-size);+}+.cm-editor .cm-placeholder {color: inherit;opacity: 0.5;diff --git a/apps/client/src/widgets/collections/legacy/ListOrGridView.css b/apps/client/src/widgets/collections/legacy/ListOrGridView.cssindex 4a66712aba..dc6cd00957 100644--- a/apps/client/src/widgets/collections/legacy/ListOrGridView.css+++ b/apps/client/src/widgets/collections/legacy/ListOrGridView.css@@ -453,7 +453,6 @@&.type-code pre {height: 100%;- padding: 1em;margin-bottom: 0;}}diff --git a/apps/client/src/widgets/type_widgets/code/CodeEmbed.spec.tsx b/apps/client/src/widgets/type_widgets/code/CodeEmbed.spec.tsxindex df5e313a62..ebdab12ab4 100644--- a/apps/client/src/widgets/type_widgets/code/CodeEmbed.spec.tsx+++ b/apps/client/src/widgets/type_widgets/code/CodeEmbed.spec.tsx@@ -19,11 +19,13 @@ import { NoteSaves } from "../text/attachment_saves";import { getContentEmbedTools, getEmbedFindTarget } from "../text/content_embed_tools";import CodeEmbed from "./CodeEmbed";-const renderCodePreview = vi.hoisted(() => vi.fn(async (content: string, _mime: string) => {- const pre = document.createElement("pre");- pre.textContent = content;- return pre;-}));+const renderCodePreview = vi.hoisted(() => vi.fn(+ async (content: string, _mime: string, _note?: unknown) => {+ const pre = document.createElement("pre");+ pre.textContent = content;+ return pre;+ }+));vi.mock("../../../services/content_renderer", () => ({ renderCodePreview }));vi.mock("../../../services/i18n", () => ({t: (key: string, values?: Record<string, unknown>) =>@@ -238,12 +240,12 @@ describe("CodeEmbed", () => {expect(textEditor.execute).toHaveBeenLastCalledWith("setContentEmbedCodeView", { language: null });await vi.waitFor(() => {- expect(renderCodePreview).toHaveBeenLastCalledWith("if a:\n b", "text/x-python");+ expect(renderCodePreview).toHaveBeenLastCalledWith("if a:\n b", "text/x-python", null);});await select("codeLanguage", "Plain text");expect(figure.getAttribute("data-code-language")).toBe("text/plain");await vi.waitFor(() => {- expect(renderCodePreview).toHaveBeenLastCalledWith("if a:\n b", "text/plain");+ expect(renderCodePreview).toHaveBeenLastCalledWith("if a:\n b", "text/plain", null);});// The indentation, which a re-indent sets with the content, as one change.@@ -301,7 +303,7 @@ describe("CodeEmbed", () => {await Promise.resolve();});await vi.waitFor(() => {- expect(renderCodePreview).toHaveBeenLastCalledWith("ab", "text/x-python");+ expect(renderCodePreview).toHaveBeenLastCalledWith("ab", "text/x-python", null);});});diff --git a/apps/client/src/widgets/type_widgets/code/CodeEmbed.tsx b/apps/client/src/widgets/type_widgets/code/CodeEmbed.tsxindex dc4df951d0..d153d680b6 100644--- a/apps/client/src/widgets/type_widgets/code/CodeEmbed.tsx+++ b/apps/client/src/widgets/type_widgets/code/CodeEmbed.tsx@@ -61,7 +61,7 @@ export default function CodeEmbed({const shownPreview = useEmbedPreview(preview,`${mime}\n${content}`,- () => renderCodePreview(content, mime),+ () => renderCodePreview(content, mime, note),isEditing);// The editor while it is open, otherwise the content with the unsaved changes of any embed ofdiff --git a/apps/client/vite-plugins.mts b/apps/client/vite-plugins.mtsindex 70a5845670..8cb0626159 100644--- a/apps/client/vite-plugins.mts+++ b/apps/client/vite-plugins.mts@@ -3,9 +3,15 @@ import type { ServerResponse } from "node:http";import { join, posix } from "node:path";import { fileURLToPath } from "node:url";+// Node loads these without a bundler, so neither imports another source file.+import { getThemeById } from "@triliumnext/codemirror/src/color_themes.js";+import {+ buildCodePreviewCss, readPreviewTheme+} from "@triliumnext/codemirror/src/preview_theme.js";import type { ShareThemeManifest } from "@triliumnext/commons";import {- resolveShareThemeGroups, SHARE_HOSTED_NOTE_TYPES, SHARE_HOSTED_VIEW_TYPES+ resolveShareThemeGroups, SHARE_CODE_PREVIEW_THEMES, SHARE_HOSTED_NOTE_TYPES,+ SHARE_HOSTED_VIEW_TYPES} from "@triliumnext/commons/src/lib/share_hosting.js";import {buildVsCodeThemeCss, VS_CODE_DARK, VS_CODE_LIGHT@@ -405,20 +411,32 @@ async function emitShareTheme(/*** Serves `virtual:code-themes.css`: the VS Code highlighting themes code notes also use, one per- * share theme mode. `:where()` keeps the block rules as weak as a stock highlight.js theme's, so- * the share theme's own `.ck-content code` colors still win inside text notes.+ * share theme mode, for the highlight.js code blocks of text notes and for the code notes that+ * `renderCodePreview()` renders. `:where()` keeps the block rules as weak as a stock highlight.js+ * theme's, so the share theme's own `.ck-content code` colors still win inside text notes.*/function codeThemesPlugin(): Plugin {return {name: "share-theme-code-themes",resolveId: (id) => (id === CODE_THEMES_ID ? `\0${CODE_THEMES_ID}` : null),// The development server asks for `?direct` when `scripts.css` imports the themes.- load: (id) => (id.split("?")[0] === `\0${CODE_THEMES_ID}`- ? [+ load: async (id) => {+ if (id.split("?")[0] !== `\0${CODE_THEMES_ID}`) return null;++ const codePreviewCss = await Promise.all(SHARE_CODE_PREVIEW_THEMES.map(+ async ({ id: themeId, key, scope }) => {+ const definition = getThemeById(themeId);+ if (!definition) throw new Error(`Unknown code note theme "${themeId}".`);+ const theme = readPreviewTheme(themeId, await definition.load());+ return buildCodePreviewCss({ theme, key }, scope);+ }+ ));+ return [buildVsCodeThemeCss(VS_CODE_LIGHT, ":where(html.theme-light)"),- buildVsCodeThemeCss(VS_CODE_DARK, ":where(html.theme-dark)")- ].join("\n")- : null)+ buildVsCodeThemeCss(VS_CODE_DARK, ":where(html.theme-dark)"),+ ...codePreviewCss+ ].join("\n");+ }};}diff --git a/apps/server/src/assets/help/help_content.json b/apps/server/src/assets/help/help_content.jsonindex b123049942..e242d7ec5e 100644--- a/apps/server/src/assets/help/help_content.json+++ b/apps/server/src/assets/help/help_content.json@@ -71,7 +71,7 @@"_help_MKmLg5x6xkor": "<p>Archived notes are notes which have <code>archived</code> <a href=\"#root/_help_zEY4DaJG4YT5\">attribute</a> - either directly or <a href=\"#root/_help_bwZpz2ajCEwO\">inherited</a>.</p><p>Such notes are then by default not shown in the autocomplete and in the full text <a href=\"#root/_help_eIg8jdvaoNNd\">search</a>.</p><p>This can be useful for notes which are no longer very useful but still valuable enough to keep around without them getting too much in the way.</p><p>You can control whether archived notes are displayed in the note tree with a setting:</p><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Notes/Archived%20Notes_hide-archived.png\"></p>","_help_vZWERwf8U3nx": "<figure class=\"image\"><img style=\"aspect-ratio:2089/1515;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Notes/Note%20Revisions_image.png\" width=\"2089\" height=\"1515\"></figure><p>Trilium supports seamless versioning of notes by storing snapshots (\"revisions\") of notes at regular intervals.</p><p>To display the revisions, press the <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> and select <em>Note revisions…</em> (<span class=\"tn-icon bx bx-history\"></span>).</p><h2>Interaction</h2><aside class=\"admonition note\"><p>This documentation matches the redesign of the note revisions dialog on v0.103.0, older versions have a similar dialog but with some differences.</p></aside><ul><li>The full list of revisions are displayed on the left in reverse chronological order.<ul><li>The revisions are grouped by the date the revision was taken.</li><li>This list does not contain the <em>current state</em> of the note, so it is possible to have notes with no revisions/snapshots saved.</li></ul></li><li>The icon of a revision indicates the <em>source</em> of that revision (e.g. a <span class=\"tn-icon bx bx-save\"></span> icon for a manually saved revision).</li><li>Pressing the <span class=\"tn-icon bx bx-dots-horizontal-rounded\"></span> button on the top-right of the dialog displays multiple options, including:<ul><li><span class=\"tn-icon bx bx-save\"></span> Saving a new revision now.</li><li>Checking the interval and limit for this note (see below).</li><li><span class=\"tn-icon bx bx-trash\"></span> Deleting all the revisions of this note.</li></ul></li><li>For supported notes (text, code), changes are highlighted. This behavior can be toggled via the <em>Highlight changes</em> at the top of the dialog.<ul><li>The highlighted changes are relative to the <strong>current state of the note</strong>, not to the revision prior to this one.</li></ul></li><li>For any given revision, the buttons on the top-right allow operating on it:<ul><li><span class=\"tn-icon bx bx-trash\"></span> Deleting the revision.</li><li><span class=\"tn-icon bx bx-download\"></span> Downloading the revision locally.</li><li><span class=\"tn-icon bx bx-history\"></span> Restoring the revision, which replaces the current content of the note with the one from the revision. Another revision is saved containing the current content of the note.</li></ul></li></ul><h2>Named revisions</h2><p>Named revisions are a new feature of Trilium v0.103.0 which allows adding a short description of what the changes in the snapshot contain.</p><p>In the list of note revisions:</p><ul><li>The name of the revision is displayed underneath the time of the revision in the sidebar, as well as at the top of the dialog where it is displayed in full.</li><li>Clicking on the <span class=\"tn-icon bx bx-edit-alt\"></span> edit button near the name of the revision allows it to be changed.</li></ul><p>To create a named revision, either:</p><ul><li>Go to the <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a>, select <em>Save named revision…</em> (<span class=\"tn-icon bx bx-purchase-tag\"></span>), enter the name of revision and confirm.</li><li>Use the corresponding <a href=\"#root/_help_A9Oc6YKKc65v\">keyboard shortcut</a> or the <a class=\"reference-link\" href=\"#root/_help_F1r9QtzQLZqm\">Jump to & command palette</a> command with the same name.</li><li>Save a revision normally, and adjust the name afterwards from the note revision list.</li></ul><h2>When revisions are saved</h2><p>Revisions are saved:</p><ul><li>Automatically at a fixed interval. This behavior can be configured (see below).</li><li>Manually, by:<ul><li>Going to the <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> and selecting <em>Save revision</em> (<span class=\"tn-icon bx bx-save\"></span>).</li><li>Using the <em>Force Save Revision</em> <a href=\"#root/_help_A9Oc6YKKc65v\">keyboard shortcut</a>.</li><li>In the <em>Note Revisions</em> dialog, pressing the <span class=\"tn-icon bx bx-dots-horizontal-rounded\"></span> button in the top-right and selecting <em>Save a revision now</em>.</li></ul></li></ul><p>Additionally, revisions can also come from somewhere else, and this is indicated via the icon of the revision:</p><ul><li><span class=\"tn-icon bx bx-code-alt\"></span> Generated externally, by <a class=\"reference-link\" href=\"#root/_help_pgxEVkzLl1OP\">ETAPI (REST API)</a>.</li><li><span class=\"tn-icon bx bx-bot\"></span> A modification created by <a class=\"reference-link\" href=\"#root/_help_GBBMSlVSOIGP\">AI</a>.</li><li><span class=\"tn-icon bx bx-history\"></span> A revision is restored, causing the existing note content to be saved as a revision to prevent potential data loss.</li></ul><h4>Snapshot interval</h4><p>Time interval of taking note snapshot is configurable in the Options → Other dialog. This provides a trade-off between more revisions and more data to store.</p><p>To turn off note versioning for a particular note (or sub-tree), add <code>disableVersioning</code> <a href=\"#root/_help_zEY4DaJG4YT5\">label</a> to the note.</p><h4>Maximum revisions</h4><p>The limit on the number of note snapshots can be configured in the Options → Other dialog. The note revision snapshot number limit refers to the maximum number of revisions that can be saved for each note. Where -1 means no limit, 0 means delete all revisions. You can set the maximum revisions for a single note through the <code>versioningLimit=X</code> label.</p><p>The note limit will not take effect immediately; it will only apply when the note is modified.</p><p>You can click the <em>Erase now</em> button under <em>Erase excess revision snapshots</em> to apply the changes immediately.</p>","_help_aGlEvb9hyDhS": "<h2>Manual sorting</h2><p>You can sort notes by right-clicking the parent note in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> and selecting Advanced -> Sort notes by ... This will sort existing notes, but will not automatically sort future notes added to this parent note.</p><p>The sorting dialog allows:</p><ul><li>Sorting by title, creation or modification date, or by the value of a label on the child notes.</li><li>Sorting by several such criteria in turn, each ascending or descending: the next level only decides between notes the previous ones left equal.</li><li>Ensuring folders are displayed at the top.</li><li>Natural sort, based on the sorting rules of a particular language.</li></ul><h2>Automatic/Permanent Sorting</h2><p>Child notes can be automatically sorted by attaching specific <a href=\"#root/_help_zEY4DaJG4YT5\">labels</a> to the parent note:</p><figure class=\"table\"><table><thead><tr><th>Label</th><th>Description</th></tr></thead><tbody><tr><td><code>#sorted</code></td><td><p>Keeps child notes sorted by title alphabetically.</p><p>When given a value, it will sort by other criteria instead: a comma-separated list of levels, each a label on the child notes written with <code>#</code>, or one of the properties <code>title</code>, <code>dateCreated</code>, <code>dateModified</code> and <code>folders</code>, optionally followed by <code>asc</code> or <code>desc</code>, as in a search's <code>orderBy</code>. For example <code>#sorted=\"#priority desc, #dueDate\"</code> sorts by priority, highest first, and notes of equal priority by due date. A child note without a level's label sorts after every child that has it, whichever direction the level runs in. When neither note has the label, the next level decides.</p><p>A label followed by <code>first</code> or <code>last</code> instead groups the child notes that have it before or after the rest, whatever its value. For example <code>#sorted=\"#archived last, title\"</code> keeps <a href=\"#root/_help_MKmLg5x6xkor\">archived notes</a> below the others.</p></td></tr><tr><td><code>#sortDirection</code></td><td><p>If <code>sorted</code> is applied, specifies the direction of the sort:</p><ul><li><code>ASC</code>, ascending (default)</li><li><code>DESC</code>, descending</li></ul><p>A level of <code>sorted</code> followed by its own <code>asc</code> or <code>desc</code> keeps that direction regardless, and so does a <code>first</code> or <code>last</code> group.</p></td></tr><tr><td><code>#sortFoldersFirst</code></td><td>If <code>sorted</code> is applied, folders (notes with children) will be sorted as a group at the top (at the bottom when <code>#sortDirection</code> is <code>desc</code>), and the rest will be sorted. Ignored when <code>sorted</code> places <code>folders</code> itself.</td></tr><tr><td><code>#sortNatural</code></td><td>Sort numbers naturally instead of alphabetically, so 2 comes before 10.</td></tr><tr><td><code>#sortLocale</code></td><td>The language code driving the natural sort (e.g. <code>zh-CN</code>, <code>de</code>). Only meaningful together with <code>#sortNatural</code>.</td></tr><tr><td><code>#top</code></td><td>If <code>sorted</code> is applied to the parent note, keeps given note on top in its parent.</td></tr><tr><td><code>#bottom</code></td><td>If <code>sorted</code> is applied to the parent note, keeps given note on bottom in its parent.</td></tr></tbody></table></figure><p>Sorting is done by comparing note properties or specific labels on child notes. There are four sorting levels, with the first having the highest priority. Lower priority levels are applied only if higher priority comparisons result in equality.</p><ol><li><strong>Top Label Sorting</strong>: Child notes with the <code>#top</code> label will appear at the top of the folder, unless <code>#sorted</code> places <code>#top</code> itself (see below).</li><li><strong>Bottom Label Sorting</strong>: (Introduced in Trilium 0.62) Child notes with the <code>#bottom</code> label will appear at the bottom of the folder, unless <code>#sorted</code> places <code>#bottom</code> itself.</li><li><strong>Property/Label-Based Sorting</strong>: Sorting is based on the parent note's <code>#sorted</code> label:<ul><li><strong>Default Sorting</strong>: If <code>#sorted</code> has no value, notes are sorted alphabetically.</li><li><strong>Property Sorting</strong>: If <code>#sorted</code> is set to <code>title</code>, <code>dateModified</code>, or <code>dateCreated</code>, notes are sorted based on the specified property. The <code>folders</code> property, which notes with children have, is meant for grouping, as in <code>folders first</code>, which a bare <code>folders</code> level also does since notes without children sort after those with; on its own, <code>#sorted=folders</code> still sorts by a <code>#folders</code> label.</li><li><strong>Label Sorting</strong>: If <code>#sorted</code> is set to the name of a child note's label, sorting is based on the values of this label. For example, setting <code>#sorted=#myOrder</code> on the parent note and using <code>#myOrder=001</code>, <code>#myOrder=002</code>, etc., on child notes. A single name without <code>#</code> that is not one of the properties above is also treated as a label, so <code>#sorted=myOrder</code> works the same way.</li><li><strong>Multi-Level Sorting</strong>: Several of the above can be combined, separated by commas; each level is applied only where the previous ones are equal. A label is written with <code>#</code> and a property without it. Every level can carry its own direction as a word after the name, <code>asc</code> or <code>desc</code>, otherwise it follows <code>#sortDirection</code>. For example <code>#sorted=\"#priority desc, #area, dateCreated\"</code> sorts by priority, highest first, then by area, then by creation date.</li><li><strong>Grouping</strong>: A label, or <code>folders</code>, followed by <code>first</code> or <code>last</code> puts the child notes that have it, with any value, before or after the rest, regardless of <code>#sortDirection</code>. The following levels then sort within each group. For example <code>#sorted=\"#archived last, #priority desc\"</code>. Notes with <code>#top</code> or <code>#bottom</code> stay at the top or bottom even when they belong to a group, unless <code>#sorted</code> names those labels too.</li><li><strong>Placing <code>#top</code> and <code>#bottom</code></strong>: Naming <code>#top</code> or <code>#bottom</code> in <code>#sorted</code> applies it at that position instead of before every level. For example <code>#sorted=\"#archived last, #top first, #bottom last, title\"</code> keeps archived notes below all the others, including those with <code>#bottom</code>, and <code>#top</code> and <code>#bottom</code> then apply within each of the two groups. Adding <code>folders first</code> after them, as in <code>#sorted=\"#archived last, #top first, #bottom last, folders first, title\"</code>, groups folders within each group too, so archived folders sort below the other notes. <code>#sortFoldersFirst</code> places <code>folders first</code> the same way, right after the last of <code>#top</code> and <code>#bottom</code>. Written with <code>first</code> or <code>last</code>, the labels ignore their values; to order several pinned notes by value, add a level such as <code>#top</code> or <code>#bottom desc</code> after them.</li></ul></li><li><strong>Alphabetical Sorting</strong>: Used as a last resort when other criteria result in equality.</li></ol><aside class=\"admonition warning\"><p>Since v0.107.0, a label in a multi-level <code>#sorted</code> must be written with <code>#</code>. In v0.106.0 the names were written bare, as in <code>#sorted=\"priority desc, dueDate\"</code>; such a value now reads both names as properties that do not exist and falls back to sorting by title. Add a <code>#</code> before each label name to restore it.</p></aside><p>All comparisons are made string-wise (e.g., \"1\" < \"2\" or \"2020-10-10\" < \"2021-01-15\", but also \"2\" > \"10\").</p>",- "_help_NRnIZmSMc5sj": "<figure class=\"image\"><img style=\"aspect-ratio:2023/1488;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Notes/Printing%20%26%20Exporting%20as%20PDF_image.png\" width=\"2023\" height=\"1488\"><figcaption>Screenshot of the Print preview functionality introduced in v0.103.0.</figcaption></figure><p>Trilium allows printing notes to a real printer, or generating a structured PDF for a single note or for multiple notes through <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a>.</p><p>Note that not all note types are printable as of now. We do plan to increase the coverage of supported note types in the future.</p><p>Printing and exporting as PDF are not perfect. Due to technical limitations, and sometimes even browser or Electron glitches the text might appear cut off in some circumstances. </p><h2>Printing a note or exporting as PDF on the desktop</h2><aside class=\"admonition note\"><p>Versions prior to v0.103.0 had two different options, one for printing and another one for exporting to PDF. With the introduction of the print preview, these functions have been unified.</p></aside><p>On the desktop application of Trilium it is possible to export a note as PDF. To print a note:</p><ul><li>Press the menu button in the <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> and select <em>Print note</em>.</li><li>Alternatively, printing can be triggered from a <a href=\"#root/_help_A9Oc6YKKc65v\">keyboard shortcut</a> (unassigned by default) or through the <a href=\"#root/_help_F1r9QtzQLZqm\">command palette</a>.</li></ul><p>This will trigger the print preview screen next.</p><h3>Print preview & print options</h3><p>The print preview dialog allows the following printing options to be adjusted:</p><ul><li>The printer to use<ul><li><em>Save as PDF</em> generates a PDF that is structured (maintains a table of contents, keeps the text selectable). Prefer this over other virtual PDF printers that ship with the operating system.</li></ul></li><li>Page orientation: <em>Portrait</em> (default) or <em>Landscape</em>.</li><li>Page size</li><li>Scale the entire content from 10% to 200% to improve the fit within the page.</li><li>Margins, which can be removed completely or adjusted individually for all the four edges.</li><li>Print only a subset of pages. Individual page numbers are separated by colons and hyphen-based ranges are supported (e.g. 3-5 for pages 3 to 5).</li></ul><p>Additional interaction:</p><ul><li><em>Print using system dialog</em> allows setting more options that are otherwise not available in Trilium.</li></ul><p>If the note cannot be rendered with the current options, or stops making progress for 30 seconds, the preview is replaced by an error message. Adjust the options to try again.</p><aside class=\"admonition note\"><p>Most of the options here (except printer & which pages to print) are managed at note level through <a class=\"reference-link\" href=\"#root/_help_zEY4DaJG4YT5\">Attributes</a> (such as <code>#printLandscape</code>, <code>#printPageSize</code>, <code>#printScale</code>, <code>#printMargins</code>).</p><p>This means that the print settings will be restored when printing the same note. There are no default settings that can be configured for all the notes, but this can be achieved via <a href=\"#root/_help_bwZpz2ajCEwO\">inheritable attributes</a>.</p></aside><h2>Printing on the browser</h2><p>This feature allows printing of notes. It works on both the desktop client, but also on the web.</p><p>To print a note, click the <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> and select <em>Print note</em>. Depending on the size and type of the note, this can take up to a few seconds. Afterwards you will be redirected to the system/browser printing dialog.</p><p>On the server or PWA (mobile), the option is not available due to technical constraints and it will be hidden.</p><h2>Reporting issues with the rendering</h2><p>Should you encounter any visual issues in the resulting PDF file (e.g. a table does not fit properly, there is cut off text, etc.) feel free to <a href=\"#root/_help_wy8So3yZZlH9\">report the issue</a>. In this case, it's best to offer a sample note (click on the <span class=\"tn-icon cke cke-three-vertical-dots\"></span> button, select <em>Export note</em> → <em>This note and all of its descendants</em> → <em>HTML in ZIP archive</em>). Make sure not to accidentally leak any personal information.</p><p>Consider adjusting font sizes and using <a href=\"#root/_help_CohkqWQC1iBv\">page breaks</a> to work around the layout.</p><aside class=\"admonition tip\"><p>Although direct export as PDF is not available in the browser version of the application, it's still possible to generate a PDF by selecting the <em>Print</em> option instead and selecting “Save to PDF” as the printer (depending on the browser). Generally, Mozilla Firefox has better printing capabilities.</p></aside><h3>Automatic opening of the file</h3><p>When the PDF is exported, it is automatically opened with the system default application for easy preview.</p><p>Note that if you are using Linux with the GNOME desktop environment, sometimes the default application might seem incorrect (such as opening in GIMP). This is because it uses Gnome's “Recommended applications” list.</p><p>To solve this, you can change the recommended application for PDFs via this command line. First, list the available applications via <code>gio mime application/pdf</code> and then set the desired one. For example to use GNOME's Evince:</p><pre><code class=\"language-text-x-trilium-auto\">gio mime application/pdf</code></pre><h2>Printing multiple notes</h2><p>Since v0.100.0, it is possible to print more than one note at the time by using <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a>:</p><ol><li>First create a collection.</li><li>Configure it to use <a class=\"reference-link\" href=\"#root/_help_mULW0Q3VojwY\">List View</a>.</li><li>Print the collection note normally.</li></ol><p>The resulting collection will contain all the children of the collection, while maintaining the hierarchy.</p><aside class=\"admonition note\"><p>Not all note types are supported when printing or exporting to PDF. When an unsupported note is encountered, it is skipped. At the end, if any of the notes were skipped, a message will be displayed with the possibility of viewing the full list of skipped notes. The same limitations as the ones described in <em>Constraints & limitations</em> apply.</p></aside><h2>Keyboard shortcut</h2><p>It's possible to trigger both printing and export as PDF from the keyboard by going to <em>Keyboard shortcuts</em> in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> and assigning a key combination for:</p><ul><li><em>Print Active Note</em></li><li><em>Export Active Note as PDF</em></li></ul><h2>Constraints & limitations</h2><p>Not all <a class=\"reference-link\" href=\"#root/_help_KSZ04uQ2D1St\">Note Types</a> are supported when printing, in which case the <em>Print</em> and <em>Export as PDF</em> options will be disabled.</p><ul><li>For <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes, font, background and table colors are printed in the shades of light themes, whatever the current theme (see <a class=\"reference-link\" href=\"#root/_help_Gr6xFaF6ioJ5\">General formatting</a>).</li><li>For <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> notes:<ul><li>Line numbers are not printed.</li><li>Syntax highlighting is enabled, however a default theme (Visual Studio) is enforced.</li></ul></li><li>A <a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a> is printed as it is displayed, without running its script again, once its <code>~renderNote</code> relation is set.</li><li>For <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a>, the following are supported:<ul><li><a class=\"reference-link\" href=\"#root/_help_mULW0Q3VojwY\">List View</a>, allowing to print multiple notes at once while preserving hierarchy (similar to a book).</li><li><a class=\"reference-link\" href=\"#root/_help_zP3PMqaG71Ct\">Presentation</a>, where each slide/sub-note is displayed.<ul><li>Most note types are supported, especially the ones that have an image representation such as <a class=\"reference-link\" href=\"#root/_help_grjYqerjn243\">Canvas</a> and <a class=\"reference-link\" href=\"#root/_help_gBbsAeiuUxI5\">Mind Map</a>.</li></ul></li><li><a class=\"reference-link\" href=\"#root/_help_2FvYrpmOXm29\">Table</a>, where the table is rendered in a print-friendly way.<ul><li>Tables that are too complex (especially if they have multiple columns) might not fit properly, however tables with a large number of rows are supported thanks to pagination.</li><li>Consider printing in landscape mode, or using <code>#printLandscape</code> if exporting to PDF.</li></ul></li><li>The rest of the collections are not supported, but we plan to add support for all the collection types at some point.</li></ul></li><li>Using <a class=\"reference-link\" href=\"#root/_help_AlhDUqhENtH7\">Custom app-wide CSS</a> for printing is no longer supported, instead a custom <code>printCss</code> relation needs to be used (see below).</li></ul><h2>Customizing the print CSS</h2><p>As an advanced use case, it's possible to customize the CSS used for printing such as adjusting the fonts, sizes or margins. Note that <a class=\"reference-link\" href=\"#root/_help_AlhDUqhENtH7\">Custom app-wide CSS</a> will not work for printing.</p><p>To do so:</p><ul><li>Create a CSS <a href=\"#root/_help_6f9hih2hXXZk\">code note</a>.</li><li>On the note being printed, apply the <code>~printCss</code> relation to point to the newly created CSS code note.</li><li>To apply the CSS to multiple notes, consider using <a href=\"#root/_help_bwZpz2ajCEwO\">inheritable attributes</a> or <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a>.</li></ul><p>For example, to change the font of the document from the one defined by the theme or the user to a serif one:</p><pre><code class=\"language-text-x-trilium-auto\">body {\n\t--print-font-family: serif;\n --print-font-size: 11pt;\n}</code></pre><aside class=\"admonition important\"><p>When altering <code>--print-font-family</code>, make sure the change is done at <code>body</code> level and not <code>:root</code>, since otherwise it won't be picked up due to specificity rules.</p></aside><p>To remark:</p><ul><li>Multiple CSS notes can be add by using multiple <code>~printCss</code> relations.</li><li>If the note pointing to the <code>printCss</code> doesn't have the right note type or mime type, it will be ignored.</li><li>If migrating from a previous version where <a class=\"reference-link\" href=\"#root/_help_AlhDUqhENtH7\">Custom app-wide CSS</a>, there's no need for <code>@media print {</code> since the style-sheet is used only for printing.</li></ul><h2>Under the hood</h2><p>Both printing and exporting as PDF use the same mechanism: a note is rendered individually in a separate webpage that is then sent to the browser or the Electron application either for printing or exporting as PDF.</p><p>The webpage that renders a single note can actually be accessed in a web browser. For example <code>http://localhost:8080/#root/WWRGzqHUfRln/RRZsE9Al8AIZ?ntxId=0o4fzk</code> becomes <code>http://localhost:8080/?print#root/WWRGzqHUfRln/RRZsE9Al8AIZ</code>.</p><p>Accessing the print note in a web browser allows for easy debugging to understand why a particular note doesn't render well. The mechanism for rendering is similar to the one used in <a class=\"reference-link\" href=\"#root/_help_0ESUbbAxVnoK\">Note List</a>.</p>",+ "_help_NRnIZmSMc5sj": "<figure class=\"image\"><img style=\"aspect-ratio:2023/1488;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Notes/Printing%20%26%20Exporting%20as%20PDF_image.png\" width=\"2023\" height=\"1488\"><figcaption>Screenshot of the Print preview functionality introduced in v0.103.0.</figcaption></figure><p>Trilium allows printing notes to a real printer, or generating a structured PDF for a single note or for multiple notes through <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a>.</p><p>Note that not all note types are printable as of now. We do plan to increase the coverage of supported note types in the future.</p><p>Printing and exporting as PDF are not perfect. Due to technical limitations, and sometimes even browser or Electron glitches the text might appear cut off in some circumstances. </p><h2>Printing a note or exporting as PDF on the desktop</h2><aside class=\"admonition note\"><p>Versions prior to v0.103.0 had two different options, one for printing and another one for exporting to PDF. With the introduction of the print preview, these functions have been unified.</p></aside><p>On the desktop application of Trilium it is possible to export a note as PDF. To print a note:</p><ul><li>Press the menu button in the <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> and select <em>Print note</em>.</li><li>Alternatively, printing can be triggered from a <a href=\"#root/_help_A9Oc6YKKc65v\">keyboard shortcut</a> (unassigned by default) or through the <a href=\"#root/_help_F1r9QtzQLZqm\">command palette</a>.</li></ul><p>This will trigger the print preview screen next.</p><h3>Print preview & print options</h3><p>The print preview dialog allows the following printing options to be adjusted:</p><ul><li>The printer to use<ul><li><em>Save as PDF</em> generates a PDF that is structured (maintains a table of contents, keeps the text selectable). Prefer this over other virtual PDF printers that ship with the operating system.</li></ul></li><li>Page orientation: <em>Portrait</em> (default) or <em>Landscape</em>.</li><li>Page size</li><li>Scale the entire content from 10% to 200% to improve the fit within the page.</li><li>Margins, which can be removed completely or adjusted individually for all the four edges.</li><li>Print only a subset of pages. Individual page numbers are separated by colons and hyphen-based ranges are supported (e.g. 3-5 for pages 3 to 5).</li></ul><p>Additional interaction:</p><ul><li><em>Print using system dialog</em> allows setting more options that are otherwise not available in Trilium.</li></ul><p>If the note cannot be rendered with the current options, or stops making progress for 30 seconds, the preview is replaced by an error message. Adjust the options to try again.</p><aside class=\"admonition note\"><p>Most of the options here (except printer & which pages to print) are managed at note level through <a class=\"reference-link\" href=\"#root/_help_zEY4DaJG4YT5\">Attributes</a> (such as <code>#printLandscape</code>, <code>#printPageSize</code>, <code>#printScale</code>, <code>#printMargins</code>).</p><p>This means that the print settings will be restored when printing the same note. There are no default settings that can be configured for all the notes, but this can be achieved via <a href=\"#root/_help_bwZpz2ajCEwO\">inheritable attributes</a>.</p></aside><h2>Printing on the browser</h2><p>This feature allows printing of notes. It works on both the desktop client, but also on the web.</p><p>To print a note, click the <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> and select <em>Print note</em>. Depending on the size and type of the note, this can take up to a few seconds. Afterwards you will be redirected to the system/browser printing dialog.</p><p>On the server or PWA (mobile), the option is not available due to technical constraints and it will be hidden.</p><h2>Reporting issues with the rendering</h2><p>Should you encounter any visual issues in the resulting PDF file (e.g. a table does not fit properly, there is cut off text, etc.) feel free to <a href=\"#root/_help_wy8So3yZZlH9\">report the issue</a>. In this case, it's best to offer a sample note (click on the <span class=\"tn-icon cke cke-three-vertical-dots\"></span> button, select <em>Export note</em> → <em>This note and all of its descendants</em> → <em>HTML in ZIP archive</em>). Make sure not to accidentally leak any personal information.</p><p>Consider adjusting font sizes and using <a href=\"#root/_help_CohkqWQC1iBv\">page breaks</a> to work around the layout.</p><aside class=\"admonition tip\"><p>Although direct export as PDF is not available in the browser version of the application, it's still possible to generate a PDF by selecting the <em>Print</em> option instead and selecting “Save to PDF” as the printer (depending on the browser). Generally, Mozilla Firefox has better printing capabilities.</p></aside><h3>Automatic opening of the file</h3><p>When the PDF is exported, it is automatically opened with the system default application for easy preview.</p><p>Note that if you are using Linux with the GNOME desktop environment, sometimes the default application might seem incorrect (such as opening in GIMP). This is because it uses Gnome's “Recommended applications” list.</p><p>To solve this, you can change the recommended application for PDFs via this command line. First, list the available applications via <code>gio mime application/pdf</code> and then set the desired one. For example to use GNOME's Evince:</p><pre><code class=\"language-text-x-trilium-auto\">gio mime application/pdf</code></pre><h2>Printing multiple notes</h2><p>Since v0.100.0, it is possible to print more than one note at the time by using <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a>:</p><ol><li>First create a collection.</li><li>Configure it to use <a class=\"reference-link\" href=\"#root/_help_mULW0Q3VojwY\">List View</a>.</li><li>Print the collection note normally.</li></ol><p>The resulting collection will contain all the children of the collection, while maintaining the hierarchy.</p><aside class=\"admonition note\"><p>Not all note types are supported when printing or exporting to PDF. When an unsupported note is encountered, it is skipped. At the end, if any of the notes were skipped, a message will be displayed with the possibility of viewing the full list of skipped notes. The same limitations as the ones described in <em>Constraints & limitations</em> apply.</p></aside><h2>Keyboard shortcut</h2><p>It's possible to trigger both printing and export as PDF from the keyboard by going to <em>Keyboard shortcuts</em> in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> and assigning a key combination for:</p><ul><li><em>Print Active Note</em></li><li><em>Export Active Note as PDF</em></li></ul><h2>Constraints & limitations</h2><p>Not all <a class=\"reference-link\" href=\"#root/_help_KSZ04uQ2D1St\">Note Types</a> are supported when printing, in which case the <em>Print</em> and <em>Export as PDF</em> options will be disabled.</p><ul><li>For <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes, font, background and table colors are printed in the shades of light themes, whatever the current theme (see <a class=\"reference-link\" href=\"#root/_help_Gr6xFaF6ioJ5\">General formatting</a>).</li><li><a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> notes are printed with line numbers and syntax highlighting, in the <em>Light theme</em> of <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Code Notes</em> → <em>Appearance</em>, whatever the current theme.</li><li>A <a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a> is printed as it is displayed, without running its script again, once its <code>~renderNote</code> relation is set.</li><li>For <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a>, the following are supported:<ul><li><a class=\"reference-link\" href=\"#root/_help_mULW0Q3VojwY\">List View</a>, allowing to print multiple notes at once while preserving hierarchy (similar to a book).</li><li><a class=\"reference-link\" href=\"#root/_help_zP3PMqaG71Ct\">Presentation</a>, where each slide/sub-note is displayed.<ul><li>Most note types are supported, especially the ones that have an image representation such as <a class=\"reference-link\" href=\"#root/_help_grjYqerjn243\">Canvas</a> and <a class=\"reference-link\" href=\"#root/_help_gBbsAeiuUxI5\">Mind Map</a>.</li></ul></li><li><a class=\"reference-link\" href=\"#root/_help_2FvYrpmOXm29\">Table</a>, where the table is rendered in a print-friendly way.<ul><li>Tables that are too complex (especially if they have multiple columns) might not fit properly, however tables with a large number of rows are supported thanks to pagination.</li><li>Consider printing in landscape mode, or using <code>#printLandscape</code> if exporting to PDF.</li></ul></li><li>The rest of the collections are not supported, but we plan to add support for all the collection types at some point.</li></ul></li><li>Using <a class=\"reference-link\" href=\"#root/_help_AlhDUqhENtH7\">Custom app-wide CSS</a> for printing is no longer supported, instead a custom <code>printCss</code> relation needs to be used (see below).</li></ul><h2>Customizing the print CSS</h2><p>As an advanced use case, it's possible to customize the CSS used for printing such as adjusting the fonts, sizes or margins. Note that <a class=\"reference-link\" href=\"#root/_help_AlhDUqhENtH7\">Custom app-wide CSS</a> will not work for printing.</p><p>To do so:</p><ul><li>Create a CSS <a href=\"#root/_help_6f9hih2hXXZk\">code note</a>.</li><li>On the note being printed, apply the <code>~printCss</code> relation to point to the newly created CSS code note.</li><li>To apply the CSS to multiple notes, consider using <a href=\"#root/_help_bwZpz2ajCEwO\">inheritable attributes</a> or <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a>.</li></ul><p>For example, to change the font of the document from the one defined by the theme or the user to a serif one:</p><pre><code class=\"language-text-x-trilium-auto\">body {\n\t--print-font-family: serif;\n --print-font-size: 11pt;\n}</code></pre><aside class=\"admonition important\"><p>When altering <code>--print-font-family</code>, make sure the change is done at <code>body</code> level and not <code>:root</code>, since otherwise it won't be picked up due to specificity rules.</p></aside><p>To remark:</p><ul><li>Multiple CSS notes can be add by using multiple <code>~printCss</code> relations.</li><li>If the note pointing to the <code>printCss</code> doesn't have the right note type or mime type, it will be ignored.</li><li>If migrating from a previous version where <a class=\"reference-link\" href=\"#root/_help_AlhDUqhENtH7\">Custom app-wide CSS</a>, there's no need for <code>@media print {</code> since the style-sheet is used only for printing.</li></ul><h2>Under the hood</h2><p>Both printing and exporting as PDF use the same mechanism: a note is rendered individually in a separate webpage that is then sent to the browser or the Electron application either for printing or exporting as PDF.</p><p>The webpage that renders a single note can actually be accessed in a web browser. For example <code>http://localhost:8080/#root/WWRGzqHUfRln/RRZsE9Al8AIZ?ntxId=0o4fzk</code> becomes <code>http://localhost:8080/?print#root/WWRGzqHUfRln/RRZsE9Al8AIZ</code>.</p><p>Accessing the print note in a web browser allows for easy debugging to understand why a particular note doesn't render well. The mechanism for rendering is similar to the one used in <a class=\"reference-link\" href=\"#root/_help_0ESUbbAxVnoK\">Note List</a>.</p>","_help_CoFPLs3dRlXc": "<p>Some note types such as <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>, <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> notes and even some of the <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a> can be set to read-only. When a note is in read-only mode, it is presented to the user in a non-editable view, with the option to switch to editing mode if needed.</p><h2>Automatic read-only mode</h2><p>For optimization purposes, Trilium will automatically set very large notes to read-only. Displaying such lengthy notes in editing mode can slow down performance, especially when editing is unnecessary.</p><p>This behavior can be disabled on a per-note basis, by following the instructions of the next section.</p><p>In addition, it's possible to change the number of characters at which the automatic read-only mode will trigger in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> by going to the options for <a class=\"reference-link\" href=\"#root/_hidden/_options/_optionsTextNotes\">Text Notes</a> and <a class=\"reference-link\" href=\"#root/_hidden/_options/_optionsCodeNotes\">Code Notes</a>.</p><h2>Changing a note's read-only behavior</h2><p>A note's read-only behavior can be changed via <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> → <em>Editable.</em> The following options are possible:</p><ul><li><strong>Auto</strong><br>This is the default behavior in which the note will be editable by default, unless it becomes large enough to trigger read-only mode.</li><li><strong>Read-only</strong><br>The note will be always marked as read-only, regardless of its size. Nevertheless, it's still possible to temporarily edit the note if needed. This is generally useful for notes that are not prone to change.</li><li><strong>Always Editable</strong><br>This option will bypass the automatic read-only activation for this particular note. It's useful for large notes that are frequently edited.</li></ul><p>If the <em>Editable</em> section is missing from the <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a>, then the note type does not support read-only mode.</p><h3>Manually setting the options</h3><p>Apart from using the <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> as previously mentioned, it's also possible to use <a href=\"#root/_help_zEY4DaJG4YT5\">labels</a> to change the behavior:</p><ul><li>To set as read-only, apply the <code>readOnly</code> label to the note.</li><li>To disable automatic read-only (always editable), apply the <code>autoReadOnlyDisabled</code> label.</li></ul><h2>Temporarily editing a read-only note</h2><p>When accessing a read-only note, it's possible to temporarily edit it pressing the <em>Read-only</em> badge.</p><p>When pressed, the note will become editable but will become read-only again after navigating to a different note.</p><p>The pages of the built-in user guide are an exception: they are part of Trilium itself and cannot be edited, not even temporarily. Their <em>Read-only</em> badge cannot be pressed, the note menu does not offer to edit them, and their attributes are shown in the right sidebar without a way to change them.</p>","_help_0ESUbbAxVnoK": "<figure class=\"image\"><img style=\"aspect-ratio:990/590;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Notes/Note%20List_image.png\" width=\"990\" height=\"590\"></figure><p>When a note has one or more child notes, they will be listed at the end of the note for easy navigation.</p><h2>Configuration</h2><ul><li>To hide the note list for a particular note, simply apply the <code>hideChildrenOverview</code> <a href=\"#root/_help_zEY4DaJG4YT5\">label</a>.</li><li>For some view types, such as Grid view, only a subset of notes will be displayed and pagination can be used to navigate through all of them for performance reasons. To adjust the number of notes per page, set <code>pageSize</code> to the desired number.</li></ul><h2>View types</h2><p>The view types dictate how the child notes are represented. By default, the notes will be displayed in a grid, however there are also some other view types available.</p><p>Generally the view type can only be changed from the <a class=\"reference-link\" href=\"#root/_help_CssoWBu8I7jF\">Collection Properties</a>, but it can also be changed manually on any type of note using the <code>#viewType</code> <a href=\"#root/_help_HI6GBBIduIgv\">label</a>.</p>","_help_S0Fos78ZfcY7": "<p>The inbox is the default destination for quickly captured notes. When a note is created without picking a location first, it lands in the inbox. This makes it easy to quickly capture notes and sort them later.</p><h2>Where the inbox is used</h2><ul><li>The <em>New note</em> button in the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>.</li><li>The global <em>Create note into inbox</em> shortcut (default <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>P</kbd>).</li><li>The <em>New note</em> action in the <a href=\"#root/_help_7iwde4lsKc6O\">tray icon menu</a>.</li><li>The <a class=\"reference-link\" href=\"#root/_help_MtPxeAWVAzMg\">Web Clipper</a> extension.</li><li>The <em>Create note</em> option offered when a search finds no match, in <a class=\"reference-link\" href=\"#root/_help_F1r9QtzQLZqm\">Jump to & command palette</a>, in an empty tab and in the <code>@</code> completion of a text note.</li></ul><h2>Setting a note inbox</h2><p>To create a note inbox, apply the <code>#inbox</code> <a href=\"#root/_help_HI6GBBIduIgv\">label</a> to it.</p><p>Only one note should carry this label. If there are multiple notes, only one will be used by the application.</p><aside class=\"admonition note\"><p>If there is no inbox note, Trilium will fall back to today's <a href=\"#root/_help_l0tKav7yLHGF\">day note</a>, creating it and its calendar ancestors as needed. If the journal has been removed altogether, the note is created at the top level instead of a new journal being built for it.</p></aside><h2>Workspace inboxes</h2><p>Each <a href=\"#root/_help_9sRHySam5fXb\">workspace</a> can have its own inbox, set via the <code>#workspaceInbox</code> label.</p><p>When a new note is created while hoisted in a workspace, the location is determined in the following order:</p><ul><li>A note carrying the <code>#workspaceInbox</code> label in that workspace.</li><li>A note carrying the <code>#inbox</code> within that workspace.</li><li>Today's <a href=\"#root/_help_l0tKav7yLHGF\">day note</a>, if the workspace has a <code>#workspaceCalendarRoot</code>.</li><li>The workspace root note itself.</li></ul>",@@ -134,7 +134,7 @@"_help_0Ofbk1aSuVRu": "<figure class=\"image image-style-align-right image_resized\" style=\"width:50.47%;\"><img style=\"aspect-ratio:880/553;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Images/Image%20references_image.png\" width=\"880\" height=\"553\"></figure><p>Image references are an easy way to embed the preview of another note type into a <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> note.</p><h2>Supported note types</h2><ul><li><a class=\"reference-link\" href=\"#root/_help_grjYqerjn243\">Canvas</a></li><li><a class=\"reference-link\" href=\"#root/_help_s1aBHPd79XYj\">Mermaid Diagrams</a></li><li><a class=\"reference-link\" href=\"#root/_help_gBbsAeiuUxI5\">Mind Map</a></li></ul><h2>Steps</h2><ol><li>Go to one of the supported notes (listed above) and look for the <span class=\"tn-icon bx bx-copy\"></span> button in the <a class=\"reference-link\" href=\"#root/_help_1P8QXI5edXNd\">Note buttons</a> area.</li><li>Go to a <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> note and use the Paste function to insert the reference to that note.</li></ol><h2>Interaction</h2><ul><li>Double-clicking an image reference from a text note will automatically open the target note.</li><li>Clicking an image reference while <kbd>Ctrl</kbd> is pressed will open the target note in a new tab.</li><li>Modifying the target note should also update the image reference. If that doesn't happen, consider <a class=\"reference-link\" href=\"#root/_help_s8alTXmpFR61\">Refreshing the application</a>.</li></ul>","_help_VRoP0g1uHHc2": "<figure class=\"image image-style-align-center image_resized\" style=\"width:76.29%;\"><img style=\"aspect-ratio:1479/865;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/In-editor%20AI%20assistant_image.png\" width=\"1479\" height=\"865\"></figure><p>The AI assistant works on the text you are already writing: select a passage and have it rewritten, translated or turned into a table, or ask for new content at the cursor. Unlike the <a href=\"#root/_help_LrKznOtw9cQD\">AI chat</a>, it does not open a conversation window, the result is previewed in place and only enters the note when you accept it.</p><h2>Requirements</h2><p>The assistant is only available once at least one provider is configured in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>AI / LLM</em>, with at least one model selected for it. Until then the toolbar entry is not shown at all.</p><h2>Accessing the AI assistant</h2><p>To access the AI assistant:</p><ul><li>Look for the <span class=\"tn-icon cke cke-trilium-ai\"></span> button in the <a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>. Press the button itself to enter the <em>Ask AI</em> mode or press the arrow key next to it to access the quick commands and the model selection.</li><li>Look for <em>AI assistant</em> or any of the <em>AI</em>-prefixed quick commands in <a class=\"reference-link\" href=\"#root/_help_ZlN4nump6EbW\">Slash Commands</a>.</li><li>Press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>K</kbd>.</li><li>Select a text and choose the <em>AI assistant</em> option in the <a class=\"reference-link\" href=\"#root/_help_jcQVxzYybYgz\">Note contextual menu</a>.</li></ul><h2>What the assistant works on</h2><figure class=\"table\"><table><thead><tr><th>Situation</th><th>What is sent</th></tr></thead><tbody><tr><td>Text is selected</td><td>The selection.</td></tr><tr><td>Nothing is selected, and you pick a quick action</td><td>The paragraph the cursor is in.</td></tr><tr><td>Nothing is selected, and you type your own prompt</td><td>Nothing, the response is new content written at the cursor.</td></tr></tbody></table></figure><p>In all cases the assistant also sends the text before and after the target, so that the model can tell what it is writing into: asked to <em>Continue writing</em> or to summarize, a model that can only see the selected words is guessing at the document around them. This surrounding text is context only, it is never rewritten.</p><aside class=\"admonition important\"><p>That means a single run sends more than the passage you highlighted. See <a class=\"reference-link\" href=\"#root/_help_cRRrdZjgyhNc\">Privacy</a> for exactly what leaves your machine.</p></aside><h2>Quick actions</h2><p>The arrow beside the toolbar button opens a menu of ready-made instructions, grouped by what they do.</p><ul><li>The <em>Reformat</em> actions produce real Trilium content rather than plain text: <em>Diagram</em> inserts a Mermaid diagram, <em>Callout</em> an admonition, and <em>Collapsible</em> a collapsible block.</li><li>The <em>Translate</em> group lists the <a href=\"#root/_help_veGu4faJErEM\">content languages</a> you have enabled, or a predefined list if no content languages are set. It can be filled from within the editor, the last entry of the submenu opens the language configuration directly.</li></ul><p>Actions that need something to work on are greyed out when there is nothing to work on (for example an empty paragraph with no selection).</p><h2>Asking for something specific</h2><p>Choosing <em>Ask AI…</em> (<span class=\"tn-icon bx bx-message-square-dots\"></span>) opens a prompt where you can describe the change in your own words, for example: \"make this less formal\", \"add a row for 2024\", \"write an intro paragraph for this section\". Press <kbd>Enter</kbd> or the <span class=\"tn-icon cke cke-arrow-up\"></span> send button to run it.</p><p>Once a response arrives you can keep going in the same prompt, and the assistant treats it as a conversation rather than as a fresh request: after <em>Translate this to German</em>, asking for <em>make it shorter</em> shortens the German, not the original.</p><h2>Reviewing the result</h2><p>The response streams in as it is generated, and can be interrupted at any point by pressing the <em>Stop</em> (<span class=\"tn-icon cke cke-stop\"></span>) button; whatever arrived before that stays usable.</p><p>Nothing is written into the note until you say so. The review offers:</p><ul><li><em>Result</em>, which displays the response as it will be inserted.</li><li><em>Changes</em>, which displays an inline diff against the original, with insertions and deletions marked. When the model rewrote the passage rather than editing it, the review opens on <em>Result</em> instead: a diff of two texts with little in common is harder to read than the answer itself.</li><li><em>Try again</em> (<span class=\"tn-icon cke cke-refresh\"></span>), to re-run the same instruction.</li><li><em>Replace</em>, which substitutes the original passage</li><li><em>Insert below</em>, which keeps the original and adds the response after it.</li></ul><p>Trilium also reports the model that produced it, the tokens consumed and, for providers that report it, the price.</p><p>If you ask for a correction and there is nothing to correct, the assistant will indicate it instead of showing a blank diff.</p><h2>Choosing the model</h2><p>The bottom of the quick actions menu shows which model the assistant runs on, and lets you pick another from the models you selected in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>AI / LLM</em>, grouped by provider.</p><p>The model can also be changed while asking for something specific, or after the assistant has generated its response (i.e. if the response needs a better model).</p><p>This choice is separate from the model used by the chat, and is remembered across notes and devices. Left unset, the assistant follows the first configured provider.</p>","_help_mVEYwt20exhO": "<p><em>Quick actions</em> are a feature of the <a class=\"reference-link\" href=\"#root/_help_VRoP0g1uHHc2\">In-editor AI assistant</a> for <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes which automatically triggers an LLM suggestion based on a defined prompt. The built-in quick actions come with a predefined prompt, but it is also possible to define your own quick actions.</p><h2>Creating a custom quick action</h2><p>In the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>: </p><ol><li>Right-click the note where you want to place the quick action.</li><li>Select <em>Insert child note</em>.</li><li>Select <em>More</em> → <em>AI Quick Action</em>. The entry appears only when AI is enabled.</li></ol><p>Afterwards, simply type in the content of the note the desired prompt. The text can be formatted in the same manner as a normal text note and it will be passed to the LLM as Markdown.</p><p>The title of the note will become the title of the quick action.</p><p>Of note:</p><ul><li><a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> notes work too.</li><li>An empty note is ignored.</li><li><a class=\"reference-link\" href=\"#root/_help_MKmLg5x6xkor\">Archived Notes</a> are also excluded.</li></ul><h2>Using a quick action</h2><p>Once a quick action is defined, the action will appear under the <em>Quick Actions</em> dropdown in a group called <em>Custom</em>.</p>",- "_help_nBAXQFj20hS1": "<p>Text notes can \"include\" another note as a read-only widget or an interactive widget, depending on the type of note.</p><p>This can be useful for e.g. including a dynamically generated chart (from scripts & \"render HTML\" note) or other more advanced use cases.</p><h2>Including a note</h2><p>In the <a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>, look for the <span class=\"tn-icon cke cke-trilium-note\"></span> button. There is also a keyboard shortcut defined for it but it is not allocated by default.</p><p>To include a note that is already linked, right-click a reference link to it in a text note being edited and select <em>Convert link to an included note</em>, at the end of the menu. The include gets the box size that suits the note, as one added from the button does.</p><p>An <a href=\"#root/_help_0vhv7lsOLy82\">attachment</a> can be included the same way, from the context menu of a link to it (see <em>Embedding an attachment</em> there).</p><p>A link to blocks of a text note is converted the same way, with <em>Convert link to note excerpt</em>, and the include then shows only those blocks. See <a class=\"reference-link\" href=\"#root/_help_klC3ilXa9kUE\">Block references</a>.</p><h2>Box sizes</h2><p>The box size sets how much of the included note is shown.</p><ul><li><em>Tiny</em> shows a single row instead of the content: the note's icon, its title with the path to the note above it, and buttons to act on the note. The included note is never rendered, so wherever the note is shown outside the editor, such as in print, in a tooltip or on a shared page, a <em>Tiny</em> include appears as a link to the included note.</li><li><em>Small</em> and <em>Medium</em> show the content in a box of limited height. Text scrolls inside the box, while a picture, a diagram or a video is scaled down to fit it.</li><li><em>Full</em> shows the whole content.</li><li><em>Expandable</em> shows only the title until its <span class=\"tn-icon bx bx-chevron-right\"></span> arrow is pressed. In a read-only note, a click anywhere on the title row other than its buttons and link expands or collapses it as well.</li></ul><p>A new include gets the size that suits what it shows:</p><ul><li><em>Tiny</em> for a note or an attachment that has no preview, such as a relation map or an archive.</li><li><em>Small</em> for audio.</li><li><em>Full</em> for a code note or a code file, such as a <code>.js</code>, <code>.py</code> or <code>.txt</code> attachment, and for an excerpt of the blocks of a text note.</li><li><em>Medium</em> for anything else.</li></ul><p>The dialog that includes a note selects that size once the note is picked, and you can choose another one there. To change the size later, select the include and use the <em>Box size</em> menu in its toolbar, or the <em>Size</em> submenu of its <em>More actions</em> menu.</p><h2>Resizing</h2><p>A <em>Small</em>, <em>Medium</em> or <em>Expandable</em> include can be resized to any width and height. A <em>Tiny</em> or <em>Full</em> include always fits its content.</p><ul><li>To resize an include, select it and drag the handle in its bottom-right corner. To change only the width or only the height, drag the middle of its right or bottom edge instead, where a touch screen shows a handle too. In right-to-left text, the handle is in the bottom-left corner and the width changes from the left edge.</li><li>Resizing works with a mouse, a pen or a finger.</li><li>While the height changes, moving the handle near the top or the bottom of the note scrolls the note.</li><li>An include narrower than the note is centered, so changing its width moves both of its sides. Making it as wide as the note returns it to the full width.</li><li>To cancel a resize, press <kbd>Esc</kbd> before releasing the handle.</li><li>To reset the size, double-click the corner handle, or double-tap it on a touch screen. Double-clicking the right or bottom edge resets only the width or the height.</li><li>Choosing a box size resets the height. Choosing <em>Tiny</em> or <em>Full</em> resets the width too.</li><li>While an <em>Expandable</em> include is collapsed, only its width can be changed.</li></ul><h2>Caption</h2><p>An include can have a caption, shown centered at the bottom of its box. The caption is part of the text note, so it can be formatted like the rest of the text, for example in bold or with a link.</p><ul><li>To add a caption, select the include, press the <span class=\"tn-icon cke cke-caption\"></span> <em>Toggle caption on</em> button in its toolbar and type the caption.</li><li>To remove the caption, press the same button again. Pressing it once more brings back the text it had, as long as the note stays open.</li><li>A <em>Tiny</em> include has no caption. Switching an include to <em>Tiny</em> removes its caption, and switching it back to a larger size restores the caption, as long as the note stays open.</li><li>An <em>Expandable</em> include shows its caption under the title while the content is collapsed, and under the content once it is expanded.</li></ul><h2>Title</h2><p>The title row of an include links to the included note and holds its buttons. To show only the content, select the include and press the <span class=\"tn-icon bx bx-window-alt\"></span> <em>Show title</em> button in its toolbar. Pressing it again shows the title.</p><ul><li>While the title is hidden, the <span class=\"tn-icon cke cke-three-vertical-dots\"></span> <em>More actions</em> button in the toolbar of the include opens the menu of the included note.</li><li>A <em>Tiny</em> or <em>Expandable</em> include always shows its title, and its toolbar has no <em>Show title</em> button.</li></ul><h2>Opening an included note</h2><p>To open an included note in a new tab, press the <span class=\"tn-icon bx bx-link-external\"></span> <em>Open in new tab</em> button at the end of its title. An embedded attachment has the same button.</p><p>The <span class=\"tn-icon bx bx-dots-vertical-rounded\"></span> <em>More actions</em> button at the end of the title row opens the same menu as right-clicking anywhere on the title row: the other places to open the note in and, for an embedded attachment, the actions on the attachment.</p><p>In a note being edited, the menu also has the commands of the include's toolbar: the <em>Size</em> submenu, <em>Show title</em> and <em>Show caption</em>, each checked while it is in effect, and <em>Convert to link</em> at the end. A drawing canvas, an included text, code or Markdown note and an embedded code or Markdown file also have <em>Editable</em>, above <em>Size</em>. An included Markdown note and an embedded Markdown file also have <em>Source view</em>, <em>Split view</em> and <em>Preview</em> after <em>Editable</em>. For an embedded attachment they follow its first group of actions; for an included note they end the menu.</p><p>To show an include of size <em>Medium</em> or <em>Full</em> on the whole screen, press the <span class=\"tn-icon bx bx-fullscreen\"></span> <em>Fullscreen</em> button at the end of its title. An excerpt of the blocks of a note has an <span class=\"tn-icon bx bx-pencil\"></span> <em>Edit excerpt</em> button there instead; see <a class=\"reference-link\" href=\"#root/_help_klC3ilXa9kUE\">Block references</a>. To return, press <span class=\"tn-icon bx bx-exit\"></span> <em>Exit fullscreen</em> in the top-right corner, or <kbd>Esc</kbd>.</p><p>A <em>Tiny</em> include has these buttons instead, followed by the same <em>More actions</em> button:</p><ul><li>For a note, <span class=\"tn-icon bx bx-edit\"></span> <em>Quick edit</em> opens the note in <a class=\"reference-link\" href=\"#root/_help_ZjLYv08Rp3qC\">Quick edit</a>, and <span class=\"tn-icon bx bx-link-external\"></span> <em>Open in new tab</em> opens it in a new tab.</li><li>For an embedded attachment, <span class=\"tn-icon bx bx-file-find\"></span> <em>Open externally</em> opens the file in another application, and <span class=\"tn-icon bx bx-download\"></span> <em>Download</em> downloads it. The size of the file is shown under its title.</li></ul><h2>Converting an include to a link</h2><p>To replace an include with a link to the included note, select it and press the <span class=\"tn-icon cke cke-link\"></span> <em>Convert to link</em> button in its toolbar, or choose <em>Convert to link</em> at the end of its <em>More actions</em> menu. An embedded attachment turns into a link to the attachment the same way.</p><h2>Included notes in the share functionality</h2><p>If a <a href=\"#root/_help_R9pX4DGra2Vt\">shared note</a> contains one or more included notes, they will be displayed in the content of the note as if they were part of the note itself. The caption of an include is shown under the included content. A <em>Tiny</em> include is shown as a link to the included note instead, and so is an include that would show a note already shown around it, such as a note that includes itself. The same goes for a printed or exported note.</p><p>For this to work, the included notes must also be shared, otherwise they will not be shown. However, the included notes can still be hidden from the note tree via <code>#shareHiddenFromTree</code>.</p><h2>Interactive notes</h2><p>Since v0.104.0, included notes might become interactive depending on their note type:</p><ul><li><a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a> (e.g. <a class=\"reference-link\" href=\"#root/_help_81SGnPGMk7Xc\">Geo Map</a>) will render fully interactive, including creating new notes.</li><li><a class=\"reference-link\" href=\"#root/_help_m523cpzocqaD\">Saved Search</a> will also display the results.</li><li><a class=\"reference-link\" href=\"#root/_help_1vHRoWCEjj0L\">Web View</a> provides an interactive preview of the website.</li></ul><h2>Included images</h2><p>An included image, whether an image note or an image attachment, is shown in the image viewer, which zooms and pans it:</p><ul><li>To zoom, press the <span class=\"tn-icon bx bx-plus-circle\"></span> <em>Zoom in</em> and <span class=\"tn-icon bx bx-minus-circle\"></span> <em>Zoom out</em> buttons in the bottom-right corner of the image, or pinch on a touch screen. The percentage between them resets the zoom.</li><li>To zoom with the mouse wheel, click the image first. Until then, the mouse wheel scrolls the note.</li><li>To pan an image that is zoomed in, drag it. At its fitted size, dragging the image on a touch screen scrolls the note.</li><li>To return to the fitted size, double-click the image.</li></ul><p>In a <em>Small</em> or <em>Medium</em> box, the image is scaled down to fit the height of the box. In fullscreen, it fits the screen.</p><h2>Editing an include in place</h2><p>An included text note, an included code note and an embedded code file such as a <code>.js</code>, <code>.py</code> or <code>.txt</code> attachment can be edited without leaving the note that includes them. A code note or file is shown with syntax highlighting until then. Included Markdown can be edited too, see <em>Included Markdown</em> below.</p><ul><li>To edit, select the include and turn on the <span class=\"tn-icon bx bx-edit-alt\"></span> <em>Editable</em> button at the start of its toolbar, or check <em>Editable</em> in its <span class=\"tn-icon cke cke-three-vertical-dots\"></span> <em>More actions</em> menu. Turn <em>Editable</em> off to return to the preview.</li><li>While <em>Editable</em> is on, the arrow keys move the caret into the include and back out, as through the rest of the text. Entering from above or from the left puts the caret at the start of the include, and entering from below or from the right puts it at the end. A collapsed <em>Expandable</em> include is skipped.</li><li>While an included text note has the focus, the formatting toolbar applies to it. The notes it includes in turn stay read-only.</li><li>Code is edited in the same code editor as a <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> note, with its theme, indentation and line wrapping settings.</li><li>The toolbar of an included code note or an embedded code file also has the language and indentation menus of the <a class=\"reference-link\" href=\"#root/_help_AlJ73vBCjWDw\">Status bar</a>, between <em>Editable</em> and the <em>Box size</em> menu: <em>Change language mode</em>, which shows the current language, and <em>Change tab width</em>, which shows the current indentation. <em>Re-indent content to</em> converts the indentation of the code itself and saves it to the included note or file, whether <em>Editable</em> is on or off.<ul><li>For an included note, the menus change the note, as they do in its own tab.</li><li>For an embedded code file, the language and indentation settings change only how this include shows the file, and are saved with the note that includes it. The language replaces the one that the file name gives, and the <em>Use default</em> entries return to the indentation set in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Code Notes</em>. These settings leave the file itself unchanged, and other includes of it keep their own settings.</li></ul></li><li>The changes are saved as you type, to the included note or to the attachment, as they would be in its own tab.</li><li>An include of <a class=\"reference-link\" href=\"#root/_help_klC3ilXa9kUE\">Block references</a> edits only the referenced blocks.</li><li>Editing is not available in a <a href=\"#root/_help_CoFPLs3dRlXc\">read-only note</a>, for an included note marked <code>#readOnly</code>, or for an attachment of another note.</li><li><a class=\"reference-link\" href=\"#root/_help_McngOG2jbUWX\">Search in note</a> finds the text of included text and code notes among the results of the note around them, and replaces it while <em>Editable</em> is on.</li></ul><h2>Included Markdown</h2><p>An included <a class=\"reference-link\" href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a> note and an embedded Markdown file, such as a <code>.md</code> attachment, are shown with the same three views as a Markdown note in its own tab (see <a class=\"reference-link\" href=\"#root/_help_SL5f1Auq7sVN\">Note types with split view</a>): <span class=\"tn-icon bx bx-code\"></span> <em>Source view</em>, <span class=\"tn-icon bx bxs-dock-left\"></span> <em>Split view</em> and <span class=\"tn-icon bx bx-show\"></span> <em>Preview</em>.</p><ul><li>To switch the view, press one of the three buttons in the title row of the include. In a note being edited, the toolbar of the include has the same buttons after <em>Editable</em>, and its <span class=\"tn-icon cke cke-three-vertical-dots\"></span> <em>More actions</em> menu has them as <em>Source view</em>, <em>Split view</em> and <em>Preview</em>.</li><li>Until a view is chosen, the include shows the <em>Preview</em>, and the <em>Split view</em> while <em>Editable</em> is on.</li><li>To edit the Markdown, turn on <em>Editable</em> (see <em>Editing an include in place</em> above). The source is edited in the code editor of a Markdown note, and the preview follows the changes as you type. While <em>Editable</em> is off, the source can be read and copied but not changed.</li><li>As in a Markdown note, the preview scrolls along with the source and highlights the block where the cursor is, and <kbd>Ctrl</kbd>+<kbd>B</kbd>, <kbd>Ctrl</kbd>+<kbd>I</kbd>, <kbd>Ctrl</kbd>+<kbd>M</kbd> and <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>X</kbd> format the selection.</li><li>In a note being edited, the view is saved with the include, so two includes of the same note can show different views. In a <a href=\"#root/_help_CoFPLs3dRlXc\">read-only note</a>, the view can be changed too, until the note is opened again.</li><li>While the source shows, the include has the height of its box size, or the height it was resized to. A <em>Full</em> include gets a fixed height too, instead of fitting its content.</li><li><a class=\"reference-link\" href=\"#root/_help_McngOG2jbUWX\">Search in note</a> searches the source while it shows, and the preview otherwise.</li></ul><h2>Drawing canvases</h2><p>A drawing canvas is an Excalidraw canvas, like the one of a <a class=\"reference-link\" href=\"#root/_help_grjYqerjn243\">Canvas</a> note, drawn directly in the text note. It is not a note of its own: the drawing is kept in a <code>Canvas.excalidraw</code> <a href=\"#root/_help_0vhv7lsOLy82\">attachment</a> of the text note and is saved together with the text.</p><ul><li>To insert a drawing canvas, open the <span class=\"tn-icon cke cke-plus\"></span> <em>Insert</em> menu of the <a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a> and choose <span class=\"tn-icon bx bx-pen\"></span> <em>Drawing canvas</em>, above <em>Mermaid diagram</em>. It is also available as <em>Drawing canvas</em> in the <a class=\"reference-link\" href=\"#root/_help_ZlN4nump6EbW\">Slash Commands</a>. The canvas is added empty and editable, in a <em>Medium</em> box with its title hidden, and takes the focus, ready for drawing.</li><li>To draw or write over an image, select the image and press the <span class=\"tn-icon bx bxs-pen\"></span> <em>Convert image to a drawing canvas</em> button of its toolbar. The image is replaced by an editable drawing canvas in a <em>Medium</em> box, with its title hidden and the focus in it. The image sits at its original size in the middle of the canvas, zoomed so that all of it shows, and is locked so that it cannot be selected or moved by accident. While it is locked, the canvas can be zoomed in on the image but not zoomed out past it or scrolled beyond its edges. To move or resize the image anyway, right-click it and choose <em>Unlock</em>. The caption of the image is kept, but not its alignment or link. Only an image on its own line can be converted, not one inside a paragraph. Undo brings the image back.</li><li>An Excalidraw file (<code>.excalidraw</code>) attached with the <span class=\"tn-icon cke cke-paper-clip\"></span><em>Attach file</em> button becomes a drawing canvas too, in a <em>Medium</em> box titled with the file name. It starts with <em>Editable</em> off, so the drawing shows but cannot be changed until <em>Editable</em> is turned on (see below).</li><li>To draw on a canvas that does not have the focus, click it first. Until then, touch gestures scroll the note. The canvas then has the tools, menus and keyboard shortcuts of a Canvas note. The toolbars, the menus and the properties of the selected shapes show only while the canvas has the focus, so elsewhere the drawing reads like a picture in the text.</li><li>The mouse wheel and the touchpad scroll the note over a canvas too, as over the text. To zoom, use the zoom buttons of the canvas toolbar; to move around the drawing, use the <span class=\"tn-icon bx bxs-hand\"></span> <em>Hand</em> tool. In fullscreen, the mouse wheel moves and zooms the drawing instead.</li><li>The canvas toolbar replaces the Excalidraw menu: <em>Export image</em>, <em>Find on canvas</em>, <em>Library</em> and <em>Help</em> are at the end of its <span class=\"tn-icon bx bx-category\"></span> <em>More tools</em> menu. In fullscreen, the Excalidraw menu shows again.</li><li>A new drawing has the background color of the note. A background chosen from the Excalidraw menu replaces it.</li><li>To protect a finished drawing from accidental changes, select it and turn off the <span class=\"tn-icon bx bx-edit-alt\"></span> <em>Editable</em> button at the start of its toolbar, or uncheck <em>Editable</em> in its <span class=\"tn-icon cke cke-three-vertical-dots\"></span> <em>More actions</em> menu. The drawing then shows as a still picture, at the zoom and position it had, and can no longer be changed, zoomed or moved. To draw again, turn <em>Editable</em> back on.</li><li>The box sizes, resizing, the caption and the title work as for an included note, but the toolbar of a drawing leaves the box size, <em>Show title</em> and <em>Convert to link</em> to its <em>More actions</em> menu.</li><li>In the desktop layout, Excalidraw keeps its desktop interface however small the box is. In the mobile layout, a narrow or short box switches it to a compact interface. For more room, choose <em>Full</em>, or show the title and press <span class=\"tn-icon bx bx-fullscreen\"></span> <em>Fullscreen</em>.</li><li>Pictures added to the drawing are stored in the same attachment. A converted image is kept as an image attachment of the note instead, named with a generated code.</li><li>In a <a href=\"#root/_help_CoFPLs3dRlXc\">read-only note</a>, the drawing shows as a still picture too.</li><li>On a <a href=\"#root/_help_R9pX4DGra2Vt\">shared page</a>, the drawing is shown as a picture at its own size, whatever the size of its box, in light or dark colors to match the page. Each change to the drawing saves this picture as an SVG image attachment of the note, also named with a generated code.</li></ul><h3>Limitations</h3><ul><li>The Excalidraw shape library is not saved for a drawing canvas.</li><li>Outside the editor, for example in a tooltip, when printing or in the list of attachments, the drawing is shown as a picture.</li><li>A drawing has no picture for shared pages until its first change, except one converted from an image. Until then, for example for an attached <code>.excalidraw</code> file, a shared page shows a link to download the drawing instead.</li><li>In Safari, the picture of a drawing on a shared page follows the light or dark appearance of the system rather than the theme chosen on the page.</li><li>A copy of a drawing canvas pasted in the same note shares the drawing with the original, so a change to one shows in the other only after the note is opened again. A copy pasted in another note gets a drawing of its own.</li></ul>",+ "_help_nBAXQFj20hS1": "<p>Text notes can \"include\" another note as a read-only widget or an interactive widget, depending on the type of note.</p><p>This can be useful for e.g. including a dynamically generated chart (from scripts & \"render HTML\" note) or other more advanced use cases.</p><h2>Including a note</h2><p>In the <a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>, look for the <span class=\"tn-icon cke cke-trilium-note\"></span> button. There is also a keyboard shortcut defined for it but it is not allocated by default.</p><p>To include a note that is already linked, right-click a reference link to it in a text note being edited and select <em>Convert link to an included note</em>, at the end of the menu. The include gets the box size that suits the note, as one added from the button does.</p><p>An <a href=\"#root/_help_0vhv7lsOLy82\">attachment</a> can be included the same way, from the context menu of a link to it (see <em>Embedding an attachment</em> there).</p><p>A link to blocks of a text note is converted the same way, with <em>Convert link to note excerpt</em>, and the include then shows only those blocks. See <a class=\"reference-link\" href=\"#root/_help_klC3ilXa9kUE\">Block references</a>.</p><h2>Box sizes</h2><p>The box size sets how much of the included note is shown.</p><ul><li><em>Tiny</em> shows a single row instead of the content: the note's icon, its title with the path to the note above it, and buttons to act on the note. The included note is never rendered, so wherever the note is shown outside the editor, such as in print, in a tooltip or on a shared page, a <em>Tiny</em> include appears as a link to the included note.</li><li><em>Small</em> and <em>Medium</em> show the content in a box of limited height. Text scrolls inside the box, while a picture, a diagram or a video is scaled down to fit it.</li><li><em>Full</em> shows the whole content.</li><li><em>Expandable</em> shows only the title until its <span class=\"tn-icon bx bx-chevron-right\"></span> arrow is pressed. In a read-only note, a click anywhere on the title row other than its buttons and link expands or collapses it as well.</li></ul><p>A new include gets the size that suits what it shows:</p><ul><li><em>Tiny</em> for a note or an attachment that has no preview, such as a relation map or an archive.</li><li><em>Small</em> for audio.</li><li><em>Full</em> for a code note or a code file, such as a <code>.js</code>, <code>.py</code> or <code>.txt</code> attachment, and for an excerpt of the blocks of a text note.</li><li><em>Medium</em> for anything else.</li></ul><p>The dialog that includes a note selects that size once the note is picked, and you can choose another one there. To change the size later, select the include and use the <em>Box size</em> menu in its toolbar, or the <em>Size</em> submenu of its <em>More actions</em> menu.</p><h2>Resizing</h2><p>A <em>Small</em>, <em>Medium</em> or <em>Expandable</em> include can be resized to any width and height. A <em>Tiny</em> or <em>Full</em> include always fits its content.</p><ul><li>To resize an include, select it and drag the handle in its bottom-right corner. To change only the width or only the height, drag the middle of its right or bottom edge instead, where a touch screen shows a handle too. In right-to-left text, the handle is in the bottom-left corner and the width changes from the left edge.</li><li>Resizing works with a mouse, a pen or a finger.</li><li>While the height changes, moving the handle near the top or the bottom of the note scrolls the note.</li><li>An include narrower than the note is centered, so changing its width moves both of its sides. Making it as wide as the note returns it to the full width.</li><li>To cancel a resize, press <kbd>Esc</kbd> before releasing the handle.</li><li>To reset the size, double-click the corner handle, or double-tap it on a touch screen. Double-clicking the right or bottom edge resets only the width or the height.</li><li>Choosing a box size resets the height. Choosing <em>Tiny</em> or <em>Full</em> resets the width too.</li><li>While an <em>Expandable</em> include is collapsed, only its width can be changed.</li></ul><h2>Caption</h2><p>An include can have a caption, shown centered at the bottom of its box. The caption is part of the text note, so it can be formatted like the rest of the text, for example in bold or with a link.</p><ul><li>To add a caption, select the include, press the <span class=\"tn-icon cke cke-caption\"></span> <em>Toggle caption on</em> button in its toolbar and type the caption.</li><li>To remove the caption, press the same button again. Pressing it once more brings back the text it had, as long as the note stays open.</li><li>A <em>Tiny</em> include has no caption. Switching an include to <em>Tiny</em> removes its caption, and switching it back to a larger size restores the caption, as long as the note stays open.</li><li>An <em>Expandable</em> include shows its caption under the title while the content is collapsed, and under the content once it is expanded.</li></ul><h2>Title</h2><p>The title row of an include links to the included note and holds its buttons. To show only the content, select the include and press the <span class=\"tn-icon bx bx-window-alt\"></span> <em>Show title</em> button in its toolbar. Pressing it again shows the title.</p><ul><li>While the title is hidden, the <span class=\"tn-icon cke cke-three-vertical-dots\"></span> <em>More actions</em> button in the toolbar of the include opens the menu of the included note.</li><li>A <em>Tiny</em> or <em>Expandable</em> include always shows its title, and its toolbar has no <em>Show title</em> button.</li></ul><h2>Opening an included note</h2><p>To open an included note in a new tab, press the <span class=\"tn-icon bx bx-link-external\"></span> <em>Open in new tab</em> button at the end of its title. An embedded attachment has the same button.</p><p>The <span class=\"tn-icon bx bx-dots-vertical-rounded\"></span> <em>More actions</em> button at the end of the title row opens the same menu as right-clicking anywhere on the title row: the other places to open the note in and, for an embedded attachment, the actions on the attachment.</p><p>In a note being edited, the menu also has the commands of the include's toolbar: the <em>Size</em> submenu, <em>Show title</em> and <em>Show caption</em>, each checked while it is in effect, and <em>Convert to link</em> at the end. A drawing canvas, an included text, code or Markdown note and an embedded code or Markdown file also have <em>Editable</em>, above <em>Size</em>. An included Markdown note and an embedded Markdown file also have <em>Source view</em>, <em>Split view</em> and <em>Preview</em> after <em>Editable</em>. For an embedded attachment they follow its first group of actions; for an included note they end the menu.</p><p>To show an include of size <em>Medium</em> or <em>Full</em> on the whole screen, press the <span class=\"tn-icon bx bx-fullscreen\"></span> <em>Fullscreen</em> button at the end of its title. An excerpt of the blocks of a note has an <span class=\"tn-icon bx bx-pencil\"></span> <em>Edit excerpt</em> button there instead; see <a class=\"reference-link\" href=\"#root/_help_klC3ilXa9kUE\">Block references</a>. To return, press <span class=\"tn-icon bx bx-exit\"></span> <em>Exit fullscreen</em> in the top-right corner, or <kbd>Esc</kbd>.</p><p>A <em>Tiny</em> include has these buttons instead, followed by the same <em>More actions</em> button:</p><ul><li>For a note, <span class=\"tn-icon bx bx-edit\"></span> <em>Quick edit</em> opens the note in <a class=\"reference-link\" href=\"#root/_help_ZjLYv08Rp3qC\">Quick edit</a>, and <span class=\"tn-icon bx bx-link-external\"></span> <em>Open in new tab</em> opens it in a new tab.</li><li>For an embedded attachment, <span class=\"tn-icon bx bx-file-find\"></span> <em>Open externally</em> opens the file in another application, and <span class=\"tn-icon bx bx-download\"></span> <em>Download</em> downloads it. The size of the file is shown under its title.</li></ul><h2>Converting an include to a link</h2><p>To replace an include with a link to the included note, select it and press the <span class=\"tn-icon cke cke-link\"></span> <em>Convert to link</em> button in its toolbar, or choose <em>Convert to link</em> at the end of its <em>More actions</em> menu. An embedded attachment turns into a link to the attachment the same way.</p><h2>Included notes in the share functionality</h2><p>If a <a href=\"#root/_help_R9pX4DGra2Vt\">shared note</a> contains one or more included notes, they will be displayed in the content of the note as if they were part of the note itself. The caption of an include is shown under the included content. A <em>Tiny</em> include is shown as a link to the included note instead, and so is an include that would show a note already shown around it, such as a note that includes itself. The same goes for a printed or exported note.</p><p>For this to work, the included notes must also be shared, otherwise they will not be shown. However, the included notes can still be hidden from the note tree via <code>#shareHiddenFromTree</code>.</p><h2>Interactive notes</h2><p>Since v0.104.0, included notes might become interactive depending on their note type:</p><ul><li><a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a> (e.g. <a class=\"reference-link\" href=\"#root/_help_81SGnPGMk7Xc\">Geo Map</a>) will render fully interactive, including creating new notes.</li><li><a class=\"reference-link\" href=\"#root/_help_m523cpzocqaD\">Saved Search</a> will also display the results.</li><li><a class=\"reference-link\" href=\"#root/_help_1vHRoWCEjj0L\">Web View</a> provides an interactive preview of the website.</li></ul><h2>Included images</h2><p>An included image, whether an image note or an image attachment, is shown in the image viewer, which zooms and pans it:</p><ul><li>To zoom, press the <span class=\"tn-icon bx bx-plus-circle\"></span> <em>Zoom in</em> and <span class=\"tn-icon bx bx-minus-circle\"></span> <em>Zoom out</em> buttons in the bottom-right corner of the image, or pinch on a touch screen. The percentage between them resets the zoom.</li><li>To zoom with the mouse wheel, click the image first. Until then, the mouse wheel scrolls the note.</li><li>To pan an image that is zoomed in, drag it. At its fitted size, dragging the image on a touch screen scrolls the note.</li><li>To return to the fitted size, double-click the image.</li></ul><p>In a <em>Small</em> or <em>Medium</em> box, the image is scaled down to fit the height of the box. In fullscreen, it fits the screen.</p><h2>Editing an include in place</h2><p>An included text note, an included code note and an embedded code file such as a <code>.js</code>, <code>.py</code> or <code>.txt</code> attachment can be edited without leaving the note that includes them. A code note or file is shown with syntax highlighting and line numbers until then, in the colors of the code editor. Included Markdown can be edited too, see <em>Included Markdown</em> below.</p><ul><li>To edit, select the include and turn on the <span class=\"tn-icon bx bx-edit-alt\"></span> <em>Editable</em> button at the start of its toolbar, or check <em>Editable</em> in its <span class=\"tn-icon cke cke-three-vertical-dots\"></span> <em>More actions</em> menu. Turn <em>Editable</em> off to return to the preview.</li><li>While <em>Editable</em> is on, the arrow keys move the caret into the include and back out, as through the rest of the text. Entering from above or from the left puts the caret at the start of the include, and entering from below or from the right puts it at the end. A collapsed <em>Expandable</em> include is skipped.</li><li>While an included text note has the focus, the formatting toolbar applies to it. The notes it includes in turn stay read-only.</li><li>Code is edited in the same code editor as a <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> note, with its theme, indentation and line wrapping settings.</li><li>The toolbar of an included code note or an embedded code file also has the language and indentation menus of the <a class=\"reference-link\" href=\"#root/_help_AlJ73vBCjWDw\">Status bar</a>, between <em>Editable</em> and the <em>Box size</em> menu: <em>Change language mode</em>, which shows the current language, and <em>Change tab width</em>, which shows the current indentation. <em>Re-indent content to</em> converts the indentation of the code itself and saves it to the included note or file, whether <em>Editable</em> is on or off.<ul><li>For an included note, the menus change the note, as they do in its own tab.</li><li>For an embedded code file, the language and indentation settings change only how this include shows the file, and are saved with the note that includes it. The language replaces the one that the file name gives, and the <em>Use default</em> entries return to the indentation set in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Code Notes</em>. These settings leave the file itself unchanged, and other includes of it keep their own settings.</li></ul></li><li>The changes are saved as you type, to the included note or to the attachment, as they would be in its own tab.</li><li>An include of <a class=\"reference-link\" href=\"#root/_help_klC3ilXa9kUE\">Block references</a> edits only the referenced blocks.</li><li>Editing is not available in a <a href=\"#root/_help_CoFPLs3dRlXc\">read-only note</a>, for an included note marked <code>#readOnly</code>, or for an attachment of another note.</li><li><a class=\"reference-link\" href=\"#root/_help_McngOG2jbUWX\">Search in note</a> finds the text of included text and code notes among the results of the note around them, and replaces it while <em>Editable</em> is on.</li></ul><h2>Included Markdown</h2><p>An included <a class=\"reference-link\" href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a> note and an embedded Markdown file, such as a <code>.md</code> attachment, are shown with the same three views as a Markdown note in its own tab (see <a class=\"reference-link\" href=\"#root/_help_SL5f1Auq7sVN\">Note types with split view</a>): <span class=\"tn-icon bx bx-code\"></span> <em>Source view</em>, <span class=\"tn-icon bx bxs-dock-left\"></span> <em>Split view</em> and <span class=\"tn-icon bx bx-show\"></span> <em>Preview</em>.</p><ul><li>To switch the view, press one of the three buttons in the title row of the include. In a note being edited, the toolbar of the include has the same buttons after <em>Editable</em>, and its <span class=\"tn-icon cke cke-three-vertical-dots\"></span> <em>More actions</em> menu has them as <em>Source view</em>, <em>Split view</em> and <em>Preview</em>.</li><li>Until a view is chosen, the include shows the <em>Preview</em>, and the <em>Split view</em> while <em>Editable</em> is on.</li><li>To edit the Markdown, turn on <em>Editable</em> (see <em>Editing an include in place</em> above). The source is edited in the code editor of a Markdown note, and the preview follows the changes as you type. While <em>Editable</em> is off, the source can be read and copied but not changed.</li><li>As in a Markdown note, the preview scrolls along with the source and highlights the block where the cursor is, and <kbd>Ctrl</kbd>+<kbd>B</kbd>, <kbd>Ctrl</kbd>+<kbd>I</kbd>, <kbd>Ctrl</kbd>+<kbd>M</kbd> and <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>X</kbd> format the selection.</li><li>In a note being edited, the view is saved with the include, so two includes of the same note can show different views. In a <a href=\"#root/_help_CoFPLs3dRlXc\">read-only note</a>, the view can be changed too, until the note is opened again.</li><li>While the source shows, the include has the height of its box size, or the height it was resized to. A <em>Full</em> include gets a fixed height too, instead of fitting its content.</li><li><a class=\"reference-link\" href=\"#root/_help_McngOG2jbUWX\">Search in note</a> searches the source while it shows, and the preview otherwise.</li></ul><h2>Drawing canvases</h2><p>A drawing canvas is an Excalidraw canvas, like the one of a <a class=\"reference-link\" href=\"#root/_help_grjYqerjn243\">Canvas</a> note, drawn directly in the text note. It is not a note of its own: the drawing is kept in a <code>Canvas.excalidraw</code> <a href=\"#root/_help_0vhv7lsOLy82\">attachment</a> of the text note and is saved together with the text.</p><ul><li>To insert a drawing canvas, open the <span class=\"tn-icon cke cke-plus\"></span> <em>Insert</em> menu of the <a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a> and choose <span class=\"tn-icon bx bx-pen\"></span> <em>Drawing canvas</em>, above <em>Mermaid diagram</em>. It is also available as <em>Drawing canvas</em> in the <a class=\"reference-link\" href=\"#root/_help_ZlN4nump6EbW\">Slash Commands</a>. The canvas is added empty and editable, in a <em>Medium</em> box with its title hidden, and takes the focus, ready for drawing.</li><li>To draw or write over an image, select the image and press the <span class=\"tn-icon bx bxs-pen\"></span> <em>Convert image to a drawing canvas</em> button of its toolbar. The image is replaced by an editable drawing canvas in a <em>Medium</em> box, with its title hidden and the focus in it. The image sits at its original size in the middle of the canvas, zoomed so that all of it shows, and is locked so that it cannot be selected or moved by accident. While it is locked, the canvas can be zoomed in on the image but not zoomed out past it or scrolled beyond its edges. To move or resize the image anyway, right-click it and choose <em>Unlock</em>. The caption of the image is kept, but not its alignment or link. Only an image on its own line can be converted, not one inside a paragraph. Undo brings the image back.</li><li>An Excalidraw file (<code>.excalidraw</code>) attached with the <span class=\"tn-icon cke cke-paper-clip\"></span><em>Attach file</em> button becomes a drawing canvas too, in a <em>Medium</em> box titled with the file name. It starts with <em>Editable</em> off, so the drawing shows but cannot be changed until <em>Editable</em> is turned on (see below).</li><li>To draw on a canvas that does not have the focus, click it first. Until then, touch gestures scroll the note. The canvas then has the tools, menus and keyboard shortcuts of a Canvas note. The toolbars, the menus and the properties of the selected shapes show only while the canvas has the focus, so elsewhere the drawing reads like a picture in the text.</li><li>The mouse wheel and the touchpad scroll the note over a canvas too, as over the text. To zoom, use the zoom buttons of the canvas toolbar; to move around the drawing, use the <span class=\"tn-icon bx bxs-hand\"></span> <em>Hand</em> tool. In fullscreen, the mouse wheel moves and zooms the drawing instead.</li><li>The canvas toolbar replaces the Excalidraw menu: <em>Export image</em>, <em>Find on canvas</em>, <em>Library</em> and <em>Help</em> are at the end of its <span class=\"tn-icon bx bx-category\"></span> <em>More tools</em> menu. In fullscreen, the Excalidraw menu shows again.</li><li>A new drawing has the background color of the note. A background chosen from the Excalidraw menu replaces it.</li><li>To protect a finished drawing from accidental changes, select it and turn off the <span class=\"tn-icon bx bx-edit-alt\"></span> <em>Editable</em> button at the start of its toolbar, or uncheck <em>Editable</em> in its <span class=\"tn-icon cke cke-three-vertical-dots\"></span> <em>More actions</em> menu. The drawing then shows as a still picture, at the zoom and position it had, and can no longer be changed, zoomed or moved. To draw again, turn <em>Editable</em> back on.</li><li>The box sizes, resizing, the caption and the title work as for an included note, but the toolbar of a drawing leaves the box size, <em>Show title</em> and <em>Convert to link</em> to its <em>More actions</em> menu.</li><li>In the desktop layout, Excalidraw keeps its desktop interface however small the box is. In the mobile layout, a narrow or short box switches it to a compact interface. For more room, choose <em>Full</em>, or show the title and press <span class=\"tn-icon bx bx-fullscreen\"></span> <em>Fullscreen</em>.</li><li>Pictures added to the drawing are stored in the same attachment. A converted image is kept as an image attachment of the note instead, named with a generated code.</li><li>In a <a href=\"#root/_help_CoFPLs3dRlXc\">read-only note</a>, the drawing shows as a still picture too.</li><li>On a <a href=\"#root/_help_R9pX4DGra2Vt\">shared page</a>, the drawing is shown as a picture at its own size, whatever the size of its box, in light or dark colors to match the page. Each change to the drawing saves this picture as an SVG image attachment of the note, also named with a generated code.</li></ul><h3>Limitations</h3><ul><li>The Excalidraw shape library is not saved for a drawing canvas.</li><li>Outside the editor, for example in a tooltip, when printing or in the list of attachments, the drawing is shown as a picture.</li><li>A drawing has no picture for shared pages until its first change, except one converted from an image. Until then, for example for an attached <code>.excalidraw</code> file, a shared page shows a link to download the drawing instead.</li><li>In Safari, the picture of a drawing on a shared page follows the light or dark appearance of the system rather than the theme chosen on the page.</li><li>A copy of a drawing canvas pasted in the same note shares the drawing with the original, so a change to one shows in the other only after the note is opened again. A copy pasted in another note gets a drawing of its own.</li></ul>","_help_CohkqWQC1iBv": "<p>Press the <span class=\"tn-icon cke cke-plus\"></span> button in the <a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a> to reveal special inserable items and blocks such as symbols, Math expressions and separators.</p><h2>Bookmarks</h2><p>See the dedicated <a class=\"reference-link\" href=\"#root/_help_oSuaNgyyKnhu\">Anchors</a> section.</p><h2>Emoji</h2><figure class=\"image image-style-align-right image_resized\" style=\"width:42.4%;\"><img style=\"aspect-ratio:366/410;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Insert%20buttons_plus.png\" width=\"366\" height=\"410\"></figure><p>This feature allows inserting Unicode emoji characters. Simply select a category and a desired emoji to insert it.</p><p>Emojis can also be searched by their English name and the skin tone can be selected via a combo box to the right.</p><p>There is also the possibility of inserting emojis directly by typing <code>:</code> followed by a name of an emoji, triggering the display of a list of emojis. Simply use the arrow keys to select one and press <kbd>Enter</kbd> or <kbd>Tab</kbd> to insert it.</p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/1_Insert%20buttons_plus.png\" width=\"272\" height=\"187\"><h2>Symbols</h2><figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:346/322;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Insert%20buttons_image.png\" width=\"346\" height=\"322\"></figure><p>Pressing the <span class=\"tn-icon cke cke-special-characters\"></span> button will reveal a popup window displaying a list of characters that are generally more difficult to insert directly from the keyboard, such as a subset of emojis, quotation characters, etc.</p><p>Interaction:</p><ul><li>Click on a character to insert it at the current cursor position.</li><li>The window can be dragged around by the top bar where the title is, to avoid it getting in the way of the text.</li><li>Click on the <em>Category</em> selector to filter the characters.</li></ul><h2>Multicolumn layout</h2><p>See the dedicated <a class=\"reference-link\" href=\"#root/_help_wYDzQ1fBFgfT\">Multicolumn layout</a> page.</p><h2>Math equations</h2><p>See the dedicated <a class=\"reference-link\" href=\"#root/_help_YfYAtQBcfo5V\">Math Equations</a> page.</p><h2>Drawing canvas</h2><p>Choose <span class=\"tn-icon bx bx-pen\"></span> <em>Drawing canvas</em> to draw on an Excalidraw canvas inside the text. See <em>Drawing canvases</em> in <a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>.</p><h2>Mermaid diagram</h2><p>Press the <span class=\"tn-icon cke cke-trilium-mermaid-insert\"></span> button to create an inline Mermaid diagram.</p><p>This feature is quite similar to the <a class=\"reference-link\" href=\"#root/_help_s1aBHPd79XYj\">Mermaid Diagrams</a> note types and is meant as an alternative to it for simple diagrams. For more complex diagrams, use the <a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a> feature for a dedicated Mermaid note.</p><figure class=\"image\"><img style=\"aspect-ratio:1174/358;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/2_Insert%20buttons_image.png\" width=\"1174\" height=\"358\"></figure><h2>Horizontal ruler</h2><p>This feature will display a horizontal line, generally useful to separate different sections of the text. To do so, press the <span class=\"tn-icon cke cke-horizontal-line\"></span> button in the <a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>.</p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/1_Insert%20buttons_image.png\" width=\"502\" height=\"95\"><p>Alternatively, it's possible to insert a horizontal ruler by typing <code>---</code>.</p><h2>Page break</h2><figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:371/79;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/3_Insert%20buttons_image.png\" width=\"371\" height=\"79\"></figure><p>Page breaks provide a way to force the next paragraph or block (table, image, etc.) to be displayed onto the next page when printing (either to a real printer to <a href=\"#root/_help_NRnIZmSMc5sj\">when exporting to PDF</a>).</p><p>Page breaks are marked in the editor with the words <em>Page break</em>, but they will not actually be shown when printed.</p><ul><li>To insert a page break, press the <span class=\"tn-icon cke cke-page-break\"></span> in the formatting toolbar.</li><li>To insert many page breaks at once, insert a page break first, click on it and press <kbd>Ctrl</kbd>+<kbd>C</kbd>. Then use <kbd>Ctrl</kbd>+<kbd>V</kbd>, to paste as many times as needed.</li></ul><h2>Date and time</h2><p>The <span class=\"tn-icon cke cke-trilium-date-time\"></span> button inserts the current date and time at the cursor, replacing the selected text if there is any. The inserted text takes the formatting of the text around it, so a date inserted inside bold text is bold too.</p><ul><li>To insert the date in the default format, press the button itself or press <kbd>Alt</kbd>+<kbd>T</kbd>.</li><li>To insert it in another format, press the arrow next to the button and pick a format from the list. Each entry shows the current date and time in that format: the default one, the date or the time alone, the date written out, and ISO 8601.</li><li>The same formats are offered by the <a class=\"reference-link\" href=\"#root/_help_ZlN4nump6EbW\">Slash Commands</a>: type <code>/date</code>, <code>/time</code>, <code>/now</code> or <code>/today</code>. The <em>Insert date/time</em> entry uses the default format, and shows what it inserts underneath; the other entries show their output in the title.</li></ul><p>The default format can be changed in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Text Notes</em> → <em>Editor</em> → <em>Date/time format</em>, using <a href=\"https://day.js.org/docs/en/display/format\">Day.js format tokens</a> (for example <code>DD.MM.YYYY HH:mm</code>).</p><h2>Icons</h2><p>Icons just like the ones for the <a href=\"#root/_help_p9kXRFAkwN4o\">note icon</a> can be inserted in text. For more information see <a class=\"reference-link\" href=\"#root/_help_hD8GawVuazff\">Icons</a>.</p>","_help_hD8GawVuazff": "<p>Icons just like the <a href=\"#root/_help_hD8GawVuazff\">note icons</a> can be inserted in the content of a note, including from any other <a href=\"#root/_help_gOKqSJgXLcIj\">custom icon packs</a>.</p><h2>Features</h2><ul><li>The icon can be formatted through the<a class=\"reference-link\" href=\"#root/_help_Gr6xFaF6ioJ5\">General formatting</a> tools of the <a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>:<ul><li>Foreground/icon color</li><li>Background color/highlight</li><li>Font size</li></ul></li><li>Custom <a class=\"reference-link\" href=\"#root/_help_gOKqSJgXLcIj\">Icon Packs</a> are also supported.<ul><li>For emojis, prefer the Emoji functionality from <a class=\"reference-link\" href=\"#root/_help_CohkqWQC1iBv\">Insert buttons</a>.</li></ul></li><li>When an icon is clicked a floating toolbar appears with the following functions:<ul><li><span class=\"tn-icon bx bx-sticker\"></span> which changes the icon.</li><li><span class=\"tn-icon bx bx-reflect-horizontal\"></span> which applies transforms: rotate (90 / 180 / 270) and flip horizontal/vertical. Only one transform can be used per icon.</li></ul></li></ul><h2>Usage</h2><ul><li>The in-app help/user guide makes use of these icons in order to illustrate buttons in the UI.</li><li>The <a class=\"reference-link\" href=\"#root/_help_GnhlmrATVqcH\">Microsoft OneNote</a> importer also makes use of them for the <a class=\"reference-link\" href=\"#root/_help_LpvyEIBIAAj7\">Tags</a>.</li></ul><h2>Inserting an icon</h2><p>There are two ways to insert an icon:</p><ul><li>Via the <a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a> look for the <span class=\"tn-icon bx bx-plus\"></span> icon and then the <span class=\"tn-icon bx bx-sticker\"></span> icon.</li><li>Via <a class=\"reference-link\" href=\"#root/_help_ZlN4nump6EbW\">Slash Commands</a>, type <code>/icon</code>.</li></ul><p>An icon picker will appear, search for an icon and click it to insert it in the document.</p><h2>Finding notes by their icons</h2><p>An icon can be <a href=\"#root/_help_eIg8jdvaoNNd\">searched</a>. A note containing a <span class=\"tn-icon bx bx-star\"></span> icon can be found by searching for <code>star</code>, or its <code>iconClass</code> (<code>bx-star</code>).</p><p>To find the name of the icon, hover the mouse over an icon while in the icon picker.</p><h2>Markdown rendering</h2><p>When exporting to <a class=\"reference-link\" href=\"#root/_help_Oau6X9rCuegd\">Markdown</a>, the item will render as raw HTML representation of the icon as is used by Trilium:</p><pre><code class=\"language-text-html\"><span class=\"tn-icon bx bx-star\"></span></code></pre>","_help_oiVPnW8QfnvS": "<h2>Trilium-specific shortcuts</h2><figure class=\"table\"><table><thead><tr><th>Action</th><th>PC</th><th>Mac</th></tr></thead><tbody><tr><td>Bring up inline formatting toolbar (arrow keys ←,→ to navigate, Enter to apply)</td><td>Alt+F10</td><td>⌥+F10</td></tr><tr><td>Bring up block formatting toolbar</td><td>Alt+F10</td><td>⌥+F10</td></tr><tr><td>Create <a href=\"#root/_help_QEAPj01N5f7w\">external link</a></td><td>Ctrl+K</td><td>⌘+K</td></tr><tr><td>Create <a href=\"#root/_help_QEAPj01N5f7w\">internal (note) link</a></td><td>Ctrl+L</td><td>⌘+L</td></tr><tr><td>Inserts current date and time at caret position</td><td>Alt+T</td><td>⌥+T</td></tr><tr><td>Increase paragraph indentation</td><td>Tab</td><td>⇥</td></tr><tr><td>Decrease paragraph indentation</td><td>Shift + Tab</td><td>⇧ + ⇥</td></tr><tr><td>Mark selected text as <a href=\"#root/_help_UYuUB1ZekNQU\">keyboard shortcut</a></td><td>Ctrl + Alt + K</td><td>⌘+ ⌥+ K</td></tr><tr><td>Insert <a class=\"reference-link\" href=\"#root/_help_YfYAtQBcfo5V\">Math Equations</a></td><td>Ctrl + M</td><td>⌘+ M</td></tr><tr><td>Move blocks (lists, paragraphs, etc.) up</td><td>Ctrl+↑</td><td>⌘+↑</td></tr><tr><td>Alt+↑</td><td>⌥+↑</td><td></td></tr><tr><td>Move blocks (lists, paragraphs, etc.) down</td><td>Ctrl+↑</td><td>⌘+↑</td></tr><tr><td>Alt+↓</td><td>⌥+↓</td><td></td></tr><tr><td>Move the selected content to another column of a <a class=\"reference-link\" href=\"#root/_help_wYDzQ1fBFgfT\">Multicolumn layout</a></td><td>Ctrl+←, Ctrl+→, Ctrl+Shift+Home, Ctrl+Shift+End</td><td>⌘+←, ⌘+→, ⌘+⇧+Home, ⌘+⇧+End</td></tr><tr><td>Move the current column of a multicolumn layout</td><td>Ctrl+Alt+←, Ctrl+Alt+→, Ctrl+Alt+Home, Ctrl+Alt+End</td><td>⌘+⌥+←, ⌘+⌥+→, ⌘+⌥+Home, ⌘+⌥+End</td></tr><tr><td>Add a column after or before the current one in a multicolumn layout</td><td>Ctrl+Enter, Ctrl+Shift+Enter</td><td>⌘+Enter, ⌘+⇧+Enter</td></tr><tr><td>Move the selected content to another tab in <a class=\"reference-link\" href=\"#root/_help_EK2ckIZ74tbT\">Content tabs</a></td><td>Ctrl+←, Ctrl+→, Ctrl+Shift+Home, Ctrl+Shift+End</td><td>⌘+←, ⌘+→, ⌘+⇧+Home, ⌘+⇧+End</td></tr><tr><td>Move the current tab of a tabs block</td><td>Ctrl+Alt+←, Ctrl+Alt+→, Ctrl+Alt+Home, Ctrl+Alt+End</td><td>⌘+⌥+←, ⌘+⌥+→, ⌘+⌥+Home, ⌘+⌥+End</td></tr><tr><td>Add a tab after or before the current one in a tabs block</td><td>Ctrl+Enter, Ctrl+Shift+Enter</td><td>⌘+Enter, ⌘+⇧+Enter</td></tr></tbody></table></figure><h2>Common shortcuts</h2><aside class=\"admonition tip\"><p>This section of keyboard shortcuts presents a subset of the keyboard shortcuts as supported by the editor technology we are using, <a class=\"reference-link\" href=\"#root/_help_MI26XDLSAlCD\">CKEditor</a>. The shortcuts were taken from the <a href=\"https://ckeditor.com/docs/ckeditor5/latest/features/accessibility.html#keyboard-shortcuts\">official documentation</a>. Note that not all the shortcuts in the original documentation are applicable (due to using a different configuration).</p></aside><h3>Content editing</h3><figure class=\"table\"><table><thead><tr><th>Action</th><th>PC</th><th>Mac</th></tr></thead><tbody><tr><td>Insert a hard break (a new paragraph)</td><td>Enter</td><td></td></tr><tr><td>Insert a soft break (a <code><br></code> element)</td><td>Shift+Enter</td><td>⇧Enter</td></tr><tr><td>Copy selected content</td><td>Ctrl+C</td><td>⌘C</td></tr><tr><td>Paste content</td><td>Ctrl+V</td><td>⌘V</td></tr><tr><td>Paste content as plain text</td><td>Ctrl+Shift+V</td><td>⌘⇧V</td></tr><tr><td>Undo</td><td>Ctrl+Z</td><td>⌘Z</td></tr><tr><td>Redo</td><td>Ctrl+Y, Ctrl+Shift+Z</td><td>⌘Y, ⌘⇧Z</td></tr><tr><td>Bold text</td><td>Ctrl+B</td><td>⌘B</td></tr><tr><td>Change text case</td><td>Shift+F3</td><td>⇧F3 (may require Fn)</td></tr><tr><td>Create link</td><td>Ctrl+K</td><td>⌘K</td></tr><tr><td>Move out of a link</td><td>←←, →→</td><td></td></tr><tr><td>Move out of an inline code style</td><td>←←, →→</td><td></td></tr><tr><td>Select all</td><td>Ctrl+A</td><td>⌘A</td></tr><tr><td>Find in the document</td><td>Ctrl+F</td><td>⌘F</td></tr><tr><td>Copy text formatting</td><td>Ctrl+Shift+C</td><td>⌘⇧C</td></tr><tr><td>Paste text formatting</td><td>Ctrl+Shift+V</td><td>⌘⇧V</td></tr><tr><td>Italic text</td><td>Ctrl+I</td><td>⌘I</td></tr><tr><td>Strikethrough text</td><td>Ctrl+Shift+X</td><td>⌘⇧X</td></tr><tr><td>Underline text</td><td>Ctrl+U</td><td>⌘U</td></tr><tr><td>Revert autoformatting action</td><td>Backspace</td><td></td></tr></tbody></table></figure><h3>Interacting with blocks</h3><p>Blocks are images, tables, blockquotes, annotations.</p><figure class=\"table\"><table><thead><tr><th>Action</th><th>PC</th><th>Mac</th></tr></thead><tbody><tr><td>Insert a new paragraph directly after a widget</td><td>Enter</td><td></td></tr><tr><td>Insert a new paragraph directly before a widget</td><td>Shift+Enter</td><td>⇧Enter</td></tr><tr><td>Move the caret to allow typing directly before a widget</td><td>↑, ←</td><td></td></tr><tr><td>Move the caret to allow typing directly after a widget</td><td>↓, →</td><td></td></tr><tr><td>After entering a nested editable, move the selection to the closest ancestor widget. For example: move from an image caption to the whole image widget.</td><td>Tab then Esc</td><td></td></tr></tbody></table></figure><p>Specifically for lists:</p><figure class=\"table\"><table><thead><tr><th>Action</th><th>PC</th><th>Mac</th></tr></thead><tbody><tr><td>Increase list item indent</td><td>⇥</td><td></td></tr><tr><td>Decrease list item indent</td><td>Shift+⇥</td><td>⇧⇥</td></tr></tbody></table></figure><p>In tables:</p><figure class=\"table\"><table><thead><tr><th>Action</th><th>PC</th><th>Mac</th></tr></thead><tbody><tr><td>Move the selection to the next cell</td><td>⇥</td><td></td></tr><tr><td>Move the selection to the previous cell</td><td>Shift+⇥</td><td>⇧⇥</td></tr><tr><td>Insert a new table row (when in the last cell of a table)</td><td>⇥</td><td></td></tr><tr><td>Navigate through the table</td><td>↑, →, ↓, ←</td><td></td></tr></tbody></table></figure><h3>General UI shortcuts</h3><figure class=\"table\"><table><thead><tr><th>Action</th><th>PC</th><th>Mac</th></tr></thead><tbody><tr><td>Close contextual balloons, dropdowns, and dialogs</td><td>Esc</td><td></td></tr><tr><td>Open the accessibility help dialog</td><td>Alt+0</td><td>⌥0</td></tr><tr><td>Move focus between form fields (inputs, buttons, etc.)</td><td>⇥, Shift+⇥</td><td>⇥, ⇧⇥</td></tr><tr><td>Move focus to the toolbar, navigate between toolbars</td><td>Alt+F10</td><td>⌥F10 (may require Fn)</td></tr><tr><td>Navigate through the toolbar or menu bar</td><td>↑, →, ↓, ←</td><td></td></tr><tr><td>Navigate to the next focusable field or an element outside the editor</td><td>Tab, Shift+Tab</td><td></td></tr><tr><td>Execute the currently focused button. Executing buttons that interact with the editor content moves the focus back to the content.</td><td>Enter, Space</td><td></td></tr><tr><td>Move focus in and out of an active dialog window</td><td>Ctrl+F6</td><td>⌘F6 (may require Fn)</td></tr></tbody></table></figure>",@@ -155,7 +155,7 @@"_help_NdowYOC1GFKS": "<p>Tables are a powerful feature for <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes, since editing them is generally easy.</p><figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:176/204;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/2_Tables_image.png\" width=\"176\" height=\"204\"></figure><p>To create a table, simply press the table button and select with the mouse the desired amount of columns and rows, as indicated in the adjacent figure.</p><p>Since v0.107.0, the same menu starts with an <em>Insert table…</em> item, for a table larger than the grid or to type its size instead:</p><ol><li>Click the <span class=\"tn-icon cke cke-table\"></span>button and select <em>Insert table…</em>. A small form opens at the cursor.</li><li>Enter the number of <em>Columns</em> (up to 100) and <em>Rows</em> (up to 1000). The table can have at most 5000 cells in total, for example 1000 rows of 5 columns.</li><li>Press <em>Insert</em> or <kbd>Enter</kbd>.</li></ol><p>To close the form without inserting a table, press <kbd>Esc</kbd> or click outside it. From the keyboard, <kbd>Tab</kbd> moves between <em>Insert table…</em> and the grid while the menu is open.</p><p>On the <a class=\"reference-link\" href=\"#root/_help_RDslemsQ6gCp\">Mobile Frontend</a>, the <span class=\"tn-icon cke cke-table\"></span>button opens the form directly, without the grid.</p><h2>Formatting toolbar</h2><p>When a table is selected, a special formatting toolbar will appear:</p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/3_Tables_image.png\" width=\"384\" height=\"100\"><h2>Context menu</h2><p>Since v0.106.0, right-clicking anywhere inside a table opens a context menu with the most common table operations:</p><ul><li><em>Insert row above</em> and <em>Insert row below</em> insert a blank row next to the row of the current cell. When the selection spans multiple rows, the same number of rows is inserted.</li><li><em>Insert column to the left</em> and <em>Insert column to the right</em> work the same way for columns.</li><li>Since v0.107.0, <em>Set as header</em> or <em>Set header up to this row</em>, depending on the selection, turns rows into header rows, which always start at the top of the table:<ul><li><em>Set as header</em> shows when the selection starts at the first row, and makes every selected row a header row.</li><li><em>Set header up to this row</em> shows when the selection is in a single row below the first, and makes that row and every row above it header rows.</li><li>Neither shows when the selection spans several rows below the first.</li><li>A check mark shows that the rows are already header rows. Choosing the item again turns them, and every header row below them, back into regular rows. For example, in a table with five header rows, choosing <em>Set header up to this row</em> on the third row leaves only the first two as header rows.</li></ul></li><li><em>Merge cells</em> merges the selected cells into one. The selected cells must form a rectangle.</li><li><em>Split cell</em> splits each selected cell in two, either <em>Vertically</em> or <em>Horizontally</em>. <em>Unmerge cells</em>, in the same submenu, turns each merged cell in the selection back into the single cells it covers, keeping its content in the top-left one; cells that are not merged stay as they are.</li><li><em>Distribute columns evenly</em> splits the combined width of the columns the selection touches equally between them. The other columns and the width of the table stay as they are. It needs a selection spanning at least two columns; a merged cell counts for every column it covers.</li><li><em>Cut</em>, <em>Copy</em> and <em>Copy as Markdown</em> act on the selected cells. Since v0.107.0, <em>Copy</em> and <em>Paste</em> open submenus with their variants, such as <em>Copy as Markdown</em> and <em>Paste as plain text</em>; clicking <em>Copy</em> or <em>Paste</em> itself still copies or pastes:<ul><li>Cutting or copying produces a smaller table holding just the selected cells. Pasting it over a cell selection replaces those cells; pasting elsewhere inserts it as a table of its own. Cutting clears the cells without removing rows or columns.</li><li><em>Copy as Markdown</em> converts the selected cells to a Markdown table. A selected header row becomes the Markdown header; without one, an empty header row is emitted, since Markdown tables require one.</li></ul></li><li>Since v0.107.0, <em>Paste rows above</em> and <em>Paste rows below</em>, in the <em>Paste</em> submenu, paste the clipboard as new rows next to the row of the current cell, instead of over the cells from the cursor on. They show only when the selection is in a single row, and, like <em>Paste</em>, only where the clipboard can be read:<ul><li>A copied table becomes one new row for each of its rows, filled from the first column. When it has more columns than the table, the table gains columns, as with a regular paste. Other content goes in the first cell of a single new row.</li><li>The new rows are selected afterwards.</li><li>When merged cells join the row to others, the new rows go above or below that whole block of rows.</li></ul></li><li><em>Sort</em>, below the clipboard section, sorts the rows by the column of the current cell, in <em>Ascending</em> or <em>Descending</em> order. See <a href=\"#sorting-rows\">Sorting rows</a>.</li><li><em>Delete row</em> and <em>Delete column</em>, below <em>Sort</em>, remove every row or column the selection touches, even when only some of their cells are selected.</li><li><em>Delete table</em> removes the whole table and leaves an empty paragraph in its place. In a table nested inside another, only the inner table is removed.</li><li>Since v0.107.0, <em>Select</em>, below <em>Delete table</em>, selects the cells of every row (<em>Row</em>) or column (<em>Column</em>) the selection touches, or every cell of the table (<em>Table</em>). Unlike the <span class=\"tn-icon cke cke-drag-handle\"></span>button, which selects the table as a whole, <em>Table</em> selects its cells, so cell operations such as <em>Merge cells</em> apply to all of them. In a table nested inside another, <em>Table</em> selects only the cells of the inner table.</li></ul><p>Right-clicking a cell that is not part of the current selection moves the cursor there first, so the menu always applies to the cell under the pointer.</p><aside class=\"admonition note\"><p>In the browser, Trilium's menu replaces the browser's own context menu inside tables. To reach the browser's menu (for example for its spell checking suggestions), hold <kbd>Shift</kbd> while right-clicking. The desktop application is unaffected, since its menu already includes the spelling suggestions. In the browser, the menu also offers <em>Paste</em> only when the page can read the clipboard, which requires a secure (HTTPS) context and your permission; otherwise, paste with <kbd>Ctrl</kbd>+<kbd>V</kbd>.</p></aside><h2>Navigating a table</h2><ul><li>Using the mouse:<ul><li>Click on a cell to focus it.</li><li>Click the <span class=\"tn-icon cke cke-return-arrow\"></span> button at the top or the bottom of a table to insert an empty paragraph near it.</li><li>Click the <span style=\"--tn-color:hsl(0,0%,60%);color:hsl(0,0%,60%);\"><span class=\"tn-icon cke cke-drag-handle\"></span></span> button at the top-left of the table to select it entirely (for easy copy-pasting or cutting) or drag and drop it to relocate the table.</li></ul></li><li>Using the keyboard:<ul><li>Use the arrow keys on the keyboard to easily navigate between cells.</li><li>It's also possible to use <kbd>Tab</kbd> to go to the next cell and Shift+Tab to go to the previous cell.</li><li>Unlike arrow keys, pressing <kbd>Tab</kbd> at the end of the table (last row, last column) will create a new row automatically.</li><li>To select multiple cells, hold <kbd>Shift</kbd> while using the arrow keys.</li></ul></li><li>Using touch:<ul><li>Since v0.107.0, touching a table outlines the cell with the cursor, or the selected cells, and shows a handle at each corner of the outline.</li><li>To select multiple cells, drag one of the handles across the table. The cell at the opposite corner stays selected, so the selection grows or shrinks as the finger moves. The note and wide tables scroll when the handle reaches the edge of the screen.</li></ul></li></ul><h2>Resizing cells</h2><ul><li>Columns can be resized by hovering the mouse over the border of two adjacent cells and dragging it.</li><li>To give several columns the same width, select cells across them and choose <em>Distribute columns evenly</em> from the <span class=\"tn-icon cke cke-table-column\"></span>button of the formatting toolbar or from the <a href=\"#context-menu\">context menu</a>.</li><li>By default, the row height is not adjustable using the mouse, but it can be configured from the cell settings (see below).</li><li>To adjust exactly the width (in pixels or percentages) of a cell, select the <span class=\"tn-icon cke cke-table-cell-properties\"></span> button.</li></ul><h3>Resizing with touch</h3><p>Since v0.107.0, touching a table shows a bar at the bottom of the note, above the formatting toolbar on mobile. The bar has a segment for each column of the table, with a divider at the end of each column. Only the divider of the column with the cursor is a handle that resizes; the other dividers only mark where the columns meet, so a swipe across them scrolls instead. When several cells are selected, each column they cover has a handle.</p><ul><li>To resize a column, place the cursor in one of its cells or tap its segment, then drag its handle. The table grows or shrinks with the column, and scrolls when the handle reaches the edge of the screen. The column snaps to its starting width and to the widths of the columns beside it.</li><li>To cancel a resize, drag the handle back to where it started, or touch the screen with a second finger.</li><li>To give a column and the next one the same width, double-tap the handle between them.</li><li>To select a column, tap its segment. To open the column menu, touch and hold the segment.</li><li>To scroll a wide table sideways, swipe along the bar.</li></ul><p>A wide table scrolls a little past its end, so the handle of its last column stays away from the edge of the screen, where a swipe navigates back.</p><h2>Wide tables</h2><p>Since v0.107.0, a table can be wider than the <a class=\"reference-link\" href=\"#root/_help_t596jLvPrqkS\">Content width</a>. Such a table scrolls sideways, while the rest of the note keeps its width.</p><ul><li>A new table is as wide as the content. To make it wider, drag the right border of its last column past the edge of the content. The border snaps to the edge and holds there briefly, so the table is easy to bring back to the width of the content.</li><li>To set an exact width, enter a percentage above <code>100%</code> or a width in pixels in the <span class=\"tn-icon cke cke-table-properties\"></span> <a href=\"#table-properties\">table properties</a>.</li><li>A table whose content needs more room than the note, such as a pasted table with many columns, also scrolls instead of stretching the note.</li><li>Wide tables scroll the same way in read-only notes and on shared pages.</li><li>When printing or exporting to PDF, a wide table is shrunk to fit the page.</li></ul><p>Tables inside other blocks, such as block quotes, admonitions, collapsible blocks, columns or tabs, are limited to the width of their block and do not scroll.</p><h3>Mobile support</h3><p>On the <a class=\"reference-link\" href=\"#root/_help_RDslemsQ6gCp\">Mobile Frontend</a>, a table keeps the width it has on a desktop and scrolls sideways, instead of squeezing its columns into the width of the screen. The full width of a table is the <em>Max content width</em> set in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Appearance</em> → <em>Content Width</em> on the mobile device, 1200 pixels by default. For example, a table set to <code>50%</code> is 600 pixels wide.</p><p>To resize columns on mobile, use the bar described in <a href=\"#resizing-with-touch\">Resizing with touch</a>.</p><h2>Long tables</h2><p>Since v0.107.0, the header rows of a table stay visible at the top of the note while you scroll through the rest of the table, and leave with the end of the table. This also works in read-only notes, on shared pages and in wide tables.</p><p>To turn rows into header rows, use <em>Set as header</em> in the <a href=\"#context-menu\">context menu</a>, or <em>Header row</em> in the <span class=\"tn-icon cke cke-table-row\"></span> button of the formatting toolbar.</p><p>To let header rows scroll away with the rest of the table, turn off <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Text Notes</em> → <em>Features</em> → <em>Use sticky header rows for tables</em>. The setting applies to the current device only, and shared pages keep their sticky header rows.</p><h2>Inserting new rows and new columns</h2><ul><li>To insert a new column, click on a desired location, then press the <span class=\"tn-icon cke cke-table-column\"></span> button from the formatting toolbar and select <em>Insert column left or right.</em></li><li>To insert a new row, click on a desired location, then press the <span class=\"tn-icon cke cke-table-row\"></span> button and select <em>Insert row above</em> or <em>below</em>.<ul><li>A quicker alternative to creating a new row while at the end of the table is to press the <kbd>Tab</kbd> key.</li></ul></li><li>Both operations are also available in the <a href=\"#context-menu\">context menu</a>, which inserts as many rows or columns as the selection spans.</li></ul><h2>Moving rows and columns</h2><p>Since v0.106.0, rows and columns can be reordered with the keyboard:</p><ul><li><kbd>Alt</kbd>+<kbd>Up</kbd> and <kbd>Alt</kbd>+<kbd>Down</kbd> move the rows touched by the selection up or down.</li><li><kbd>Alt</kbd>+<kbd>Left</kbd> and <kbd>Alt</kbd>+<kbd>Right</kbd> move the columns touched by the selection left or right.</li></ul><p>Merged cells are never split by a move. The rows or columns held together by a merged cell travel as one block, and moving toward such a block jumps over it entirely.</p><p>When the table has a header row, a header row moved below the header area becomes a regular row, and a regular row moved into the header area becomes a header row. Header columns behave the same way.</p><p>Outside of tables, <kbd>Alt</kbd>+<kbd>Left</kbd> and <kbd>Alt</kbd>+<kbd>Right</kbd> keep navigating the note history, and <kbd>Alt</kbd>+<kbd>Up</kbd> and <kbd>Alt</kbd>+<kbd>Down</kbd> keep moving the current paragraph.</p><h2>Sorting rows</h2><p>Since v0.107.0, the rows of a table can be sorted by the values of one column:</p><ul><li>To sort all the rows, place the cursor in any cell of the column to sort by, then select <em>Sort</em> → <em>Ascending</em> or <em>Descending</em> from the <a href=\"#context-menu\">context menu</a>. The same items are in the <span class=\"tn-icon bx bx-sort-alt-2\"></span>button of the formatting toolbar.</li><li>To sort only some of the rows, select their cells in the column to sort by, then sort the same way. Sorting is not available while the selection spans more than one column.</li></ul><p>Header rows always stay at the top of the table and are never sorted. A sort can be undone with <kbd>Ctrl</kbd>+<kbd>Z</kbd>.</p><h3>How values are compared</h3><p>Each cell is read as plain text, so formatting does not affect the order. Trilium then detects what kind of value the cell holds:</p><figure class=\"table\"><table><thead><tr><th>Kind</th><th>Examples</th><th>Compared by</th></tr></thead><tbody><tr><td>Time</td><td><code>15:02</code>, <code>15:02:38</code>, <code>3:02 PM</code></td><td>The time of day.</td></tr><tr><td>Date</td><td><code>2026-09-30</code>, <code>2026-09-30 15:02</code>, <code>30 September 2026</code>, <code>Wednesday, 30 September 2026</code>, <code>2026-09-30T15:02:38+03:00</code></td><td>The date and time.</td></tr><tr><td>Number</td><td><code>12</code>, <code>-3.5</code>, <code>1,234.56</code>, <code>$ 12.04</code>, <code>21 RON</code>, <code>24.5m</code></td><td>The numeric value.</td></tr><tr><td>Text</td><td>Anything else.</td><td>Alphabetically, ignoring case, with numbers inside the text in numeric order (<code>Item 9</code> before <code>Item 10</code>). Accents count, so <code>a</code> and <code>á</code> differ.</td></tr><tr><td>Empty</td><td>An empty cell, or one holding only spaces.</td><td>Not compared. Empty cells always go last.</td></tr></tbody></table></figure><p>Ascending order puts times first, then dates, numbers and text. Descending order reverses it. Empty cells go last in both directions.</p><p>Numbers, dates and times with the same value are ordered by their text, so <code>5 apples</code> comes before <code>5 pears</code>. Rows whose cells hold the same text, ignoring case, keep their relative order.</p><ul><li>Dates are also recognized in the formats of the note's language, such as <code>30.09.2026</code> or <code>30. September 2026</code> for German, and in the format chosen in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Text Notes</em> → <em>Editor</em> → <em>Date/time format</em> for <a href=\"#root/_help_CohkqWQC1iBv\">inserting the date and time</a>.</li><li>A number can start with a currency symbol, such as <code>$</code>, <code>€</code> or <code>£</code>. Whatever follows the number, such as a unit, is ignored, so units are not converted: <code>1 km</code> sorts before <code>500 m</code>. A cell that starts with letters, such as <code>RON 21</code>, is text.</li><li>The decimal separator follows the language of the note: <code>1.500</code> is one and a half in English, but one thousand five hundred in German. A comma or period that is not followed by exactly three digits is always read as a decimal separator, so <code>1,5</code> is one and a half in either language.</li><li>The language of the note set in the <a class=\"reference-link\" href=\"#root/_help_AlJ73vBCjWDw\">Status bar</a> via the <span class=\"tn-icon bx bx-globe\"></span> icon, or else the default content language. See <a class=\"reference-link\" href=\"#root/_help_veGu4faJErEM\">Content language & Right-to-left support</a>.</li></ul><h3>Merged cells</h3><p>Rows joined by a merged cell are kept together and move as one block. The block is sorted by the value in its first row. When the block has more than one cell in the sorted column, the other cells do not affect the order, and a message says so: <em>Some rows were sorted together because merged cells tie them to each other</em>.</p><p>When the selection covers only part of such a block, the whole block is sorted.</p><h2>Merging cells</h2><p>To merge two or more cells together, simply select them via drag & drop and press the <span class=\"tn-icon cke cke-table-merge-cell\"></span> button from the formatting toolbar.</p><p>More options are available by pressing the arrow next to it:</p><ul><li>Click on a single cell and select Merge cell up/down/right/left to merge with an adjacent cell.</li><li>Select <em>Merge selected cells</em> to merge the selected cells, the same as pressing the button itself.</li><li>Select <em>Split cell vertically</em> or <em>horizontally</em>, to split a cell into multiple cells (can also be used to undo a merge).</li><li>Select <em>Unmerge cells</em> to turn each merged cell in the selection back into the single cells it covers, keeping its content in the top-left one.</li></ul><p><em>Merge selected cells</em> and <em>Unmerge cells</em> are available since v0.107.0. Merging and splitting are also available by right-clicking the selected cells, via the <a href=\"#context-menu\">context menu</a>, where <em>Unmerge cells</em> is in the <em>Split cell</em> submenu.</p><h2>Table properties</h2><figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:312/311;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Tables_image.png\" width=\"312\" height=\"311\"></figure><p>The table properties can be accessed via the <span class=\"tn-icon cke cke-table-properties\"></span> button and allows for the following adjustments:</p><ul><li>Border (not the border of the cells, but the outer rim of the table), which includes the style (single, double), color and width.</li><li>The background color, with none set by default.</li><li>The width and height of the table in percentage (must end with <code>%</code>) or pixels (must end with <code>px</code>).</li><li>The alignment of the table.<ul><li>Left or right-aligned, case in which the text will flow next to it.</li><li>Centered, case in which text will avoid the table, regardless of the table width.</li></ul></li></ul><p>The table will immediately update to reflect the changes, but the <em>Save</em> button must be pressed for the changes to persist.</p><h2>Cell properties</h2><figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:320/386;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/1_Tables_image.png\" width=\"320\" height=\"386\"></figure><p>Similarly to table properties, the <span class=\"tn-icon cke cke-table-cell-properties\"></span> button opens a popup which adjusts the styling of one or more cells (based on the user's selection).</p><p>The following options can be adjusted:</p><ul><li>The border style, color and width (same as table properties), but applying to the current cell only.</li><li>The background color, with none set by default.</li><li>The width and height of the cell in percentage (must end with <code>%</code>) or pixels (must end with <code>px</code>).</li><li>The padding (the distance of the text compared to the cell's borders).</li><li>The alignment of the text, both horizontally (left, centered, right, justified) and vertically (top, middle or bottom).</li></ul><p>The cell will immediately update to reflect the changes, but the <em>Save</em> button must be pressed for the changes to persist.</p><h2>Border and background colors</h2><p>The border and background colors of tables and cells adapt to the <a href=\"#root/_help_Wy267RK4M69c\">theme</a>, the same way as <a href=\"#root/_help_Gr6xFaF6ioJ5\">text colors</a> do. A color picked from the palette, chosen with the color picker or typed in is shown in a lighter or darker shade that suits the current theme, so borders stay visible and text stays readable on the background. The hue stays the same, and the table keeps the color as it was picked.</p><p>Colors applied with older versions of Trilium are shown exactly as they were picked, until the note is next edited.</p><p>Older browsers that can't adapt colors show them exactly as they were picked.</p><h2>Caption</h2><p>Press the <span class=\"tn-icon cke cke-caption\"></span> button to insert a caption or a text description of the table, which is going to be displayed above the table.</p><h2>Table borders</h2><p>By default, tables will come with a predefined gray border.</p><p>To adjust the borders, follow these steps:</p><ol><li>Select the table.</li><li>In the floating panel, select the <em>Table properties</em> option (<span class=\"tn-icon cke cke-table-properties\"></span>).<ol><li>Look for the <em>Border</em> section at the top of the newly opened panel.</li><li>This will control the outer borders of the table.</li><li>Select a style for the border. Generally <em>Single</em> is the desirable option.</li><li>Select a color for the border.</li><li>Select a width for the border, expressed in pixels.</li></ol></li><li>Select all the cells of the table and then press the <em>Cell properties</em> option (<span class=\"tn-icon cke cke-table-cell-properties\"></span>).<ol><li>This will control the inner borders of the table, at cell level.</li><li>Note that it's possible to change the borders individually by selecting one or more cells, case in which it will only change the borders that intersect these cells.</li><li>Repeat the same steps as from step (2).</li></ol></li></ol><h3>Tables with invisible borders</h3><p>Tables can be set to have invisible borders in order to allow for basic layouts (columns, grids) of text or <a href=\"#root/_help_mT0HEkOsz6i1\">images</a> without the distraction of their border:</p><ol><li>First insert a table with the desired number of columns and rows.</li><li>Select the entire table.</li><li>In <em>Table properties</em>, set:<ol><li><em>Style</em> to <em>Single</em></li><li><em>Color</em> to <code>transparent</code></li><li>Width to <code>1px</code>.</li></ol></li><li>In Cell Properties, set the same as on the previous step.</li></ol><h2>Table indentation</h2><p>Since v0.104.1, tables can be indented as a block (the whole table moves, rather than just the content of a cell).</p><ol><li>Click the <span style=\"--tn-color:hsl(0,0%,60%);color:hsl(0,0%,60%);\"><span class=\"tn-icon cke cke-drag-handle\"></span></span> button to select the entire table. Otherwise, the indentation applies only to the current cell's content.</li><li>Press <kbd>Tab</kbd> to increase the indent, or <kbd>Shift</kbd>+<kbd>Tab</kbd> to decrease it. Alternatively, use the indentation buttons in the formatting toolbar.</li></ol><p>Markdown does not support indented tables, so the indentation is lost when converting to Markdown.</p><h2>Markdown import/export</h2><p>Simple tables are exported in GitHub-flavored Markdown format (e.g. a series of <code>|</code> items). If the table is found to be more complex (it contains HTML elements, has custom sizes or images), the table is converted to a HTML one instead.</p><p>Generally formatting loss should be minimal when exported to Markdown due to the fallback to HTML formatting.</p>","_help_pwc194wlRzcH": "<figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:265/108;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Text%20Snippets_image.png\" width=\"265\" height=\"108\"></figure><p>Text Snippets are closely related to <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a>, but instead of defining the content of an entire note, text snippets are pieces of formatted text that can easily be inserted in a text note.</p><h2>Creating a text snippet</h2><p>In the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>: </p><ol><li>Right click a note where to place the text snippet.</li><li>Select <em>Insert child note</em>.</li><li>Select <em>More</em> → <em>Text snippet</em>.</li></ol><p>Afterwards, simply type in the content of the note the desired text. The text can be formatted in the same manner as a normal text note.</p><p>The title of the note will become the title of the template. Optionally, a description can be added in the <a class=\"reference-link\" href=\"#root/_help_OFXdgB2nNk1F\">Promoted Attributes</a> section.</p><h2>Inserting a snippet</h2><p>Once a snippet is created, there are two options to insert it:</p><ol><li>From the <a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>, by looking for the <span class=\"tn-icon cke cke-trilium-template\"></span> button.</li><li>Using <a class=\"reference-link\" href=\"#root/_help_ZlN4nump6EbW\">Slash Commands</a>: <ol><li>To look for a specific template, start typing the name of the template (its title).</li><li>To look for all the templates, type <code>template</code>.</li></ol></li></ol><aside class=\"admonition tip\"><p>A newly created snippet doesn't appear? Generally it takes up to a few seconds to refresh the list of templates once you make a change.</p><p>If this doesn't happen, <a href=\"#root/_help_s8alTXmpFR61\">reload the application</a> and <a href=\"#root/_help_wy8So3yZZlH9\">report the issue</a>to us. </p></aside><h2>Limitations</h2><ul><li>Whenever a snippet is created, deleted or its title/description are modified, all the open text notes will need to be refreshed. This causes a slight flash for usually under a second, but it can cause some discomfort.</li><li>Unlike <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a>, the snippets cannot be limited to a particular <a href=\"#root/_help_9sRHySam5fXb\">workspace</a>.</li></ul>","_help_fASfBrYnquKU": "<h2>Extended task states</h2><figure class=\"image image-style-align-left\"><img style=\"aspect-ratio:303/264;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/To-do%20Lists_image.png\" width=\"303\" height=\"264\"></figure><p>In Trilium, to-do items aren't limited to a simple \"done\" or \"not done.\" Tasks can also be marked as <em>in progress</em> (\"doing\"), <em>under consideration</em> (\"maybe\"), or <em>cancelled</em> (\"won't do\"), thus giving a more accurate picture of where things actually stand.</p><p>Right-click the checkbox and select the desired state. Alternatively, press <kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>Enter </kbd> to cycle through the task states. Tapping or left-clicking the checkbox will always toggle between \"None\" and \"Done\".</p><p>Task states are fully preserved when converting between <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> and <a class=\"reference-link\" href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a> notes, in both directions.</p><h3>Customizing the extended task states</h3><p>Task states are customizable: you can reorder them, create new ones with different colors and symbols, or delete the ones you don't need. See <a class=\"reference-link\" href=\"#root/_help_i16PM6A7GXdU\">Customizing to-do task states</a> for more details.</p><h2>Keyboard shortcuts</h2><p>When at the beginning on an empty paragraph, type the following to insert a to-do list:</p><ul><li><code>[ ]</code> for an unchecked item</li><li><code>[x]</code> for a checked item</li></ul><p>Extended task states are supported as well, using its corresponding <em>Markdown symbol</em>. These are the defaults but they can be changed if needed (see <a class=\"reference-link\" href=\"#root/_help_i16PM6A7GXdU\">Customizing to-do task states</a>):</p><ul><li><code>[/]</code> for “Doing”.</li><li><code>[?]</code> for “Maybe”.</li><li><code>[-]</code> for “Cancelled”.</li></ul><p>To reorder the item under the cursor, press <kbd>Alt</kbd>+<kbd>Up</kbd> or <kbd>Alt</kbd>+<kbd>Down</kbd>. To reorder multiple items, select them first.</p><h2>See also</h2><ul><li>To-do lists are meant for small task lists. For more complicated, day-to-day task tracking consider using a <a class=\"reference-link\" href=\"#root/_help_CtBQqbwXDx1w\">Kanban Board</a> collection instead.</li></ul>",- "_help_6f9hih2hXXZk": "<p>Trilium supports creating \"code\" notes, i.e. notes which contain some sort of formal code - be it programming language (C++, JavaScript), structured data (JSON, XML) or other types of codes (CSS etc.).</p><p>This can be useful for a few things:</p><ul><li>computer programmers can store code snippets as notes with syntax highlighting</li><li>JavaScript code notes can be executed inside Trilium for some extra functionality<ul><li>we call such JavaScript code notes \"scripts\" – see <a class=\"reference-link\" href=\"#root/_help_CdNpE2pqjmI6\">Scripting</a></li></ul></li><li>JSON, XML etc. can be used as storage for structured data (typically used in conjunction with scripting)</li></ul><p>For shorter snippets of code that can be embedded in <a href=\"#root/_help_iPIMuisry3hd\">Text</a> notes, see <a href=\"#root/_help_QxEyIjRBizuC\">Code blocks</a>.</p><p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Code_image.jpg\"></p><h2>Creating a code note</h2><p>In the <a href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>, right-click a note and select <em>Insert child note</em> or <em>Insert note after</em>, then:</p><ul><li>To create a plain text code note, select <em>Code</em>.</li><li>To create a code note in a given language, hover <em>Code</em> and select the language. The list shows the languages enabled in the options (see below), and ends with <em>Configure code notes...</em>, which opens them.</li></ul><h2>Adjusting the language of a code note</h2><p>To change the language of a code note, look for the <span class=\"tn-icon bx bx-code\"></span> icon in the <a class=\"reference-link\" href=\"#root/_help_AlJ73vBCjWDw\">Status bar</a>. When clicked it will reveal the list of available languages (which can be customized according to the section below). The menu also features a search bar to quickly filter, and icons to visually distinguish some of the programming languages.</p><p>On the <a class=\"reference-link\" href=\"#root/_help_RDslemsQ6gCp\">Mobile Frontend</a>, the same list is available in the <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> → <em>Change language mode</em>.</p><h2>Adjusting the list of languages</h2><p>Trilium supports syntax highlighting for many languages, but by default displays only some of them. The supported languages can be adjusted by going to <a href=\"#root/_help_4TIF1oA4VQRO\">Options</a>, then <em>Code Notes</em> and looking for the <em>Available MIME types in the dropdown</em> section. Simply check any of the items to add them to the list, or un-check them to remove them from the list.</p><p>Note that the list of languages is not immediately refreshed, you'd have to manually <a href=\"#root/_help_s8alTXmpFR61\">refresh the application</a>.</p><p>The list of languages is also shared with the <a href=\"#root/_help_QxEyIjRBizuC\">Code blocks</a> feature of <a href=\"#root/_help_iPIMuisry3hd\">Text</a> notes.</p><h2>Word wrap</h2><p>Long lines can be displayed on multiple lines:</p><ul><li>Globally for all code notes, from <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Code Notes.</em></li><li>For a particular note, by going to the menu in <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> and selecting <em>Word wrap</em> and selecting the appropriate option:<ul><li><em>Auto</em>, to respect the global word wrap for code notes.</li><li><em>On</em> or <em>Off</em>, to change the state of the word wrap for this note regardless of the global option.</li></ul></li></ul><aside class=\"admonition note\"><p>Word wrapping can also be adjusted at note level through the <code>#wrapLines</code> <a href=\"#root/_help_HI6GBBIduIgv\">label</a>, which can also be inherited.</p></aside><h2>Adjusting options using the status bar</h2><p>The status bar at the bottom of the editor shows the current indentation settings and language. Clicking on the indentation indicator opens a menu with three sections:</p><ol><li><em>Indent Using</em> — switch between Spaces and Tabs (<code>#indentWithTabs</code>). If a per-note override is active, a \"Reset to default\" option appears.</li><li><em>Display Width</em> — choose from preset widths (1, 2, 3, 4, 6, 8). Changes are saved as a per-note <code>#tabWidth</code> label.</li><li><em>Re-indent Content To</em> — convert existing indentation to a different style. For example, re-indent a file from 4 spaces to 2 spaces, or from spaces to tabs. This rewrites the leading whitespace on every line while preserving alignment remainders.</li></ol><p>Clicking the language indicator lets you change the note's MIME type. As in the <em>Note type</em> selector, typing narrows the list of languages.</p><p>The same two menus are in the toolbar of a code note or a code file included in a text note, see <a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>.</p><h3>Re-indentation</h3><p>When you re-indent content, the editor:</p><ul><li>Measures the visual column width of each line's leading whitespace using the current style</li><li>Calculates indent levels and any alignment remainder</li><li>Rebuilds the leading whitespace in the target style</li><li>Preserves non-leading whitespace, blank lines, and content without indentation</li></ul><h2>Color schemes</h2><p>Since Trilium 0.94.0 the colors of code notes can be customized by going <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → Code Notes and looking for the <em>Appearance</em> section.</p><aside class=\"admonition note\"><p><strong>Why are there only a few themes whereas the code block themes for text notes have a lot?</strong><br>The reason is that Code notes use a different technology than the one used in Text notes, and as such there is a more limited selection of themes. If you find a CodeMirror 6 (not 5) theme that you would like to use, let us know and we might consider adding it to the set of default themes. There is no possibility of adding new themes (at least for now), since the themes are defined in JavaScript and not at CSS level.</p></aside><h2>Programming ligatures</h2><p>If you see <code>!=</code> displayed as <code>≠</code> or <code>-></code> as <code>→</code> inside a code note, those are <em>font ligature</em>: the default monospace font draws certain character pairs as a single symbol. The underlying text is not changed by Trilium (unlike text notes which have <a class=\"reference-link\" href=\"#root/_help_oI7GoyilXXAr\">Automatic replacements</a>), and copying it out gives you back <code>!=</code> and <code>-></code>.</p><p>This can be turned off with <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a><em>→ Appearance → Fonts → Programming ligatures</em>.</p><h2>Virtual keyboard behavior</h2><p>When using a virtual keyboard, keyboard suggestions and corrections are controlled as follows:</p><ul><li>For <a class=\"reference-link\" href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a> and plain text code notes, the autocorrect is <strong>on</strong>, as well as automatic capitalization.</li><li>For all the other code notes, the autocorrect is off in order to avoid issues when typing code.</li></ul><aside class=\"admonition note\"><p>Not all browsers and platforms respect this value, so the keyboard suggestions might appear without autocorrecting or the browser might disregard this and autocorrect anyway.</p></aside>",+ "_help_6f9hih2hXXZk": "<p>Trilium supports creating \"code\" notes, i.e. notes which contain some sort of formal code - be it programming language (C++, JavaScript), structured data (JSON, XML) or other types of codes (CSS etc.).</p><p>This can be useful for a few things:</p><ul><li>computer programmers can store code snippets as notes with syntax highlighting</li><li>JavaScript code notes can be executed inside Trilium for some extra functionality<ul><li>we call such JavaScript code notes \"scripts\" – see <a class=\"reference-link\" href=\"#root/_help_CdNpE2pqjmI6\">Scripting</a></li></ul></li><li>JSON, XML etc. can be used as storage for structured data (typically used in conjunction with scripting)</li></ul><p>For shorter snippets of code that can be embedded in <a href=\"#root/_help_iPIMuisry3hd\">Text</a> notes, see <a href=\"#root/_help_QxEyIjRBizuC\">Code blocks</a>.</p><p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Code_image.jpg\"></p><h2>Creating a code note</h2><p>In the <a href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>, right-click a note and select <em>Insert child note</em> or <em>Insert note after</em>, then:</p><ul><li>To create a plain text code note, select <em>Code</em>.</li><li>To create a code note in a given language, hover <em>Code</em> and select the language. The list shows the languages enabled in the options (see below), and ends with <em>Configure code notes...</em>, which opens them.</li></ul><h2>Adjusting the language of a code note</h2><p>To change the language of a code note, look for the <span class=\"tn-icon bx bx-code\"></span> icon in the <a class=\"reference-link\" href=\"#root/_help_AlJ73vBCjWDw\">Status bar</a>. When clicked it will reveal the list of available languages (which can be customized according to the section below). The menu also features a search bar to quickly filter, and icons to visually distinguish some of the programming languages.</p><p>On the <a class=\"reference-link\" href=\"#root/_help_RDslemsQ6gCp\">Mobile Frontend</a>, the same list is available in the <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> → <em>Change language mode</em>.</p><h2>Adjusting the list of languages</h2><p>Trilium supports syntax highlighting for many languages, but by default displays only some of them. The supported languages can be adjusted by going to <a href=\"#root/_help_4TIF1oA4VQRO\">Options</a>, then <em>Code Notes</em> and looking for the <em>Available MIME types in the dropdown</em> section. Simply check any of the items to add them to the list, or un-check them to remove them from the list.</p><p>Note that the list of languages is not immediately refreshed, you'd have to manually <a href=\"#root/_help_s8alTXmpFR61\">refresh the application</a>.</p><p>The list of languages is also shared with the <a href=\"#root/_help_QxEyIjRBizuC\">Code blocks</a> feature of <a href=\"#root/_help_iPIMuisry3hd\">Text</a> notes.</p><h2>Word wrap</h2><p>Long lines can be displayed on multiple lines:</p><ul><li>Globally for all code notes, from <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Code Notes.</em></li><li>For a particular note, by going to the menu in <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> and selecting <em>Word wrap</em> and selecting the appropriate option:<ul><li><em>Auto</em>, to respect the global word wrap for code notes.</li><li><em>On</em> or <em>Off</em>, to change the state of the word wrap for this note regardless of the global option.</li></ul></li></ul><aside class=\"admonition note\"><p>Word wrapping can also be adjusted at note level through the <code>#wrapLines</code> <a href=\"#root/_help_HI6GBBIduIgv\">label</a>, which can also be inherited.</p></aside><h2>Adjusting options using the status bar</h2><p>The status bar at the bottom of the editor shows the current indentation settings and language. Clicking on the indentation indicator opens a menu with three sections:</p><ol><li><em>Indent Using</em> — switch between Spaces and Tabs (<code>#indentWithTabs</code>). If a per-note override is active, a \"Reset to default\" option appears.</li><li><em>Display Width</em> — choose from preset widths (1, 2, 3, 4, 6, 8). Changes are saved as a per-note <code>#tabWidth</code> label.</li><li><em>Re-indent Content To</em> — convert existing indentation to a different style. For example, re-indent a file from 4 spaces to 2 spaces, or from spaces to tabs. This rewrites the leading whitespace on every line while preserving alignment remainders.</li></ol><p>Clicking the language indicator lets you change the note's MIME type. As in the <em>Note type</em> selector, typing narrows the list of languages.</p><p>The same two menus are in the toolbar of a code note or a code file included in a text note, see <a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>.</p><h3>Re-indentation</h3><p>When you re-indent content, the editor:</p><ul><li>Measures the visual column width of each line's leading whitespace using the current style</li><li>Calculates indent levels and any alignment remainder</li><li>Rebuilds the leading whitespace in the target style</li><li>Preserves non-leading whitespace, blank lines, and content without indentation</li></ul><h2>Color schemes</h2><p>Since Trilium 0.94.0 the colors of code notes can be customized by going <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → Code Notes and looking for the <em>Appearance</em> section.</p><p>A code note or a code file shown without its editor, such as in an <a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>, on the cards of <a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a> or in a tooltip, uses the same colors and shows line numbers, as the editor does. A printout uses the <em>Light theme</em>. A <a href=\"#root/_help_R9pX4DGra2Vt\">shared page</a> uses the VS Code light or dark theme, following the mode of the page.</p><aside class=\"admonition note\"><p><strong>Why are there only a few themes whereas the code block themes for text notes have a lot?</strong><br>The reason is that Code notes use a different technology than the one used in Text notes, and as such there is a more limited selection of themes. If you find a CodeMirror 6 (not 5) theme that you would like to use, let us know and we might consider adding it to the set of default themes. There is no possibility of adding new themes (at least for now), since the themes are defined in JavaScript and not at CSS level.</p></aside><h2>Programming ligatures</h2><p>If you see <code>!=</code> displayed as <code>≠</code> or <code>-></code> as <code>→</code> inside a code note, those are <em>font ligature</em>: the default monospace font draws certain character pairs as a single symbol. The underlying text is not changed by Trilium (unlike text notes which have <a class=\"reference-link\" href=\"#root/_help_oI7GoyilXXAr\">Automatic replacements</a>), and copying it out gives you back <code>!=</code> and <code>-></code>.</p><p>This can be turned off with <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a><em>→ Appearance → Fonts → Programming ligatures</em>.</p><h2>Virtual keyboard behavior</h2><p>When using a virtual keyboard, keyboard suggestions and corrections are controlled as follows:</p><ul><li>For <a class=\"reference-link\" href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a> and plain text code notes, the autocorrect is <strong>on</strong>, as well as automatic capitalization.</li><li>For all the other code notes, the autocorrect is off in order to avoid issues when typing code.</li></ul><aside class=\"admonition note\"><p>Not all browsers and platforms respect this value, so the keyboard suggestions might appear without autocorrecting or the browser might disregard this and autocorrect anyway.</p></aside>","_help_m523cpzocqaD": "<p>Trilium allows you to save common searches as notes within the note tree. The search results will appear as sub-notes under these \"saved search\" notes. Here is an example of how it works:</p><figure class=\"image image-style-align-center image_resized\" style=\"width:50%;\"><img style=\"aspect-ratio:812/585;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Saved%20Search_saved-search.gif\" width=\"812\" height=\"585\"></figure><p>A saved search runs when you open it, and when you expand it in the note tree. A saved search in a tab that is not shown, such as a background tab restored at startup, runs when you switch to that tab. Its results stay until you run the search again with the <em>Search</em> button of the search parameters. If the query has an error, it appears as a notification.</p><p>In <a class=\"reference-link\" href=\"#root/_help_64ZTlUPgEPtW\">Safe mode</a>, and when the request fails, the search does not run on its own. Press <em>Search now</em> to run it.</p><p>Once a search is saved, the <em>Search parameters</em> is still available underneath the <a class=\"reference-link\" href=\"#root/_help_l7pigIGu01K2\">Title</a> in order to be able to change the settings later on but it will appear collapsed by default.</p><h2>Location</h2><p>By default, saved searches are stored in the day note. However, you can designate a different note to store saved searches by marking it with the <code>#searchHome</code> label. Additionally, for <a href=\"#root/_help_9sRHySam5fXb\">workspaces</a>, you can use the <code>#workspaceSearchHome</code> label to specify a storage location for saved searches within that workspace.</p>","_help_iRwzGnHPzonm": "<p>Relation map is a type of note which visualizes notes and their <a href=\"#root/_help_zEY4DaJG4YT5\">relations</a>.</p><h2>Interaction</h2><ul><li>To create a new note and add it to the map, press the <span class=\"tn-icon bx bx-note\"></span> <em>Add note</em> button at the bottom of the map, then click anywhere on the map to place it there.<ul><li>While the map waits for the click, a translucent box follows the mouse to show where the note will go. To cancel, press the button again (now labeled <em>Cancel</em>) or press <kbd>Esc</kbd>.</li><li>The note is created as a child of the map, with the default title of a new note. It opens in the note panel (see below) with its title selected, so you can type its name straight away.</li></ul></li><li>An existing note can also be dragged from the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>. It will be placed at the position it's dragged on.<ul><li>Multiple notes can also be dragged via <a class=\"reference-link\" href=\"#root/_help_yTjUdsOi4CIE\">Multiple selection</a>. The notes will be positioned near the dragged position without overlapping.</li><li>The dragged note can be a sub-child of the map, or it can be at any arbitrary position.</li></ul></li><li>Notes can also be pasted onto the map. Copy or cut them in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>, then click the map and press <kbd>Ctrl</kbd>+<kbd>V</kbd>, or right click an empty part of the map and select <em>Paste note(s)</em>.<ul><li>With <kbd>Ctrl</kbd>+<kbd>V</kbd>, the notes are placed under the mouse, or in the middle of the map if the mouse is not over it. From the right click menu, they are placed where the menu was opened.</li><li>Copied notes stay where they are in the tree. Cut notes are moved under the map, as if they had been pasted into it in the tree.</li><li>Links to notes, such as an <a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a> copied from a text note, can be pasted the same way. If the clipboard holds no link to a note, the notes last copied or cut in the tree are pasted.</li><li>The right click menu of an empty part of the map also has <em>Add note</em>, which creates a new note where the menu was opened.</li></ul></li><li>To create a relationship, hold the mouse on the dot on the right of a note and then:<ul><li>Drag it over another note to create a relationship pointing from the first note to the second one.</li><li>Drag over the same note to create a self-referencing relationship (represented as a loop).</li><li>Once dragged, a popover next to the relationship asks for its name. Type a new name and press <kbd>Enter</kbd>, or pick a relation name already in use from the suggestions. To cancel, press <kbd>Esc</kbd>, close the popover or click elsewhere on the map.</li></ul></li><li>Each note is shown as a card with its icon and title, colored in the note's color the same way as the cards of a <a class=\"reference-link\" href=\"#root/_help_CtBQqbwXDx1w\">Kanban Board</a>.</li><li>Hovering a note highlights its relationships, in the note's color if it has one, and fades the other relationships.</li><li>To view or edit a note, click it on the map. This opens the note panel (see below).<ul><li>To open the note in a new tab instead, <kbd>Ctrl</kbd>+click it or click it with the middle mouse button. <kbd>Shift</kbd>+click opens it in a new window. The right click menu offers the same options.</li></ul></li><li>To edit the title of a note, change its color or delete it (either from the map, or delete it completely), right click the note.</li><li>To rename or delete a relationship, right click it and select the corresponding option.</li><li>On a <a href=\"#root/_help_CoFPLs3dRlXc\">read-only</a> map, notes cannot be moved and relationships cannot be drawn, renamed or deleted. The right click menu of a note only offers to open it, and a relationship has no right click menu.</li><li>To move around the map, drag an empty part of it, and zoom with the mouse wheel or the <span class=\"tn-icon bx bx-minus-circle\"></span> and <span class=\"tn-icon bx bx-plus-circle\"></span> buttons at the bottom-right corner. Clicking the zoom percentage goes back to 100%, and <span class=\"tn-icon bx bx-scan\"></span> <em>Fit to view</em> zooms and pans so that all the notes are visible.<ul><li>Once the map has been clicked, the arrow keys or <kbd>W</kbd> <kbd>A</kbd> <kbd>S</kbd> <kbd>D</kbd> pan it, and <kbd>+</kbd> and <kbd>-</kbd> zoom it. The <kbd>?</kbd> button at the top-right corner of the map lists all its keyboard shortcuts.</li></ul></li></ul><h2>Note panel</h2><p>When a note on the map is clicked, a panel opens to the right of the map and the note is highlighted. If the panel would cover the note, or the note is partly off-screen, the map pans to bring it into view. The panel contains:</p><ul><li>The title and icon of the note, both editable.</li><li>A <span class=\"tn-icon bx bx-expand-alt\"></span> button to expand the panel over the whole map, and to restore it afterwards.</li><li>Buttons to interact with the note:<ul><li><span class=\"tn-icon bx bx-log-in\"></span> Open the note in the current tab, or, through the <span class=\"tn-icon bx bx-dots-horizontal-rounded\"></span> menu, in a new tab, split, window or the quick edit popup.</li><li>A <span class=\"tn-icon bx bx-palette\"></span> color picker to change the color of the note.</li><li>A <span class=\"tn-icon bx bx-trash\"></span> button to remove the note from the map, which can optionally delete the note as well.</li></ul></li><li>The <a class=\"reference-link\" href=\"#root/_help_OFXdgB2nNk1F\">Promoted Attributes</a> of the note, if any.</li><li>The note's content, which can be edited directly from the panel.</li></ul><p>The color picker and the remove button are not shown if the map is read-only.</p><p>Clicking another note on the map switches the panel to it. Similarly, clicking an <a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a> inside the panel switches the panel to that note, as long as it is on the map.</p><p>To close the panel, press the <span class=\"tn-icon bx bx-x\"></span> button at its top-right, click an empty part of the map, or press <kbd>Esc</kbd>.</p><p>On mobile, the note opens as a dialog over the whole screen instead of a panel.</p><h2>Development process demo</h2><p>This is a basic example how you can create simple diagram using relation maps:</p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Relation%20Map_relation-map-dev-process.png\" width=\"934\" height=\"667\"><p>And this is how you can create it:</p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Relation%20Map_relation-map-dev-process-demo.gif\" width=\"812\" height=\"585\"><p>We start completely from scratch by first creating new note called \"Development process\" and changing its type to \"Relation map\". After that we create new notes one by one and place them by clicking into the map. We also drag <a href=\"#root/_help_zEY4DaJG4YT5\">relations</a>between notes and name them. That's all!</p><p>Items on the map - \"Specification\", \"Development\", \"Testing\" and \"Demo\" are actually notes which have been created under \"Development process\" note - you can click on them and write some content. Connections between notes are called \"<a href=\"#root/_help_zEY4DaJG4YT5\">relations</a>\".</p><h2>Family demo</h2><p>This is more complicated demo using some advanced concepts. Resulting diagram is here:</p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Relation%20Map_relation-map-family.png\" width=\"941\" height=\"758\"><p>This is how you get to it:</p><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Relation%20Map_relation-map-family-demo.gif\" width=\"812\" height=\"585\"><p>There are several steps here:</p><ul><li>we start with empty relation map and two existing notes representing Prince Philip and Queen Elizabeth II. These two notes already have <code>isPartnerOf</code> <a href=\"#root/_help_zEY4DaJG4YT5\">relations</a>defined.<ul><li>There are actually two \"inverse\" relations (one from Philip to Elizabeth and one from Elizabeth to Philip)</li></ul></li><li>we drag both notes to relation map and place to suitable position. Notice how the existing <code>isPartnerOf</code> relations are displayed.</li><li>now we create new note - we name it \"Prince Charles\" and place it on the relation map by clicking on the desired position. The note is by default created under the relation map note (visible in the note tree on the left).</li><li>we create two new relations <code>isChildOf</code> targeting both Philip and Elizabeth<ul><li>now there's something unexpected - we can also see the relation to display another <code>hasChild</code> relation. This is because there's a <a href=\"#root/_help_OFXdgB2nNk1F\">relation definition</a> which puts <code>isChildOf</code> as an \"<a href=\"#root/_help_OFXdgB2nNk1F\">inverse</a>\" relation of <code>hasChildOf</code> (and vice versa) and thus it is created automatically.</li></ul></li><li>we create another note for Princess Diana and create <code>isPartnerOf</code> relation from Charles. Again notice how the relation has arrows both ways - this is because <code>isPartnerOf</code> definition specifies its inverse relation as again \"isPartnerOf\" so the opposite relation is created automatically.</li><li>as the last step we pan & zoom the map to fit better to window dimensions.</li></ul><p>Relation definitions mentioned above come from \"Person template\" note which is assigned to any child of \"My Family Tree\" relation note. You can play with the whole thing in the <a href=\"#root/_help_wX4HbRucYSDD\">demo notes</a>.</p><h2>Details</h2><p>You can specify which relations should be displayed with comma delimited names of relations in <code>displayRelations</code> label.</p><p>Alternatively, you can specify comma delimited list of relation names in <code>hideRelations</code> which will display all relations, except for the ones defined in the label.</p><h2>See also</h2><ul><li><a class=\"reference-link\" href=\"#root/_help_bdUJEHsAPYQR\">Note Map</a> is a similar concept.</li></ul>","_help_bdUJEHsAPYQR": "<figure class=\"image image_resized\" style=\"width:72.68%;\"><img style=\"aspect-ratio:1311/1271;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Note%20Map_image.png\" width=\"1311\" height=\"1271\"></figure><p>A Note map is a note type which displays a standalone version of the feature of the same name: <a class=\"reference-link\" href=\"#root/_help_BCkXAVs63Ttv\">Note Map (Link map, Tree map)</a>. Consult that page for more information on how the note map works and what it displays.</p><p>Once created, the note map will display the relations between notes. Only the notes that are part of the parent of the note map will be displayed (including their children).</p><h2>Root note</h2><p>The root note defines the starting point of the graph, from which the relations and the hierarchy are derived from.</p><p>There are three possible root notes:</p><ul><li>The default root note is the parent note of the note map.</li><li>To use the currently <a href=\"#root/_help_OR8WJ7Iz9K4U\">hoisted note</a> instead, set the <code>mapRootNoteId</code> label to <code>hoisted</code>.</li><li>To use a specific note instead, set <code>mapRootNoteId</code> to the <a class=\"reference-link\" href=\"#root/_help_m1lbrzyKDaRB\">Note ID</a> of the desired note.</li></ul><h2>Customization</h2><p>The note map can be customized using the following <a class=\"reference-link\" href=\"#root/_help_HI6GBBIduIgv\">Labels</a>:</p><figure class=\"table\"><table><thead><tr><th>Label</th><th>Description</th></tr></thead><tbody><tr><td><code>#mapIncludeRelation</code></td><td>Comma-delimited relation names to include from the note map.</td></tr><tr><td><code>#mapExcludeRelation</code></td><td>Comma-delimited relation names to exclude from the note map.</td></tr><tr><td><code>#mapRootNoteId</code></td><td>The ID of the note the map roots from, or <code>hoisted</code>. See the root note section above for more information.</td></tr></tbody></table></figure>",@@ -180,7 +180,7 @@"_help_C2H9HK4BzwG7": "<p>The following shapes can be drawn on the map: a path, an area, a rectangle or a circle.</p><p>Unlike markers, the title of the shape is not displayed directly on the map but it will be displayed when hovered.</p><p>The shape will also be drawn in the <a href=\"#root/_help_p9kXRFAkwN4o\">color of the note</a>, if set. </p><h2>Drawing a shape on the map</h2><p>To draw a shape, use the toolbar that appears in the top-center area on desktop and on the left-center on mobile and in split view.</p><p>Once a shape is drawn, it cannot be moved or modified. To do so, simply remove the shape and draw another one instead.</p><h3>Drawing a path or an area</h3><ol><li>Press the <em>Draw a path on the map</em> (<span class=\"tn-icon bx bx-vector\"></span>) or <em>Draw an area on the map</em> (<span class=\"tn-icon bx bx-shape-polygon\"></span>) button. The button stays held down while the tool is armed, and a notification describes what to do.</li><li>Click on the map once for each point. The shape is previewed as it grows.</li><li>Finish it by pressing <kbd>Enter</kbd>. A path can also be finished by clicking its last point again, and an area by clicking the corner it started from. A path needs at least two points and an area at least three.</li></ol><h3>Drawing a rectangle or a circle</h3><ol><li>Press the <em>Draw a rectangle on the map</em> (<span class=\"tn-icon bx bx-shape-square\"></span>) or <em>Draw a circle on the map</em> (<span class=\"tn-icon bx bx-shape-circle\"></span>) button.</li><li>Click once to set the first corner, or the center of the circle. Click a second time at the opposite corner, or at the distance the circle should reach.</li><li>Instead of two clicks you can drag from one to the other. This also works on mobile and other touch-based apps.</li></ol><h3>Finishing and cancelling</h3><p>To give up on a shape while drawing it, press <kbd>Escape</kbd> or press the tool's button again. Whatever has been drawn so far is discarded.</p><p>The tool is deactivated once a shape is finished, so drawing a second shape requires another button press.</p><h2>Interaction</h2><p>Once a shape is created:</p><ul><li>Clicking a shape opens the standard panel which allows changing the title, the content and with buttons to open the note or remove it.<ul><li>When clicking, a marker takes priority over the shape.</li></ul></li><li>Right-clicking a shape opens a contextual menu similar to the one for markers, which allows opening the corresponding note or removing the shape.</li><li>Typing in the map's search bar finds shapes by their title, as it does markers. Selecting one brings the whole shape into view.</li></ul><h2>How shapes are represented</h2><p>Shapes are represented quite similarly to markers, which means each shape is a note. The information about the same is stored using a <a href=\"#root/_help_HI6GBBIduIgv\">label</a> called <code>geoShape</code>.</p>","_help_ZRDXGc0nAIh4": "<p>An image map is a geo map drawn over an image of your own instead of a world map, such as a floor plan, a fantasy map for a tabletop game, or a diagram to annotate. Markers and shapes work as they do on a geo map, but their positions are measured on the image instead of in latitude and longitude: in the image's own pixels, or in a coordinate system of your choosing, such as the one a video game uses.</p><h2>Creating an image map</h2><ol><li>Upload the image as a note of its own, for example by dragging the file into the note tree. PNG, JPEG, WebP and GIF images are supported; SVG images are not.</li><li>Create a geo map, or open an existing one.</li><li>Open the <span class=\"tn-icon bx bx-cog\"></span><em>Geo map properties</em> dialog from the <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> or from the settings menu of the <a class=\"reference-link\" href=\"#root/_help_CssoWBu8I7jF\">Collection Properties</a>.</li><li>Under <em>Background</em>, set <em>Type</em> to <em>Custom image</em>, then choose the image note in <em>Image note</em>. The list only offers image notes in a format the map can draw (PNG, JPEG, WebP or GIF), and shows all of them before anything is typed.</li></ol><p>The map then shows the image instead of the world map and opens with the whole image in view. To go back to a world map, set <em>Type</em> back to <em>Vector & Raster</em>. The image is switched off rather than removed: its relation is renamed to <code>~disabled:map:image</code>, so setting <em>Type</em> to <em>Custom image</em> again brings back the same image, with its coordinates. An image that the geo map inherits from a parent note or a template can only be switched off on the note that holds it.</p><p>The image note is stored in a <code>~map:image</code> <a href=\"#root/_help_Cq5X6iKQop6R\">relation</a> of the geo map, which can also be added by hand.</p><h2>Image size</h2><p>Images are resized when they are uploaded, so by default the image of a map is at most 2000 pixels on its longer side, which can be too coarse for a detailed map. To keep an image at a higher resolution, do one of the following before uploading it:</p><ul><li>In <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Media</em>, raise <em>Max image dimensions</em> or turn off <em>Automatically compress images</em>.</li><li>Upload it through the <em>Import</em> dialog with <em>Compress images</em> unchecked.</li></ul><p>An image that was already uploaded keeps its size; upload it again after changing the settings.</p><p>The image is drawn as a single picture by the graphics card, which limits how large it can be. Images up to 4096 pixels on their longer side are safe on practically every device, and most computers handle up to 16384 pixels. On a device whose graphics card cannot hold the image, the markers and shapes still appear but the image itself does not. The <em>Geo map properties</em> dialog warns about an image larger than 4096 pixels, and about one that can't be used at all, such as an SVG image.</p><h2>Interaction</h2><p>Adding, moving and removing markers, drawing shapes, the popup view and the contextual menu work as described for the <a class=\"reference-link\" href=\"#root/_help_81SGnPGMk7Xc\">Geo Map</a>. The camera stays over the image and can zoom in up to four times past the image's own resolution.</p><p>The features that only make sense on a real map are not available on an image map:</p><ul><li>Searching the map and searching for places online.</li><li>Going to your location.</li><li>Adding GPS tracks.</li><li>Clicking the places the base map shows.</li><li>The 3D buildings.</li><li>Opening a location in an external map application.</li></ul><p>The look of the marker titles follows the image: if the image is dark, turn on <em>Dark image</em> under <em>Background</em> in the <em>Geo map properties</em> dialog, so that the titles are drawn in a light color. This sets the <code>#map:darkStyle</code> label.</p><p>The <em>Map style</em> setting doesn't apply to an image map, so it's hidden from the settings menu of the collection while the map has an image.</p><h2>Choosing the coordinate system</h2><p>By default, positions are measured in pixels of the image at its original size, from its top-left corner, with <code>x</code> growing to the right and <code>y</code> growing downwards.</p><p>To use coordinates of your own instead, open the <em>Geo map properties</em> dialog, set <em>Coordinates</em> under <em>Background</em> to <em>Custom</em>, and enter the coordinates of the image's <em>Top-left corner</em> and <em>Bottom-right corner</em>. Switching to <em>Custom</em> starts from the image's size in pixels, so the markers stay where they are until the corners are changed; for that reason, <em>Custom</em> can only be chosen once the image has loaded. All positions are then read and written in those coordinates, including the ones shown in the contextual menu and in the popup view. To go back to pixels, set <em>Coordinates</em> to <em>Image pixels</em>. Corners that the geo map inherits from a parent note or a template can only be removed on the note that holds them; entering other corners on this map overrides them.</p><p>The corners are stored in the <code>#map:imageBounds</code> label of the geo map as <code>x,y x,y</code>, with a space between the two corners, which can also be set by hand. For example:</p><ul><li>A screenshot of a game map that covers <code>x</code> from -512 to 512 and <code>y</code> from -512 to 512, with <code>y</code> growing downwards: <code>#map:imageBounds=-512,-512 512,512</code>. Coordinates copied from the game can then be pasted directly into <code>#mapPosition</code>.</li><li>A world whose <code>y</code> grows upwards, with the origin in the middle of the image: <code>#map:imageBounds=-2000,1000 2000,-1000</code>. A top-left <code>y</code> larger than the bottom-right one is what flips the axis.</li><li>A floor plan measured in meters: <code>#map:imageBounds=0,0 24,12</code>.</li></ul><p>The two axes don't have to use the same scale. A circle is always measured in the map's own units, so it appears as an ellipse when the units are stretched differently along the two axes.</p><p>Corners that share an <code>x</code> or a <code>y</code> don't span an area: the dialog doesn't save them, and a label holding them, or a value that cannot be read, is ignored and the pixels of the image are used instead.</p><h2>Coordinate rulers</h2><p>Enabling <em>Show scale</em> in the collection properties draws rulers along the edges of the image instead of a distance scale. Round values of the map's coordinates are marked with ticks along all four edges, labeled along the top and left ones, with faint grid lines across the image. The spacing follows the zoom level, and the values follow <code>#map:imageBounds</code> when it is set.</p><p>The rulers are drawn on the image itself, so they move out of view along with its edges when zooming in. The grid lines remain visible across the image.</p><h2>How the positions are stored</h2><p>Because positions are stored in different labels from the ones of a geo map, the same note can be placed both on a geo map and on an image map.</p><figure class=\"table\"><table><thead><tr><th>Label</th><th>Content</th></tr></thead><tbody><tr><td><code>#mapPosition</code></td><td>The position of a marker, as <code>x,y</code>, for example <code>#mapPosition=320,145</code>.</td></tr><tr><td><code>#mapShape</code></td><td>A shape, in the same format as <code>#geoShape</code> (see <a class=\"reference-link\" href=\"#root/_help_C2H9HK4BzwG7\">Drawing shapes</a>) but with <code>x,y</code> pairs, and a circle's radius in the map's units, for example <code>#mapShape=circle:400,300 50</code>.</td></tr></tbody></table></figure><p>The positions belong to the coordinate system, not to the image. When replacing the image with a different one, for example a higher-resolution copy, keep <code>#map:imageBounds</code> describing the area the new image covers and every marker stays in place. With <em>Image pixels</em>, the positions are pixels, so an image of a different size moves the markers relative to what the image shows; to avoid that, switch <em>Coordinates</em> to <em>Custom</em> before replacing the image, which keeps the size of the old one (<code>0,0 <width>,<height></code>) as the corners.</p><aside class=\"admonition tip\"><p>To draw freely over an image instead of placing notes on it, consider a <a class=\"reference-link\" href=\"#root/_help_grjYqerjn243\">Canvas</a>.</p></aside>","_help_zP3PMqaG71Ct": "<figure class=\"image\"><img style=\"aspect-ratio:1120/763;\" src=\"{{helpAssets}}/User%20Guide/Collections/Presentation_image.png\" width=\"1120\" height=\"763\"></figure><p>The Presentation view allows the creation of slideshows directly from within Trilium.</p><h3>Creating a new presentation</h3><p>Right click on an existing note in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> and select <em>Insert child note</em> → <em>Collection</em> → <em>Presentation</em>.</p><h2>How it works</h2><ul><li>Each slide is a child note of the collection.</li><li>The order of the child notes determines the order of the slides.</li><li>Unlike traditional presentation software, slides can be laid out both horizontally and vertically (see below for more information).</li><li>Direct children will be laid out horizontally and the children of those will be laid out vertically. Children deeper than two levels of nesting are ignored.</li></ul><h2>Interaction and navigation</h2><p>In the floating toolbar (top-right):</p><ul><li><span class=\"tn-icon bx bx-edit\"></span> <em>Edit this slide</em> button to go to the corresponding note of the current slide. A <a href=\"#root/_help_CoFPLs3dRlXc\">read-only</a> presentation doesn't show it.</li><li>Press the <span class=\"tn-icon bx bx-grid-horizontal\"></span> Overview button (or the <kbd>O</kbd> key) to show a birds-eye view of the slides. Press the button again to disable it.</li><li>Press the <span class=\"tn-icon bx bx-fullscreen\"></span> “Start presentation” button to show the presentation in full-screen.</li></ul><p>The following keyboard shortcuts are supported:</p><ul><li>Press <kbd>←</kbd> and <kbd>→</kbd> (or <kbd>H</kbd> and <kbd>L</kbd>) to go to the slide on the left or on the right (horizontal).</li><li>Press <kbd>↑</kbd> and <kbd>↓</kbd> (or <kbd>K</kbd> and <kbd>J</kbd>) to go to the upward or downward slide (vertical).</li><li>Press <kbd>Space</kbd> and <kbd>Shift</kbd> + <kbd>Space</kbd> or to go to the next/previous slide in order.</li><li>And a few more, press <kbd>?</kbd> to display a popup with all the supported keyboard combinations.</li></ul><h2>Vertical slides and nesting</h2><p>Unlike traditional presentation software such as Microsoft PowerPoint, the slides in Trilium can be laid out horizontally or vertically in order to create depth or better organize the slides by topic.</p><p>This horizontal/vertical organization affects transitions (especially on the “slide” transition), however it is most noticeable in navigation.</p><ul><li>Pressing <kbd>←</kbd> and <kbd>→</kbd> will navigate through slides horizontally, thus skipping vertical notes under the current slide. This is useful to skip entire chapters/related slides.</li><li>Pressing <kbd>↑</kbd> and <kbd>↓</kbd> will navigate through the vertical slides at the current level.</li><li>Pressing <kbd>Space</kbd> and <kbd>Shift</kbd> + <kbd>Space</kbd> will go to the next/previous slide in order, regardless of the direction. This is generally the key combination to use when presenting.</li><li>The arrows on the bottom-right of the slide will also reflect this navigation scheme.</li></ul><figure class=\"image image-style-align-right image_resized\" style=\"width:55.57%;\"><img style=\"aspect-ratio:890/569;\" src=\"{{helpAssets}}/User%20Guide/Collections/1_Presentation_image.png\" width=\"890\" height=\"569\"></figure><p>All direct children of the collection will be laid out horizontally. If a direct child also has children, those children will be placed as vertical slides.</p><p>In the following example, the note structure is as follows:</p><ul><li>Presentation collection<ul><li>Trilium Notes (demo page)</li><li>“Introduction” slide<ul><li>“The challenge of personal knowledge management”</li><li>“Note-taking structures”</li></ul></li><li>“Demo & Feature highlights” slide<ul><li>“Really fast installation process”</li><li>Video slide</li></ul></li></ul></li></ul><h2>Customization</h2><p>At collection level, it's possible to adjust:</p><ul><li>The theme of the entire presentation to one of the predefined themes by going to the <a class=\"reference-link\" href=\"#root/_help_CssoWBu8I7jF\">Collection Properties</a> and looking for the <em>Theme</em> option.</li><li>It's currently not possible to create custom themes, although it is planned.</li><li>Note that it is note possible to alter the CSS via <a class=\"reference-link\" href=\"#root/_help_AlhDUqhENtH7\">Custom app-wide CSS</a> because the slides are rendered isolated (in a shadow DOM).</li></ul><p>At slide level:</p><ul><li>It's possible to adjust the background color of a slide by using the <a href=\"#root/_help_OFXdgB2nNk1F\">predefined promoted attribute</a> for the color or manually setting <code>#slide:background</code> to a hex color.</li><li>More complex backgrounds can be achieved via gradients. There's no UI for it; it has to be set via <code>#slide:background</code> to a CSS gradient definition such as: <code>linear-gradient(to bottom, #283b95, #17b2c3)</code>.</li></ul><h2>Tips and tricks</h2><ul><li>Text notes generally respect the formatting (bold, italic, foreground and background colors) and font size. Code blocks and tables also work.</li><li>Try using more than just text notes, the presentation uses the same mechanism as <a href=\"#root/_help_R9pX4DGra2Vt\">shared notes</a> and <a class=\"reference-link\" href=\"#root/_help_0ESUbbAxVnoK\">Note List</a> so it should be able to display <a class=\"reference-link\" href=\"#root/_help_s1aBHPd79XYj\">Mermaid Diagrams</a>, <a class=\"reference-link\" href=\"#root/_help_grjYqerjn243\">Canvas</a> and <a class=\"reference-link\" href=\"#root/_help_gBbsAeiuUxI5\">Mind Map</a> in full-screen (without the interactivity).<ul><li><p>Consider using a transparent background for <a class=\"reference-link\" href=\"#root/_help_grjYqerjn243\">Canvas</a>, if the slides have a custom background (go to the hamburger menu in the Canvas, press the button select a custom color and write <code>transparent</code>).</p></li><li><p>For <a class=\"reference-link\" href=\"#root/_help_s1aBHPd79XYj\">Mermaid Diagrams</a>, some of them have a predefined background which can be changed via the frontmatter. For example, for XY-charts:</p><pre><code class=\"language-text-x-trilium-auto\">---\nconfig:\n themeVariables:\n xyChart:\n backgroundColor: transparent\n---</code></pre></li></ul></li></ul><h2>Under the hood</h2><p>The Presentation view uses <a href=\"https://revealjs.com/\">Reveal.js</a> to handle the navigation and layout of the slides.</p>",- "_help_8QqnMzx393bx": "<figure class=\"image\"><img style=\"aspect-ratio:990/590;\" src=\"{{helpAssets}}/User%20Guide/Collections/Grid%20View_image.png\" width=\"990\" height=\"590\"></figure><p>This view presents the child notes in a grid format, allowing for a more visual navigation experience.</p><p>Each tile contains:</p><ul><li>The title of a note.</li><li>A snippet of the content.</li><li>For empty notes, the sub-children are also displayed, allowing for quick navigation.</li></ul><p>Depending on the type of note:</p><ul><li>For <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes, the text can be slightly scrollable via the mouse wheel to reveal more context.</li><li>For <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> notes, syntax highlighting is applied.</li><li>For <a class=\"reference-link\" href=\"#root/_help_W8vYD3Q1zjCR\">File</a> notes, a preview is made available for audio, video and PDF notes.</li><li>If the note does not have a content, a list of its child notes will be displayed instead.</li></ul><p>The grid view is also used by default in the <a class=\"reference-link\" href=\"#root/_help_0ESUbbAxVnoK\">Note List</a> of every note, making it easy to navigate to children notes.</p><h3>Creating a new table</h3><p>Right click on an existing note in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> and select <em>Insert child note</em> → <em>Collection</em> → <em>Grid View</em>.</p><h2>Configuration</h2><p>Unlike most other view types, the grid view is not actually configurable.</p>",+ "_help_8QqnMzx393bx": "<figure class=\"image\"><img style=\"aspect-ratio:990/590;\" src=\"{{helpAssets}}/User%20Guide/Collections/Grid%20View_image.png\" width=\"990\" height=\"590\"></figure><p>This view presents the child notes in a grid format, allowing for a more visual navigation experience.</p><p>Each tile contains:</p><ul><li>The title of a note.</li><li>A snippet of the content.</li><li>For empty notes, the sub-children are also displayed, allowing for quick navigation.</li></ul><p>Depending on the type of note:</p><ul><li>For <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes, the text can be slightly scrollable via the mouse wheel to reveal more context.</li><li>For <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> notes, syntax highlighting is applied, with line numbers.</li><li>For <a class=\"reference-link\" href=\"#root/_help_W8vYD3Q1zjCR\">File</a> notes, a preview is made available for audio, video and PDF notes.</li><li>If the note does not have a content, a list of its child notes will be displayed instead.</li></ul><p>The grid view is also used by default in the <a class=\"reference-link\" href=\"#root/_help_0ESUbbAxVnoK\">Note List</a> of every note, making it easy to navigate to children notes.</p><h3>Creating a new table</h3><p>Right click on an existing note in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> and select <em>Insert child note</em> → <em>Collection</em> → <em>Grid View</em>.</p><h2>Configuration</h2><p>Unlike most other view types, the grid view is not actually configurable.</p>","_help_mULW0Q3VojwY": "<figure class=\"image\"><img style=\"aspect-ratio:1387/758;\" src=\"{{helpAssets}}/User%20Guide/Collections/List%20View_image.png\" width=\"1387\" height=\"758\"></figure><p>List view is similar to <a class=\"reference-link\" href=\"#root/_help_8QqnMzx393bx\">Grid View</a>, but in the list view mode, each note is displayed in a single row with only the title and the icon of the note being visible by the default. By pressing the <span class=\"tn-icon bx bx-chevron-right\"></span> expand button it's possible to view the content of the note, as well as the children of the note (recursively).</p><p>In the example above, the \"Node.js\" note on the left panel contains several child notes. The right panel displays the content of these child notes as a single continuous document.</p><h3>Creating a new table</h3><p>Right click on an existing note in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> and select <em>Insert child note</em> → <em>Collection</em> → <em>List View</em>.</p><h2>Interaction</h2><ul><li>Each note can be expanded or collapsed by clicking on the <span class=\"tn-icon bx bx-chevron-right\"></span> arrow to the left of the title.</li><li>In the <a class=\"reference-link\" href=\"#root/_help_CssoWBu8I7jF\">Collection Properties</a>, there are buttons to expand (<span class=\"tn-icon bx bx-move-vertical\"></span>) and to collapse (<span class=\"tn-icon bx bx-layer-minus\"></span>) all notes easily.</li></ul><h2>Printing and exporting to PDF</h2><p>Since v0.100.0, list collections can be <a href=\"#root/_help_NRnIZmSMc5sj\">printed or exported to PDF</a>.</p><p>A printed list collection will print all the notes in the collection, in the right order and preserving the full hierarchy.</p><p>If exported to PDF within the desktop application, there is additional functionality:</p><ul><li>The table of contents of the PDF will reflect the structure of the notes.</li><li>Reference and inline links to other notes within the same hierarchy will be functional (will jump to the corresponding page). If a link refers to a note that is not in the printed hierarchy, it will be unlinked.</li></ul><h2>Expanding and collapsing multiple notes at once</h2><p>Apart from individually expanding or collapsing notes, it's also possible to expand or collapse them all at once. To do so, go to the <a class=\"reference-link\" href=\"#root/_help_CssoWBu8I7jF\">Collection Properties</a> and look for the corresponding button.</p><p>By default, the <em>Expand</em> (<span class=\"tn-icon bx bx-move-vertical\"></span>) button will only expand the direct children (first level) of the collection. Starting with v0.100.0, it's possible to expand multiple levels of notes using the arrow button next to the button.</p><p>Manually expanded notes will reset if the application/tab is closed and then the collection is visited again. However notes automatically expanded/collapsed via the buttons in <a class=\"reference-link\" href=\"#root/_help_CssoWBu8I7jF\">Collection Properties</a> will persist.</p><aside class=\"admonition tip\"><p>By design, the UI provides only a handful of levels of depth for expanding notes (direct children, 2-5, all levels). It's also possible to specify any desired depth by manually setting the <a href=\"#root/_help_HI6GBBIduIgv\">corresponding label</a>. For example: <code>#expanded=100</code> to expand up to 100 levels of depth.</p></aside><aside class=\"admonition note\"><p>From a performance standpoint, the List collection is efficient since it does not load child notes unless the notes are actually expanded. Expanding the list for a significantly large hierarchy can cause slow-downs.</p></aside>","_help_CssoWBu8I7jF": "<figure class=\"image\"><img style=\"aspect-ratio:1177/98;\" src=\"{{helpAssets}}/User%20Guide/Collections/Collection%20Properties_image.png\" width=\"1177\" height=\"98\"></figure><p>The <em>Collection Properties</em> is a toolbar that is displayed at the top of every <a href=\"#root/_help_GTwFsgaA0lCt\">collection note</a>.</p><p>The collection properties has:</p><ul><li>A quick selector for the view type (e.g. grid, calendar, board).</li><li>A settings button with:<ul><li>Settings for the current view, for example hiding the weekends in a calendar.</li><li>Generic settings for the collection, such as <a href=\"#root/_help_wyaGBBQrl4i3\">hiding the child notes</a> or showing <a href=\"#root/_help_MKmLg5x6xkor\">archived notes</a>.</li></ul></li><li>Specific interactions for the current view, for example month selector and view switcher for the calendar.</li></ul>","_help_IF7Q6I9x7zuw": "<figure class=\"image\"><img style=\"aspect-ratio:1406/1030;\" src=\"{{helpAssets}}/User%20Guide/Collections/Dashboard_image.png\" width=\"1406\" height=\"1030\"></figure><aside class=\"admonition note\"><p>The dashboard is currently considered beta. This means that it might face some changes in behavior until it is stabilized.</p></aside><p>The dashboard is a collection introduced in Trilium v0.104.0. It is similar to the <a class=\"reference-link\" href=\"#root/_help_8QqnMzx393bx\">Grid View</a> collection, but with some key differences:</p><ul><li>The grid layout is not fixed, allowing for tiles of varying widths and heights. The grid has 12 columns and an unlimited number of rows.</li><li>Each widget represents a child note of the collection and can be reordered or resized.</li><li>The grid will distribute the columns evenly to fill the entire screen.<ul><li>If the available space is too low (e.g. in a split or in mobile), the columns are collapsed so that all widgets are displayed one under the other.</li><li>While the columns are collapsed, the widgets cannot be reordered or resized.</li></ul></li><li>Unlike the <a class=\"reference-link\" href=\"#root/_help_8QqnMzx393bx\">Grid View</a>, the widgets are not clickable which allows them to be interactive.</li></ul><h2>Types of widgets</h2><p>The dashboard uses the same rendering mechanism as the <a class=\"reference-link\" href=\"#root/_help_8QqnMzx393bx\">Grid View</a> or the <a class=\"reference-link\" href=\"#root/_help_0ESUbbAxVnoK\">Note List</a>, which means every note can be rendered, such as:</p><ul><li>Static content, via <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> or <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a>.</li><li>Images via <a class=\"reference-link\" href=\"#root/_help_W8vYD3Q1zjCR\">File</a>, <a class=\"reference-link\" href=\"#root/_help_s1aBHPd79XYj\">Mermaid Diagrams</a>, <a class=\"reference-link\" href=\"#root/_help_gBbsAeiuUxI5\">Mind Map</a>.</li><li>Interactive widgets via <a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a>.</li><li>Web pages can be displayed via <a class=\"reference-link\" href=\"#root/_help_1vHRoWCEjj0L\">Web View</a> and refreshed via the context menu.</li><li><a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a> render interactively inside the dashboard</li></ul><aside class=\"admonition tip\"><p>Interactive widgets through the use of <a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a> is the highlighted use case of the dashboard. Using the <a class=\"reference-link\" href=\"#root/_help_GBBMSlVSOIGP\">AI</a> chat, these widgets can be easily created as the AI is instructed in how to write them.</p></aside><h2>Adding new widgets</h2><p>There are two ways to add widgets to a dashboard:</p><ul><li>Create a child note of any type, the dashboard will automatically pick it up and add it onto the grid.</li><li>From the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>, drag an existing note onto the dashboard and it will be placed there. This will <a href=\"#root/_help_IakOLONlIfGI\">clone</a> the note into the collection.</li></ul><h2>Read-only dashboards</h2><p>On a <a href=\"#root/_help_CoFPLs3dRlXc\">read-only</a> dashboard, the widgets can't be moved or resized, notes dragged from the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> aren't added, and the menu of a widget no longer offers to remove it.</p>",@@ -207,7 +207,7 @@"_help_VQjhl61rlWh9": "<p>Markdown Snippets are closely related to <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a>, but instead of defining the content of an entire note, a snippet is a reusable piece of Markdown text that can easily be inserted into a <a class=\"reference-link\" href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a> note.</p><h2>Creating a Markdown snippet</h2><p>In the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>: </p><ol><li>Right-click the note where you want to place the snippet.</li><li>Select <em>Insert child note</em>.</li><li>Select <em>More</em> → <em>Markdown snippet</em>.</li></ol><p>Then simply type the desired content into the note.</p><p>The note's title becomes the title of the snippet. Optionally, you can add a description in the <a class=\"reference-link\" href=\"#root/_help_OFXdgB2nNk1F\">Promoted Attributes</a> section.</p><h2>Inserting a snippet</h2><p>To insert a snippet, type <code>/snippet</code> and select its title from the dropdown.</p><p><a class=\"reference-link\" href=\"#root/_help_IEgsWp5hHH35\">Code Snippets</a> with their language mode set to \"Plain text\" are also listed here.</p><h2>Limitations</h2><ul><li>Unlike <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a>, snippets cannot be limited to a particular <a href=\"#root/_help_9sRHySam5fXb\">workspace</a>.</li></ul>","_help_IEgsWp5hHH35": "<p>Code Snippets are closely related to <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a>, but instead of defining the content of an entire note, a snippet is a reusable piece of code that can easily be inserted into a <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> note.</p><h2>Creating a Code snippet</h2><p>In the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>: </p><ol><li>Right-click the note where you want to place the snippet.</li><li>Select <em>Insert child note</em>.</li><li>Select <em>More</em> → <em>Code snippet</em>.</li></ol><p>Then simply type the desired code into the note and set the correct language mode.</p><p>The note's title becomes the title of the snippet. Optionally, you can add a description in the <a class=\"reference-link\" href=\"#root/_help_OFXdgB2nNk1F\">Promoted Attributes</a> section.</p><h2>Inserting a snippet</h2><p>To insert a snippet, type <code>/snippet</code> and select its title from the dropdown.</p><aside class=\"admonition important\"><p>Only code snippets whose language mode matches the current code note are listed. For example, a CSS code note shows only CSS snippets, not JavaScript ones. The exception is snippets set to \"Plain text\", which are available in <a class=\"reference-link\" href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a> notes and any code note regardless of its language mode.</p></aside><h2>Limitations</h2><ul><li>Unlike <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a>, snippets cannot be limited to a particular <a href=\"#root/_help_9sRHySam5fXb\">workspace</a>.</li></ul>","_help_BCkXAVs63Ttv": "<p>Note map is a visualization of connections between notes. This provides an insight into a structure (\"web\") of notes.</p><p>There are two types of note map:</p><ul><li>Link Map, which shows relations between notes.</li><li>Note Map, which shows the hierarchical tree structure.</li></ul><h2>Accessing the note map</h2><p>The note map comes into multiple flavors:</p><ul><li>The note map is available in the <a class=\"reference-link\" href=\"#root/_help_KRlZFoIH0j6p\">Connections tab</a> in the <a class=\"reference-link\" href=\"#root/_help_RnaPdbciOfeq\">Right Sidebar</a>, in the <em>Note map</em> section.<ul><li>It can also be accessed by going to <a class=\"reference-link\" href=\"#root/_help_8YBEPzcpUgxw\">Note menu</a> → <em>Note map</em>, which will focus the sidebar at the right section.</li></ul></li><li>To display a full-screen note map, there is a <a href=\"#root/_help_bdUJEHsAPYQR\">dedicated note type</a> with the same name.</li><li>To view the global note map (of all the notes in the knowledge base), there is a dedicated <em>Note map</em> button in the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>.</li></ul><h2>Terminology and structure</h2><ul><li>Each note is represented as a <em>node</em> in the graph, with the title displayed underneath.<ul><li>When the map is zoomed out, the title can still be viewed by hovering over the node.</li><li>The <a href=\"#root/_help_p9kXRFAkwN4o\">icon and color</a> of the note are respected.</li></ul></li><li>The root node is the reference point for which the relations and hierarchical structure are displayed.<ul><li>When accessing the note map through the <a class=\"reference-link\" href=\"#root/_help_RnaPdbciOfeq\">Right Sidebar</a>, the root node is the current note.</li><li>When using a dedicated <a class=\"reference-link\" href=\"#root/_help_bdUJEHsAPYQR\">Note Map</a> note, the root note can be either the parent note, the currently <a href=\"#root/_help_OR8WJ7Iz9K4U\">hoisted</a> note or a specific note. See the note type documentation for more information.</li></ul></li></ul><h2>Interaction</h2><ul><li>Nodes can be dragged around, but they will return to their original position once released.<ul><li>To have the notes remain in the same position as they were dragged, press the <em>Fix nodes</em> button. The position of the notes is not saved, so it will return to normal once you navigate to another note or restart the application.</li></ul></li><li>When hovering over a node, the adjacent relations and nodes are highlighted.</li><li>The distance between nodes can be adjusted via the slider in the bottom-left. Similarly, this value is not saved.</li><li>To zoom, use the mouse wheel, pinch on a touch screen, or press the <span class=\"tn-icon bx bx-plus-circle\"></span> and <span class=\"tn-icon bx bx-minus-circle\"></span> buttons in the bottom-right corner.<ul><li>To bring the whole map back into view, press the <span class=\"tn-icon bx bx-scan\"></span> <em>Fit to view</em> button next to them.</li><li>The zoom buttons are not shown on mobile, where pinching zooms instead. The <em>Fit to view</em> button is always shown.</li></ul></li><li><a class=\"reference-link\" href=\"#root/_help_MKmLg5x6xkor\">Archived Notes</a> are generally ignored by the note map in order to reduce clutter. There is one exception: if the root note is also archived, then all archived notes are displayed too.</li></ul><h2>Link Map</h2><img src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Note%20Map%20(Link%20map%2C%20Tree%20map)_image.png\" width=\"1425\" height=\"1093\"><p>The link map is a visualization of links and <a class=\"reference-link\" href=\"#root/_help_Cq5X6iKQop6R\">Relations</a> incoming to and outgoing from a particular note.</p><p>The map indicates the following types of relations:</p><ul><li><a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a> between notes.</li><li><a class=\"reference-link\" href=\"#root/_help_Cq5X6iKQop6R\">Relations</a></li></ul><p>The link map will also show unlinked notes that are part of the hierarchy as a cloud of unconnected dots. On the <a class=\"reference-link\" href=\"#root/_help_RnaPdbciOfeq\">Right Sidebar</a> deliberately omits this in order to save some space, but they will be revealed once the map is maximized.</p><h2>Tree Map</h2><p>Shows hierarchical map of notes:</p><figure class=\"image\"><img style=\"aspect-ratio:1420/1490;\" src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/1_Note%20Map%20(Link%20map%2C%20Tree%20map)_image.png\" width=\"1420\" height=\"1490\"></figure><h2>See also</h2><ul><li>Apart from the note map feature which can be accessed from any note, it is also possible to create a dedicated note which will display the relations in full screen. See <a class=\"reference-link\" href=\"#root/_help_bdUJEHsAPYQR\">Note Map</a> for more information.</li><li><a class=\"reference-link\" href=\"#root/_help_iRwzGnHPzonm\">Relation Map</a> is a similar concept, with some differences:<ul><li>note map is automatically generated while relation map must be created manually</li><li>relation map is a type of note while a link map is just virtual visualization</li></ul></li></ul>",- "_help_R9pX4DGra2Vt": "<p>Trilium allows you to share selected notes as <strong>publicly accessible</strong> read-only documents. This feature is particularly useful for publishing content directly from your Trilium notes, making it accessible to others online.</p><figure class=\"image\"><img style=\"aspect-ratio:1144/660;\" src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Sharing_image.png\" width=\"1144\" height=\"660\"></figure><h2>Features, interaction and limitations</h2><ul><li>Searching by note title.</li><li>Light and dark mode, following the visitor's system setting by default, also while the page is open. The visitor can pick <em>Light</em>, <em>Dark</em> or <em>System</em> with the buttons at the top of the navigation pane; the choice is remembered by the browser.</li><li>A layout centered on wide screens, with the navigation tree and the table of contents at either side of the content, and a mobile-friendly layout on narrow ones. There, the navigation tree slides in from the menu button in the header, and lists the headings of the current page below its entry (at the top of the pane, for a page the tree does not show).</li><li>Collapsible tree with the same note icons as the application. It keeps the sections the visitor expanded and its scroll position while they move between the pages of the site, and shows the current note.</li><li>Customizable logo.</li><li>Quick navigation buttons (previous and next note).</li><li>Notes that hide their children from the tree with <code>#subtreeHidden</code> (such as a <a class=\"reference-link\" href=\"#root/_help_CtBQqbwXDx1w\">Kanban Board</a>) show a badge counting them in place of listing them. The page of one of those children shows only that child below its parent, and the previous and next buttons skip them.</li><li>The subpages of a text or code note shown below its content as cards, as in the application. Each card shows the icon of the subpage and the start of its text (or its <code>#shareDescription</code>), or, for a subpage without text, links to its own first subpages. The cards can be hidden with <code>#hideChildrenOverview</code>.</li><li>Displaying the date of the last update of the note, written out in the application's language.</li><li>Marking the page with the application's language and its text direction, and the content of the note with its own <a href=\"#root/_help_veGu4faJErEM\">content language</a>, for screen readers and right-to-left text.</li></ul><h3>By note type</h3><figure class=\"table\"><table class=\"ck-table-resized\"><colgroup><col style=\"width:19.92%;\"><col style=\"width:41.66%;\"><col style=\"width:38.42%;\"></colgroup><thead><tr><th> </th><th>Supported features</th><th>Limitations</th></tr></thead><tbody><tr><th><a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a></th><td><ul><li>Table of contents.</li><li>A link next to each heading, shown while the pointer is over the heading. Clicking it shows the address of the section in the address bar of the browser and copies it, to share a link to the section.</li><li>Syntax highlight of code blocks, in the language selected for each block and in the colors of the VS Code light or dark theme, following the page's mode. For “Auto-detected” blocks, the language is guessed among the ones enabled in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Code Notes</em>; a language not enabled there is not highlighted.</li><li>Rendering for math equations.</li><li><a href=\"#root/_help_nBAXQFj20hS1\">Including notes</a> (only if the included notes are also shared).</li><li>Drawing canvases, shown as pictures at their own size.</li><li>Mermaid diagrams in code blocks, drawn in the page's light or dark mode and redrawn when the visitor switches it.</li></ul></td><td> </td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a></th><td><ul><li>Basic support (displaying the contents of the note in a monospace font).</li></ul></td><td><ul><li>No syntax highlight.</li></ul></td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_m523cpzocqaD\">Saved Search</a></th><td>Not supported.</td><td> </td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_iRwzGnHPzonm\">Relation Map</a></th><td>Not supported.</td><td> </td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_bdUJEHsAPYQR\">Note Map</a></th><td>Not supported.</td><td> </td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a></th><td>Not supported.</td><td> </td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a></th><td><ul><li>The child notes are shown as cards, or as a list when the view type of the collection is <em>List</em>. Each shows its icon and the start of its text (or its <code>#shareDescription</code>), or, for a child note without text, links to its own first child notes.</li></ul></td><td><ul><li>The calendar, table, board, geo map, dashboard and presentation view types are shown as in the app, but read-only.</li></ul></td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_s1aBHPd79XYj\">Mermaid Diagrams</a></th><td><ul><li>The diagram is drawn in the page's light or dark mode and redrawn when the visitor switches it. In browsers with JavaScript disabled, the image saved when the note was last edited is shown instead, and the source of the diagram can be expanded below it.</li><li>The diagram fills the page and can be zoomed with the <span class=\"tn-icon bx bx-minus-circle\"></span> and <span class=\"tn-icon bx bx-plus-circle\"></span> buttons in its bottom corner or with the mouse wheel, between 50% and 1000% of its fitted size, and on touch screens by pinching. Clicking the percentage between the buttons, or double-clicking the diagram, shows it whole again. The diagram can be panned by dragging it.</li></ul></td><td> </td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_grjYqerjn243\">Canvas</a></th><td><ul><li>The diagram is displayed as a vector image.</li></ul></td><td><ul><li>No further interaction supported.</li></ul></td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_1vHRoWCEjj0L\">Web View</a></th><td>Not supported.</td><td> </td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_gBbsAeiuUxI5\">Mind Map</a></th><td>The diagram is displayed as a vector image.</td><td><ul><li>No further interaction supported.</li></ul></td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_81SGnPGMk7Xc\">Geo Map</a></th><td>Not supported.</td><td> </td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_W8vYD3Q1zjCR\">File</a></th><td>Basic interaction (downloading the file).</td><td><ul><li>No further interaction supported.</li></ul></td></tr></tbody></table></figure><p>While the sharing feature is powerful, it has some limitations:</p><ul><li><strong>Code Notes</strong>: No syntax highlighting.</li><li><strong>Static Note Tree</strong></li><li><strong>Protected Notes</strong>: Cannot be shared.</li><li><strong>Include Notes</strong>: Not supported.</li></ul><p>Some of these limitations may be addressed in future updates.</p><h2>Prerequisites</h2><p>To use the sharing feature, you must have a <a class=\"reference-link\" href=\"#root/_help_WOcw2SLH6tbX\">Server Installation</a> of Trilium. This is necessary because the notes will be hosted from the server.</p><h2>Sharing a note</h2><ol><li><p><strong>Enable Sharing</strong>: To share a note, toggle the <code>Shared</code> switch within the note's interface. Once sharing is enabled, an URL will appear, which you can click to access the shared note.</p><p><img src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Sharing_share-single-note.png\" alt=\"Share Note\"></p></li><li><p><strong>Access the Shared Note</strong>: The link provided will open the note in your browser. If your server is not configured with a public IP, the URL will refer to <code>localhost (127.0.0.1)</code>.</p></li></ol><h2>Sharing a note subtree</h2><p>When you share a note, you actually share the entire subtree of notes beneath it. If the note has child notes, they will also be included in the shared content. For example, sharing the \"Formatting\" subtree will display a page with basic navigation for exploring all the notes within that subtree.</p><h2>Viewing and managing shared notes</h2><p>You can view a list of all shared notes by clicking on \"Show Shared Notes Subtree\" in the <a class=\"reference-link\" href=\"#root/_help_x3i7MxGccDuM\">Global menu</a>. This allows you to manage and navigate through all the notes you have made public.</p><h2>Security considerations</h2><ul><li>Shared notes are published on the open internet and can be accessed by anyone with the URL unless the notes are password-protected.</li><li>The URL's randomness does not provide security, so it is crucial not to share sensitive information through this feature.</li><li>Trilium takes precautions to protect your publicly shared instance from leaking information for non-shared notes, including opening a separate read-only connection to the <a class=\"reference-link\" href=\"#root/_help_wX4HbRucYSDD\">Database</a>. Depending on your threat model, it might make more sense to use <a class=\"reference-link\" href=\"#root/_help_ycBFjKrrwE9p\">Exporting static HTML for web publishing</a> and use battle-tested web servers such as Nginx or Apache to serve static content.</li></ul><h3>Password protection</h3><p>To protect shared notes with a username and password, you can use the <code>#shareCredentials</code> attribute. Add this label to the note with the format <code>#shareCredentials=\"username:password\"</code>. To protect an entire subtree, make sure the label is <a href=\"#root/_help_bwZpz2ajCEwO\">inheritable</a>.</p><h2>Advanced sharing options</h2><h3>Customizing the appearance of shared notes</h3><p>The default design should be a good starting point, but you can customize it using your own CSS:</p><ul><li><strong>Custom CSS</strong>: Link a CSS <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> note to the shared page by adding a <code>~shareCss</code> relation to the note. If you want this style to apply to the entire subtree, make the label inheritable. You can hide the CSS code note from the tree navigation by adding the <code>#shareHiddenFromTree</code> label.</li><li><strong>Omitting Default CSS</strong>: For extensive styling changes, use the <code>#shareOmitDefaultCss</code> label to avoid conflicts with Trilium's <a href=\"#root/_help_Wy267RK4M69c\">default stylesheet</a>.</li></ul><h3>Adding JavaScript</h3><p>You can inject custom JavaScript into the shared note using the <code>~shareJs</code> relation. This allows you to access note attributes or traverse the note tree using the <code>fetchNote()</code> API, which retrieves note data based on its ID.</p><h3>Adding custom HTML</h3><p>You can inject custom HTML snippets into specific locations of the shared page using the <code>~shareHtml</code> relation. The HTML note should contain the raw HTML content you want to inject, and you can control where it appears by adding the <code>#shareHtmlLocation</code> label to the HTML snippet note itself.</p><p>The <code>#shareHtmlLocation</code> label accepts values in the format <code>location:position</code>:</p><ul><li><strong>Locations</strong>: <code>head</code>, <code>body</code>, <code>content</code></li><li><strong>Positions</strong>: <code>start</code>, <code>end</code></li></ul><p>For example:</p><ul><li><code>#shareHtmlLocation=head:start</code> - Injects HTML at the beginning of the <code><head></code> section</li><li><code>#shareHtmlLocation=head:end</code> - Injects HTML at the end of the <code><head></code> section (default)</li><li><code>#shareHtmlLocation=body:start</code> - Injects HTML at the beginning of the <code><body></code> section</li><li><code>#shareHtmlLocation=content:start</code> - Injects HTML at the beginning of the content area</li><li><code>#shareHtmlLocation=content:end</code> - Injects HTML at the end of the content area</li></ul><p>If no location is specified, the HTML will be injected at <code>content:end</code> by default.</p><p>Example:</p><pre><code class=\"language-text-javascript\">const currentNote = await fetchNote();\nconst parentNote = await fetchNote(currentNote.parentNoteIds[0]);\n\nfor (const attr of parentNote.attributes) {\n console.log(attr.type, attr.name, attr.value);\n}</code></pre><h3>Custom share templates</h3><p>To completely redesign the share, it is possible to create or use an existing <a href=\"#root/_help_Ad7Ku5gOHrDU\">custom share template</a>.</p><h3>Creating human-readable URL aliases</h3><p>Shared notes typically have URLs like <code>http://domain.tld/share/knvU8aJy4dJ7</code>, where the last part is the note's ID. You can make these URLs more user-friendly by adding the <code>#shareAlias</code> label to individual notes (e.g., <code>#shareAlias=highlighting</code>). This will change the URL to <code>http://domain.tld/share/highlighting</code>. The URL with the note's ID keeps working and redirects to the alias.</p><p><strong>Important</strong>:</p><ol><li>Ensure that aliases are unique.</li><li>Using slashes (<code>/</code>) within aliases to create subpaths is not supported.</li></ol><aside class=\"admonition tip\"><ul><li>To easily identify pages that don't have a share alias, run a <a class=\"reference-link\" href=\"#root/_help_eIg8jdvaoNNd\">Search</a> with <code>#!shareAlias</code>.</li><li>To be able to enter the share alias faster, consider using <a class=\"reference-link\" href=\"#root/_help_OFXdgB2nNk1F\">Promoted Attributes</a> (for example <code>#label:shareAlias(inheritable)=\"promoted,alias=Slug,single,text\"</code>).</li></ul></aside><h3>Setting a custom favicon</h3><p>To customize the favicon for your shared pages, create a relation <code>~shareFavicon</code> pointing to a file note containing the favicon (e.g., in <code>.ico</code> format).</p><h3>Sharing a note as the root</h3><p>You can designate a specific note or folder as the root of your shared content by adding the <code>#shareRoot</code> label. This note will be linked when visiting <code>[http://domain.tld/share](http://domain/share)</code>, making it easier to use Trilium as a fully-fledged website.</p><aside class=\"admonition tip\"><p>Consider combining this with the <code>#shareIndex</code> label, which will display a list of all shared notes.</p></aside><h3>Displaying an index of shared notes</h3><p>When accessing a share, the sub-notes will be displayed in a tree on the left. But since multiple note trees can be shared, it might be useful to display a list of all the different share trees.</p><p>To do so, create a shared text note and apply the <code>shareIndex</code> label. When viewed, the list of shared roots will be displayed at the bottom of the note.</p><h3>Linking to an external website</h3><p>Sometimes it's useful to include a link to an external website alongside your shared notes — for example in the shared navigation or in an index. To do so, add the <code>#shareExternalLink</code> label to a note, with the target URL as its value (e.g. <code>#shareExternalLink=\"https://example.com\"</code>).</p><p>Any link pointing to this note will then redirect to the external website and open in a new browser tab, instead of opening the note's own shared page. Opening the note's shared URL by its ID also redirects to the external website. This applies to:</p><ul><li>the listing produced by the <code>#shareIndex</code> label;</li><li>the navigation tree of the shared site;</li><li>the \"Subpages\" list shown under a parent note;</li><li>inline links to this note from within other shared notes.</li></ul><p>The URL must be absolute and include the scheme (e.g. <code>https://</code>).</p><aside class=\"admonition note\"><p>The note still exists in the share tree and its own page remains reachable by its direct URL — the label only changes how links to it behave.</p></aside><h2>Attribute reference</h2><figure class=\"table\"><table class=\"ck-table-resized\"><colgroup><col style=\"width:18.38%;\"><col style=\"width:81.62%;\"></colgroup><thead><tr><th>Attribute</th><th>Description</th></tr></thead><tbody><tr><td><code>#shareHiddenFromTree</code></td><td>this note is hidden from the left navigation tree, from its parent's list of subpages, from shared note maps and from the share's search, but still accessible with its URL</td></tr><tr><td><code>#shareExternalLink</code></td><td>when a link points to this note (from the share index, a subpage list, or an inline link in another shared note), it redirects to the given external URL in a new tab instead of the note's shared page. Value is the absolute URL, e.g. <code>https://example.com</code>.</td></tr><tr><td><code>#shareAlias</code></td><td>define an alias using which the note will be available under <code>https://your_trilium_host/share/[your_alias]</code></td></tr><tr><td><code>#shareOmitDefaultCss</code></td><td>default share page CSS will be omitted. Use when you make extensive styling changes.</td></tr><tr><td><code>#shareRoot</code></td><td>marks note which is served on /share root.</td></tr><tr><td><code>#shareDescription</code></td><td>define text to be added to the HTML meta tag for description. It also describes the note in the list of subpages of its parent, in place of the start of its text.</td></tr><tr><td><code>#shareRaw</code></td><td>Note will be served in its raw format, without HTML wrapper. See also <a class=\"reference-link\" href=\"#root/_help_Qjt68inQ2bRj\">Serving directly the content of a note</a> for an alternative method without setting an attribute.</td></tr><tr><td><code>#shareDisallowRobotIndexing</code></td><td><p>Indicates to web crawlers that the page should not be indexed of this note by:</p><ul><li>Setting the <code>X-Robots-Tag: noindex</code> HTTP header.</li><li>Setting the <code>noindex, follow</code> meta tag.</li></ul></td></tr><tr><td><code>#shareCredentials</code></td><td>require credentials to access this shared note. Value is expected to be in format <code>username:password</code>. Don't forget to make this inheritable to apply to child-notes/images.</td></tr><tr><td><code>#shareIndex</code></td><td>Note with this label will list all roots of shared notes.</td></tr><tr><td><code>#shareHtmlLocation</code></td><td>defines where custom HTML injected via <code>~shareHtml</code> relation should be placed. Applied to the HTML snippet note itself. Format: <code>location:position</code> where location is <code>head</code>, <code>body</code>, or <code>content</code> and position is <code>start</code> or <code>end</code>. Defaults to <code>content:end</code>.</td></tr></tbody></table></figure><h3>Customizing logo</h3><p>It's possible to adjust the logo which is displayed above the navigation tree (in the header, on a narrow screen).</p><figure class=\"table\"><table><thead><tr><th>Attribute</th><th>Description</th></tr></thead><tbody><tr><td><code>~shareLogo</code></td><td>Relation set to an image to use as logo. The image must be part of the share tree (it can be hidden if needed). Without it, the logo is the icon of the shared root note.</td></tr><tr><td><code>#shareLogoWidth</code></td><td>The width of the logo, as a number without unit. With <code>#shareLogoHeight</code>, it sets the proportions of the logo, which is shown 32 pixels wide. Default is <code>53</code>.</td></tr><tr><td><code>#shareLogoHeight</code></td><td>The height of the logo, as a number without unit. With <code>#shareLogoWidth</code>, it sets the proportions of the logo. Default is <code>40</code>.</td></tr><tr><td><code>#shareRootLink</code></td><td>URL to navigate to when the logo is pressed.</td></tr></tbody></table></figure><h3>Customizing OpenGraph</h3><p>A meta-property is left out of the page when its attribute is not set. Without an image, link previews use a small card.</p><figure class=\"table\"><table><thead><tr><th>Attribute</th><th>Description</th></tr></thead><tbody><tr><td><code>#shareOpenGraphColor</code></td><td>This adjusts the <code>theme-color</code> meta-property.</td></tr><tr><td><code>#shareOpenGraphURL</code></td><td>This adjusts the <code>og:url</code> and <code>twitter:url</code> meta-properties. It is also the address a relative <code>og:image</code> is completed with, so it should be the public address of the shared site, such as <code>https://example.com/share/</code>.</td></tr><tr><td><code>#shareOpenGraphDomain</code></td><td>Adjusts the <code>twitter:domain</code> meta-property.</td></tr><tr><td><code>#shareOpenGraphImage</code> <br><code>~shareOpenGraphImage</code></td><td>Can be either a label with the address of an image, or a relation to an image <a class=\"reference-link\" href=\"#root/_help_W8vYD3Q1zjCR\">File</a>. This controls the <code>og:image</code> meta-property. Sites that show a preview of the link load the image from their own servers, so a relative address, which the relation always gives, is completed with <code>#shareOpenGraphURL</code>; without it, the image does not show in such previews.</td></tr></tbody></table></figure><h2>Credits</h2><p>Since v0.95.0, a new theme was introduced (and enabled by default) which greatly improves the visual aspect of the Share feature, as well as its functionality (such as mobile support, dark/light mode, collapsible tree, etc.). This theme is an adaptation of the <a href=\"https://github.com/zerebos/trilium.rocks\">Trilium Rocks!</a> by <a href=\"https://github.com/zerebos\">zerebos</a>.</p>",+ "_help_R9pX4DGra2Vt": "<p>Trilium allows you to share selected notes as <strong>publicly accessible</strong> read-only documents. This feature is particularly useful for publishing content directly from your Trilium notes, making it accessible to others online.</p><figure class=\"image\"><img style=\"aspect-ratio:1144/660;\" src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Sharing_image.png\" width=\"1144\" height=\"660\"></figure><h2>Features, interaction and limitations</h2><ul><li>Searching by note title.</li><li>Light and dark mode, following the visitor's system setting by default, also while the page is open. The visitor can pick <em>Light</em>, <em>Dark</em> or <em>System</em> with the buttons at the top of the navigation pane; the choice is remembered by the browser.</li><li>A layout centered on wide screens, with the navigation tree and the table of contents at either side of the content, and a mobile-friendly layout on narrow ones. There, the navigation tree slides in from the menu button in the header, and lists the headings of the current page below its entry (at the top of the pane, for a page the tree does not show).</li><li>Collapsible tree with the same note icons as the application. It keeps the sections the visitor expanded and its scroll position while they move between the pages of the site, and shows the current note.</li><li>Customizable logo.</li><li>Quick navigation buttons (previous and next note).</li><li>Notes that hide their children from the tree with <code>#subtreeHidden</code> (such as a <a class=\"reference-link\" href=\"#root/_help_CtBQqbwXDx1w\">Kanban Board</a>) show a badge counting them in place of listing them. The page of one of those children shows only that child below its parent, and the previous and next buttons skip them.</li><li>The subpages of a text or code note shown below its content as cards, as in the application. Each card shows the icon of the subpage and the start of its text (or its <code>#shareDescription</code>), or, for a subpage without text, links to its own first subpages. The cards can be hidden with <code>#hideChildrenOverview</code>.</li><li>Displaying the date of the last update of the note, written out in the application's language.</li><li>Marking the page with the application's language and its text direction, and the content of the note with its own <a href=\"#root/_help_veGu4faJErEM\">content language</a>, for screen readers and right-to-left text.</li></ul><h3>By note type</h3><figure class=\"table\"><table class=\"ck-table-resized\"><colgroup><col style=\"width:19.92%;\"><col style=\"width:41.66%;\"><col style=\"width:38.42%;\"></colgroup><thead><tr><th> </th><th>Supported features</th><th>Limitations</th></tr></thead><tbody><tr><th><a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a></th><td><ul><li>Table of contents.</li><li>A link next to each heading, shown while the pointer is over the heading. Clicking it shows the address of the section in the address bar of the browser and copies it, to share a link to the section.</li><li>Syntax highlight of code blocks, in the language selected for each block and in the colors of the VS Code light or dark theme, following the page's mode. For “Auto-detected” blocks, the language is guessed among the ones enabled in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Code Notes</em>; a language not enabled there is not highlighted.</li><li>Rendering for math equations.</li><li><a href=\"#root/_help_nBAXQFj20hS1\">Including notes</a> (only if the included notes are also shared).</li><li>Drawing canvases, shown as pictures at their own size.</li><li>Mermaid diagrams in code blocks, drawn in the page's light or dark mode and redrawn when the visitor switches it.</li></ul></td><td> </td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a></th><td><ul><li>Syntax highlight with line numbers, in the language of the note and in the colors of the VS Code light or dark theme, following the page's mode. A language not enabled in <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Code Notes</em> is not highlighted.</li></ul></td><td> </td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_m523cpzocqaD\">Saved Search</a></th><td>Not supported.</td><td> </td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_iRwzGnHPzonm\">Relation Map</a></th><td>Not supported.</td><td> </td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_bdUJEHsAPYQR\">Note Map</a></th><td>Not supported.</td><td> </td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a></th><td>Not supported.</td><td> </td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a></th><td><ul><li>The child notes are shown as cards, or as a list when the view type of the collection is <em>List</em>. Each shows its icon and the start of its text (or its <code>#shareDescription</code>), or, for a child note without text, links to its own first child notes.</li></ul></td><td><ul><li>The calendar, table, board, geo map, dashboard and presentation view types are shown as in the app, but read-only.</li></ul></td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_s1aBHPd79XYj\">Mermaid Diagrams</a></th><td><ul><li>The diagram is drawn in the page's light or dark mode and redrawn when the visitor switches it. In browsers with JavaScript disabled, the image saved when the note was last edited is shown instead, and the source of the diagram can be expanded below it.</li><li>The diagram fills the page and can be zoomed with the <span class=\"tn-icon bx bx-minus-circle\"></span> and <span class=\"tn-icon bx bx-plus-circle\"></span> buttons in its bottom corner or with the mouse wheel, between 50% and 1000% of its fitted size, and on touch screens by pinching. Clicking the percentage between the buttons, or double-clicking the diagram, shows it whole again. The diagram can be panned by dragging it.</li></ul></td><td> </td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_grjYqerjn243\">Canvas</a></th><td><ul><li>The diagram is displayed as a vector image.</li></ul></td><td><ul><li>No further interaction supported.</li></ul></td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_1vHRoWCEjj0L\">Web View</a></th><td>Not supported.</td><td> </td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_gBbsAeiuUxI5\">Mind Map</a></th><td>The diagram is displayed as a vector image.</td><td><ul><li>No further interaction supported.</li></ul></td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_81SGnPGMk7Xc\">Geo Map</a></th><td>Not supported.</td><td> </td></tr><tr><th><a class=\"reference-link\" href=\"#root/_help_W8vYD3Q1zjCR\">File</a></th><td>Basic interaction (downloading the file).</td><td><ul><li>No further interaction supported.</li></ul></td></tr></tbody></table></figure><p>While the sharing feature is powerful, it has some limitations:</p><ul><li><strong>Static Note Tree</strong></li><li><strong>Protected Notes</strong>: Cannot be shared.</li><li><strong>Include Notes</strong>: Not supported.</li></ul><p>Some of these limitations may be addressed in future updates.</p><h2>Prerequisites</h2><p>To use the sharing feature, you must have a <a class=\"reference-link\" href=\"#root/_help_WOcw2SLH6tbX\">Server Installation</a> of Trilium. This is necessary because the notes will be hosted from the server.</p><h2>Sharing a note</h2><ol><li><p><strong>Enable Sharing</strong>: To share a note, toggle the <code>Shared</code> switch within the note's interface. Once sharing is enabled, an URL will appear, which you can click to access the shared note.</p><p><img src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Sharing_share-single-note.png\" alt=\"Share Note\"></p></li><li><p><strong>Access the Shared Note</strong>: The link provided will open the note in your browser. If your server is not configured with a public IP, the URL will refer to <code>localhost (127.0.0.1)</code>.</p></li></ol><h2>Sharing a note subtree</h2><p>When you share a note, you actually share the entire subtree of notes beneath it. If the note has child notes, they will also be included in the shared content. For example, sharing the \"Formatting\" subtree will display a page with basic navigation for exploring all the notes within that subtree.</p><h2>Viewing and managing shared notes</h2><p>You can view a list of all shared notes by clicking on \"Show Shared Notes Subtree\" in the <a class=\"reference-link\" href=\"#root/_help_x3i7MxGccDuM\">Global menu</a>. This allows you to manage and navigate through all the notes you have made public.</p><h2>Security considerations</h2><ul><li>Shared notes are published on the open internet and can be accessed by anyone with the URL unless the notes are password-protected.</li><li>The URL's randomness does not provide security, so it is crucial not to share sensitive information through this feature.</li><li>Trilium takes precautions to protect your publicly shared instance from leaking information for non-shared notes, including opening a separate read-only connection to the <a class=\"reference-link\" href=\"#root/_help_wX4HbRucYSDD\">Database</a>. Depending on your threat model, it might make more sense to use <a class=\"reference-link\" href=\"#root/_help_ycBFjKrrwE9p\">Exporting static HTML for web publishing</a> and use battle-tested web servers such as Nginx or Apache to serve static content.</li></ul><h3>Password protection</h3><p>To protect shared notes with a username and password, you can use the <code>#shareCredentials</code> attribute. Add this label to the note with the format <code>#shareCredentials=\"username:password\"</code>. To protect an entire subtree, make sure the label is <a href=\"#root/_help_bwZpz2ajCEwO\">inheritable</a>.</p><h2>Advanced sharing options</h2><h3>Customizing the appearance of shared notes</h3><p>The default design should be a good starting point, but you can customize it using your own CSS:</p><ul><li><strong>Custom CSS</strong>: Link a CSS <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> note to the shared page by adding a <code>~shareCss</code> relation to the note. If you want this style to apply to the entire subtree, make the label inheritable. You can hide the CSS code note from the tree navigation by adding the <code>#shareHiddenFromTree</code> label.</li><li><strong>Omitting Default CSS</strong>: For extensive styling changes, use the <code>#shareOmitDefaultCss</code> label to avoid conflicts with Trilium's <a href=\"#root/_help_Wy267RK4M69c\">default stylesheet</a>.</li></ul><h3>Adding JavaScript</h3><p>You can inject custom JavaScript into the shared note using the <code>~shareJs</code> relation. This allows you to access note attributes or traverse the note tree using the <code>fetchNote()</code> API, which retrieves note data based on its ID.</p><h3>Adding custom HTML</h3><p>You can inject custom HTML snippets into specific locations of the shared page using the <code>~shareHtml</code> relation. The HTML note should contain the raw HTML content you want to inject, and you can control where it appears by adding the <code>#shareHtmlLocation</code> label to the HTML snippet note itself.</p><p>The <code>#shareHtmlLocation</code> label accepts values in the format <code>location:position</code>:</p><ul><li><strong>Locations</strong>: <code>head</code>, <code>body</code>, <code>content</code></li><li><strong>Positions</strong>: <code>start</code>, <code>end</code></li></ul><p>For example:</p><ul><li><code>#shareHtmlLocation=head:start</code> - Injects HTML at the beginning of the <code><head></code> section</li><li><code>#shareHtmlLocation=head:end</code> - Injects HTML at the end of the <code><head></code> section (default)</li><li><code>#shareHtmlLocation=body:start</code> - Injects HTML at the beginning of the <code><body></code> section</li><li><code>#shareHtmlLocation=content:start</code> - Injects HTML at the beginning of the content area</li><li><code>#shareHtmlLocation=content:end</code> - Injects HTML at the end of the content area</li></ul><p>If no location is specified, the HTML will be injected at <code>content:end</code> by default.</p><p>Example:</p><pre><code class=\"language-text-javascript\">const currentNote = await fetchNote();\nconst parentNote = await fetchNote(currentNote.parentNoteIds[0]);\n\nfor (const attr of parentNote.attributes) {\n console.log(attr.type, attr.name, attr.value);\n}</code></pre><h3>Custom share templates</h3><p>To completely redesign the share, it is possible to create or use an existing <a href=\"#root/_help_Ad7Ku5gOHrDU\">custom share template</a>.</p><h3>Creating human-readable URL aliases</h3><p>Shared notes typically have URLs like <code>http://domain.tld/share/knvU8aJy4dJ7</code>, where the last part is the note's ID. You can make these URLs more user-friendly by adding the <code>#shareAlias</code> label to individual notes (e.g., <code>#shareAlias=highlighting</code>). This will change the URL to <code>http://domain.tld/share/highlighting</code>. The URL with the note's ID keeps working and redirects to the alias.</p><p><strong>Important</strong>:</p><ol><li>Ensure that aliases are unique.</li><li>Using slashes (<code>/</code>) within aliases to create subpaths is not supported.</li></ol><aside class=\"admonition tip\"><ul><li>To easily identify pages that don't have a share alias, run a <a class=\"reference-link\" href=\"#root/_help_eIg8jdvaoNNd\">Search</a> with <code>#!shareAlias</code>.</li><li>To be able to enter the share alias faster, consider using <a class=\"reference-link\" href=\"#root/_help_OFXdgB2nNk1F\">Promoted Attributes</a> (for example <code>#label:shareAlias(inheritable)=\"promoted,alias=Slug,single,text\"</code>).</li></ul></aside><h3>Setting a custom favicon</h3><p>To customize the favicon for your shared pages, create a relation <code>~shareFavicon</code> pointing to a file note containing the favicon (e.g., in <code>.ico</code> format).</p><h3>Sharing a note as the root</h3><p>You can designate a specific note or folder as the root of your shared content by adding the <code>#shareRoot</code> label. This note will be linked when visiting <code>[http://domain.tld/share](http://domain/share)</code>, making it easier to use Trilium as a fully-fledged website.</p><aside class=\"admonition tip\"><p>Consider combining this with the <code>#shareIndex</code> label, which will display a list of all shared notes.</p></aside><h3>Displaying an index of shared notes</h3><p>When accessing a share, the sub-notes will be displayed in a tree on the left. But since multiple note trees can be shared, it might be useful to display a list of all the different share trees.</p><p>To do so, create a shared text note and apply the <code>shareIndex</code> label. When viewed, the list of shared roots will be displayed at the bottom of the note.</p><h3>Linking to an external website</h3><p>Sometimes it's useful to include a link to an external website alongside your shared notes — for example in the shared navigation or in an index. To do so, add the <code>#shareExternalLink</code> label to a note, with the target URL as its value (e.g. <code>#shareExternalLink=\"https://example.com\"</code>).</p><p>Any link pointing to this note will then redirect to the external website and open in a new browser tab, instead of opening the note's own shared page. Opening the note's shared URL by its ID also redirects to the external website. This applies to:</p><ul><li>the listing produced by the <code>#shareIndex</code> label;</li><li>the navigation tree of the shared site;</li><li>the \"Subpages\" list shown under a parent note;</li><li>inline links to this note from within other shared notes.</li></ul><p>The URL must be absolute and include the scheme (e.g. <code>https://</code>).</p><aside class=\"admonition note\"><p>The note still exists in the share tree and its own page remains reachable by its direct URL — the label only changes how links to it behave.</p></aside><h2>Attribute reference</h2><figure class=\"table\"><table class=\"ck-table-resized\"><colgroup><col style=\"width:18.38%;\"><col style=\"width:81.62%;\"></colgroup><thead><tr><th>Attribute</th><th>Description</th></tr></thead><tbody><tr><td><code>#shareHiddenFromTree</code></td><td>this note is hidden from the left navigation tree, from its parent's list of subpages, from shared note maps and from the share's search, but still accessible with its URL</td></tr><tr><td><code>#shareExternalLink</code></td><td>when a link points to this note (from the share index, a subpage list, or an inline link in another shared note), it redirects to the given external URL in a new tab instead of the note's shared page. Value is the absolute URL, e.g. <code>https://example.com</code>.</td></tr><tr><td><code>#shareAlias</code></td><td>define an alias using which the note will be available under <code>https://your_trilium_host/share/[your_alias]</code></td></tr><tr><td><code>#shareOmitDefaultCss</code></td><td>default share page CSS will be omitted. Use when you make extensive styling changes.</td></tr><tr><td><code>#shareRoot</code></td><td>marks note which is served on /share root.</td></tr><tr><td><code>#shareDescription</code></td><td>define text to be added to the HTML meta tag for description. It also describes the note in the list of subpages of its parent, in place of the start of its text.</td></tr><tr><td><code>#shareRaw</code></td><td>Note will be served in its raw format, without HTML wrapper. See also <a class=\"reference-link\" href=\"#root/_help_Qjt68inQ2bRj\">Serving directly the content of a note</a> for an alternative method without setting an attribute.</td></tr><tr><td><code>#shareDisallowRobotIndexing</code></td><td><p>Indicates to web crawlers that the page should not be indexed of this note by:</p><ul><li>Setting the <code>X-Robots-Tag: noindex</code> HTTP header.</li><li>Setting the <code>noindex, follow</code> meta tag.</li></ul></td></tr><tr><td><code>#shareCredentials</code></td><td>require credentials to access this shared note. Value is expected to be in format <code>username:password</code>. Don't forget to make this inheritable to apply to child-notes/images.</td></tr><tr><td><code>#shareIndex</code></td><td>Note with this label will list all roots of shared notes.</td></tr><tr><td><code>#shareHtmlLocation</code></td><td>defines where custom HTML injected via <code>~shareHtml</code> relation should be placed. Applied to the HTML snippet note itself. Format: <code>location:position</code> where location is <code>head</code>, <code>body</code>, or <code>content</code> and position is <code>start</code> or <code>end</code>. Defaults to <code>content:end</code>.</td></tr></tbody></table></figure><h3>Customizing logo</h3><p>It's possible to adjust the logo which is displayed above the navigation tree (in the header, on a narrow screen).</p><figure class=\"table\"><table><thead><tr><th>Attribute</th><th>Description</th></tr></thead><tbody><tr><td><code>~shareLogo</code></td><td>Relation set to an image to use as logo. The image must be part of the share tree (it can be hidden if needed). Without it, the logo is the icon of the shared root note.</td></tr><tr><td><code>#shareLogoWidth</code></td><td>The width of the logo, as a number without unit. With <code>#shareLogoHeight</code>, it sets the proportions of the logo, which is shown 32 pixels wide. Default is <code>53</code>.</td></tr><tr><td><code>#shareLogoHeight</code></td><td>The height of the logo, as a number without unit. With <code>#shareLogoWidth</code>, it sets the proportions of the logo. Default is <code>40</code>.</td></tr><tr><td><code>#shareRootLink</code></td><td>URL to navigate to when the logo is pressed.</td></tr></tbody></table></figure><h3>Customizing OpenGraph</h3><p>A meta-property is left out of the page when its attribute is not set. Without an image, link previews use a small card.</p><figure class=\"table\"><table><thead><tr><th>Attribute</th><th>Description</th></tr></thead><tbody><tr><td><code>#shareOpenGraphColor</code></td><td>This adjusts the <code>theme-color</code> meta-property.</td></tr><tr><td><code>#shareOpenGraphURL</code></td><td>This adjusts the <code>og:url</code> and <code>twitter:url</code> meta-properties. It is also the address a relative <code>og:image</code> is completed with, so it should be the public address of the shared site, such as <code>https://example.com/share/</code>.</td></tr><tr><td><code>#shareOpenGraphDomain</code></td><td>Adjusts the <code>twitter:domain</code> meta-property.</td></tr><tr><td><code>#shareOpenGraphImage</code> <br><code>~shareOpenGraphImage</code></td><td>Can be either a label with the address of an image, or a relation to an image <a class=\"reference-link\" href=\"#root/_help_W8vYD3Q1zjCR\">File</a>. This controls the <code>og:image</code> meta-property. Sites that show a preview of the link load the image from their own servers, so a relative address, which the relation always gives, is completed with <code>#shareOpenGraphURL</code>; without it, the image does not show in such previews.</td></tr></tbody></table></figure><h2>Credits</h2><p>Since v0.95.0, a new theme was introduced (and enabled by default) which greatly improves the visual aspect of the Share feature, as well as its functionality (such as mobile support, dark/light mode, collapsible tree, etc.). This theme is an adaptation of the <a href=\"https://github.com/zerebos/trilium.rocks\">Trilium Rocks!</a> by <a href=\"https://github.com/zerebos\">zerebos</a>.</p>","_help_Qjt68inQ2bRj": "<p>When accessing a shared note, Trilium will render it as a web page. Sometimes it's desirable to serve the content directly so that it can be used in a script or downloaded by the user.</p><figure class=\"table\"><table><thead><tr><th>A note displayed as a web page (HTML)</th><th>A note displayed as a raw format</th></tr></thead><tbody><tr><td><figure class=\"image\"><img style=\"aspect-ratio:738/275;\" src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Sharing/Serving%20directly%20the%20content%20of%20a%20note_image.png\" width=\"738\" height=\"275\"></figure></td><td><img src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Sharing/Serving%20directly%20the%20content%20of%20a%20note_image.jpg\"></td></tr></tbody></table></figure><h2>By adding an attribute to the note</h2><p>Simply add the <code>#shareRaw</code> attribute and the note will always be rendered <em>raw</em> when accessed from the share URL.</p><h2>By altering the URL</h2><p>Append <code>?raw</code> to the URL to display a note in its raw format regardless of whether the <code>#shareRaw</code> attribute is added on the note.</p><p><img src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Sharing/Serving%20directly%20the%20content%20of%20a%20note_image.jpg\"></p>","_help_ycBFjKrrwE9p": "<p>As described in <a class=\"reference-link\" href=\"#root/_help_R9pX4DGra2Vt\">Sharing</a>, Trilium can act as a public server in which the shared notes are displayed in read-only mode. While this can work in most cases, it's generally not meant for high-traffic websites and since it's running on a Node.js server it can be potentially exploited.</p><p>Another alternative is to generate static HTML files (just like other static site generators such as <a href=\"https://www.mkdocs.org/\">MkDocs</a>). Since the normal HTML ZIP export does not contain any styling or additional functionality, Trilium provides a way to export the same layout and style as the <a class=\"reference-link\" href=\"#root/_help_R9pX4DGra2Vt\">Sharing</a> function into static HTML files.</p><p>Apart from the enhanced security, these HTML files are also easy to deploy on “serverless” deployments such as GitHub Pages or CloudFlare Pages and cache very easily.</p><aside class=\"admonition tip\"><p>Trilium's documentation, available at <a href=\"https://docs.triliumnotes.org/\">docs.triliumnotes.org</a> is built using this function of exporting to static HTML files which are then deployed automatically to CloudFlare Pages.</p><p>The process is <a href=\"https://github.com/TriliumNext/Trilium/blob/main/apps/edit-docs/src/build-docs.ts\">automated</a> by importing the Markdown documentation and exporting it via a script to the static web format.</p></aside><h2>Differences from normal sharing</h2><p>Apart from normal <a class=\"reference-link\" href=\"#root/_help_R9pX4DGra2Vt\">Sharing</a>, exporting to static HTML files comes with a few subtle differences:</p><ul><li>The URL structure is different. Where in normal sharing it's something along the way of <code>example.com/share/noteid</code>, the notes follow an hierarchical structure, such as <code>docs.triliumnotes.org/user-guide/concepts/navigation/tree-concepts</code>.</li><li>The <code>favicon.ico</code> is not handled automatically, it needs to be manually added on the server after the export is generated.</li><li>The “Last updated” for notes is not available.</li><li>The search functionality works slightly different since the normal one requires an active API to work. In the static export, search still works but uses a different mechanism so results might be different.</li></ul><h2>Differences from normal .zip export</h2><ul><li>The name of the files/URLs will prefer <code>shareAlias</code> to allow for clean URLs.</li><li>The export requires a functional web server as the pages will not render properly if accessed locally via a web browser due to the use of module scripts.</li><li>The directory structure is also slightly different:<ul><li>A normal HTML export results in an index file and a single directory.</li><li>Instead, for static exporting the top-root level becomes the index file and the child directories are on the root instead.</li><li>This makes it possible to easily publish to a website, without forcing everything but the root note to be in a sub-directory.</li></ul></li></ul><h2>Testing locally</h2><p>As mentioned previously, the exported static pages require a website to function. In order to test locally, a web server needs to be used.</p><p>One example is to use the Node.js-based <a href=\"https://www.npmjs.com/package/http-server\"><code>http-server</code></a> which can be installed via:</p><pre><code class=\"language-text-x-trilium-auto\">npm i -g http-server</code></pre><p>Once installed simply:</p><ol><li>Extract the exported .zip file.</li><li>Inside the extracted directory, run <code>http-server</code>.</li><li>Access the indicated address (e.g. <a href=\"http://localhost:8080\">http://localhost:8080</a>).</li></ol><h2>Automation</h2><p><a class=\"reference-link\" href=\"#root/_help_pgxEVkzLl1OP\">ETAPI (REST API)</a> could potentially be used to automate an export on a scheduled task.</p>","_help_sLIJ6f1dkJYW": "<p>It might be desirable to only expose the share functionality of Trilium to the Internet, and keep the application accessible only within a local network or via VPN.</p><p>To do so, a reverse proxy is required.</p><h2>Caddy</h2><pre><code class=\"language-text-x-trilium-auto\">http://domain.com {\n reverse_proxy /share http://localhost:8080/share\n}</code></pre><p>This is for newer versions where the share functionality is isolated, for older versions it's required to also include <code>/assets</code>.<a href=\"#fn2b8mg20aol8\"><sup>[1]</sup></a></p><ol><li><p><a href=\"#fnref2b8mg20aol8\"><strong><sup>^</sup></strong></a></p><p><a href=\"https://github.com/orgs/TriliumNext/discussions/7341#discussioncomment-14679897\">https://github.com/orgs/TriliumNext/discussions/7341#discussioncomment-14679897</a></p></li></ol>",diff --git a/docs/User Guide/User Guide/Advanced Usage/Sharing.md b/docs/User Guide/User Guide/Advanced Usage/Sharing.mdindex ae7916b119..158b1ac47f 100644--- a/docs/User Guide/User Guide/Advanced Usage/Sharing.md+++ b/docs/User Guide/User Guide/Advanced Usage/Sharing.md@@ -39,8 +39,8 @@ Trilium allows you to share selected notes as **publicly accessible** read-only</tr><tr><th><a class="reference-link" href="../Note%20Types/Code.md">Code</a></th>- <td><ul><li>Basic support (displaying the contents of the note in a monospace font).</li></ul></td>- <td><ul><li>No syntax highlight.</li></ul></td>+ <td><ul><li>Syntax highlight with line numbers, in the language of the note and in the colors of the VS Code light or dark theme, following the page's mode. A language not enabled in <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Options.md">Options</a> → <em>Code Notes</em> is not highlighted.</li></ul></td>+ <td> </td></tr><tr><th><a class="reference-link" href="../Note%20Types/Saved%20Search.md">Saved Search</a></th>@@ -102,7 +102,6 @@ Trilium allows you to share selected notes as **publicly accessible** read-onlyWhile the sharing feature is powerful, it has some limitations:-* **Code Notes**: No syntax highlighting.* **Static Note Tree*** **Protected Notes**: Cannot be shared.* **Include Notes**: Not supported.diff --git a/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Printing & Exporting as PDF.md b/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Printing & Exporting as PDF.mdindex 48b58cb37c..a96018df02 100644--- a/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Printing & Exporting as PDF.md+++ b/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Printing & Exporting as PDF.md@@ -96,9 +96,7 @@ It's possible to trigger both printing and export as PDF from the keyboard by goNot all <a class="reference-link" href="../../Note%20Types.md">Note Types</a> are supported when printing, in which case the _Print_ and _Export as PDF_ options will be disabled.* For <a class="reference-link" href="../../Note%20Types/Text.md">Text</a> notes, font, background and table colors are printed in the shades of light themes, whatever the current theme (see <a class="reference-link" href="../../Note%20Types/Text/General%20formatting.md">General formatting</a>).-* For <a class="reference-link" href="../../Note%20Types/Code.md">Code</a> notes:- * Line numbers are not printed.- * Syntax highlighting is enabled, however a default theme (Visual Studio) is enforced.+* <a class="reference-link" href="../../Note%20Types/Code.md">Code</a> notes are printed with line numbers and syntax highlighting, in the _Light theme_ of <a class="reference-link" href="../UI%20Elements/Options.md">Options</a> → _Code Notes_ → _Appearance_, whatever the current theme.* A <a class="reference-link" href="../../Note%20Types/Render%20Note.md">Render Note</a> is printed as it is displayed, without running its script again, once its `~renderNote` relation is set.* For <a class="reference-link" href="../../Collections.md">Collections</a>, the following are supported:* <a class="reference-link" href="../../Collections/List%20View.md">List View</a>, allowing to print multiple notes at once while preserving hierarchy (similar to a book).diff --git a/docs/User Guide/User Guide/Collections/Grid View.md b/docs/User Guide/User Guide/Collections/Grid View.mdindex f702a9482a..7930e27d87 100644--- a/docs/User Guide/User Guide/Collections/Grid View.md+++ b/docs/User Guide/User Guide/Collections/Grid View.md@@ -12,7 +12,7 @@ Each tile contains:Depending on the type of note:* For <a class="reference-link" href="../Note%20Types/Text.md">Text</a> notes, the text can be slightly scrollable via the mouse wheel to reveal more context.-* For <a class="reference-link" href="../Note%20Types/Code.md">Code</a> notes, syntax highlighting is applied.+* For <a class="reference-link" href="../Note%20Types/Code.md">Code</a> notes, syntax highlighting is applied, with line numbers.* For <a class="reference-link" href="../Note%20Types/File.md">File</a> notes, a preview is made available for audio, video and PDF notes.* If the note does not have a content, a list of its child notes will be displayed instead.diff --git a/docs/User Guide/User Guide/Note Types/Code.md b/docs/User Guide/User Guide/Note Types/Code.mdindex 3aebc17f5c..687015ea0b 100644--- a/docs/User Guide/User Guide/Note Types/Code.md+++ b/docs/User Guide/User Guide/Note Types/Code.md@@ -70,6 +70,8 @@ When you re-indent content, the editor:Since Trilium 0.94.0 the colors of code notes can be customized by going <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Options.md">Options</a> → Code Notes and looking for the _Appearance_ section.+A code note or a code file shown without its editor, such as in an <a class="reference-link" href="Text/Include%20Note.md">Include Note</a>, on the cards of <a class="reference-link" href="../Collections.md">Collections</a> or in a tooltip, uses the same colors and shows line numbers, as the editor does. A printout uses the _Light theme_. A [shared page](../Advanced%20Usage/Sharing.md) uses the VS Code light or dark theme, following the mode of the page.+> [!NOTE]> **Why are there only a few themes whereas the code block themes for text notes have a lot?**> The reason is that Code notes use a different technology than the one used in Text notes, and as such there is a more limited selection of themes. If you find a CodeMirror 6 (not 5) theme that you would like to use, let us know and we might consider adding it to the set of default themes. There is no possibility of adding new themes (at least for now), since the themes are defined in JavaScript and not at CSS level.diff --git a/docs/User Guide/User Guide/Note Types/Text/Include Note.md b/docs/User Guide/User Guide/Note Types/Text/Include Note.mdindex 12670bebe3..b5c45bec64 100644--- a/docs/User Guide/User Guide/Note Types/Text/Include Note.md+++ b/docs/User Guide/User Guide/Note Types/Text/Include Note.md@@ -106,7 +106,7 @@ In a _Small_ or _Medium_ box, the image is scaled down to fit the height of the## Editing an include in place-An included text note, an included code note and an embedded code file such as a `.js`, `.py` or `.txt` attachment can be edited without leaving the note that includes them. A code note or file is shown with syntax highlighting until then. Included Markdown can be edited too, see _Included Markdown_ below.+An included text note, an included code note and an embedded code file such as a `.js`, `.py` or `.txt` attachment can be edited without leaving the note that includes them. A code note or file is shown with syntax highlighting and line numbers until then, in the colors of the code editor. Included Markdown can be edited too, see _Included Markdown_ below.* To edit, select the include and turn on the <span class="tn-icon bx bx-edit-alt"></span> _Editable_ button at the start of its toolbar, or check _Editable_ in its <span class="tn-icon cke cke-three-vertical-dots"></span> _More actions_ menu. Turn _Editable_ off to return to the preview.* While _Editable_ is on, the arrow keys move the caret into the include and back out, as through the rest of the text. Entering from above or from the left puts the caret at the start of the include, and entering from below or from the right puts it at the end. A collapsed _Expandable_ include is skipped.diff --git a/packages/codemirror/package.json b/packages/codemirror/package.jsonindex 5bb9844aa1..0e8f265482 100644--- a/packages/codemirror/package.json+++ b/packages/codemirror/package.json@@ -15,6 +15,7 @@"@codemirror/lang-javascript": "6.2.5","@codemirror/lang-json": "6.0.2","@codemirror/lang-markdown": "6.5.2",+ "@codemirror/language": "6.13.1","@codemirror/language-data": "6.5.2","@codemirror/lang-php": "6.0.2","@codemirror/lang-vue": "0.1.3",@@ -56,6 +57,7 @@"@fsegurai/codemirror-theme-volcano": "6.2.7","@fsegurai/codemirror-theme-vscode-dark": "6.2.8","@fsegurai/codemirror-theme-vscode-light": "6.2.8",+ "@lezer/highlight": "1.2.5","@replit/codemirror-indentation-markers": "6.5.3","@replit/codemirror-lang-nix": "6.0.1","@replit/codemirror-vim": "6.4.0",diff --git a/packages/codemirror/src/code_preview.css b/packages/codemirror/src/code_preview.cssnew file mode 100644index 0000000000..c86ec2d384--- /dev/null+++ b/packages/codemirror/src/code_preview.css@@ -0,0 +1,60 @@+:where(:root) {+ --code-preview-background: transparent;+ --code-preview-foreground: currentColor;+ --code-preview-gutter-background: transparent;+ --code-preview-gutter-foreground: currentColor;+ --code-preview-gutter-border-width: 0px;+ --code-preview-gutter-border-color: transparent;+ --code-preview-line-height: 1.4;+}++:root pre.code-preview {+ display: flex;+ flex-direction: column;+ padding: 0;++ /* Outranks `:root .ck-content pre code` of the app and share themes. */+ > .code-preview-content {+ --code-preview-gutter-width: calc((var(--code-preview-digits, 1) + 1) * 1ch + 18px);++ display: block;+ flex-grow: 1;+ margin: 0;+ border-radius: inherit;+ padding-block: 4px;+ padding-inline: calc(var(--code-preview-gutter-width) + 6px) 2px;+ direction: ltr;+ color: var(--code-preview-foreground);+ background:+ linear-gradient(+ to right,+ var(--code-preview-gutter-background) 0+ calc(var(--code-preview-gutter-width) - var(--code-preview-gutter-border-width)),+ var(--code-preview-gutter-border-color) 0 var(--code-preview-gutter-width),+ transparent 0+ ) local,+ var(--code-preview-background);+ line-height: var(--code-preview-line-height);+ white-space: pre;+ overflow: auto;+ counter-reset: code-preview-line;+ }++ &.code-preview-wrap > .code-preview-content {+ white-space: pre-wrap;+ overflow-wrap: anywhere;+ }+}++.code-preview-line::before {+ display: inline-block;+ box-sizing: border-box;+ margin-inline: calc(-6px - var(--code-preview-gutter-width)) 6px;+ padding-inline: 5px calc(1ch + 13px);+ width: var(--code-preview-gutter-width);+ color: var(--code-preview-gutter-foreground);+ text-align: end;+ content: counter(code-preview-line);+ content: counter(code-preview-line) / "";+ counter-increment: code-preview-line;+}diff --git a/packages/codemirror/src/code_preview.spec.ts b/packages/codemirror/src/code_preview.spec.tsnew file mode 100644index 0000000000..39b553576e--- /dev/null+++ b/packages/codemirror/src/code_preview.spec.ts@@ -0,0 +1,132 @@+import { defaultHighlightStyle, type Language } from "@codemirror/language";+import { describe, expect, it, vi } from "vitest";++import {+ getLoadedPreviewLanguage, loadPreviewLanguage, loadPreviewTheme, type PreviewThemeSlot,+ renderCodePreview+} from "./code_preview.js";+import ColorThemes from "./color_themes.js";++const parser = vi.hoisted(() => ({ isTimedOut: false }));+const TWO_THEME_CLASSES = /^l\d+ d\d+$/;++vi.mock("@codemirror/language", async (importOriginal) => {+ const original = await importOriginal<typeof import("@codemirror/language")>();+ return {+ ...original,+ ensureSyntaxTree: (...args: Parameters<typeof original.ensureSyntaxTree>) =>+ (parser.isTimedOut ? null : original.ensureSyntaxTree(...args))+ };+});++describe("renderCodePreview", () => {+ it("renders a line per source line, with the classes of every theme", async () => {+ const slots = await loadSlots();+ const language = await loadPreviewLanguage("text/javascript");+ const pre = parse(renderCodePreview("const a = \"<b>&\";\r\n\n/* x\ny */", {+ themes: slots, language, isWrapped: true+ }));++ expect(pre.className).toBe("code-preview code-preview-wrap");+ expect([ pre.dataset.codeThemeL, pre.dataset.codeThemeD ])+ .toEqual([ "vs-code-light", "vs-code-dark" ]);+ expect(pre.getAttribute("style")).toBe("--code-preview-digits: 1");+ expect(pre.textContent).toBe("const a = \"<b>&\";\n\n/* x\ny */");++ const lines = [ ...pre.querySelectorAll(".code-preview-line") ];+ expect(lines.map((line) => line.textContent))+ .toEqual([ "const a = \"<b>&\";", "", "/* x", "y */" ]);+ const keyword = lines[0].querySelector("span");+ expect(keyword?.textContent).toBe("const");+ expect(keyword?.className).toMatch(TWO_THEME_CLASSES);+ // A comment over two lines is split at the line break.+ expect(lines.slice(2).map((line) => line.querySelector("span")?.className)).toEqual([+ expect.stringMatching(TWO_THEME_CLASSES), expect.stringMatching(TWO_THEME_CLASSES)+ ]);+ });++ it("shows the code plain without a language, or once the parser runs out of time", async () => {+ const slots = await loadSlots();+ const code = Array.from({ length: 10 }, (_, index) => `x < ${index}`).join("\n");+ const language = await loadPreviewLanguage("text/javascript");+ const render = (previewLanguage: Language | null) => parse(renderCodePreview(code, {+ themes: slots, language: previewLanguage, isWrapped: false+ }));++ const plain = render(null);+ expect(plain.className).toBe("code-preview");+ expect(plain.getAttribute("style")).toBe("--code-preview-digits: 2");+ expect(plain.querySelectorAll(".code-preview-line span").length).toBe(0);+ expect(plain.querySelector(".code-preview-line")?.innerHTML).toBe("x < 0");++ parser.isTimedOut = true;+ try {+ expect(render(language).querySelectorAll(".code-preview-line span").length).toBe(0);+ } finally {+ parser.isTimedOut = false;+ }+ expect(render(language).querySelectorAll(".code-preview-line span").length)+ .toBeGreaterThan(0);+ });+});++describe("loadPreviewTheme", () => {+ it("reads the colors of every code note theme", async () => {+ for (const { id } of ColorThemes) {+ const theme = await loadPreviewTheme(id);+ expect(theme.id).toBe(id);+ expect(theme.styles.length).toBeGreaterThan(0);+ expect(theme.colors).toMatchObject({+ background: expect.any(String),+ foreground: expect.any(String),+ gutterBackground: expect.any(String),+ gutterForeground: expect.any(String)+ });+ }+ const cached = loadPreviewTheme("vs-code-light");+ expect(loadPreviewTheme("vs-code-light")).toBe(cached);+ });++ it("falls back to the default highlight style for an unknown theme", async () => {+ const theme = await loadPreviewTheme("missing");+ expect(theme).toEqual({ id: "default", styles: defaultHighlightStyle.specs, colors: {} });+ });+});++describe("loadPreviewLanguage", () => {+ it("loads the language of a MIME type once", async () => {+ expect(getLoadedPreviewLanguage("text/x-python")).toBeUndefined();+ const python = loadPreviewLanguage("text/x-python");+ expect(loadPreviewLanguage("text/x-python")).toBe(python);+ expect((await python)?.name).toBe("python");+ expect(getLoadedPreviewLanguage("text/x-python")).toBe(await python);++ const names = await Promise.all([ "text/css", "application/json", "image/svg+xml" ]+ .map(async (mime) => (await loadPreviewLanguage(mime))?.name));+ expect(names).toEqual([ "css", "json", "xml" ]);+ });++ it("has no language for plain text, the backend log or an unknown MIME type", async () => {+ const results: (Language | null)[] = [];+ for (const mime of [ "text/plain", "text/x-trilium-log", "application/x-unknown" ]) {+ results.push(await loadPreviewLanguage(mime));+ }+ expect(results).toEqual([ null, null, null ]);+ expect(getLoadedPreviewLanguage("text/plain")).toBeNull();+ });+});++async function loadSlots(): Promise<PreviewThemeSlot[]> {+ const [ light, dark ] = await Promise.all([+ loadPreviewTheme("vs-code-light"), loadPreviewTheme("vs-code-dark")+ ]);+ return [ { theme: light, key: "l" }, { theme: dark, key: "d" } ];+}++function parse(html: string) {+ const template = document.createElement("template");+ template.innerHTML = html;+ const pre = template.content.firstElementChild;+ if (!(pre instanceof HTMLPreElement)) throw new Error("No <pre> in the preview.");+ return pre;+}diff --git a/packages/codemirror/src/code_preview.ts b/packages/codemirror/src/code_preview.tsnew file mode 100644index 0000000000..e8af7f72a9--- /dev/null+++ b/packages/codemirror/src/code_preview.ts@@ -0,0 +1,135 @@+import {+ ensureSyntaxTree, type Language, LanguageSupport, StreamLanguage+} from "@codemirror/language";+import { EditorState } from "@codemirror/state";+import { highlightCode, type Highlighter, tagHighlighter } from "@lezer/highlight";+import type { SupportedMimeTypes } from "@triliumnext/commons";++import { getThemeById } from "./color_themes.js";+import { type PreviewTheme, type PreviewThemeSlot, readPreviewTheme } from "./preview_theme.js";+import byMimeType, { MIME_ALIASES } from "./syntax_highlighting.js";++export {+ buildCodePreviewCss, type PreviewTheme, type PreviewThemeColors, type PreviewThemeSlot,+ readPreviewTheme+} from "./preview_theme.js";++export interface CodePreviewOptions {+ /** The themes of the preview. Every token gets a class per theme. */+ themes: readonly PreviewThemeSlot[];+ /** The language that highlights the code, or `null` to show it plain. */+ language: Language | null;+ isWrapped: boolean;+}++const DEFAULT_THEME_ID = "default";++/** The time, in milliseconds, after which `highlightLines()` stops parsing. */+const PARSE_TIMEOUT = 1000;++const HTML_ESCAPES: Record<string, string> = {+ "&": "&", "<": "<", ">": ">", "\"": """+};++const themes = new Map<string, Promise<PreviewTheme>>();+const languages = new Map<string, Promise<Language | null>>();+const loadedLanguages = new Map<string, Language | null>();++/**+ * Renders `code` as the HTML of a code preview: a `<pre>` with an element per line, which the+ * stylesheet numbers.+ */+export function renderCodePreview(+ code: string,+ { themes, language, isWrapped }: CodePreviewOptions+) {+ const text = code.replace(/\r\n?/g, "\n");+ const lines = (language && highlightLines(text, language, themes))+ ?? text.split("\n").map(escapeHtml);+ const className = isWrapped ? "code-preview code-preview-wrap" : "code-preview";+ const attributes = themes+ .map(({ theme, key }) => ` data-code-theme-${key}="${escapeHtml(theme.id)}"`)+ .join("");+ const digits = String(lines.length).length;+ const content = lines+ .map((line) => `<span class="code-preview-line">${line}</span>`)+ .join("\n");++ return `<pre class="${className}"${attributes} style="--code-preview-digits: ${digits}">`+ + `<code class="code-preview-content">${content}</code></pre>`;+}++/** Loads the theme of `ColorThemes` with the ID `id`, or `defaultHighlightStyle` for another ID. */+export function loadPreviewTheme(id: string) {+ let theme = themes.get(id);+ if (!theme) {+ const definition = getThemeById(id);+ theme = definition+ ? definition.load().then((extension) => readPreviewTheme(id, extension))+ : Promise.resolve(readPreviewTheme(DEFAULT_THEME_ID, []));+ themes.set(id, theme);+ }+ return theme;+}++/** Loads the language that highlights `mime` in a code note, or `null` if it has none. */+export function loadPreviewLanguage(mime: string) {+ let language = languages.get(mime);+ if (!language) {+ language = readLanguage(mime).then((result) => {+ loadedLanguages.set(mime, result);+ return result;+ });+ languages.set(mime, language);+ }+ return language;+}++/** Returns the language of `mime` once `loadPreviewLanguage()` has loaded it, else `undefined`. */+export function getLoadedPreviewLanguage(mime: string) {+ return loadedLanguages.get(mime);+}++/** Highlights `text` line by line, or returns `null` if the parser runs out of time. */+function highlightLines(text: string, language: Language, slots: readonly PreviewThemeSlot[]) {+ const state = EditorState.create({ doc: text, extensions: language });+ const tree = ensureSyntaxTree(state, state.doc.length, PARSE_TIMEOUT);+ if (!tree) return null;++ const lines: string[] = [];+ let line = "";+ highlightCode(text, tree, slots.map(getHighlighter), (piece, classes) => {+ const escaped = escapeHtml(piece);+ line += classes ? `<span class="${classes}">${escaped}</span>` : escaped;+ }, () => {+ lines.push(line);+ line = "";+ });+ lines.push(line);+ return lines;+}++/** Classes each token with the index of its style in the theme, after `key`. */+function getHighlighter({ theme, key }: PreviewThemeSlot): Highlighter {+ return tagHighlighter(theme.styles.map((style, index) => ({+ tag: style.tag,+ class: `${key}${index}`+ })));+}++async function readLanguage(mime: string): Promise<Language | null> {+ const load = byMimeType[(MIME_ALIASES[mime] ?? mime) as SupportedMimeTypes];+ if (!load) return null;++ const syntax = await load();+ if ("token" in syntax) return StreamLanguage.define(syntax);++ const extensions = Array.isArray(syntax) ? syntax : [ syntax ];+ return extensions+ .find((extension): extension is LanguageSupport => extension instanceof LanguageSupport)+ ?.language ?? null;+}++function escapeHtml(text: string) {+ return text.replace(/[&<>"]/g, (c) => HTML_ESCAPES[c]);+}diff --git a/packages/codemirror/src/preview_theme.spec.ts b/packages/codemirror/src/preview_theme.spec.tsnew file mode 100644index 0000000000..4000b1793f--- /dev/null+++ b/packages/codemirror/src/preview_theme.spec.ts@@ -0,0 +1,68 @@+import { defaultHighlightStyle, HighlightStyle, syntaxHighlighting } from "@codemirror/language";+import { EditorView } from "@codemirror/view";+import { tags } from "@lezer/highlight";+import { describe, expect, it } from "vitest";++import { getThemeById } from "./color_themes.js";+import { buildCodePreviewCss, readPreviewTheme } from "./preview_theme.js";++describe("readPreviewTheme", () => {+ it("reads the token styles and the editor colors of a theme", async () => {+ const theme = await readTheme("vs-code-light");++ expect(theme.styles[0]).toMatchObject({ color: "#0064ff", fontWeight: "bold" });+ expect(theme.colors).toEqual({+ background: "#ffffff",+ foreground: "#383a42",+ gutterBackground: "#f5f5f5",+ gutterForeground: "#237893",+ gutterBorderWidth: "1px",+ gutterBorderColor: "#d6d6d6",+ lineHeight: "1.6"+ });+ });++ it("keeps the default highlight style and no colors for an extension without them", () => {+ expect(readPreviewTheme("none", [])).toEqual({+ id: "none", styles: defaultHighlightStyle.specs, colors: {}+ });++ const dashed = readPreviewTheme("dashed", [+ EditorView.theme({ ".cm-gutters": { borderRight: "1px dashed red" } })+ ]);+ expect(dashed.colors).toEqual({});+ });+});++describe("buildCodePreviewCss", () => {+ it("writes the colors and the token styles of a theme, under its slot", async () => {+ const theme = await readTheme("vs-code-light");+ const css = buildCodePreviewCss({ theme, key: "l" }, ":where(html.theme-light)")+ .split("\n");+ const root = ":where(html.theme-light) .code-preview[data-code-theme-l=\"vs-code-light\"]";++ expect(css[0]).toBe(`${root} { --code-preview-background: #ffffff; `+ + "--code-preview-foreground: #383a42; --code-preview-gutter-background: #f5f5f5; "+ + "--code-preview-gutter-foreground: #237893; --code-preview-gutter-border-width: 1px; "+ + "--code-preview-gutter-border-color: #d6d6d6; --code-preview-line-height: 1.6; }");+ expect(css[1]).toBe(`${root} .l0 { color: #0064ff; font-weight: bold; }`);+ expect(css.length).toBe(theme.styles.length + 1);+ });++ it("leaves out the colors a theme does not set, and the class of a style", () => {+ const theme = readPreviewTheme("custom", syntaxHighlighting(HighlightStyle.define([+ { tag: tags.keyword, class: "keyword", color: "red", fontStyle: "italic" }+ ])));++ expect(buildCodePreviewCss({ theme, key: "t" }).split("\n")).toEqual([+ ".code-preview[data-code-theme-t=\"custom\"] { }",+ ".code-preview[data-code-theme-t=\"custom\"] .t0 { color: red; font-style: italic; }"+ ]);+ });+});++async function readTheme(id: string) {+ const definition = getThemeById(id);+ if (!definition) throw new Error(`No theme ${id}.`);+ return readPreviewTheme(id, await definition.load());+}diff --git a/packages/codemirror/src/preview_theme.ts b/packages/codemirror/src/preview_theme.tsnew file mode 100644index 0000000000..137cf70fe5--- /dev/null+++ b/packages/codemirror/src/preview_theme.ts@@ -0,0 +1,131 @@+import { defaultHighlightStyle, HighlightStyle, type TagStyle } from "@codemirror/language";+import { EditorState, type Extension } from "@codemirror/state";+import { EditorView } from "@codemirror/view";++/** A CodeMirror theme reduced to what a static code preview needs. */+export interface PreviewTheme {+ /** The ID of the theme in `ColorThemes`, or `"default"` for `defaultHighlightStyle`. */+ id: string;+ /** The token styles of the theme, in the order of its `HighlightStyle`. */+ styles: readonly TagStyle[];+ colors: PreviewThemeColors;+}++/** The colors of the editor that a theme sets, as CSS values. */+export interface PreviewThemeColors {+ background?: string;+ foreground?: string;+ gutterBackground?: string;+ gutterForeground?: string;+ gutterBorderWidth?: string;+ gutterBorderColor?: string;+ lineHeight?: string;+}++/** A theme of a code preview, and the prefix of the class names it gives the tokens. */+export interface PreviewThemeSlot {+ theme: PreviewTheme;+ key: string;+}++const COLOR_VARIABLES: Record<keyof PreviewThemeColors, string> = {+ background: "--code-preview-background",+ foreground: "--code-preview-foreground",+ gutterBackground: "--code-preview-gutter-background",+ gutterForeground: "--code-preview-gutter-foreground",+ gutterBorderWidth: "--code-preview-gutter-border-width",+ gutterBorderColor: "--code-preview-gutter-border-color",+ lineHeight: "--code-preview-line-height"+};++const EDITOR_RULE = /^\.[^\s.,]+ \{(.*)\}$/;+const GUTTERS_RULE = /^\.[^\s.,]+ \.cm-gutters \{(.*)\}$/;+const CONTENT_RULE = /^\.[^\s.,]+ \.cm-content \{(.*)\}$/;++/** Reads the token styles and the editor colors of the CodeMirror theme `extension`. */+export function readPreviewTheme(id: string, extension: Extension): PreviewTheme {+ const highlightStyle = findHighlightStyle(extension) ?? defaultHighlightStyle;+ const rules = EditorState.create({ extensions: extension })+ .facet(EditorView.styleModule)+ .filter((module) => module !== highlightStyle.module)+ .flatMap((module) => module.getRules().split("\n"));+ const editor = readDeclarations(rules, EDITOR_RULE);+ const gutters = readDeclarations(rules, GUTTERS_RULE);+ const content = readDeclarations(rules, CONTENT_RULE);+ const border = /^(\S+) solid (.+)$/.exec(gutters.get("border-right") ?? "");++ return {+ id,+ styles: highlightStyle.specs,+ colors: {+ background: editor.get("background-color"),+ foreground: editor.get("color"),+ gutterBackground: gutters.get("background-color"),+ gutterForeground: gutters.get("color"),+ gutterBorderWidth: border?.[1],+ gutterBorderColor: border?.[2],+ lineHeight: content.get("line-height")+ }+ };+}++/**+ * Returns the CSS that colors the previews rendered with `slot`.+ *+ * @param scope a selector the rules are nested under, such as `:where(html.theme-dark)`.+ */+export function buildCodePreviewCss({ theme, key }: PreviewThemeSlot, scope?: string) {+ const root = `${scope ? `${scope} ` : ""}.code-preview[data-code-theme-${key}="${theme.id}"]`;+ const variables = Object.entries(theme.colors)+ .filter(([ , value ]) => value !== undefined)+ .map(([ name, value ]) => {+ const variable = COLOR_VARIABLES[name as keyof PreviewThemeColors];+ return `${variable}: ${value};`;+ });+ const rules = [ `${root} { ${variables.join(" ")} }` ];+ for (const [ index, style ] of theme.styles.entries()) {+ rules.push(`${root} .${key}${index} { ${toDeclarations(style)} }`);+ }+ return rules.join("\n");+}++/** Finds the `HighlightStyle` that `syntaxHighlighting()` adds to `extension` as a facet value. */+function findHighlightStyle(extension: Extension): HighlightStyle | undefined {+ if (Array.isArray(extension)) {+ for (const child of extension) {+ const style = findHighlightStyle(child);+ if (style) return style;+ }+ return undefined;+ }++ const { value } = extension as { value?: unknown };+ return value instanceof HighlightStyle ? value : undefined;+}++/** Reads the declarations of the first rule in `rules` that `pattern` matches, by property. */+function readDeclarations(rules: string[], pattern: RegExp) {+ const declarations = new Map<string, string>();+ const body = rules.map((rule) => pattern.exec(rule)?.[1]).find((match) => match !== undefined);+ for (const declaration of (body ?? "").split(";")) {+ const separator = declaration.indexOf(":");+ if (separator > 0) {+ declarations.set(+ declaration.slice(0, separator).trim(),+ declaration.slice(separator + 1).trim()+ );+ }+ }+ return declarations;+}++function toDeclarations(style: TagStyle) {+ return Object.entries(style)+ .filter(([ name ]) => name !== "tag" && name !== "class")+ .map(([ name, value ]) => `${toKebabCase(name)}: ${value};`)+ .join(" ");+}++function toKebabCase(name: string) {+ return name.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`);+}diff --git a/packages/commons/src/lib/share_hosting.ts b/packages/commons/src/lib/share_hosting.tsindex bc3d54a8cd..4702e3e2bb 100644--- a/packages/commons/src/lib/share_hosting.ts+++ b/packages/commons/src/lib/share_hosting.ts@@ -17,6 +17,15 @@ export const SHARE_HOSTED_NOTE_TYPES: readonly string[] = ["canvas", "image", "mermaid", "mindMap", "noteMap", "relationMap", "render", "spreadsheet"];+/**+ * The CodeMirror themes of the code notes on a shared page, one per share theme mode. `key` is+ * the prefix of the class names of the tokens, `scope` the selector the CSS of the theme is under.+ */+export const SHARE_CODE_PREVIEW_THEMES: readonly { id: string; key: string; scope: string }[] = [+ { id: "vs-code-light", key: "l", scope: ":where(html.theme-light)" },+ { id: "vs-code-dark", key: "d", scope: ":where(html.theme-dark)" }+];+/*** Returns `names` and every group they require in `requires`, directly or through the groups* they require, each once.diff --git a/packages/share-theme/package.json b/packages/share-theme/package.jsonindex a53184f162..6f92f411b8 100644--- a/packages/share-theme/package.json+++ b/packages/share-theme/package.json@@ -24,6 +24,7 @@"devDependencies": {"@triliumnext/ckeditor5": "workspace:*","@triliumnext/client": "workspace:*",+ "@triliumnext/codemirror": "workspace:*","@types/ejs": "3.1.5","ejs": "7.0.1","happy-dom": "21.0.1",diff --git a/packages/share-theme/src/index.ts b/packages/share-theme/src/index.tsindex 02f2a83034..a8e7d4e709 100644--- a/packages/share-theme/src/index.ts+++ b/packages/share-theme/src/index.ts@@ -22,6 +22,7 @@ import setupMath from "./content/math.js";import setupAppView from "./content/app_view.js";import setupMermaid from "./content/mermaid.js";import "virtual:code-themes.css";+import "@triliumnext/codemirror/src/code_preview.css";import "@triliumnext/ckeditor5/src/theme/ck-content.css";import "@triliumnext/ckeditor5/src/theme/scrollable_bar.css";import "@triliumnext/ckeditor5/src/theme/tabs.css";diff --git a/packages/trilium-core/package.json b/packages/trilium-core/package.jsonindex 536568fcb5..090698cc7d 100644--- a/packages/trilium-core/package.json+++ b/packages/trilium-core/package.json@@ -13,6 +13,7 @@"@ai-sdk/google": "4.0.95","@ai-sdk/openai": "4.0.93","@braintree/sanitize-url": "7.1.2",+ "@triliumnext/codemirror": "workspace:*","@triliumnext/commons": "workspace:*","@triliumnext/highlightjs": "workspace:*","@triliumnext/share-theme": "workspace:*",diff --git a/packages/trilium-core/src/share/content_renderer.spec.ts b/packages/trilium-core/src/share/content_renderer.spec.tsindex e970acb992..ddebcc1825 100644--- a/packages/trilium-core/src/share/content_renderer.spec.ts+++ b/packages/trilium-core/src/share/content_renderer.spec.ts@@ -688,10 +688,13 @@ describe("content_renderer", () => {expect(auto.innerHTML).toContain("hljs-tag");});- it("highlights an embedded code note in its own language", async () => {+ it("renders an embedded code note with CodeMirror, in its own language", async () => {await ensureShareHighlighting();buildShareNotes([- { id: "pycode", type: "code", mime: "text/x-python", content: `<t t-name="x"></t>` }+ {+ id: "pycode", type: "code", mime: "text/x-python",+ content: `x = "<t t-name='x'>"`+ }]);const note = buildShareNote({content: '<section class="include-note" data-note-id="pycode" '@@ -700,10 +703,13 @@ describe("content_renderer", () => {const result = getContent(note);if (typeof result.content !== "string") throw new Error("expected string content");- const code = parse(result.content, { blockTextElements: {} }).querySelector("code");- expect(code?.classList.contains("language-text-x-python")).toBe(true);- expect(code?.innerHTML).toContain("hljs-string");- expect(code?.innerHTML).not.toContain("hljs-tag");+ const code = parse(result.content, { blockTextElements: {} })+ .querySelector("pre.code-preview > code.code-preview-content");+ expect(code?.text).toBe(`x = "<t t-name='x'>"`);+ expect(code?.querySelectorAll("span:not(.code-preview-line)")+ .map((token) => token.getAttribute("class")))+ .toEqual(expect.arrayContaining([ expect.stringMatching(/^l\d+ d\d+$/) ]));+ expect(result.content).not.toContain("hljs");});it("renders a picture or drawing embed as an image, any other embed as a download", () => {@@ -1174,23 +1180,75 @@ describe("content_renderer", () => {expect(emptyResult.isEmpty).toBeTruthy();});- it("wraps code in <pre><code>", () => {- const result: Result = {- header: "",- content: "\tHello\nworld"- };- renderCode(result);+ it("escapes the code until ensureShareHighlighting() loads CodeMirror", async () => {+ // A fresh copy of the module, which no test has loaded CodeMirror into.+ vi.resetModules();+ const { renderCode: renderUnloaded } = await import("./content_renderer.js");++ const result: Result = { header: "", content: "\tHello\nworld" };+ renderUnloaded(result);expect(result.isEmpty).toBeFalsy();expect(result.content).toBe("<pre><code>\tHello\nworld</code></pre>");- });- it("escapes HTML-significant characters so the content cannot be re-parsed as markup", () => {- const result: Result = {+ const markup: Result = {header: "",content: `const x: Array<Map<string, number>> = a < b && c > d; // <div>`};- renderCode(result);- expect(result.content).toBe(`<pre><code>const x: Array<Map<string, number>> = a < b && c > d; // <div></code></pre>`);+ renderUnloaded(markup, "application/typescript");+ expect(markup.content).toBe(`<pre><code class="language-application-typescript">`+ + "const x: Array<Map<string, number>> = a < b && c > d; "+ + "// <div></code></pre>");+ });++ it("renders a code note as CodeMirror shows it, with line numbers", async () => {+ await ensureShareHighlighting();+ const render = (content: string, mime?: string) => {+ const result: Result = { header: "", content };+ renderCode(result, mime);+ return parse(String(result.content), { blockTextElements: {} })+ .querySelector("pre");+ };++ const python = render("def x():\n return \"<a>\"", "text/x-python");+ expect(python?.getAttribute("class")).toBe("code-preview code-preview-wrap");+ expect([ "l", "d" ].map((key) => python?.getAttribute(`data-code-theme-${key}`)))+ .toEqual([ "vs-code-light", "vs-code-dark" ]);+ expect(python?.querySelectorAll(".code-preview-line").map((line) => line.text))+ .toEqual([ "def x():", " return \"<a>\"" ]);+ expect(python?.querySelector(".code-preview-line span")?.getAttribute("class"))+ .toMatch(/^l\d+ d\d+$/);+ expect(python?.innerHTML).toContain("<a>");++ // No MIME type, a language that is not enabled, and code too long to highlight.+ const long = Array.from({ length: 600 }, () => "x = 1").join("\n");+ const plain = [+ render("x = 1"), render("x = 1", "text/x-cobol"), render(long, "text/x-python")+ ];+ expect(plain.map((pre) => pre?.querySelectorAll(".code-preview-line span").length))+ .toEqual([ 0, 0, 0 ]);+ expect(plain[2]?.querySelectorAll(".code-preview-line").length).toBe(600);+ });++ it("wraps the lines by the `#wrapLines` label of the note, else by the option", async () => {+ await ensureShareHighlighting();+ const isWrapped = (note?: SNote) => {+ const result: Result = { header: "", content: "x" };+ renderCode(result, "text/plain", note);+ return String(result.content)+ .startsWith(`<pre class="code-preview code-preview-wrap"`);+ };+ const labeled = (value: string) => buildShareNote({ type: "code", "#wrapLines": value });++ expect(isWrapped()).toBe(true);+ expect(isWrapped(labeled("false"))).toBe(false);+ expect(isWrapped(labeled(""))).toBe(true);+ mockOptions({ codeLineWrapEnabled: "false" });+ try {+ expect(isWrapped()).toBe(false);+ expect(isWrapped(labeled("true"))).toBe(true);+ } finally {+ vi.restoreAllMocks();+ }});});diff --git a/packages/trilium-core/src/share/content_renderer.ts b/packages/trilium-core/src/share/content_renderer.tsindex f9758cb7f2..0354ada411 100644--- a/packages/trilium-core/src/share/content_renderer.ts+++ b/packages/trilium-core/src/share/content_renderer.ts@@ -1,9 +1,10 @@+import type { PreviewThemeSlot } from "@triliumnext/codemirror/src/code_preview.js";import {CANVAS_ATTACHMENT_MIME, getAttachmentEmbedHref, getDrawingPictureTitle, getEmbedKey,getNestedEmbedOptions, getNoteEmbedHref, isHttpUrl, isImageAttachmentRole, MIME_TYPE_AUTO,- normalizeMimeTypeForCKEditor, readLinkPreviewData, renderLinkEmbedHtml, renderLinkMentionHtml,- resolveContentEmbed, resolveEnabledMimeTypes, SHARE_HOSTED_NOTE_TYPES, SHARE_HOSTED_VIEW_TYPES,- shouldSyntaxHighlight, sliceToBlockReference+ type MimeType, normalizeMimeTypeForCKEditor, readLinkPreviewData, renderLinkEmbedHtml,+ renderLinkMentionHtml, resolveContentEmbed, resolveEnabledMimeTypes, SHARE_CODE_PREVIEW_THEMES,+ SHARE_HOSTED_NOTE_TYPES, SHARE_HOSTED_VIEW_TYPES, shouldSyntaxHighlight, sliceToBlockReference} from "@triliumnext/commons";import { renderToHtml as renderMarkdownToHtml } from "@triliumnext/commons/src/lib/markdown_renderer.js";import { renderSpreadsheetToHtml } from "@triliumnext/commons/src/lib/spreadsheet/render_to_html.js";@@ -521,7 +522,7 @@ export function getContent(note: SNote | BNote, options: ShareRenderOptions = {}} else if (note.type === "code" && note.mime === "text/x-markdown") {renderMarkdown(result, note);} else if (note.type === "code") {- renderCode(result, note.mime);+ renderCode(result, note.mime, note);} else if (note.type === "mermaid") {renderMermaid(result, note);hostNoteView(result, note, options);@@ -687,6 +688,10 @@ function renderText(result: Result, note: SNote | BNote, options: ShareRenderOpt// Mermaid is handled on client-side, we don't want to break it by adding syntax highlighting.continue;}+ // An embedded code note is already highlighted by `renderCode()`.+ if (codeEl.classList.contains("code-preview-content")) {+ continue;+ }highlightCodeBlock(codeEl);}@@ -864,13 +869,18 @@ function highlightCodeBlock(codeEl: HTMLElement) {}}+type CodePreviewModule = typeof import("@triliumnext/codemirror/src/code_preview.js");+let registeredMimeTypesOption: string | null = null;let pendingRegistration: Promise<void> | null = null;+/** The renderer of code notes and the share themes, once `ensureShareHighlighting()` loads them. */+let codePreviews: { module: CodePreviewModule; themes: PreviewThemeSlot[] } | null = null;/*** Registers the highlight.js languages enabled in the `codeNotesMimeTypes` option and unregisters- * the disabled ones, so `highlightAuto` considers only the enabled ones. The renderer is- * synchronous, so callers await this before rendering a share page or a share-theme export.+ * the disabled ones, so `highlightAuto` considers only the enabled ones. Loads the CodeMirror+ * languages of the same MIME types for the code notes. The renderer is synchronous, so callers+ * await this before rendering a share page or a share-theme export.*/export function ensureShareHighlighting(): Promise<void> {const optionValue = options.getOptionOrNull("codeNotesMimeTypes");@@ -880,9 +890,10 @@ export function ensureShareHighlighting(): Promise<void> {registeredMimeTypesOption = optionValue;pendingRegistration = Promise.resolve()- .then(() => {+ .then(async () => {const enabledMimes = optionValue ? JSON.parse(optionValue) : null;- return syncMimeTypes(resolveEnabledMimeTypes(enabledMimes));+ const mimeTypes = resolveEnabledMimeTypes(enabledMimes);+ await Promise.all([ syncMimeTypes(mimeTypes), loadCodePreviews(mimeTypes) ]);}).catch((e: unknown) => {getLog().error(`Unable to register the languages for syntax highlighting: ${e}`);@@ -891,12 +902,36 @@ export function ensureShareHighlighting(): Promise<void> {return pendingRegistration;}+/** Loads the renderer of code notes, its themes and its languages for the enabled `mimeTypes`. */+async function loadCodePreviews(mimeTypes: MimeType[]) {+ const module = await import("@triliumnext/codemirror/src/code_preview.js");+ const enabledMimes = mimeTypes.filter(({ enabled }) => enabled).map(({ mime }) => mime);+ const [ themes ] = await Promise.all([+ Promise.all(SHARE_CODE_PREVIEW_THEMES.map(async ({ id, key }) => ({+ theme: await module.loadPreviewTheme(id), key+ }))),+ Promise.all(enabledMimes.map((mime) => module.loadPreviewLanguage(mime)))+ ]);+ codePreviews = { module, themes };+}+/**- * Renders a code note.+ * Renders a code note as CodeMirror shows it, with line numbers, once `ensureShareHighlighting()`+ * has loaded the renderer. Until then the code is escaped in a `<pre><code>`.+ *+ * @param note the note whose `#wrapLines` label sets the line wrapping, over the option.*/-export function renderCode(result: Result, mime?: string) {+export function renderCode(result: Result, mime?: string, note?: SNote | BNote) {if (typeof result.content !== "string" || !result.content?.trim()) {result.isEmpty = true;+ } else if (codePreviews) {+ const { module, themes } = codePreviews;+ const language = mime && shouldSyntaxHighlight(result.content)+ ? module.getLoadedPreviewLanguage(mime) ?? null+ : null;+ result.content = module.renderCodePreview(result.content, {+ themes, language, isWrapped: isLineWrapped(note)+ });} else {// Escape the raw code so that any `<`/`>` it contains are not later re-parsed as HTML.// When such a code note is embedded into a shared text note, renderText re-parses the@@ -911,6 +946,13 @@ export function renderCode(result: Result, mime?: string) {}}+function isLineWrapped(note: SNote | BNote | undefined) {+ const label = note?.getLabelValue("wrapLines");+ return label == null+ ? options.getOptionOrNull("codeLineWrapEnabled") !== "false"+ : label !== "false";+}+/*** Renders a Mermaid note as the image the app saved, which the share theme's script replaces with* a diagram drawn from `.mermaid-note-source` in the page's light or dark theme.diff --git a/packages/trilium-core/tsconfig.lib.json b/packages/trilium-core/tsconfig.lib.jsonindex 08a9c313e4..8b489c789a 100644--- a/packages/trilium-core/tsconfig.lib.json+++ b/packages/trilium-core/tsconfig.lib.json@@ -17,6 +17,9 @@"src/**/*.json"],"references": [+ {+ "path": "../codemirror/tsconfig.lib.json"+ },{"path": "../highlightjs/tsconfig.lib.json"}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex b24d14d3ed..6cd2aff35b 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -1156,6 +1156,9 @@ importers:'@codemirror/lang-xml':specifier: 6.1.0version: 6.1.0+ '@codemirror/language':+ specifier: 6.13.1+ version: 6.13.1'@codemirror/language-data':specifier: 6.5.2version: 6.5.2@@ -1258,6 +1261,9 @@ importers:'@fsegurai/codemirror-theme-vscode-light':specifier: 6.2.8version: 6.2.8(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])(@lezer/[email protected])+ '@lezer/highlight':+ specifier: 1.2.5+ version: 1.2.5'@replit/codemirror-indentation-markers':specifier: 6.5.3version: 6.5.3(@codemirror/[email protected])(@codemirror/[email protected])(@codemirror/[email protected])@@ -1388,6 +1394,9 @@ importers:'@triliumnext/client':specifier: workspace:*version: link:../../apps/client+ '@triliumnext/codemirror':+ specifier: workspace:*+ version: link:../codemirror'@types/ejs':specifier: 3.1.5version: 3.1.5@@ -1442,6 +1451,9 @@ importers:'@braintree/sanitize-url':specifier: 7.1.2version: 7.1.2+ '@triliumnext/codemirror':+ specifier: workspace:*+ version: link:../codemirror'@triliumnext/commons':specifier: workspace:*version: link:../commons