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/text editor: make "create child not"e from note auto-complete behave like "Create a new child note"
Adorian Doran07d26fe19522
diff --git a/apps/client/src/widgets/react/NoteAutocomplete.tsx b/apps/client/src/widgets/react/NoteAutocomplete.tsxindex 172c58bb3c..b803dfa151 100644--- a/apps/client/src/widgets/react/NoteAutocomplete.tsx+++ b/apps/client/src/widgets/react/NoteAutocomplete.tsx@@ -452,7 +452,10 @@ export default function NoteAutocomplete({ id, inputRef: externalInputRef, text,* creation row: `onPick` then receives a promise, settling on `undefined` where the creation is* canceled.*/-export function NoteMentionList({ query, anchor, allowCreatingNotes, parentNotePath, preselect = true, onPick, handleRef, elementRef, onActiveDescendant }: {+export function NoteMentionList({+ query, anchor, allowCreatingNotes, parentNotePath, preselect = true, onPick, onPickChildNote,+ handleRef, elementRef, onActiveDescendant+}: {query: string;anchor: PopupProps["anchor"];allowCreatingNotes?: boolean;@@ -461,6 +464,11 @@ export function NoteMentionList({ query, anchor, allowCreatingNotes, parentNoteP/** Opens the list with an entry highlighted, so that Enter takes it. */preselect?: boolean;onPick(notePath: string | Promise<string | undefined>): void;+ /**+ * Takes the pick of the row creating a child note, with the title typed, in place of `onPick`,+ * for a host that creates the note itself.+ */+ onPickChildNote?(title: string): void;handleRef: RefObject<AutocompleteListHandle | null>;elementRef?: PopupProps["elementRef"];/** Called with the id of the highlighted entry's element, or `null` while none is highlighted. */@@ -476,7 +484,9 @@ export function NoteMentionList({ query, anchor, allowCreatingNotes, parentNotePquery,source,onPick: (suggestion: Suggestion) => {- if (suggestion.action === "create-note" || suggestion.action === "create-child-note") {+ if (suggestion.action === "create-child-note" && onPickChildNote) {+ onPickChildNote(suggestion.noteTitle ?? "");+ } else if (rowGroup(suggestion) === "create") {onPick(createNoteFromSuggestion(suggestion, parentNotePath));} else if (suggestion.notePath) {onPick(suggestion.notePath);diff --git a/apps/client/src/widgets/type_widgets/text/CKEditor.tsx b/apps/client/src/widgets/type_widgets/text/CKEditor.tsxindex f137fb09d1..fb82b90232 100644--- a/apps/client/src/widgets/type_widgets/text/CKEditor.tsx+++ b/apps/client/src/widgets/type_widgets/text/CKEditor.tsx@@ -296,6 +296,12 @@ export default function CKEditor({ containerRef: externalContainerRef, contentLacontentLanguage: contentLanguage ?? null,templates: templatesRef.current,getNoteLocation: () => noteLocationRef.current,+ getChildNoteParent: () => {+ const parentNote = noteRef.current;+ const parentNotePath = noteLocationRef.current?.notePath;+ if (!parentNote || !parentNotePath) return undefined;+ return { notePath: parentNotePath, isProtected: parentNote.isProtected, ntxId };+ },getNoteId: () => noteRef.current?.noteId,getComponentId: () => parentComponent?.componentId,triggerHostCommand: (command, data) => parentComponent?.triggerCommand(command, data),diff --git a/apps/client/src/widgets/type_widgets/text/EditableText.spec.ts b/apps/client/src/widgets/type_widgets/text/EditableText.spec.tsindex 276d3f7d81..8e3be60087 100644--- a/apps/client/src/widgets/type_widgets/text/EditableText.spec.ts+++ b/apps/client/src/widgets/type_widgets/text/EditableText.spec.ts@@ -7,13 +7,11 @@* being uploaded flickered and vanished instead of a "cannot upload" toast appearing.*/import type { CKEditorError, CKTextEditor, FileUploadData } from "@triliumnext/ckeditor5";-import { afterEach, beforeEach, describe, expect, it, type MockInstance, vi } from "vitest";+import { beforeEach, describe, expect, it, vi } from "vitest";-import appContext from "../../../components/app_context";import type FAttachment from "../../../entities/fattachment";import froca from "../../../services/froca";import type LoadResults from "../../../services/load_results";-import noteCreate from "../../../services/note_create";const showError = vi.hoisted(() => vi.fn());const showErrorTitleAndMessage = vi.hoisted(() => vi.fn());@@ -45,7 +43,6 @@ const {applyPendingAttachmentChanges,getAddLinkOpts,getBlockData,- insertChildNote,isCaretInFocus,notifyAttachmentChanges,onNotificationInfo,@@ -486,50 +483,3 @@ describe("getAddLinkOpts", () => {expect(api.updateLink).not.toHaveBeenCalled();});});--describe("insertChildNote", () => {- const editor = { execute: vi.fn() };- const insert = (ntxId: string) => insertChildNote(editor as unknown as CKTextEditor, {- parentNotePath: "root/parent", isProtected: true, ntxId- });- let createNote: MockInstance<typeof noteCreate.createNote>;- let triggerCommand: MockInstance<typeof appContext.triggerCommand>;-- beforeEach(() => {- editor.execute.mockClear();- createNote = vi.spyOn(noteCreate, "createNote")- .mockResolvedValue({ note: { noteId: "child" }, branch: null } as never);- triggerCommand = vi.spyOn(appContext, "triggerCommand").mockReturnValue(undefined);- });-- afterEach(() => {- vi.restoreAllMocks();- });-- it("links to a new child note and opens it to be named, nested in a popup", async () => {- await insert("ntx-1");-- expect(createNote).toHaveBeenCalledExactlyOnceWith("root/parent", {- activate: false, isProtected: true- });- expect(editor.execute)- .toHaveBeenCalledExactlyOnceWith("referenceLink", { href: "#root/parent/child" });- expect(triggerCommand).toHaveBeenCalledExactlyOnceWith("openInPopup", {- noteIdOrPath: "root/parent/child", showNoteTypeSwitcher: true, selectTitle: true- });-- await insert("_popup-editor");- expect(triggerCommand).toHaveBeenLastCalledWith(- "openInNestedPopup", expect.objectContaining({ noteIdOrPath: "root/parent/child" })- );- });-- it("links and opens nothing when the note is not created", async () => {- createNote.mockResolvedValue({ note: null, branch: undefined } as never);-- await insert("ntx-1");-- expect(editor.execute).not.toHaveBeenCalled();- expect(triggerCommand).not.toHaveBeenCalled();- });-});diff --git a/apps/client/src/widgets/type_widgets/text/EditableText.tsx b/apps/client/src/widgets/type_widgets/text/EditableText.tsxindex f8378c5abf..ea60701498 100644--- a/apps/client/src/widgets/type_widgets/text/EditableText.tsx+++ b/apps/client/src/widgets/type_widgets/text/EditableText.tsx@@ -30,9 +30,9 @@ import {useSearchTermsConsumer, useTriliumEvent, useTriliumOption, useTriliumOptionBool} from "../../react/hooks";import { setEditorNoteId } from "../../react/NoteStore";-import { POPUP_EDITOR_NTX_ID } from "../../react/react_utils";import { TypeWidgetProps } from "../type_widget";import AttachmentSaves, { InlineSourceSaves, useNoteEditor } from "./attachment_saves";+import { insertChildNote } from "./child_note";import CKEditor, { CKEditorApi, NotificationEventData, NotificationEventInfo } from "./CKEditor";import type { ContentEmbedHandlers } from "./config";import { enterContentEmbed, getContentEmbedTools } from "./content_embed_tools";@@ -268,7 +268,7 @@ export default function EditableText({if (!editor || !parentNote || !parentNotePath) return;await insertChildNote(editor, {- parentNotePath,+ notePath: parentNotePath,isProtected: parentNote.isProtected,ntxId});@@ -596,33 +596,6 @@ export function getAddLinkOpts(api: CKEditorApi, ready: () => Promise<unknown>):};}-/**- * Creates an empty child note of `parentNotePath`, links to it at the selection of `editor`, and- * opens it in the quick edit popup with its title selected. An editor in that popup opens it in the- * nested popup, over the note being edited.- *- * Exported for testing.- */-export async function insertChildNote(editor: CKTextEditor, {- parentNotePath, isProtected, ntxId-}: {- parentNotePath: string;- isProtected: boolean;- ntxId: string | null | undefined;-}) {- const { note } = await note_create.createNote(parentNotePath, { activate: false, isProtected });- if (!note) return;-- const notePath = `${parentNotePath}/${note.noteId}`;- editor.execute("referenceLink", { href: `#${notePath}` });- const command = ntxId?.startsWith(POPUP_EDITOR_NTX_ID) ? "openInNestedPopup" : "openInPopup";- void appContext.triggerCommand(command, {- noteIdOrPath: notePath,- showNoteTypeSwitcher: true,- selectTitle: true- });-}-/*** What a link's `href` opens the Add link dialog on: the note, with the anchor it points at, or* the address.diff --git a/apps/client/src/widgets/type_widgets/text/child_note.spec.ts b/apps/client/src/widgets/type_widgets/text/child_note.spec.tsnew file mode 100644index 0000000000..7244816e29--- /dev/null+++ b/apps/client/src/widgets/type_widgets/text/child_note.spec.ts@@ -0,0 +1,65 @@+import type { CKTextEditor } from "@triliumnext/ckeditor5";+import { afterEach, beforeEach, describe, expect, it, type MockInstance, vi } from "vitest";++import appContext from "../../../components/app_context";+import noteCreate from "../../../services/note_create";+import { createChildNote, insertChildNote, openChildNote } from "./child_note";++describe("child notes", () => {+ const editor = { execute: vi.fn() };+ const parent = (ntxId: string) => ({ notePath: "root/parent", isProtected: true, ntxId });+ const insert = (ntxId: string) =>+ insertChildNote(editor as unknown as CKTextEditor, parent(ntxId));+ let createNote: MockInstance<typeof noteCreate.createNote>;+ let triggerCommand: MockInstance<typeof appContext.triggerCommand>;++ beforeEach(() => {+ editor.execute.mockClear();+ createNote = vi.spyOn(noteCreate, "createNote")+ .mockResolvedValue({ note: { noteId: "child" }, branch: null } as never);+ triggerCommand = vi.spyOn(appContext, "triggerCommand").mockReturnValue(undefined);+ });++ afterEach(() => {+ vi.restoreAllMocks();+ });++ it("links to a new child note and opens it to be named, nested in a popup", async () => {+ await insert("ntx-1");++ expect(createNote).toHaveBeenCalledExactlyOnceWith("root/parent", {+ title: undefined, activate: false, isProtected: true+ });+ expect(editor.execute)+ .toHaveBeenCalledExactlyOnceWith("referenceLink", { href: "#root/parent/child" });+ expect(triggerCommand).toHaveBeenCalledExactlyOnceWith("openInPopup", {+ noteIdOrPath: "root/parent/child", showNoteTypeSwitcher: true, selectTitle: true+ });++ await insert("_popup-editor");+ expect(triggerCommand).toHaveBeenLastCalledWith(+ "openInNestedPopup", expect.objectContaining({ noteIdOrPath: "root/parent/child" })+ );+ });++ it("links and opens nothing when the note is not created", async () => {+ createNote.mockResolvedValue({ note: null, branch: undefined } as never);++ await insert("ntx-1");++ expect(editor.execute).not.toHaveBeenCalled();+ expect(triggerCommand).not.toHaveBeenCalled();+ });++ it("creates a named child note, and opens it on its content", async () => {+ expect(await createChildNote(parent("ntx-1"), "Named")).toBe("root/parent/child");+ expect(createNote).toHaveBeenCalledExactlyOnceWith("root/parent", {+ title: "Named", activate: false, isProtected: true+ });++ openChildNote("root/parent/child", parent("ntx-1"), { selectTitle: false });+ expect(triggerCommand).toHaveBeenCalledExactlyOnceWith("openInPopup", {+ noteIdOrPath: "root/parent/child", showNoteTypeSwitcher: true, selectTitle: false+ });+ });+});diff --git a/apps/client/src/widgets/type_widgets/text/child_note.ts b/apps/client/src/widgets/type_widgets/text/child_note.tsnew file mode 100644index 0000000000..f8f5328209--- /dev/null+++ b/apps/client/src/widgets/type_widgets/text/child_note.ts@@ -0,0 +1,46 @@+import type { CKTextEditor } from "@triliumnext/ckeditor5";++import appContext from "../../../components/app_context";+import note_create from "../../../services/note_create";+import { POPUP_EDITOR_NTX_ID } from "../../react/react_utils";++/** The note a text editor is open on, which the child notes created from the editor go under. */+export interface ChildNoteParent {+ notePath: string;+ isProtected: boolean;+ /** The note context the editor is in, which decides the popup a new child note opens in. */+ ntxId: string | null | undefined;+}++/**+ * Creates an empty child note of `parent`, links to it at the selection of `editor`, and opens it+ * in Quick edit with its title selected.+ */+export async function insertChildNote(editor: CKTextEditor, parent: ChildNoteParent) {+ const notePath = await createChildNote(parent);+ if (!notePath) return;++ editor.execute("referenceLink", { href: `#${notePath}` });+ openChildNote(notePath, parent, { selectTitle: true });+}++/** Creates a child note of `parent` titled `title`, or untitled, and returns the path to it. */+export async function createChildNote({ notePath, isProtected }: ChildNoteParent, title?: string) {+ const { note } = await note_create.createNote(notePath, {+ title, activate: false, isProtected+ });+ return note ? `${notePath}/${note.noteId}` : undefined;+}++/**+ * Opens a note made by `createChildNote()` in Quick edit, which offers the note types to turn the+ * empty note into. An editor already in Quick edit opens it in the nested popup.+ */+export function openChildNote(+ notePath: string, { ntxId }: ChildNoteParent, { selectTitle }: { selectTitle: boolean }+) {+ const command = ntxId?.startsWith(POPUP_EDITOR_NTX_ID) ? "openInNestedPopup" : "openInPopup";+ void appContext.triggerCommand(command, {+ noteIdOrPath: notePath, showNoteTypeSwitcher: true, selectTitle+ });+}diff --git a/apps/client/src/widgets/type_widgets/text/config.ts b/apps/client/src/widgets/type_widgets/text/config.tsindex c9608e54ef..d4ce0c0ac4 100644--- a/apps/client/src/widgets/type_widgets/text/config.ts+++ b/apps/client/src/widgets/type_widgets/text/config.ts@@ -27,6 +27,7 @@ import { convertImageToDrawing } from "../canvas/image_to_drawing.js";import SAMPLE_DIAGRAMS from "../mermaid/sample_diagrams.js";import buildAiAssistantStream, { type AiNoteLocationProvider, buildAiAssistantQuickActions } from "./ai_assistant_stream.js";import diffAiResponse from "./ai_diff.js";+import type { ChildNoteParent } from "./child_note.js";import { createColorMenuHost } from "./color_menu.js";import { buildFontColorConfig, buildTableColorConfig } from "./color_palette.js";import { createEmojiList, createNoteMentionList, createSlashCommandList } from "./mention_list_view.js";@@ -48,12 +49,16 @@ export interface BuildEditorOptions {contentLanguage: string | null;templates: SnippetDefinition[];/**- * Names the note the editor is open on, for the AI assistant to say where a run is writing and- * for the `@` list to create a child note under.+ * Names the note the editor is open on, for the AI assistant to say where a run is writing.* A getter rather than the note itself: switching notes reuses the editor, so anything captured* here would name the note that happened to be open when it was built.*/getNoteLocation?: AiNoteLocationProvider;+ /**+ * The note the editor is open on, for the `@` list to create a child note under. A getter for+ * the same reason as `getNoteLocation`.+ */+ getChildNoteParent?: () => ChildNoteParent | undefined;/** The ID of the note the editor is open on. A getter for the same reason as `getNoteLocation`. */getNoteId?: () => string | undefined;/** The ID of the component that hosts the editor, which changes the editor makes are sent as. */@@ -386,7 +391,7 @@ export async function buildConfig(opts: BuildEditorOptions): Promise<EditorConfiallowSpaces: true,list: () => createNoteMentionList({allowCreatingNotes: true,- getParentNotePath: () => opts.getNoteLocation?.()?.notePath+ getChildNoteParent: opts.getChildNoteParent})}] : []diff --git a/apps/client/src/widgets/type_widgets/text/mention_list_view.spec.tsx b/apps/client/src/widgets/type_widgets/text/mention_list_view.spec.tsxindex 488a633351..9294a1d2fd 100644--- a/apps/client/src/widgets/type_widgets/text/mention_list_view.spec.tsx+++ b/apps/client/src/widgets/type_widgets/text/mention_list_view.spec.tsx@@ -13,6 +13,13 @@ vi.mock("../../../services/note_autocomplete", async (importOriginal) => ({createNoteFromSuggestion}));+const { createChildNote, openChildNote } = vi.hoisted(() => ({+ createChildNote: vi.fn<(parent: object, title?: string) => Promise<string | undefined>>(),+ openChildNote: vi.fn()+}));++vi.mock("./child_note", () => ({ createChildNote, openChildNote }));+import { createAutocompleteMentionList, createEmojiList, createNoteMentionList, createSlashCommandList } from "./mention_list_view";describe("createNoteMentionList", () => {@@ -83,6 +90,51 @@ describe("createNoteMentionList", () => {expect(createNoteFromSuggestion).toHaveBeenLastCalledWith(childRow, "root/second");list.destroy?.();});++ it("creates a child note without asking its type, and opens it once linked", async () => {+ const childRow = {+ action: "create-child-note", noteTitle: "al", highlightedNotePathTitle: "Create child"+ };+ getNoteSuggestions.mockResolvedValue([ childRow ] as never);+ createNoteFromSuggestion.mockClear();+ createChildNote.mockResolvedValueOnce("root/edited/al").mockResolvedValueOnce(undefined);+ const parent = { notePath: "root/edited", isProtected: false, ntxId: "ntx" };+ const order: string[] = [];+ openChildNote.mockImplementation(() => order.push("open"));+ const pick = async () => {+ const list = createNoteMentionList({+ allowCreatingNotes: true, getChildNoteParent: () => parent+ });+ // As the editor does, which inserts the link once the promised mention settles.+ const commit = vi.fn<MentionHostedListState["commit"]>((item) => {+ void Promise.resolve(item).then((mention) => order.push(mention ? "link" : "none"));+ });+ await act(async () => list.show({+ query: "al", caretRect: () => new DOMRect(10, 10, 1, 16), editable: null,+ commit, setActiveDescendant: vi.fn()+ }));+ await act(async () => { await vi.advanceTimersByTimeAsync(300); });+ list.handleKeyDown(new KeyboardEvent("keydown", { key: "Enter", cancelable: true }));+ await act(async () => { await vi.advanceTimersByTimeAsync(0); });+ list.destroy?.();+ return commit;+ };++ const commit = await pick();+ expect(createChildNote).toHaveBeenLastCalledWith(parent, "al");+ expect(createNoteFromSuggestion).not.toHaveBeenCalled();+ expect(await commit.mock.calls[0]?.[0])+ .toEqual({ id: "@root/edited/al", notePath: "root/edited/al" });+ expect(openChildNote)+ .toHaveBeenCalledExactlyOnceWith("root/edited/al", parent, { selectTitle: false });+ expect(order).toEqual([ "link", "open" ]);++ // Nothing is linked or opened where the note is not created.+ order.length = 0;+ await pick();+ expect(order).toEqual([ "none" ]);+ expect(openChildNote).toHaveBeenCalledOnce();+ });});describe("createAutocompleteMentionList", () => {diff --git a/apps/client/src/widgets/type_widgets/text/mention_list_view.tsx b/apps/client/src/widgets/type_widgets/text/mention_list_view.tsxindex 86a5c9a07a..1b423ed569 100644--- a/apps/client/src/widgets/type_widgets/text/mention_list_view.tsx+++ b/apps/client/src/widgets/type_widgets/text/mention_list_view.tsx@@ -4,6 +4,7 @@ import type { ComponentChildren } from "preact";import { AutocompleteList } from "../../react/FormAutocomplete";import { type CommandEntry, CommandMentionList, createHostedList, NoteMentionList } from "../../react/NoteAutocomplete";+import { type ChildNoteParent, createChildNote, openChildNote } from "./child_note";/** The editor a list for a plugin's marker is created for. */type HostEditor = Parameters<NonNullable<SlashCommandConfig["list"]>>[0];@@ -12,7 +13,9 @@ type HostEditor = Parameters<NonNullable<SlashCommandConfig["list"]>>[0];* Lists the notes for the query typed after `@` as the note autocomplete does, for the editor config's* `mention.hostedFeeds`, and mentions the note picked as a reference link.*/-export function createNoteMentionList({ allowCreatingNotes, preselect, getParentNotePath }: {+export function createNoteMentionList({+ allowCreatingNotes, preselect, getParentNotePath, getChildNoteParent+}: {allowCreatingNotes?: boolean;preselect?: boolean;/**@@ -20,19 +23,37 @@ export function createNoteMentionList({ allowCreatingNotes, preselect, getParent* notes reuses the editor.*/getParentNotePath?(): string | null | undefined;+ /**+ * The note the editor is open on, in place of `getParentNotePath`: the child note row then+ * creates the note without asking for its type, and opens it in Quick edit once linked.+ */+ getChildNoteParent?(): ChildNoteParent | undefined;} = {}): MentionHostedList {- return createHostedList<MentionHostedListState>((state, list) => (- <NoteMentionList- {...list}- query={state.query}- allowCreatingNotes={allowCreatingNotes}- parentNotePath={getParentNotePath?.()}- preselect={preselect}- onPick={(notePath) => state.commit(typeof notePath === "string"- ? toMention(notePath)- : notePath.then((path) => path ? toMention(path) : undefined))}- />- ));+ return createHostedList<MentionHostedListState>((state, list) => {+ const childNoteParent = getChildNoteParent?.();++ return (+ <NoteMentionList+ {...list}+ query={state.query}+ allowCreatingNotes={allowCreatingNotes}+ parentNotePath={getParentNotePath?.()}+ preselect={preselect}+ onPick={(notePath) => state.commit(typeof notePath === "string"+ ? toMention(notePath)+ : notePath.then(toMentionIfCreated))}+ onPickChildNote={childNoteParent && ((title) => {+ const mention = createChildNote(childNoteParent, title)+ .then(toMentionIfCreated);+ state.commit(mention);+ // Runs after the commit inserts the link, which focuses the editor.+ void mention.then((created) => created && openChildNote(+ created.notePath, childNoteParent, { selectTitle: false }+ ));+ })}+ />+ );+ });}/**@@ -133,3 +154,7 @@ function toEmojiEntry(suggestion: EmojiSuggestion): EmojiEntry {function toMention(notePath: string) {return { id: `@${notePath}`, notePath };}++function toMentionIfCreated(notePath: string | undefined) {+ return notePath ? toMention(notePath) : undefined;+}diff --git a/apps/server/src/assets/help/help_content.json b/apps/server/src/assets/help/help_content.jsonindex 31df4a26f3..f7bec2d12f 100644--- a/apps/server/src/assets/help/help_content.json+++ b/apps/server/src/assets/help/help_content.json@@ -141,7 +141,7 @@"_help_UmgZAfcltxkS": "<p>Link previews turn a pasted URL into a rich, metadata-aware widget that can be displayed in three visual modes:</p><h2>Display modes</h2><p>A link preview can be displayed in one of three modes:</p><ul><li><strong>Inline</strong> — a link showing the site's favicon and page title (quite similar to <a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a>). Use this when you want the link to flow with the surrounding paragraph.</li><li><strong>Card</strong> — a block-level preview with thumbnail, title, description, and site name. Use this when the link is the focus of a paragraph.</li><li><strong>Embed</strong> — a block-level interactive embed.<ul><li>Currently supported for YouTube videos, which render interactively (via an <code>iframe</code>).</li><li>To prevent unwanted remote requests, the video is shown only after clicking on it first.</li></ul></li></ul><div class=\"trilium-multicolumn-layout\" data-trilium-column-ratios=\"1-1-1\"><div class=\"trilium-multicolumn-column\"><figure class=\"image image_resized\" style=\"width:100%;\"><img style=\"aspect-ratio:251/42;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Link%20Previews_image.png\" width=\"251\" height=\"42\"><figcaption><em>Inline</em> link preview</figcaption></figure></div><div class=\"trilium-multicolumn-column\"><figure class=\"image image_resized\" style=\"width:100%;\"><img style=\"aspect-ratio:1217/196;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/2_Link%20Previews_image.png\" width=\"1217\" height=\"196\"><figcaption><em>Card</em> link preview</figcaption></figure></div><div class=\"trilium-multicolumn-column\"><figure class=\"image image_resized\" style=\"width:100%;\"><img style=\"aspect-ratio:994/563;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/1_Link%20Previews_image.png\" width=\"994\" height=\"563\"><figcaption><em>Embed</em> link preview</figcaption></figure></div></div><h2>Inserting a link preview</h2><p>There are three ways to create one:</p><h3>1. By pasting a URL</h3><p>A link preview is automatically created:</p><ul><li>By pasting the URL and pressing <kbd>Space</kbd>. This will create an <em>inline</em> link preview.</li><li>When at the start of a new paragraph, pressing <kbd>Enter</kbd> will create a <em>card</em> or an <em>embed</em> for YouTube URLs.</li></ul><p>To undo an automatic link preview, press <kbd>Ctrl</kbd>+<kbd>Z</kbd> immediately afterwards which keeps it as a plain link instead. Alternatively, once a link preview was created, click on the link and select <em>Plain link</em> from the link preview toolbar.</p><p>This automatic conversion can be disabled by going to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Text Notes</em> and unchecking <em>Autogenerate link previews</em> from the <em>Features</em> section.</p><p>If the link is not accessible to the Trilium server (or the network request fails for any other reason), it will not be converted to a link preview.</p><aside class=\"admonition note\"><p>A URL is only auto-converted when the pasted text <em>is</em> the URL. Links with a display name (e.g. <a href=\"https://triliumnotes.org\">Trilium Notes website</a>) are left as plain links.</p></aside><h3>2. By using the \"Link preview\" toolbar button or slash command</h3><p>Click <em>Link preview</em> (<span class=\"tn-icon cke cke-trilium-link-preview\"></span>) in the formatting toolbar to open the <em>Link preview</em> popup. Paste the URL and choose the type of preview.</p><p>Alternatively, use <a class=\"reference-link\" href=\"#root/_help_ZlN4nump6EbW\">Slash Commands</a> and look for <em>link preview</em> (it is also found by <em>embed</em>, <em>url</em> or <em>video</em>), which opens the same popup at the cursor.</p><h3>3. By saving browser tabs from the Web Clipper</h3><p>When the <a class=\"reference-link\" href=\"#root/_help_MtPxeAWVAzMg\">Web Clipper</a> saves the tabs of a window, each tab becomes an <em>inline</em> link preview showing the title and favicon the browser displays for it. Because this data comes from the browser, pages behind a login keep their real title, and the Trilium server does not contact the saved pages.</p><p>When <em>Autogenerate link previews</em> is turned off, the tabs are saved as a list of plain links instead.</p><h2>Altering an existing link preview</h2><p>Click on an inserted link preview to select it, and a small toolbar will appear with the following options:</p><ul><li>The normal link operations (opening in a new tab, copying the link, unlinking).</li><li>A button to edit the title of the link preview. This is especially useful if the title is hidden behind a login screen.</li><li>A way to switch between the link preview modes (Inline, Card or Embed) as well as to convert it to a normal link instead.<ul><li>The Embed option is only enabled when the URL points to a supported service (YouTube today).</li></ul></li></ul><h2>Where the preview data comes from</h2><p>When you insert a link preview, Trilium fetches metadata once and stores it inside the note's HTML:</p><ul><li><strong>YouTube URLs</strong> — title, channel name, and thumbnail are fetched via YouTube's public oEmbed endpoint.</li><li><strong>All other URLs</strong> — Trilium fetches the page and reads OpenGraph tags (<code>og:title</code>, <code>og:description</code>, <code>og:image</code>, <code>og:site_name</code>), falling back to the page's <code><title></code> and <code><meta name=\"description\"></code>. The site's favicon is downloaded and inlined.</li></ul><p>Because the data is stored in the note itself, link previews continue to render correctly when you reopen the note, share/publish it, or export to HTML — without any further network requests.</p><p>The metadata is captured <strong>at insertion time</strong> and is not automatically refreshed. If the linked page later changes its title or thumbnail, you'll need to re-insert the link to pick up the new values. To refresh a link, simply create it again.</p><p>When accessing a <a class=\"reference-link\" href=\"#root/_help_WOcw2SLH6tbX\">Server Installation</a>, the data is fetched from the remote URL by the server and not the client.</p><h2>Known limitations</h2><ul><li>The Embed display mode currently only supports YouTube. Other video and media platforms fall back to a Card preview.</li><li>Pages that block automated fetches may produce a minimal preview (hostname only).</li><li>Link previews require the Trilium server to reach the target URL, so they won't generate previews for pages on networks the server can't see.</li></ul>","_help_QEAPj01N5f7w": "<p>There are two types of links:</p><ul><li><a class=\"reference-link\" href=\"#root/_help_3IDVtesTQ8ds\">External links</a>, for standard hyperlinks to websites or other resources.</li><li><a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a> for links to other notes within Trilium.<ul><li>The list of notes that refer to a particular note is called <a class=\"reference-link\" href=\"#root/_help_wfGXLmm7x27z\">Backlinks</a>.</li></ul></li></ul><h2>Note map</h2><p>Trilium provides a visualization of incoming and outgoing links for a particular note. See <a href=\"#root/_help_BCkXAVs63Ttv\">note map</a> for details.</p>","_help_3IDVtesTQ8ds": "<p>An external link is a standard web link targeting for example a website. For example, <a href=\"https://en.wikipedia.org/wiki/South_China_Sea\">https://en.wikipedia.org/wiki/South_China_Sea</a> is an external link to a Wikipedia page.</p><p>To create a link without a custom text:</p><ul><li>Press <span class=\"tn-icon cke cke-link\"></span> in the <a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>:<ul><li>A popup will appear, type or paste the URL in the box.</li><li>Press <kbd>Enter</kbd> or the check mark icon to confirm.</li></ul></li><li>Alternatively, press <kbd>Ctrl</kbd>+<kbd>K</kbd> to trigger the aforementioned popup.</li><li>A simpler way is to paste the raw link and press space to turn it automatically into a link.</li><li>Since v0.107.0, the <em>Add link</em> dialog of <a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a> (<kbd>Ctrl</kbd>+<kbd>L</kbd> or the <span class=\"tn-icon cke cke-trilium\"></span> button) creates external links as well. Select <em>Web link</em> at the top of the dialog, type or paste the address, and optionally a <em>Link title</em>; without one, the link shows its address. An address without a scheme, such as <code>example.com</code>, gets <code>https://</code>. A URL pasted into the <em>Note</em> field, or picked from its search, switches the dialog to <em>Web link</em>. The dialog also opens on <em>Web link</em> when the selected text is a URL.</li></ul><p>To create a link with a custom text:</p><ul><li>First, type and select the text which will be turned into a link.</li><li>Follow the previous steps to open the link interface (via the formatting toolbar, or <kbd>Ctrl</kbd>+<kbd>K</kbd>).</li><li>Alternatively, simply paste (<kbd>Ctrl</kbd>+<kbd>V</kbd>) over the selected text to turn it into a link.</li></ul><p>Once a link is inserted:</p><ul><li>The text inside the link can be changed if needed but the link itself will remain.</li><li>To modify the link, click on the link to display the popup and press the <span class=\"tn-icon cke cke-pencil\"></span> <em>Edit link</em> button. Since v0.107.0, it opens the <em>Edit link</em> dialog, filled with the link's address and text, as do placing the cursor inside the link and pressing <kbd>Ctrl</kbd>+<kbd>L</kbd> or the <span class=\"tn-icon cke cke-trilium\"></span> button. <em>Save link</em> changes the whole link, its text included, and the dialog can also turn it into a link to a note.</li><li>To remove a link, click on it and press the <span class=\"tn-icon cke cke-unlink\"></span> <em>Unlink</em> button.</li></ul><p>You can follow external link by either double clicking (will open new tab/window) it or right clicking on them and choosing \"Open in new tab\".</p>",- "_help_hrZ1D00cLbal": "<p>Internal links are links to other notes within Trilium.</p><p>You can open an internal link by clicking it. You can also see a read-only preview of an internal link's contents by hovering over it.</p><h2>Inserting internal links</h2><p>Internal links can be created at the current position in a text note by:</p><ol><li>Pressing <kbd>Ctrl</kbd> + <kbd>L</kbd> or the <span class=\"tn-icon cke cke-trilium\"></span> button underneath the <span class=\"tn-icon cke cke-plus\"></span> menu in the <a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>.</li><li>Searching for the title of the desired note to link. It's also possible to create new notes from this dialog by typing a non-existing note title and selecting either <em>Create note</em>, which places it in the <a class=\"reference-link\" href=\"#root/_help_S0Fos78ZfcY7\">Note Inbox</a> (today's day note, or the top level, when no inbox is set), or <em>Create child note</em>, which places it under the note being edited.</li></ol><p>There are two link types, chosen with the <em>Mirror the note's title</em> switch of the dialog, which is on by default:</p><ol><li>With the switch on, the link mirrors the note's title.<ol><li>This is sometimes also called \"reference link\".</li><li>The title of this link cannot be changed. Instead, it will always show the current title of the linked note.</li><li>The icon of the linked note will also be displayed.</li><li>If the linked note is deleted, the link keeps the last title it showed, in red and with a <span class=\"tn-icon bx bx-x\"></span> icon instead of the note icon. Clicking it while editing opens the <em>Fix link</em> dialog, which searches for that title; picking a note, or creating a new one, replaces the link with one to that note.</li></ol></li><li>With the switch off, the link has a title of its own, typed in the <em>Link title</em> field.<ol><li>This will create a traditional hyperlink, where the text of the link can be different from the note title.</li></ol></li></ol><p>Since v0.107.0, to change a link whose title does not mirror the note's, click it and press the <span class=\"tn-icon cke cke-pencil\"></span> <em>Edit link</em> button in its popup, or place the cursor inside it and press <kbd>Ctrl</kbd> + <kbd>L</kbd> or the <span class=\"tn-icon cke cke-trilium\"></span> button. The <em>Edit link</em> dialog opens on the linked note, with its anchor and the link's text; <em>Save link</em> changes the whole link. Turning <em>Mirror the note's title</em> on there turns it into a link that mirrors the title.</p><h2>In-place linking</h2><p>You can also insert internal links “inline” by using the <code>@</code> symbol:</p><ol><li>Type <code>@</code> in a text note, which will open the note search menu.</li><li>Search for the desired note's title by typing a few characters. Use <kbd>Up</kbd> and <kbd>Down</kbd> to select the correct note, and press <kbd>Enter</kbd> or <kbd>Tab</kbd> to create the link. It's also possible to create new notes with this method by typing a non-existing note title and selecting <em>Create note</em> or <em>Create child note</em>, as described above.</li></ol><p>To create an empty child note and link to it before naming it, use <em>New child note</em>, described in <a class=\"reference-link\" href=\"#root/_help_CohkqWQC1iBv\">Insert buttons</a>.</p><h2>Pasting internal links</h2><p>You can also insert internal links by copying a note from the note tree.</p><ol><li>In the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>, select a note and press <kbd>Ctrl</kbd> + <kbd>C</kbd>.</li><li>In a text note, paste the link by pressing <kbd>Ctrl</kbd> + <kbd>V</kbd>.</li></ol>",+ "_help_hrZ1D00cLbal": "<p>Internal links are links to other notes within Trilium.</p><p>You can open an internal link by clicking it. You can also see a read-only preview of an internal link's contents by hovering over it.</p><h2>Inserting internal links</h2><p>Internal links can be created at the current position in a text note by:</p><ol><li>Pressing <kbd>Ctrl</kbd> + <kbd>L</kbd> or the <span class=\"tn-icon cke cke-trilium\"></span> button underneath the <span class=\"tn-icon cke cke-plus\"></span> menu in the <a class=\"reference-link\" href=\"#root/_help_nRhnJkTT8cPs\">Formatting toolbar</a>.</li><li>Searching for the title of the desired note to link. It's also possible to create new notes from this dialog by typing a non-existing note title and selecting either <em>Create note</em>, which places it in the <a class=\"reference-link\" href=\"#root/_help_S0Fos78ZfcY7\">Note Inbox</a> (today's day note, or the top level, when no inbox is set), or <em>Create child note</em>, which places it under the note being edited.</li></ol><p>There are two link types, chosen with the <em>Mirror the note's title</em> switch of the dialog, which is on by default:</p><ol><li>With the switch on, the link mirrors the note's title.<ol><li>This is sometimes also called \"reference link\".</li><li>The title of this link cannot be changed. Instead, it will always show the current title of the linked note.</li><li>The icon of the linked note will also be displayed.</li><li>If the linked note is deleted, the link keeps the last title it showed, in red and with a <span class=\"tn-icon bx bx-x\"></span> icon instead of the note icon. Clicking it while editing opens the <em>Fix link</em> dialog, which searches for that title; picking a note, or creating a new one, replaces the link with one to that note.</li></ol></li><li>With the switch off, the link has a title of its own, typed in the <em>Link title</em> field.<ol><li>This will create a traditional hyperlink, where the text of the link can be different from the note title.</li></ol></li></ol><p>Since v0.107.0, to change a link whose title does not mirror the note's, click it and press the <span class=\"tn-icon cke cke-pencil\"></span> <em>Edit link</em> button in its popup, or place the cursor inside it and press <kbd>Ctrl</kbd> + <kbd>L</kbd> or the <span class=\"tn-icon cke cke-trilium\"></span> button. The <em>Edit link</em> dialog opens on the linked note, with its anchor and the link's text; <em>Save link</em> changes the whole link. Turning <em>Mirror the note's title</em> on there turns it into a link that mirrors the title.</p><h2>In-place linking</h2><p>You can also insert internal links “inline” by using the <code>@</code> symbol:</p><ol><li>Type <code>@</code> in a text note, which will open the note search menu.</li><li>Search for the desired note's title by typing a few characters. Use <kbd>Up</kbd> and <kbd>Down</kbd> to select the correct note, and press <kbd>Enter</kbd> or <kbd>Tab</kbd> to create the link. It's also possible to create new notes with this method by typing a non-existing note title and selecting <em>Create note</em>, as described above, or <em>Create child note</em>. <em>Create child note</em> creates the note under the note being edited without asking for its type, inserts the link and opens the new note in <a class=\"reference-link\" href=\"#root/_help_ZjLYv08Rp3qC\">Quick edit</a>, which offers the note types to turn it into while it is still empty.</li></ol><p>To create an empty child note and link to it before naming it, use <em>New child note</em>, described in <a class=\"reference-link\" href=\"#root/_help_CohkqWQC1iBv\">Insert buttons</a>.</p><h2>Pasting internal links</h2><p>You can also insert internal links by copying a note from the note tree.</p><ol><li>In the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>, select a note and press <kbd>Ctrl</kbd> + <kbd>C</kbd>.</li><li>In a text note, paste the link by pressing <kbd>Ctrl</kbd> + <kbd>V</kbd>.</li></ol>","_help_wfGXLmm7x27z": "<p>A link points from one note to another; a <em>backlink</em> is that same connection seen from the other end: the list of notes that refer to the current one.</p><p>Backlinks are maintained automatically and are read-only from this side. A backlink disappears when the note that created it removes the link; it cannot be deleted from the note being pointed at.</p><h2>What counts as a backlink</h2><p>Any <a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a> pointing at the current note, which covers two rather different cases:</p><ul><li>Relations that Trilium maintains on your behalf.<ul><li>The most common is <code>internalLink</code>, created whenever a note refers to another one through <a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a> in its text.</li><li>Embedded images (<code>imageLink</code>), relation map connections (<code>relationMapLink</code>) and note inclusions (<code>includeNoteLink</code>) work the same way.</li></ul></li><li>Relations you define yourself.<ul><li>If another note has <code>~author</code> pointing at the current note, that note is listed here as well.</li></ul></li></ul><p>Relations coming from a <a class=\"reference-link\" href=\"#root/_help_m523cpzocqaD\">Saved Search</a> are excluded, since a search stores an <code>ancestor</code> relation that would otherwise list every one of its results as a backlink.</p><aside class=\"admonition note\"><p>Only some note types have their content scanned for links: <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a>, <a class=\"reference-link\" href=\"#root/_help_6RM1Q7ppFVoj\">Markdown</a>, <a class=\"reference-link\" href=\"#root/_help_iRwzGnHPzonm\">Relation Map</a> and <a class=\"reference-link\" href=\"#root/_help_GBBMSlVSOIGP\">AI</a> chats. A link written inside a <a class=\"reference-link\" href=\"#root/_help_6f9hih2hXXZk\">Code</a> note is not registered and will not appear as a backlink on the target note. A relation set manually on a code note does still count.</p></aside><h2>How entries are displayed</h2><p>Each entry names the note the reference comes from, followed by one of:</p><ul><li><strong>An excerpt</strong> of the surrounding content, with the link itself highlighted. This is available for <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes and for <a class=\"reference-link\" href=\"#root/_help_GBBMSlVSOIGP\">AI</a> chat notes. Roughly 200 characters of context are quoted around the link, trimmed with an ellipsis where the surrounding text is longer, and images are left out.</li><li><strong>The name of the relation</strong>, for every other note type where the source cannot be quoted. This is the case for <a class=\"reference-link\" href=\"#root/_help_iRwzGnHPzonm\">Relation Map</a> notes and for any note carrying a relation you defined yourself.</li></ul><p>A note is listed once per reference it makes, so a note that links to the current one three times occupies three rows.</p><p>Of note:</p><ul><li>For AI chat notes, only the assistant's own prose is quoted. A chat that reached the note purely through tool calls has nothing to quote and is listed by relation name instead.</li><li>Excerpts are only generated for roughly the first 50 sources. On a heavily referenced note, the remaining entries fall back to showing the relation name.</li></ul><h2>Where backlinks are shown</h2><ul><li>In the <a class=\"reference-link\" href=\"#root/_help_KRlZFoIH0j6p\">Connections tab</a> of the <a class=\"reference-link\" href=\"#root/_help_RnaPdbciOfeq\">Right Sidebar</a>, as a dedicated section.</li><li>As a badge in the <a class=\"reference-link\" href=\"#root/_help_AlJ73vBCjWDw\">Status bar</a> showing the number of backlinks. The badge only appears when the note is being read normally (not in a revision or attachment view) and when there is at least one backlink; pressing it opens the section above.</li><li>In <a class=\"reference-link\" href=\"#root/_help_ZjLYv08Rp3qC\">Quick edit</a>, as a button with a link icon in the header of the popup, under the same conditions; its tooltip gives the number of backlinks. Pressing a backlink opens that note in the popup.</li><li>Incoming links are also drawn on the link map, see <a class=\"reference-link\" href=\"#root/_help_BCkXAVs63Ttv\">Note Map (Link map, Tree map)</a>.</li></ul>","_help_S6Xx8QIWTV66": "<p>There are three types of lists supported by text notes:</p><ul><li><span class=\"tn-icon cke cke-bulleted-list\"></span> Bulleted lists (also known as unordered lists).</li><li><span class=\"tn-icon cke cke-numbered-list\"></span> Numbered lists (or ordered lists).</li><li><span class=\"tn-icon cke cke-todo-list\"></span> To-do lists</li></ul><p>For bulleted and numbered lists, it's possible to configure an alternative marker such as squares or Roman numbering by pressing the <span class=\"tn-icon cke cke-dropdown-arrow\"></span> icon. For numbered lists, it's also possible to specify the number to start at or whether to count in reverse order. On the <a class=\"reference-link\" href=\"#root/_help_RDslemsQ6gCp\">Mobile Frontend</a>, these are in the row of the <em>List ›</em> button, which shows while the cursor is in a list; its <em>List type</em> button also turns the list into another kind, to-do lists included.</p><h2>Keyboard interaction</h2><ul><li>To create a new list:<ul><li>Bulleted list: Start a line with <code>*</code> or <code>-</code> followed by a space;</li><li>Numbered list: Start a line with <code>1.</code> or <code>1)</code> followed by a space;</li><li>To-do list: Start a line with <code>- [ ]</code> for an unchecked item or <code>[x]</code> for a checked item.</li></ul></li><li>To create a new item in the list, press <kbd>Enter</kbd>.</li><li>To create a blank line within a list item, press <kbd>Shift</kbd>+<kbd>Enter</kbd>.</li><li>To exit out of the list, press <kbd>Enter</kbd> twice.</li><li>To merge two lists, simply delete the gap between them.</li><li>To create nested lists, simply use the <span class=\"tn-icon cke cke-indent\"></span> button (see <em>Indentation</em> in <a class=\"reference-link\" href=\"#root/_help_dEHYtoWWi8ct\">Other features</a>) or the <kbd>Tab</kbd> key. To decrease the nesting level for the current element, press <kbd>Shift</kbd>+<kbd>Tab</kbd>.</li></ul><h2>Headings, code blocks within lists</h2><p>It possible to add content-level blocks such as headings, code blocks, tables within lists, as follows:</p><figure class=\"table\"><table><tbody><tr><td>1</td><td><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/2_Lists_image.jpg\"></td><td>First, create a list.</td></tr><tr><td>2</td><td><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/4_Lists_image.jpg\"></td><td>Press Enter to create a new list item.</td></tr><tr><td>3</td><td><img src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/1_Lists_image.jpg\"></td><td>Press Backspace to get rid of the bullet point. Notice the cursor position.</td></tr><tr><td>4</td><td><img class=\"image_resized\" style=\"aspect-ratio:676/112;width:98.29%;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/5_Lists_image.jpg\" width=\"676\" height=\"112\"></td><td>At this point, insert any desired block-level item such as a code block.</td></tr><tr><td>5</td><td><img class=\"image_resized\" style=\"aspect-ratio:675/129;width:94.22%;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/3_Lists_image.jpg\" width=\"675\" height=\"129\"></td><td>To continue with a new bullet point, press Enter until the cursor moves to a new blank position.</td></tr><tr><td>6</td><td><img class=\"image_resized\" style=\"aspect-ratio:675/129;width:100%;\" src=\"{{helpAssets}}/User%20Guide/Note%20Types/Text/Lists_image.jpg\" width=\"675\" height=\"129\"></td><td>Press Enter once more to create the new bullet.</td></tr></tbody></table></figure><p>The same principle applies to all three list types (bullet, numbered and to-do).</p><h2>Sorting</h2><p>The items of a list can be sorted, nested items moving with the item they belong to. This is experimental, see <a class=\"reference-link\" href=\"#root/_help_0vgWgxQAWj4a\">Sorting</a>.</p><h2>Alignment</h2><p>A list item can be centered or aligned to the right, either with the text alignment button in the formatting toolbar or by aligning the <a class=\"reference-link\" href=\"#root/_help_NdowYOC1GFKS\">Tables</a> cell that contains the list. The bullet, number or checkbox then moves together with the text of the item.</p><h2>To-do lists</h2><p>See <a class=\"reference-link\" href=\"#root/_help_fASfBrYnquKU\">To-do Lists</a>.</p><h2>Collapsible lists</h2><p>Starting with Trilium v0.104.0, it is possible to collapse nested list items. This applies to bullet lists, numbered lists as well as to-do lists.</p><p>To collapse or expand a list item that has nested sub-items:</p><ul><li>Using the mouse, move the cursor over the list item and an arrow will appear to its left. Clicking it will toggle between collapsed and expanded.</li><li>For bullet lists and numbered lists, it's also possible to click directly on the marker (e.g. the bullet or the number) instead of on the arrow to collapse or expand it. This won't work for to-do lists since this would toggle the to-do instead.</li><li>Press <kbd>Ctrl</kbd>+<kbd>Alt</kbd>+<kbd>Enter</kbd> which will toggle the collapse/expand state for the item at the cursor position.</li></ul><p>Of note:</p><ul><li>Collapsed items always show the arrow to indicate its state.</li><li>The collapsed state is saved at note level and synced across instances, which means that it will restore after a refresh or reopening of the application.</li><li>The collapsed state is also persisted in <a class=\"reference-link\" href=\"#root/_help_mHbBMPDPkVV5\">Import & Export</a>, but only for the HTML format. Markdown exports will not preserve the collapse state.</li><li>Collapsible bullets only exist in the context of editable text notes. Read-only lists will always be fully expanded.</li><li>The list items will auto-expand on edit to avoid typing in a hidden area.</li></ul>","_help_QrtTYPmdd1qq": "<p>Markdown-like formatting allows inserting some basic formatting by typing the Markdown equivalent. Note that this does not mean that <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes supports Markdown, these are just some convenience shortcuts.</p><p>To import more complex formatting into text notes, consider using the <a href=\"#root/_help_dEHYtoWWi8ct\"><em>Import from Markdown</em></a> function. For fully-fleged Markdown notes imports, consider using the dedicated <a href=\"#root/_help_Oau6X9rCuegd\">import</a> function.</p><ul><li>For <a href=\"#root/_help_Gr6xFaF6ioJ5\">headings:</a><ul><li><code>##</code> for Heading 2 (the first-level heading is reserved for the note title).</li><li><code>###</code> for Heading 3</li><li><code>####</code> for Heading 4</li><li><code>#####</code> for Heading 5</li><li><code>######</code> for Heading 6</li></ul></li><li>For <a class=\"reference-link\" href=\"#root/_help_Gr6xFaF6ioJ5\">General formatting</a>:<ul><li><strong>Bold</strong>: Type <code>**text**</code> or <code>__text__</code></li><li><em>Italic</em>: Type <code>*text*</code> or <code>_text_</code></li><li><del>Strikethrough</del>: Type <code>~~text~~</code></li></ul></li><li>For <a class=\"reference-link\" href=\"#root/_help_S6Xx8QIWTV66\">Lists</a>:<ul><li>Bulleted list: Start a line with <code>*</code> or <code>-</code> followed by a space;</li><li>Numbered list: Start a line with <code>1.</code> or <code>1)</code> followed by a space;</li><li>To-do list: Start a line with <code>[ ]</code> for an unchecked item or <code>[x]</code> for a checked item.</li></ul></li><li>For <a href=\"#root/_help_NwBbFdNZ9h7O\">block quotes</a>, press <code>></code>, followed by a space.</li><li>For <a class=\"reference-link\" href=\"#root/_help_QxEyIjRBizuC\">Code blocks</a>, type <code>```</code>.</li><li>For a <a href=\"#root/_help_dEHYtoWWi8ct\">horizontal line</a>, type <code>---</code>.</li><li>For <a href=\"#root/_help_NwBbFdNZ9h7O\">admonitions</a>:<ul><li><code>!!! note</code></li><li><code>!!! tip</code></li><li><code>!!! important</code></li><li><code>!!! caution</code></li><li><code>!!! warning</code></li><li>Starting any other text with <code>!!!</code> will insert a note admonition with the text inside of it.</li></ul></li><li>For <a href=\"#root/_help_CohkqWQC1iBv\">emojis</a>, type <code>:</code> followed by an emoji name to trigger an auto-completion.</li></ul><p>If auto-formatting is not desirable, press <kbd>Ctrl</kbd> + <kbd>Z</kbd> to revert the text to its original form.</p>",@@ -203,7 +203,7 @@"_help_Cq5X6iKQop6R": "<p>A relation is similar to a <a href=\"#root/_help_HI6GBBIduIgv\">label</a>, but instead of having a text value it refers to another note.</p><h2>Common use cases</h2><ul><li><strong>Metadata Relationships for personal use</strong>: For example, linking a book note to an author note.<br>This can be combined with <a class=\"reference-link\" href=\"#root/_help_OFXdgB2nNk1F\">Promoted Attributes</a> to make their display more user-friendly.</li><li><strong>Configuration</strong>: For configuring some notes such as <a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a>, or configuring <a class=\"reference-link\" href=\"#root/_help_R9pX4DGra2Vt\">Sharing</a> or <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a> (see the list below).</li><li><strong>Scripting</strong>: Attaching scripts to events or conditions related to the note.</li></ul><h2>Creating a relation using the visual editor</h2><ol><li>Go to the <a class=\"reference-link\" href=\"#root/_help_uNtgN0cUKEBc\">Attributes tab</a> in the <a class=\"reference-link\" href=\"#root/_help_RnaPdbciOfeq\">Right Sidebar</a>.</li><li>Press the <span class=\"tn-icon bx bx-plus\"></span> button (<em>Add a new attribute</em>) to the right of the <em>Owned attributes</em> section.</li><li>Select <em>Add new relation</em> for the relation.</li></ol><p>While in the visual editor, set the desired name and the <em>Target note</em> (the note to point to). Unlike labels, relations cannot exist with a target note.</p><p>Children can inherit this relation, click the relation and check <em>Inheritable</em>. See <a class=\"reference-link\" href=\"#root/_help_bwZpz2ajCEwO\">Attribute Inheritance</a> for more information.</p><aside class=\"admonition tip\"><p>Alternatively, press <kbd>Alt</kbd>+<kbd>L</kbd> which will open the attribute details (same view as when an existing attribute is clicked) in the <a class=\"reference-link\" href=\"#root/_help_AlJ73vBCjWDw\">Status bar</a>.</p></aside><h2>Creating a relation manually</h2><p>In the <a class=\"reference-link\" href=\"#root/_help_AlJ73vBCjWDw\">Status bar</a>, press the <span class=\"tn-icon bx bx-list-check\"></span> button to show the list of the attributes.</p><ul><li>To create a relation called <code>myRelation</code>:<ol><li>Click the input box to focus it.</li><li>Type <code>~myRelation=@</code> .</li><li>After this, an autocompletion box should appear.</li><li>Type the title of the note to point to and press <kbd>Enter</kbd> to confirm (or click the desired note).</li><li>Alternatively copy a note from the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> and paste it after the <code>=</code> sign (without the <code>@</code> , in this case).</li></ol></li><li>To create an inheritable relation, follow the same steps as previously described but instead of <code>~myRelation</code> write <code>~myRelation(inheritable)</code>.</li></ul><h2>Predefined relations</h2><p>These relations are supported and used internally by Trilium.</p><figure class=\"table\"><table><thead><tr><th>Label</th><th>Description</th></tr></thead><tbody><tr><td><code>runOn*</code></td><td>See <a class=\"reference-link\" href=\"#root/_help_GPERMystNGTB\">Backend Events</a></td></tr><tr><td><code>template</code></td><td>note's attributes will be inherited even without a parent-child relationship, note's content and subtree will be added to instance notes if empty. See documentation for details.</td></tr><tr><td><code>template:newNoteDefaultParent</code></td><td>set on a template note, points to the note under which notes created from the template are placed when no other location is picked; when set several times, the note is cloned into every target. See <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a>.</td></tr><tr><td><code>inherit</code></td><td>note's attributes will be inherited even without a parent-child relationship. See <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a> for a similar concept. See <a class=\"reference-link\" href=\"#root/_help_bwZpz2ajCEwO\">Attribute Inheritance</a> in the documentation.</td></tr><tr><td><code>renderNote</code></td><td>notes of type <a class=\"reference-link\" href=\"#root/_help_HcABDtFCkbFN\">Render Note</a> will be rendered using a code note (HTML or script) and it is necessary to point using this relation to which note should be rendered</td></tr><tr><td><code>widget</code></td><td>Used in the context of custom <a class=\"reference-link\" href=\"#root/_help_4Gn3psZKsfSm\">Launch Bar Widgets</a>, to refer to the widget that will be rendered.</td></tr><tr><td><code>shareCss</code></td><td>CSS note which will be injected into the share page. CSS note must be in the shared sub-tree as well. Consider using <code>shareHiddenFromTree</code> and <code>shareOmitDefaultCss</code> as well.</td></tr><tr><td><code>shareJs</code></td><td>JavaScript note which will be injected into the share page. JS note must be in the shared sub-tree as well. Consider using <code>shareHiddenFromTree</code>.</td></tr><tr><td><code>shareHtml</code></td><td>HTML note which will be injected into the share page at locations specified by the <code>shareHtmlLocation</code> label. HTML note must be in the shared sub-tree as well. Consider using <code>shareHiddenFromTree</code>.</td></tr><tr><td><code>shareTemplate</code></td><td>Embedded JavaScript note that will be used as the template for displaying the shared note. Falls back to the default template. Consider using <code>shareHiddenFromTree</code>.</td></tr><tr><td><code>shareFavicon</code></td><td>Favicon note to be set in the shared page. Typically you want to set it to share root and make it inheritable. Favicon note must be in the shared sub-tree as well. Consider using <code>shareHiddenFromTree</code>.</td></tr></tbody></table></figure>","_help_bwZpz2ajCEwO": "<p>Inheritance refers to the process of having a <a href=\"#root/_help_HI6GBBIduIgv\">label</a> or a <a href=\"#root/_help_Cq5X6iKQop6R\">relation</a> shared across multiple notes, generally in parent-child relations (or anywhere if using templates).</p><h2>Standard Inheritance</h2><p>In Trilium, attributes can be automatically inherited by child notes if they have the <code>isInheritable</code> flag set to <code>true</code>. This means the attribute (a key-value pair) is applied to the note and all its descendants.</p><p>To make an attribute inheritable, simply use the visual editor for <a class=\"reference-link\" href=\"#root/_help_HI6GBBIduIgv\">Labels</a> or <a class=\"reference-link\" href=\"#root/_help_Cq5X6iKQop6R\">Relations</a>. Alternatively, the attribute can be manually defined where <code>#myLabel=value</code> becomes <code>#myLabel(inheritable)=value</code> when inheritable.</p><p>As an example, the <code>archived</code> label can be set to be inheritable, allowing you to hide a whole subtree of notes from searches and other dialogs by applying this label at the top level.</p><p>Standard inheritance forces all the notes that are children (and sub-children) of a note to have that particular label or relation. If there is a need to have some notes not inherit one of the labels, then <em>copying inheritance</em> or <em>template inheritance</em> needs to be used instead.</p><h2>Copying Inheritance</h2><p>Copying inheritance differs from standard inheritance by using a <code>child:</code> prefix in the attribute name. This prefix causes new child notes to automatically receive specific attributes from the parent note. These attributes are independent of the parent and will persist even if the note is moved elsewhere.</p><p>If a parent note has the label <code>#child:exampleAttribute</code>, all newly created child notes (one level deep) will inherit the <code>#exampleAttribute</code> label. This can be useful for setting default properties for notes in a specific section.</p><p>Similarly, for relations use <code>~child:myRelation</code>.</p><p>Due to the way it's designed, copying inheritance cannot be used to cascade infinitely within a hierarchy. For that use case, consider using either standard inheritance or templates.</p><h3>Chained inheritance</h3><p>It is possible to define labels across multiple levels of depth. For example, <code>#child:child:child:foo</code> applied to a root note would create:</p><ul><li><code>#child:child:foo</code> on the first-level children.</li><li><code>#child:foo</code> on the second-level children.</li><li><code>#foo</code> on the third-level children.</li></ul><p>Similarly, use <code>~child:child:child:foo</code> if dealing with relations.</p><p>Do note that same as simple copying inheritance, the changes will not apply retroactively to existing notes in the hierarchy, it will only apply to the newly created notes.</p><h2>Template Inheritance</h2><p>Attributes can also be inherited from <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a>. When a new note is created using a template, it inherits the attributes defined in that template. This is particularly useful for maintaining consistency across notes that follow a similar structure or function.</p>","_help_OFXdgB2nNk1F": "<figure class=\"image image_resized\" style=\"width:61.4%;\"><img style=\"aspect-ratio:938/368;\" src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Attributes/Promoted%20Attributes_image.png\" width=\"938\" height=\"368\"></figure><p>Promoted attributes are <a href=\"#root/_help_zEY4DaJG4YT5\">attributes</a> which are displayed prominently in the UI which allow them to be easily viewed and edited.</p><p>The promoted attributes are shown underneath the <a class=\"reference-link\" href=\"#root/_help_l7pigIGu01K2\">Title</a> of the note, in a collapsible section. For full-height notes such as <a class=\"reference-link\" href=\"#root/_help_grjYqerjn243\">Canvas</a>, the promoted attributes are collapsed by default to make room.</p><p>One way of seeing promoted attributes is as a kind of form with several fields. Each field is just regular attribute, the only difference is that they appear on the note itself.</p><p>Attributes can be pretty useful since they allow for querying and script automation etc. but they are also inconveniently hidden. This allows you to select few of the important ones and push them to the front of the user.</p><h2>Attribute definition</h2><figure class=\"image image-style-align-right image_resized\" style=\"width:50%;\"><img style=\"aspect-ratio:885/742;\" src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Attributes/2_Promoted%20Attributes_image.png\" width=\"885\" height=\"742\"></figure><p>In order to have promoted attributes, there needs to be a way to define them.</p><p>Technically, attributes are only name-value pairs where both name and value are strings.</p><p>The <em>Attribute definition</em> specifies how should this value be interpreted:</p><ul><li>Is it just string, or is it a date?</li><li>Should we allow multiple values or note?</li><li>Should we <em>promote</em> the attribute or not?</li></ul><h2>Types of attributes</h2><p>Attribute definitions have a dedicated type field which will change how the value will be edited in the promoted attributes section.</p><p>The following types are supported:</p><ul><li><em>Text</em>, the default option which allows any type of text to be edited, similar to normal labels that don't have a type associated.</li><li><em>Multi-line text</em>, similar to a normal text field, but rendered in a bigger text box that also supports writing on multiple lines.</li><li><em>Number</em>, will display as a number input field with up/down arrows.<ul><li>Optionally a <em>precision</em> which sets how many decimals the value steps by and is displayed with.</li></ul></li><li><em>Checkbox</em>, which renders as a checkbox for a true/false value. In the label definition, this type is written as <code>boolean</code>.</li><li><em>Select,</em> which provides a list of user-defined options when editing.<ul><li>The list is not fixed, meaning that new options can be easily added from the promoted attribute.</li><li>Renaming an option does not change the existing values since the value is stored as text. Consider a <a href=\"#root/_help_ivYnonVFBxbQ\">bulk rename</a>.</li><li>The items do not have a custom color or icon. This is intentional as selects are meant to be light-weight. For a more customizable option, consider using <a class=\"reference-link\" href=\"#root/_help_Cq5X6iKQop6R\">Relations</a> instead which use notes as items and those notes can be colorized and also carry an icon.</li></ul></li><li><em>Date,</em> which provides a date picker.</li><li><em>Date & Time,</em> which provides a date & time picker.</li><li><em>Time,</em> which provides a time picker.</li><li><em>URL,</em> which provides a button to open the web address in a new window.</li><li><em>Email</em>, which provides a button to quickly send an email to that address using your operating system's default app.</li><li><em>Phone</em>, which provides a button to quickly call that number using your operating system's default app.</li><li><em>Color</em>, which provides a color picker and a way to remove the value.</li><li><em>Relation</em>, which points to another note and uses <a class=\"reference-link\" href=\"#root/_help_Cq5X6iKQop6R\">Relations</a> instead of <a class=\"reference-link\" href=\"#root/_help_HI6GBBIduIgv\">Labels</a>.</li></ul><aside class=\"admonition note\"><p>For label-based attributes, these types are not enforced by the attribute system, meaning that changing the type afterwards does not guarantee that the values in it correspond to the type (e.g. turning a text into a number).</p></aside><h2>Multiple values</h2><p>When the definition allows multiple values, each value is shown as a chip and a new one is added in the box after them. Press the <span class=\"tn-icon bx bx-x\"></span> on a chip to remove that value.</p><ul><li>For free-form types such as <em>Text</em>, <em>Number</em> or <em>Date</em>, press <kbd>Enter</kbd> (or leave the field) to add what was typed. The same value can be added more than once, for example two payments of the same amount.</li><li>For <em>Select</em>, <em>Checkbox</em> and <em>Relation</em> attributes, a value is picked from the list rather than typed, and each one can be picked only once.</li></ul><h2>Creating a new promoted attribute definition</h2><p>To create a new promoted attribute:</p><ol><li>Go to a note.</li><li>Go to the <a class=\"reference-link\" href=\"#root/_help_uNtgN0cUKEBc\">Attributes tab</a> in the <a class=\"reference-link\" href=\"#root/_help_RnaPdbciOfeq\">Right Sidebar</a>.</li><li>Press the <span class=\"tn-icon bx bx-plus\"></span> button for the top-most section (<em>Owned attributes</em>).</li><li>Select either <em>Add new label definition…</em> or <em>Add new relation definition…</em>.</li><li>Select the name which will be name of the label or relation that will be created when the promoted attribute is edited.</li><li>Ensure <em>Promoted</em> is checked in order to display it at the top of notes.</li><li>Optionally, choose an <em>Alias</em> which will be displayed next to the promoted attribute instead of the attribute name. Generally it's best to choose a “user-friendly” name since it can contain spaces and other characters which are not supported as attribute names.</li><li>Check <em>Inheritable</em> to apply it to this note and all its descendants. To keep it only for the current note, un-check it.</li><li>Press <em>Save & Close</em> to apply the changes.</li></ol><p>Alternatively, promoted attributes can be created from the <a class=\"reference-link\" href=\"#root/_help_AlJ73vBCjWDw\">Status bar</a> by going to <span class=\"tn-icon bx bx-list-check\"></span> (<em>Attributes</em>), pressing the <span class=\"tn-icon bx bx-plus\"></span> button and selecting <em>Add new label definition…</em>. The resulting attribute can also be copy-pasted or written manually (albeit discouraged).</p><h2>How attribute definitions actually work</h2><p>When a new promoted attribute definition is created, it creates a corresponding label prefixed with either <code>label</code> or <code>relation</code>, depending on the definition type:</p><pre><code class=\"language-text-x-trilium-auto\">#label:myColor(inheritable)=\"promoted,alias=Color,multi,color\"</code></pre><p>The only purpose of the attribute definition is to set up a template. If the attribute was marked as promoted, then it's also displayed to the user for easy editing.</p><figure class=\"table\"><table><tbody><tr><td><figure class=\"image\"><img style=\"aspect-ratio:495/157;\" src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Attributes/1_Promoted%20Attributes_image.png\" width=\"495\" height=\"157\"></figure></td><td>Notice how the promoted attribute definition only creates a “Due date” box above the text content.</td></tr><tr><td><figure class=\"image\"><img style=\"aspect-ratio:663/160;\" src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Attributes/3_Promoted%20Attributes_image.png\" width=\"663\" height=\"160\"></figure></td><td>Once a value is set by the user, a new label (or relation, depending on the type) is created. The name of the attribute matches one set when creating the promoted attribute.</td></tr></tbody></table></figure><p>So there's one attribute for value and one for definition. But notice how an definition attribute can be made <a href=\"#root/_help_bwZpz2ajCEwO\">Inheritable</a>, meaning that it's also applied to all descendant notes. In this case, the definition used for the whole sub-tree while \"value\" attributes are for each not individually.</p><h2>Using system attributes</h2><p>It's possible to create promoted attributes out of system attributes, to be able to easily alter them.</p><p>Here are a few practical examples:</p><ul><li><a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a> already make use of this practice, for example:<ul><li>Calendars add “Start Date”, “End Date”, “Start Time” and “End Time” as promoted attributes. These map to system attributes such as <code>startDate</code> which are then interpreted by the calendar view.</li><li><a class=\"reference-link\" href=\"#root/_help_zP3PMqaG71Ct\">Presentation</a> adds a “Background” promoted attribute for each of the slide to easily be able to customize.</li></ul></li><li>The Trilium documentation (which is edited in Trilium) uses a promoted attribute to be able to easily edit the <code>#shareAlias</code> (see <a class=\"reference-link\" href=\"#root/_help_R9pX4DGra2Vt\">Sharing</a>) in order to form clean URLs.</li><li>If you always edit a particular system attribute such as <code>#color</code>, simply create a promoted attribute for it to make it easier.</li></ul><h3>Inverse relation</h3><p>Some relations always occur in pairs - my favorite example is on the family. If you have a note representing husband and note representing wife, then there might be a relation between those two of <code>isPartnerOf</code>. This is bidirectional relationship - meaning that if a relation is pointing from husband to wife then there should be always another relation pointing from wife to husband.</p><p>Another example is with parent-child relationship. Again these always occur in pairs, but in this case it's not exact same relation - the one going from parent to child might be called <code>isParentOf</code> and the other one going from child to parent might be called <code>isChildOf</code>.</p><p>Relation definition allows you to specify such \"inverse relation\" - for the relation you just define you specify which is the inverse relation. Note that in the second example we should have two relation definitions - one for <code>isParentOf</code> which defines <code>isChildOf</code> as inverse relation and then second relation definition for <code>isChildOf</code> which defines <code>isParentOf</code> as inverse relation.</p><p>What this does internally is that whenever we save a relation which has defined inverse relation, we check that this inverse relation exists on the relation target note. Similarly, when we delete relation, we also delete inverse relation on the target note.</p><h2>See also</h2><ul><li>The <a class=\"reference-link\" href=\"#root/_help_2FvYrpmOXm29\">Table</a> collection makes heavy use of promoted attributes to define the columns of the table, since they already carry the type information. When made inheritable, it's also easy to change those fields when the child notes are opened.</li></ul>",- "_help_KC1HB96bqqHX": "<p>A template in Trilium serves as a predefined structure for other notes, referred to as instance notes. Assigning a template to a note brings three main effects:</p><ol><li><strong>Attribute Inheritance</strong>: All attributes from the template note are <a href=\"#root/_help_bwZpz2ajCEwO\">inherited</a> by the instance notes. Even attributes with <code>#isInheritable=false</code> are inherited by the instance notes, although only inheritable attributes are further inherited by the children of the instance notes.</li><li><strong>Content Duplication</strong>: The content of the template note is copied to the instance note, provided the instance note is empty at the time of template assignment.</li><li><strong>Child Note Duplication</strong>: All child notes of the template are deep-duplicated to the instance note.</li></ol><h2>Example</h2><p>A typical example would be a \"Book\" template note, which might include:</p><ul><li><strong>Promoted Attributes</strong>: Such as publication year, author, etc. (see <a href=\"#root/_help_OFXdgB2nNk1F\">promoted attributes</a>).</li><li><strong>Outline</strong>: An outline for a book review, including sections like themes, conclusion, etc.</li><li><strong>Child Notes</strong>: Additional notes for highlights, summary, etc.</li></ul><p><img src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Templates_template.png\" alt=\"Template Example\"></p><h2>Instance Note</h2><p>An instance note is a note related to a template note. This relationship means the instance note's content is initialized from the template, and all attributes from the template are inherited.</p><p>To create an instance note through the UI:</p><p><img src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Templates_template-create-instance-note.png\" alt=\"show child note templates\"></p><p>For the template to appear in the menu, the template note must have the <code>#template</code> label. Do not confuse this with the <code>~template</code> relation, which links the instance note to the template note. If you use <a href=\"#root/_help_9sRHySam5fXb\">workspaces</a>, you can also mark templates with <code>#workspaceTemplate</code> to display them only in the workspace.</p><p>Templates can also be added or changed after note creation by creating a <code>~template</code> relation pointing to the desired template note. </p><p>To specify a template for child notes, you can use a <code>~child:template</code> relation pointing to the appropriate template note. There is no limit to the depth of the hierarchy — you can use <code>~child:child:template</code>, <code>~child:child:child:template</code>, and so on.</p><aside class=\"admonition important\"><p>Changing the template hierarchy after the parent note is created will not retroactively apply to newly created child notes.<br>For example, if you initially use <code>~child:template</code> and later switch to <code>~child:child:template</code>, it will not automatically apply the new template to the grandchild notes. Only the structure present at the time of note creation is considered.</p></aside><h2>Default parent for new notes</h2><p>A template can gather the notes created from it in one place, instead of having them land wherever they happen to be created. To do so, add a <code>~template:newNoteDefaultParent</code> relation to the template note, pointing at the note that should hold the instances, for example a <em>Person</em> template pointing to a <em>People</em> note. The relation can also be set by clicking the template badge next to the note title and selecting <em>Template properties...</em>, then picking a note under <em>Default location of created notes</em>.</p><p>Adding the relation several times places the new note in every target, as <a class=\"reference-link\" href=\"#root/_help_IakOLONlIfGI\">Cloning Notes</a>. The relation can also be inherited (e.g. from a folder holding several templates), in which case a relation owned by the template itself replaces the inherited one. The default parent is only inherited from the template's ancestors in the tree: a template created from another template does not adopt that template's default parent.</p><p>The default parent is used whenever a note is created from the template through the <em>Choose note type</em> dialog:</p><ul><li>Via <code>@</code>-completion in a <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> note</li><li>Via the <em>Create note</em> or <em>Create child note</em> options of the note search (new tab or <a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a>), but only if the dialog's <em>Location</em> field is left empty.</li></ul><p>Creating an instance note from the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> context menu (<em>Insert child note</em>, <em>Insert note after</em>) still creates it at the chosen place.</p><p>Unlike the <a class=\"reference-link\" href=\"#root/_help_S0Fos78ZfcY7\">Note Inbox</a>, which holds quickly captured notes until they are sorted, the default parent is meant as the instances' permanent location.</p><h2>Regarding note types</h2><p>By default, newly created notes are <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes. If a parent note defines a <code>child:template</code> pointing to a template of a different type (e.g. a Code note), the behavior depends on how the new note is created:</p><ul><li>If no note type is explicitly chosen (e.g. the + button in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>), the template is applied and the new note takes the type and content of the template.</li><li>If a note type is explicitly selected (e.g. <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> → <em>Insert note after</em> / <em>Insert child note</em>):<ul><li>If the selected type matches the template's type, the template is applied.</li><li>If the selected type differs, the template is disregarded entirely — the new note is an empty note of the selected type.</li></ul></li></ul><p>Selecting a specific template from the creation menu always takes precedence over <code>child:template</code>.</p><h2>Default title for new notes</h2><p>A template can also give its instances a default title, using the <code>#template:titleTemplate</code> label. To set it without editing the label by hand, click the template badge next to the note title and select <em>Template properties...</em>, which checks the expressions as you type and previews the resulting title. See <a class=\"reference-link\" href=\"#root/_help_47ZrP6FNuoG8\">Default Note Title</a> for details.</p><h2>Additional Notes</h2><p>From a visual perspective, templates can define <code>#iconClass</code> and <code>#cssClass</code> attributes, allowing all instance notes (e.g., books) to display a specific icon and CSS style.</p><p>Explore the concept further in the <a class=\"reference-link\" href=\"#root/_help_6tZeKvSHEUiB\">Demo Notes</a>, including examples like the <a class=\"reference-link\" href=\"#root/_help_iRwzGnHPzonm\">Relation Map</a>, <a class=\"reference-link\" href=\"#root/_help_xYjQUYhpbUEW\">Task Manager</a>, and <a class=\"reference-link\" href=\"#root/_help_l0tKav7yLHGF\">Day Notes</a>.</p><p>Additionally, see <a class=\"reference-link\" href=\"#root/_help_47ZrP6FNuoG8\">Default Note Title</a> for creating title templates. A <code>#titleTemplate</code> on a template note is passed on to its instances like any other label, so it names the children of each instance rather than the instances themselves; to name the instances, use <code>#template:titleTemplate</code>.</p>",+ "_help_KC1HB96bqqHX": "<p>A template in Trilium serves as a predefined structure for other notes, referred to as instance notes. Assigning a template to a note brings three main effects:</p><ol><li><strong>Attribute Inheritance</strong>: All attributes from the template note are <a href=\"#root/_help_bwZpz2ajCEwO\">inherited</a> by the instance notes. Even attributes with <code>#isInheritable=false</code> are inherited by the instance notes, although only inheritable attributes are further inherited by the children of the instance notes.</li><li><strong>Content Duplication</strong>: The content of the template note is copied to the instance note, provided the instance note is empty at the time of template assignment.</li><li><strong>Child Note Duplication</strong>: All child notes of the template are deep-duplicated to the instance note.</li></ol><h2>Example</h2><p>A typical example would be a \"Book\" template note, which might include:</p><ul><li><strong>Promoted Attributes</strong>: Such as publication year, author, etc. (see <a href=\"#root/_help_OFXdgB2nNk1F\">promoted attributes</a>).</li><li><strong>Outline</strong>: An outline for a book review, including sections like themes, conclusion, etc.</li><li><strong>Child Notes</strong>: Additional notes for highlights, summary, etc.</li></ul><p><img src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Templates_template.png\" alt=\"Template Example\"></p><h2>Instance Note</h2><p>An instance note is a note related to a template note. This relationship means the instance note's content is initialized from the template, and all attributes from the template are inherited.</p><p>To create an instance note through the UI:</p><p><img src=\"{{helpAssets}}/User%20Guide/Advanced%20Usage/Templates_template-create-instance-note.png\" alt=\"show child note templates\"></p><p>For the template to appear in the menu, the template note must have the <code>#template</code> label. Do not confuse this with the <code>~template</code> relation, which links the instance note to the template note. If you use <a href=\"#root/_help_9sRHySam5fXb\">workspaces</a>, you can also mark templates with <code>#workspaceTemplate</code> to display them only in the workspace.</p><p>Templates can also be added or changed after note creation by creating a <code>~template</code> relation pointing to the desired template note. </p><p>To specify a template for child notes, you can use a <code>~child:template</code> relation pointing to the appropriate template note. There is no limit to the depth of the hierarchy — you can use <code>~child:child:template</code>, <code>~child:child:child:template</code>, and so on.</p><aside class=\"admonition important\"><p>Changing the template hierarchy after the parent note is created will not retroactively apply to newly created child notes.<br>For example, if you initially use <code>~child:template</code> and later switch to <code>~child:child:template</code>, it will not automatically apply the new template to the grandchild notes. Only the structure present at the time of note creation is considered.</p></aside><h2>Default parent for new notes</h2><p>A template can gather the notes created from it in one place, instead of having them land wherever they happen to be created. To do so, add a <code>~template:newNoteDefaultParent</code> relation to the template note, pointing at the note that should hold the instances, for example a <em>Person</em> template pointing to a <em>People</em> note. The relation can also be set by clicking the template badge next to the note title and selecting <em>Template properties...</em>, then picking a note under <em>Default location of created notes</em>.</p><p>Adding the relation several times places the new note in every target, as <a class=\"reference-link\" href=\"#root/_help_IakOLONlIfGI\">Cloning Notes</a>. The relation can also be inherited (e.g. from a folder holding several templates), in which case a relation owned by the template itself replaces the inherited one. The default parent is only inherited from the template's ancestors in the tree: a template created from another template does not adopt that template's default parent.</p><p>The default parent is used whenever a note is created from the template through the <em>Choose note type</em> dialog:</p><ul><li>Via the <em>Create note</em> option of the <code>@</code>-completion in a <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> note</li><li>Via the <em>Create note</em> or <em>Create child note</em> options of the note search (new tab or <a class=\"reference-link\" href=\"#root/_help_hrZ1D00cLbal\">Internal (reference) links</a>), but only if the dialog's <em>Location</em> field is left empty.</li></ul><p>Creating an instance note from the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> context menu (<em>Insert child note</em>, <em>Insert note after</em>) still creates it at the chosen place.</p><p>Unlike the <a class=\"reference-link\" href=\"#root/_help_S0Fos78ZfcY7\">Note Inbox</a>, which holds quickly captured notes until they are sorted, the default parent is meant as the instances' permanent location.</p><h2>Regarding note types</h2><p>By default, newly created notes are <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> notes. If a parent note defines a <code>child:template</code> pointing to a template of a different type (e.g. a Code note), the behavior depends on how the new note is created:</p><ul><li>If no note type is explicitly chosen (e.g. the + button in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>), the template is applied and the new note takes the type and content of the template.</li><li>If a note type is explicitly selected (e.g. <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> → <em>Insert note after</em> / <em>Insert child note</em>):<ul><li>If the selected type matches the template's type, the template is applied.</li><li>If the selected type differs, the template is disregarded entirely — the new note is an empty note of the selected type.</li></ul></li></ul><p>Selecting a specific template from the creation menu always takes precedence over <code>child:template</code>.</p><h2>Default title for new notes</h2><p>A template can also give its instances a default title, using the <code>#template:titleTemplate</code> label. To set it without editing the label by hand, click the template badge next to the note title and select <em>Template properties...</em>, which checks the expressions as you type and previews the resulting title. See <a class=\"reference-link\" href=\"#root/_help_47ZrP6FNuoG8\">Default Note Title</a> for details.</p><h2>Additional Notes</h2><p>From a visual perspective, templates can define <code>#iconClass</code> and <code>#cssClass</code> attributes, allowing all instance notes (e.g., books) to display a specific icon and CSS style.</p><p>Explore the concept further in the <a class=\"reference-link\" href=\"#root/_help_6tZeKvSHEUiB\">Demo Notes</a>, including examples like the <a class=\"reference-link\" href=\"#root/_help_iRwzGnHPzonm\">Relation Map</a>, <a class=\"reference-link\" href=\"#root/_help_xYjQUYhpbUEW\">Task Manager</a>, and <a class=\"reference-link\" href=\"#root/_help_l0tKav7yLHGF\">Day Notes</a>.</p><p>Additionally, see <a class=\"reference-link\" href=\"#root/_help_47ZrP6FNuoG8\">Default Note Title</a> for creating title templates. A <code>#titleTemplate</code> on a template note is passed on to its instances like any other label, so it names the children of each instance rather than the instances themselves; to name the instances, use <code>#template:titleTemplate</code>.</p>","_help_B2ORr7OVEZtc": "<p>Snippets let you define reusable pieces of text, Markdown or code that can be quickly inserted into your notes.</p>","_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 <kbd>/</kbd> followed by the first letters of its title, then select it from the list. Typing <code>/snippet</code> lists every snippet available in the note. This also works in an included code or Markdown note that is being edited in place, see <a class=\"reference-link\" href=\"#root/_help_nBAXQFj20hS1\">Include Note</a>.</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>",diff --git a/docs/User Guide/User Guide/Advanced Usage/Templates.md b/docs/User Guide/User Guide/Advanced Usage/Templates.mdindex a1e035cc33..23f28b2d99 100644--- a/docs/User Guide/User Guide/Advanced Usage/Templates.md+++ b/docs/User Guide/User Guide/Advanced Usage/Templates.md@@ -41,7 +41,7 @@ Adding the relation several times places the new note in every target, as <a clThe default parent is used whenever a note is created from the template through the _Choose note type_ dialog:-* Via `@`\-completion in a <a class="reference-link" href="../Note%20Types/Text.md">Text</a> note+* Via the _Create note_ option of the `@`\-completion in a <a class="reference-link" href="../Note%20Types/Text.md">Text</a> note* Via the _Create note_ or _Create child note_ options of the note search (new tab or <a class="reference-link" href="../Note%20Types/Text/Links/Internal%20(reference)%20links.md">Internal (reference) links</a>), but only if the dialog's _Location_ field is left empty.Creating an instance note from the <a class="reference-link" href="../Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree.md">Note Tree</a> context menu (_Insert child note_, _Insert note after_) still creates it at the chosen place.diff --git a/docs/User Guide/User Guide/Note Types/Text/Links/Internal (reference) links.md b/docs/User Guide/User Guide/Note Types/Text/Links/Internal (reference) links.mdindex 1b1c4a1c6b..e0e455d57b 100644--- a/docs/User Guide/User Guide/Note Types/Text/Links/Internal (reference) links.md+++ b/docs/User Guide/User Guide/Note Types/Text/Links/Internal (reference) links.md@@ -27,7 +27,7 @@ Since v0.107.0, to change a link whose title does not mirror the note's, click iYou can also insert internal links “inline” by using the `@` symbol:1. Type `@` in a text note, which will open the note search menu.-2. Search for the desired note's title by typing a few characters. Use <kbd>Up</kbd> and <kbd>Down</kbd> to select the correct note, and press <kbd>Enter</kbd> or <kbd>Tab</kbd> to create the link. It's also possible to create new notes with this method by typing a non-existing note title and selecting _Create note_ or _Create child note_, as described above.+2. Search for the desired note's title by typing a few characters. Use <kbd>Up</kbd> and <kbd>Down</kbd> to select the correct note, and press <kbd>Enter</kbd> or <kbd>Tab</kbd> to create the link. It's also possible to create new notes with this method by typing a non-existing note title and selecting _Create note_, as described above, or _Create child note_. _Create child note_ creates the note under the note being edited without asking for its type, inserts the link and opens the new note in <a class="reference-link" href="../../../Basic%20Concepts%20and%20Features/Navigation/Quick%20edit.md">Quick edit</a>, which offers the note types to turn it into while it is still empty.To create an empty child note and link to it before naming it, use _New child note_, described in <a class="reference-link" href="../Insert%20buttons.md">Insert buttons</a>.