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: add support for peeking the tree pane on the horizontal toolbar layout
Adorian Doran97c95322b7b5
diff --git a/apps/client/src/components/app_context.ts b/apps/client/src/components/app_context.tsindex b0b7cf1dad..972d3c1f4d 100644--- a/apps/client/src/components/app_context.ts+++ b/apps/client/src/components/app_context.ts@@ -33,6 +33,7 @@ import type { NotePickerDialogOptions } from "../widgets/dialogs/note_picker.js"import type { ItemPickerDialogOptions } from "../widgets/dialogs/item_picker.js";import type { PromptDialogOptions } from "../widgets/dialogs/prompt.js";import type NoteTreeWidget from "../widgets/note_tree.js";+import type { PaneId, PaneMode } from "../widgets/react/peek_pane.js";import type { RightPaneTabId } from "../widgets/sidebar/RightPaneTabs.jsx";import type { ToolCall } from "../widgets/type_widgets/llm_chat/llm_chat_types.js";import Component from "./component.js";@@ -427,6 +428,7 @@ export type CommandMappings = {openDevTools: CommandData;findInText: CommandData & { searchTerms?: string[] };toggleLeftPane: CommandData;+ peekLeftPane: CommandData;toggleFullscreen: CommandData;zoomOut: CommandData;zoomIn: CommandData;@@ -473,6 +475,11 @@ type EventMappings = {setLeftPaneVisibility: {leftPaneVisible: boolean | null;}+ /** Raised by a side pane after it is closed, peeked or docked. See `peek_pane.ts`. */+ paneModeChanged: {+ pane: PaneId;+ mode: PaneMode;+ }protectedSessionStarted: {};notesReloaded: {noteIds: string[];diff --git a/apps/client/src/layouts/desktop_layout.tsx b/apps/client/src/layouts/desktop_layout.tsxindex 9481e2bf07..dcc759a20a 100644--- a/apps/client/src/layouts/desktop_layout.tsx+++ b/apps/client/src/layouts/desktop_layout.tsx@@ -3,7 +3,7 @@ import type { WidgetsByParent } from "../services/bundle.js";import options from "../services/options.js";import utils from "../services/utils.js";import GlobalMenu from "../widgets/buttons/global_menu.jsx";-import LeftPaneToggle from "../widgets/buttons/left_pane_toggle.js";+import LeftPaneToggle, { LeftPanePeekButton } from "../widgets/buttons/left_pane_toggle.js";import RightPaneToggle from "../widgets/buttons/right_pane_toggle.jsx";import CloseZenModeButton from "../widgets/close_zen_button.jsx";import NoteList from "../widgets/collections/NoteList.jsx";@@ -83,8 +83,9 @@ export default class DesktopLayout {.css("flex-grow", "1").id("horizontal-main-container").optChild(!launcherPaneIsHorizontal, launcherPane)+ .optChild(launcherPaneIsHorizontal, <LeftPanePeekButton />).child(- new LeftPaneContainer()+ new LeftPaneContainer(launcherPaneIsHorizontal).optChild(!launcherPaneIsHorizontal, <QuickSearch />).child(appContext.noteTreeWidget).child(...this.customWidgets.get("left-pane"))diff --git a/apps/client/src/services/resizer.spec.ts b/apps/client/src/services/resizer.spec.tsindex 9b05382bdd..01e01fa044 100644--- a/apps/client/src/services/resizer.spec.ts+++ b/apps/client/src/services/resizer.spec.ts@@ -76,7 +76,10 @@ beforeEach(() => {SplitMock.mockImplementation(() => ({ destroy: vi.fn() }));document.body.innerHTML = `<div id="launcher-pane"></div>- <div id="left-pane"></div>+ <div id="left-pane-host">+ <div id="left-pane"></div>+ <div class="peek-pane-spacer"></div>+ </div><div id="rest-pane"></div><div id="center-pane"><div class="split-note-container-widget"></div>@@ -91,9 +94,8 @@ describe("setupLeftPaneResizer", () => {it("when left pane is hidden, stretches rest pane to full width (horizontal layout, no reserved width)", async () => {const { resizer } = await loadResizer({ layoutOrientation: "horizontal" });- resizer.setupLeftPaneResizer(false);+ resizer.setupLeftPaneResizer("closed");- expect($("#left-pane").is(":hidden") || $("#left-pane").css("display") === "none").toBe(true);expect($("#rest-pane").css("width")).toBe("100%");expect(SplitMock).not.toHaveBeenCalled();});@@ -104,7 +106,7 @@ describe("setupLeftPaneResizer", () => {setLauncherPaneWidth(120);const { resizer } = await loadResizer({ layoutOrientation: "vertical" });- resizer.setupLeftPaneResizer(false);+ resizer.setupLeftPaneResizer("closed");// reservedWidth = 120 / window.innerWidth * 100; rest-pane = (100 - reservedWidth)%.const reservedWidth = (120 / window.innerWidth) * 100;@@ -120,7 +122,7 @@ describe("setupLeftPaneResizer", () => {// fallback yields reservedWidth 0 -> rest-pane 100%.const { resizer } = await loadResizer({ layoutOrientation: "vertical" });- resizer.setupLeftPaneResizer(false);+ resizer.setupLeftPaneResizer("closed");expect($("#rest-pane").css("width")).toBe("100%");});@@ -130,7 +132,7 @@ describe("setupLeftPaneResizer", () => {setLauncherPaneWidth(120);const { resizer } = await loadResizer({ layoutOrientation: "horizontal" });- resizer.setupLeftPaneResizer(false);+ resizer.setupLeftPaneResizer("closed");expect($("#rest-pane").css("width")).toBe("100%");});@@ -140,14 +142,14 @@ describe("setupLeftPaneResizer", () => {SplitMock.mockImplementation(() => ({ destroy }));const { resizer, options } = await loadResizer({ layoutOrientation: "horizontal", leftPaneWidth: 30 });- resizer.setupLeftPaneResizer(true);+ resizer.setupLeftPaneResizer("docked");// Split is only created once the rAF callback runs.expect(SplitMock).not.toHaveBeenCalled();flushRaf();expect(SplitMock).toHaveBeenCalledTimes(1);const [elements, config] = SplitMock.mock.calls[0];- expect(elements).toEqual(["#left-pane", "#rest-pane"]);+ expect(elements).toEqual([ "#left-pane-host", "#rest-pane" ]);expect(config.sizes).toEqual([30, 70]);expect(config.gutterSize).toBe(5);expect(config.minSize).toEqual([150, 300]);@@ -158,7 +160,7 @@ describe("setupLeftPaneResizer", () => {// onDragEnd also mutates the module-level cache: a subsequent rebuild must use// the NEW (dragged + rounded) width 43, not the original 30 -> sizes [43, 57].- resizer.setupLeftPaneResizer(true);+ resizer.setupLeftPaneResizer("docked");flushRaf();expect(SplitMock).toHaveBeenCalledTimes(2);expect(SplitMock.mock.calls[1][1].sizes).toEqual([43, 57]);@@ -167,7 +169,7 @@ describe("setupLeftPaneResizer", () => {it("clamps a missing stored width (getInt -> null) up to the minimum of 5", async () => {const { resizer } = await loadResizer({ layoutOrientation: "horizontal", leftPaneWidth: null });- resizer.setupLeftPaneResizer(true);+ resizer.setupLeftPaneResizer("docked");flushRaf();// getInt returns null -> falls back to 0 -> clamped to the 5 minimum.@@ -177,7 +179,7 @@ describe("setupLeftPaneResizer", () => {it("clamps a too-small stored width (e.g. 2) up to the minimum of 5", async () => {const { resizer } = await loadResizer({ layoutOrientation: "horizontal", leftPaneWidth: 2 });- resizer.setupLeftPaneResizer(true);+ resizer.setupLeftPaneResizer("docked");flushRaf();expect(SplitMock.mock.calls[0][1].sizes).toEqual([5, 95]);@@ -188,26 +190,54 @@ describe("setupLeftPaneResizer", () => {SplitMock.mockImplementation(() => ({ destroy }));const { resizer } = await loadResizer({ layoutOrientation: "horizontal", leftPaneWidth: 30 });- resizer.setupLeftPaneResizer(true);+ resizer.setupLeftPaneResizer("docked");flushRaf();expect(destroy).not.toHaveBeenCalled();// Second invocation must tear down the existing instance before rebuilding.- resizer.setupLeftPaneResizer(true);+ resizer.setupLeftPaneResizer("docked");expect(destroy).toHaveBeenCalledTimes(1);flushRaf();expect(SplitMock).toHaveBeenCalledTimes(2);});+ it("when peeking, sizes the pane against the host's backdrop", async () => {+ const { resizer } = await loadResizer({+ layoutOrientation: "horizontal", leftPaneWidth: 30+ });++ resizer.setupLeftPaneResizer("peek");+ expect($("#rest-pane").css("width")).toBe("100%");+ flushRaf();++ const [ elements, config ] = SplitMock.mock.calls[0];+ expect(elements).toEqual([ "#left-pane", "#left-pane-host > .peek-pane-spacer" ]);+ expect(config.sizes).toEqual([ 30, 70 ]);+ expect(config.minSize).toEqual([ 150, 300 ]);+ });++ it("drops a split still waiting for its frame when the mode changes again", async () => {+ const { resizer } = await loadResizer({+ layoutOrientation: "horizontal", leftPaneWidth: 30+ });++ resizer.setupLeftPaneResizer("peek");+ resizer.setupLeftPaneResizer("closed");+ flushRaf();++ expect(SplitMock).not.toHaveBeenCalled();+ expect(cancelledRafIds).toHaveLength(1);+ });+it("reuses cached layout/width state on subsequent calls instead of re-reading options", async () => {const { resizer, options } = await loadResizer({ layoutOrientation: "horizontal", leftPaneWidth: 30 });- resizer.setupLeftPaneResizer(true);+ resizer.setupLeftPaneResizer("docked");flushRaf();const getCallsAfterFirst = (options.get as ReturnType<typeof vi.fn>).mock.calls.length;const getIntCallsAfterFirst = (options.getInt as ReturnType<typeof vi.fn>).mock.calls.length;- resizer.setupLeftPaneResizer(true);+ resizer.setupLeftPaneResizer("docked");flushRaf();// layoutOrientation / leftPaneWidth are cached after the first call (?? short-circuits).diff --git a/apps/client/src/services/resizer.ts b/apps/client/src/services/resizer.tsindex ef35f3c1ea..f856a45b43 100644--- a/apps/client/src/services/resizer.ts+++ b/apps/client/src/services/resizer.ts@@ -1,31 +1,43 @@-import options from "./options.js";import Split from "@triliumnext/split.js";+import type { PaneMode } from "../widgets/react/peek_pane.js";+import options from "./options.js";+export const DEFAULT_GUTTER_SIZE = 5;let leftPaneWidth: number;let reservedPx: number;let layoutOrientation: string;let leftInstance: ReturnType<typeof Split> | null;+let leftRafId: number | undefined;const noteSplitMap = new Map<string[], ReturnType<typeof Split> | undefined>(); // key: a group of ntxIds, value: the corresponding Split instanceconst noteSplitRafMap = new Map<string[], number>();let splitNoteContainer: HTMLElement | undefined;-function setupLeftPaneResizer(leftPaneVisible: boolean) {+/**+ * Sizes the left pane for its mode. Docked, a Split sizes `#left-pane-host` against `#rest-pane`;+ * peeking, the host covers `#rest-pane` and a Split sizes `#left-pane` against the host's spacer.+ * Both share the `leftPaneWidth` option.+ */+function setupLeftPaneResizer(mode: PaneMode) {+ if (leftRafId !== undefined) {+ cancelAnimationFrame(leftRafId);+ leftRafId = undefined;+ }if (leftInstance) {leftInstance.destroy();leftInstance = null;}- $("#left-pane").toggle(leftPaneVisible);-layoutOrientation = layoutOrientation ?? options.get("layoutOrientation");reservedPx = reservedPx ?? (layoutOrientation === "vertical" ? ($("#launcher-pane").outerWidth() || 0) : 0);// Window resizing causes `window.innerWidth` to change, so `reservedWidth` needs to be recalculated each time.const reservedWidth = reservedPx / window.innerWidth * 100;- if (!leftPaneVisible) {+ if (mode !== "docked") {$("#rest-pane").css("width", layoutOrientation === "vertical" ? `${100 - reservedWidth}%` : "100%");+ }+ if (mode === "closed") {return;}@@ -34,25 +46,27 @@ function setupLeftPaneResizer(leftPaneVisible: boolean) {leftPaneWidth = 5;}- const restPaneWidth = 100 - leftPaneWidth - reservedWidth;- /* v8 ignore next -- redundant guard: a falsy leftPaneVisible already returned above */- if (leftPaneVisible) {- // Delayed initialization ensures that all DOM elements are fully rendered and part of the layout,- // preventing Split.js from retrieving incorrect dimensions due to #left-pane not being rendered yet,- // which would cause the minSize setting to have no effect.- requestAnimationFrame(() => {- leftInstance = Split(["#left-pane", "#rest-pane"], {- sizes: [leftPaneWidth, restPaneWidth],- gutterSize: DEFAULT_GUTTER_SIZE,- minSize: [150, 300],- rtl: glob.isRtl,- onDragEnd: (sizes) => {- leftPaneWidth = Math.round(sizes[0]);- options.save("leftPaneWidth", Math.round(sizes[0]));- }- });+ const isDocked = mode === "docked";+ const elements = isDocked+ ? [ "#left-pane-host", "#rest-pane" ]+ : [ "#left-pane", "#left-pane-host > .peek-pane-spacer" ];+ const otherWidth = isDocked ? 100 - leftPaneWidth - reservedWidth : 100 - leftPaneWidth;++ // Deferred a frame so that Split.js measures #left-pane once it is laid out; otherwise+ // `minSize` has no effect.+ leftRafId = requestAnimationFrame(() => {+ leftRafId = undefined;+ leftInstance = Split(elements, {+ sizes: [ leftPaneWidth, otherWidth ],+ gutterSize: DEFAULT_GUTTER_SIZE,+ minSize: [ 150, 300 ],+ rtl: glob.isRtl,+ onDragEnd: (sizes) => {+ leftPaneWidth = Math.round(sizes[0]);+ options.save("leftPaneWidth", Math.round(sizes[0]));+ }});- }+ });}function findKeyByNtxId(ntxId: string): string[] | undefined {diff --git a/apps/client/src/stylesheets/theme-next-dark.css b/apps/client/src/stylesheets/theme-next-dark.cssindex 376faed7ff..ae03b095d3 100644--- a/apps/client/src/stylesheets/theme-next-dark.css+++ b/apps/client/src/stylesheets/theme-next-dark.css@@ -193,6 +193,7 @@--right-pane-heading-color: gray;--right-pane-peek-background: #303030dc;+ --left-pane-peek-background: #1f1f1fdc;--peek-pane-backdrop-color: #00000032;--peek-pane-shadow-color: #000000a8;diff --git a/apps/client/src/stylesheets/theme-next-light.css b/apps/client/src/stylesheets/theme-next-light.cssindex 367b586900..9809f865c1 100644--- a/apps/client/src/stylesheets/theme-next-light.css+++ b/apps/client/src/stylesheets/theme-next-light.css@@ -185,6 +185,7 @@--right-pane-heading-color: gray;--right-pane-peek-background: #ffffffea;+ --left-pane-peek-background: #f2f2f2ea;--peek-pane-backdrop-color: #0000000a;--peek-pane-shadow-color: #0000003a;diff --git a/apps/client/src/stylesheets/zen.css b/apps/client/src/stylesheets/zen.cssindex da58e35e88..83cdab65a5 100644--- a/apps/client/src/stylesheets/zen.css+++ b/apps/client/src/stylesheets/zen.css@@ -5,6 +5,8 @@ body.zen {#launcher-container,#launcher-pane,#left-pane,+ #left-pane-host,+ .left-pane-peek-button,#right-pane,#right-pane-host,.right-pane-peek-button,@@ -31,6 +33,10 @@ body.zen {--right-pane-peek-button-gutter: 0 !important;}+ #horizontal-main-container {+ --left-pane-peek-button-gutter: 0 !important;+ }+.split-note-container-widget > .gutter {display: unset !important;}diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.jsonindex b9c8ae6cf3..3950531a6e 100644--- a/apps/client/src/translations/en/translation.json+++ b/apps/client/src/translations/en/translation.json@@ -1206,7 +1206,8 @@},"left_pane_toggle": {"show_panel": "Show panel",- "hide_panel": "Hide panel"+ "hide_panel": "Hide panel",+ "peek_panel": "Peek panel"},"move_pane_button": {"move_left": "Move left",diff --git a/apps/client/src/widgets/buttons/left_pane_toggle.tsx b/apps/client/src/widgets/buttons/left_pane_toggle.tsxindex f22c9956ae..1bcbeaa7e2 100644--- a/apps/client/src/widgets/buttons/left_pane_toggle.tsx+++ b/apps/client/src/widgets/buttons/left_pane_toggle.tsx@@ -1,30 +1,60 @@import "./left_pane_toggle.css";-import { useEffect, useState } from "preact/hooks";-import ActionButton from "../react/ActionButton";-import options from "../../services/options";-import { t } from "../../services/i18n";++import clsx from "clsx";+import { useCallback, useContext, useState } from "preact/hooks";+import { showLaunchBarManagementContextMenu } from "../../menus/launcher_button_context_menu";+import { t } from "../../services/i18n";+import options from "../../services/options";+import ActionButton from "../react/ActionButton";import { useTriliumEvent } from "../react/hooks";-import resizer from "../../services/resizer";+import type { PaneMode } from "../react/peek_pane";+import PeekPaneButton from "../react/PeekPaneButton";+import { ParentComponent } from "../react/react_utils";export default function LeftPaneToggle({ isHorizontalLayout }: { isHorizontalLayout: boolean }) {- const [ currentLeftPaneVisible, setCurrentLeftPaneVisible ] = useState(options.is("leftPaneVisible"));-- useTriliumEvent("setLeftPaneVisibility", ({ leftPaneVisible }) => {- setCurrentLeftPaneVisible(leftPaneVisible ?? !currentLeftPaneVisible);- });-- useEffect(() => {- resizer.setupLeftPaneResizer(currentLeftPaneVisible);- }, [ currentLeftPaneVisible ]);+ const isDocked = useLeftPaneMode() === "docked";return (<ActionButton- className={`${isHorizontalLayout ? "toggle-button" : "launcher-button"} left-pane-toggle-button ${currentLeftPaneVisible ? "action-collapse" : "action-expand"}`}- text={currentLeftPaneVisible ? t("left_pane_toggle.hide_panel") : t("left_pane_toggle.show_panel")}- triggerCommand={currentLeftPaneVisible ? "hideLeftPane" : "showLeftPane"}+ className={clsx(+ isHorizontalLayout ? "toggle-button" : "launcher-button",+ "left-pane-toggle-button",+ isDocked ? "action-collapse" : "action-expand"+ )}+ text={isDocked ? t("left_pane_toggle.hide_panel") : t("left_pane_toggle.show_panel")}+ triggerCommand={isDocked ? "hideLeftPane" : "showLeftPane"}icon={isHorizontalLayout ? "bx bx-sidebar" : "bx bx-chevrons-left"}onContextMenu={showLaunchBarManagementContextMenu}/>- )-}\ No newline at end of file+ );+}++/** The edge button that peeks the note tree over the content, in the horizontal layout. */+export function LeftPanePeekButton() {+ const mode = useLeftPaneMode();+ const parentComponent = useContext(ParentComponent);+ const peek = useCallback(() => parentComponent?.triggerCommand("peekLeftPane"), [ parentComponent ]);++ return (+ <PeekPaneButton+ side="start"+ className="left-pane-peek-button"+ isOpen={mode !== "closed"}+ onToggle={peek}+ hideText={t("left_pane_toggle.hide_panel")}+ peekText={t("left_pane_toggle.peek_panel")}+ />+ );+}++/** The mode `LeftPaneContainer` reports for the left pane. */+function useLeftPaneMode() {+ const [ mode, setMode ] = useState<PaneMode>(() => options.is("leftPaneVisible") ? "docked" : "closed");+ useTriliumEvent("paneModeChanged", (data) => {+ if (data.pane === "left") {+ setMode(data.mode);+ }+ });+ return mode;+}diff --git a/apps/client/src/widgets/containers/left_pane_container.css b/apps/client/src/widgets/containers/left_pane_container.cssnew file mode 100644index 0000000000..16ab7770c6--- /dev/null+++ b/apps/client/src/widgets/containers/left_pane_container.css@@ -0,0 +1,46 @@+:where(:root) {+ --left-pane-peek-background: var(--left-pane-background-color);+ --left-pane-peek-backdrop-filter: blur(12px) saturate(1.5);+ --left-pane-peek-border-radius: 8px;++ --left-pane-peek-button-collapse-background-color: var(--left-pane-background-color);+}++#left-pane {+ display: flex;+ flex-direction: column;+}++/* The gutter holds `.left-pane-peek-button`; Split sizes the panes inside the padding. */+body.layout-horizontal #horizontal-main-container {+ --left-pane-peek-button-width: 12px;+ --left-pane-peek-button-gutter: calc(var(--left-pane-peek-button-width) + 2px);++ position: relative;+ padding-inline-start: var(--left-pane-peek-button-gutter);+}++.left-pane-peek-button {+ --peek-pane-button-width: var(--left-pane-peek-button-width);+ --peek-button-collapse-background-color: var(--left-pane-peek-button-collapse-background-color);+}++body.desktop.background-effects #horizontal-main-container:has(.note-split.visible.bgfx:not(.visible ~ .visible)) > .left-pane-peek-button {+ --peek-button-expand-background-color: var(--center-pane-background-color-bgfx, var(--main-background-color));+}++#left-pane-host.peek {+ inset-inline-start: var(--left-pane-peek-button-gutter, 0);+ inset-inline-end: 0;++ > #left-pane {+ border-start-end-radius: var(--left-pane-peek-border-radius);+ border-end-end-radius: var(--left-pane-peek-border-radius);+ background: var(--left-pane-peek-background);+ backdrop-filter: var(--left-pane-peek-backdrop-filter);+ }+}++body.backdrop-effects-disabled #left-pane-host.peek > #left-pane {+ background: var(--left-pane-background-color);+}diff --git a/apps/client/src/widgets/containers/left_pane_container.spec.ts b/apps/client/src/widgets/containers/left_pane_container.spec.tsnew file mode 100644index 0000000000..2a4f01a2ed--- /dev/null+++ b/apps/client/src/widgets/containers/left_pane_container.spec.ts@@ -0,0 +1,158 @@+import { afterEach, beforeEach, describe, expect, it, type MockInstance, vi } from "vitest";++const setupLeftPaneResizer = vi.hoisted(() => vi.fn());+vi.mock("../../services/resizer.js", () => ({ default: { setupLeftPaneResizer } }));++import appContext from "../../components/app_context";+import options from "../../services/options";+import FlexContainer from "./flex_container";+import LeftPaneContainer from "./left_pane_container";++describe("LeftPaneContainer", () => {+ let container: LeftPaneContainer;+ let parent: FlexContainer<LeftPaneContainer>;+ let save: MockInstance<typeof options.save>;+ let triggerEvent: MockInstance<LeftPaneContainer["triggerEvent"]>;++ beforeEach(() => {+ setupLeftPaneResizer.mockClear();+ save = vi.spyOn(options, "save").mockResolvedValue(undefined);+ appContext.tabManager = { getActiveContext: () => null } as typeof appContext.tabManager;+ });++ afterEach(() => {+ // Closes any peek, which detaches its document listeners.+ container.setLeftPaneVisibilityEvent({ leftPaneVisible: false });+ document.body.innerHTML = "";+ vi.restoreAllMocks();+ });++ it("hosts the pane's children and moves between modes, persisting only docking", () => {+ mount(false);++ const host = container.$widget;+ expect(host.attr("id")).toBe("left-pane-host");+ expect(host.children("#left-pane.peek-pane").children(".tree-stub")).toHaveLength(1);+ expect(host.children(".peek-pane-spacer")).toHaveLength(1);+ expect(host.hasClass("hidden-int")).toBe(true);+ expect(parent.$widget.hasClass("left-pane-hidden")).toBe(true);+ expect(setupLeftPaneResizer).toHaveBeenLastCalledWith("closed");++ // A peek covers the content without reflowing it, and is not persisted.+ container.peekLeftPaneEvent();+ expect(host.hasClass("hidden-int")).toBe(false);+ expect(host.hasClass("peek")).toBe(true);+ expect(parent.$widget.hasClass("left-pane-hidden")).toBe(true);+ expect(setupLeftPaneResizer).toHaveBeenLastCalledWith("peek");+ expect(save).not.toHaveBeenCalled();+ expect(triggerEvent).toHaveBeenCalledWith("focusTree", {});+ expect(triggerEvent).toHaveBeenCalledWith(+ "paneModeChanged", { pane: "left", mode: "peek" }+ );++ // "Show panel" docks the peek.+ container.setLeftPaneVisibilityEvent({ leftPaneVisible: true });+ expect(host.hasClass("peek")).toBe(false);+ expect(parent.$widget.hasClass("left-pane-hidden")).toBe(false);+ expect(setupLeftPaneResizer).toHaveBeenLastCalledWith("docked");+ expect(save).toHaveBeenCalledWith("leftPaneVisible", "true");++ // The toggle closes it, and moves the focus to the note.+ triggerEvent.mockClear();+ container.setLeftPaneVisibilityEvent({ leftPaneVisible: null });+ expect(host.hasClass("hidden-int")).toBe(true);+ expect(save).toHaveBeenLastCalledWith("leftPaneVisible", "false");+ expect(triggerEvent).toHaveBeenCalledWith("focusOnDetail", { ntxId: undefined });+ expect(triggerEvent).toHaveBeenCalledWith(+ "paneModeChanged", { pane: "left", mode: "closed" }+ );+ });++ it("starts docked where the option says so", () => {+ mount(true);++ expect(container.$widget.hasClass("hidden-int")).toBe(false);+ expect(parent.$widget.hasClass("left-pane-hidden")).toBe(false);+ expect(setupLeftPaneResizer).toHaveBeenLastCalledWith("docked");+ });++ it("does not peek where the layout cannot", () => {+ mount(false, false);++ container.peekLeftPaneEvent();+ expect(container.$widget.hasClass("hidden-int")).toBe(true);+ expect(container.$widget.hasClass("peek")).toBe(false);+ expect(triggerEvent).not.toHaveBeenCalled();+ });++ it("dismisses a peek on a press outside the tree and its buttons, or on Escape", () => {+ mount(false);+ document.body.insertAdjacentHTML("beforeend", `+ <button class="left-pane-peek-button"></button>+ <button class="left-pane-toggle-button"></button>+ <div class="tn-popup tree-settings"><input class="tree-settings-toggle" /></div>+ <div id="rest-pane"></div>+ `);+ const host = container.$widget;++ container.peekLeftPaneEvent();+ press(host.find(".tree-stub")[0]);+ press(document.querySelector(".left-pane-peek-button"));+ press(document.querySelector(".left-pane-toggle-button"));+ // The tree settings popup is portaled to the body, outside the pane.+ press(document.querySelector(".tree-settings-toggle"));+ expect(host.hasClass("peek")).toBe(true);++ // A press on the backdrop dismisses the peek without moving the focus.+ triggerEvent.mockClear();+ press(host.children(".peek-pane-spacer")[0]);+ expect(host.hasClass("hidden-int")).toBe(true);+ expect(triggerEvent).not.toHaveBeenCalledWith("focusOnDetail", expect.anything());+ expect(save).not.toHaveBeenCalled();++ container.peekLeftPaneEvent();+ document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape" }));+ expect(host.hasClass("hidden-int")).toBe(true);+ expect(document.activeElement).toBe(document.querySelector(".left-pane-peek-button"));++ // A docked pane is not dismissed.+ container.setLeftPaneVisibilityEvent({ leftPaneVisible: true });+ press(document.querySelector("#rest-pane"));+ expect(host.hasClass("hidden-int")).toBe(false);+ });++ it("gives its peek up to another pane's, and stays docked", () => {+ mount(false);+ const host = container.$widget;++ container.peekLeftPaneEvent();+ container.paneModeChangedEvent({ pane: "left", mode: "peek" });+ container.paneModeChangedEvent({ pane: "right", mode: "docked" });+ expect(host.hasClass("peek")).toBe(true);++ container.paneModeChangedEvent({ pane: "right", mode: "peek" });+ expect(host.hasClass("hidden-int")).toBe(true);+ expect(triggerEvent).toHaveBeenLastCalledWith(+ "paneModeChanged", { pane: "left", mode: "closed" }+ );++ container.setLeftPaneVisibilityEvent({ leftPaneVisible: true });+ container.paneModeChangedEvent({ pane: "right", mode: "peek" });+ expect(host.hasClass("hidden-int")).toBe(false);+ });++ function mount(docked: boolean, isPeekable = true) {+ options.set("leftPaneVisible", docked.toString());+ container = new LeftPaneContainer(isPeekable);+ container.child(new FlexContainer("column").class("tree-stub"));+ parent = new FlexContainer<LeftPaneContainer>("row").child(container);+ document.body.append(parent.render()[0]);+ triggerEvent = vi.spyOn(container, "triggerEvent");+ container.initialRenderCompleteEvent();+ }+});++function press(target: Element | null | undefined) {+ expect(target).toBeTruthy();+ target?.dispatchEvent(new MouseEvent("pointerdown", { bubbles: true }));+}diff --git a/apps/client/src/widgets/containers/left_pane_container.ts b/apps/client/src/widgets/containers/left_pane_container.tsindex cd832560bc..654c9a7f26 100644--- a/apps/client/src/widgets/containers/left_pane_container.ts+++ b/apps/client/src/widgets/containers/left_pane_container.ts@@ -1,34 +1,86 @@-import options from "../../services/options.js";-import FlexContainer from "./flex_container.js";+import "./left_pane_container.css";+import appContext, { type EventData } from "../../components/app_context.js";import type Component from "../../components/component.js";+import options from "../../services/options.js";+import resizer from "../../services/resizer.js";+import {+ type PaneAction, type PaneMode, persistedPaneVisible, reducePaneMode, watchPeekDismiss+} from "../react/peek_pane.js";+import Container from "./container.js";++/**+ * The host of `#left-pane`, which holds the note tree. Owns the pane's mode: closed, docked, or+ * peeked over the content.+ */+export default class LeftPaneContainer extends Container<Component> {-export default class LeftPaneContainer extends FlexContainer<Component> {- private currentLeftPaneVisible: boolean;+ private readonly isPeekable: boolean;+ private mode: PaneMode;+ private stopPeekDismiss?: () => void;- constructor() {- super("column");+ /** @param isPeekable whether the pane can peek, which only the horizontal layout supports. */+ constructor(isPeekable: boolean) {+ super();- this.currentLeftPaneVisible = options.is("leftPaneVisible");+ this.isPeekable = isPeekable;+ this.mode = options.is("leftPaneVisible") ? "docked" : "closed";- this.id("left-pane");- this.css("height", "100%");+ this.id("left-pane-host");+ this.class("peek-pane-host side-start");this.collapsible();}+ doRender() {+ super.doRender();+ const $pane = $(`<div id="left-pane" class="peek-pane">`).append(this.$widget.children());+ this.$widget.append($pane, $(`<div class="peek-pane-spacer">`));+ }+isEnabled() {- return super.isEnabled() && this.currentLeftPaneVisible;+ return super.isEnabled() && this.mode !== "closed";+ }++ initialRenderCompleteEvent() {+ this.applyMode();}setLeftPaneVisibilityEvent({ leftPaneVisible }: EventData<"setLeftPaneVisibility">) {- this.currentLeftPaneVisible = leftPaneVisible ?? !this.currentLeftPaneVisible;- const visible = this.isEnabled();- this.toggleInt(visible);- this.parent?.$widget.toggleClass("left-pane-hidden", !visible);+ if (leftPaneVisible === null) {+ this.changeMode("toggleDocked");+ } else {+ this.changeMode(leftPaneVisible ? "dock" : "close");+ }+ }- if (visible) {+ peekLeftPaneEvent() {+ if (this.isPeekable) {+ this.changeMode("togglePeek");+ }+ }++ paneModeChangedEvent({ pane, mode }: EventData<"paneModeChanged">) {+ if (pane !== "left" && mode === "peek") {+ this.changeMode("dismiss");+ }+ }++ private changeMode(action: PaneAction) {+ const prev = this.mode;+ this.mode = reducePaneMode(prev, action);+ if (this.mode === prev) return;++ this.applyMode();++ const persist = persistedPaneVisible(prev, this.mode);+ if (persist !== null) {+ options.save("leftPaneVisible", persist.toString());+ }++ if (this.mode !== "closed") {this.triggerEvent("focusTree", {});- } else {+ } else if (action === "close" || action === "toggleDocked") {+ // Only a hard close moves the focus. A dismissed peek leaves it on the pressed element.const ntxId = appContext.tabManager.getActiveContext()?.ntxId;const noteContainer = document.querySelector(`.note-split[data-ntx-id="${ntxId}"]`);if (!noteContainer?.contains(document.activeElement)) {@@ -36,6 +88,21 @@ export default class LeftPaneContainer extends FlexContainer<Component> {}}- options.save("leftPaneVisible", this.currentLeftPaneVisible.toString());+ this.triggerEvent("paneModeChanged", { pane: "left", mode: this.mode });+ }++ private applyMode() {+ this.toggleInt(this.isEnabled());+ this.$widget.toggleClass("peek", this.mode === "peek");+ this.parent?.$widget.toggleClass("left-pane-hidden", this.mode !== "docked");+ resizer.setupLeftPaneResizer(this.mode);++ this.stopPeekDismiss?.();+ this.stopPeekDismiss = this.mode === "peek"+ ? watchPeekDismiss(() => this.changeMode("dismiss"), {+ keepOpenSelector: "#left-pane, .left-pane-peek-button, .left-pane-toggle-button",+ focusSelector: ".left-pane-peek-button"+ })+ : undefined;}}diff --git a/apps/client/src/widgets/sidebar/RightPanePeekButton.css b/apps/client/src/widgets/react/PeekPaneButton.csssimilarity index 56%rename from apps/client/src/widgets/sidebar/RightPanePeekButton.cssrename to apps/client/src/widgets/react/PeekPaneButton.cssindex 59d5951554..5dc3391a24 100644--- a/apps/client/src/widgets/sidebar/RightPanePeekButton.css+++ b/apps/client/src/widgets/react/PeekPaneButton.css@@ -1,55 +1,57 @@:where(:root) {--peek-button-arrow-color: var(--muted-text-color);--peek-button-arrow-color-hover: var(--item-hover-text-color);-+--peek-button-expand-background-color: var(--note-split-background-color, var(--main-background-color));--peek-button-expand-hover-background-color: var(--hover-item-background-color);--peek-button-collapse-background-color: var(--right-pane-background-color);- --peek-button-expand-collapse-background-color: var(--hover-item-background-color);-}--/* The button follows the translucency of the rightmost split. */-body.desktop.background-effects #center-pane:has(.note-split.last-visible.bgfx) ~ .right-pane-peek-button {- --peek-button-expand-background-color: var(--center-pane-background-color-bgfx, var(--main-background-color));+ --peek-button-collapse-hover-background-color: var(--hover-item-background-color);}-/* The peek button is absolutely positioned in a reserved gutter on the right edge of- #vertical-main-container, so it stays fixed at the viewport's right side and fully- owns its background — independent of whether the right pane is open or collapsed. */-.right-pane-peek-button {- /* Pinned to the reserved gutter (see #vertical-main-container in RightPanelContainer.css);- width inherits --right-pane-peek-button-width, with a fallback for safety. */+/* Sits in a gutter that the pane's container reserves with padding of the same width. */+.peek-pane-button {+ display: flex;+ align-items: center;+ justify-content: center;position: absolute;- inset-inline-end: 0;top: 0;bottom: 0;- width: var(--right-pane-peek-button-width, 12px);z-index: 1;- display: flex;- align-items: center;- justify-content: center;border: 0;- background: transparent;padding: 0;+ width: var(--peek-pane-button-width, 12px);+ background: transparent;+ color: var(--peek-button-arrow-color);font-size: 16px;cursor: pointer;- color: var(--peek-button-arrow-color);transition: background 250ms ease-in, color 250ms ease-in;+ &.side-start {+ inset-inline-start: 0;+ }++ &.side-end {+ inset-inline-end: 0;+ }++ body[dir=rtl] & {+ transform: scaleX(-1);+ }+body.layout-vertical & {border-bottom: 1px solid var(--status-bar-border-color);}- &.right-pane-peek-button-action-expand {+ &.peek-pane-button-action-expand {background: var(--peek-button-expand-background-color);-+&:hover {background: var(--peek-button-expand-hover-background-color);}}- &.right-pane-peek-button-action-collapse {+ &.peek-pane-button-action-collapse {background: var(--peek-button-collapse-background-color);&:hover {diff --git a/apps/client/src/widgets/react/PeekPaneButton.spec.tsx b/apps/client/src/widgets/react/PeekPaneButton.spec.tsxnew file mode 100644index 0000000000..d897b15386--- /dev/null+++ b/apps/client/src/widgets/react/PeekPaneButton.spec.tsx@@ -0,0 +1,66 @@+import { render } from "preact";+import { act } from "preact/test-utils";+import { afterEach, describe, expect, it, vi } from "vitest";++// Bootstrap's tooltip machinery is not what is under test here.+vi.mock("./hooks", async (importOriginal) => ({+ ...(await importOriginal<typeof import("./hooks")>()),+ useStaticTooltip: vi.fn()+}));++import PeekPaneButton, { type PaneSide } from "./PeekPaneButton";++describe("PeekPaneButton", () => {+ const host = document.createElement("div");++ afterEach(() => {+ act(() => render(null, host));+ });++ it("points the arrow into the content to peek and out of it to hide, from either edge", () => {+ expect(arrow("start", false)).toBe("bx-chevron-right");+ expect(arrow("start", true)).toBe("bx-chevron-left");+ expect(arrow("end", false)).toBe("bx-chevron-left");+ expect(arrow("end", true)).toBe("bx-chevron-right");+ });++ it("names the action a press takes, and hands the press to the pane", () => {+ const onToggle = vi.fn();+ const button = renderButton("start", false, onToggle);+ expect(button.getAttribute("aria-label")).toBe("Peek");+ expect(button.classList.contains("my-peek-button")).toBe(true);+ expect(button.classList.contains("side-start")).toBe(true);+ expect(button.classList.contains("peek-pane-button-action-expand")).toBe(true);++ button.click();+ expect(onToggle).toHaveBeenCalledTimes(1);++ const openButton = renderButton("start", true, onToggle);+ expect(openButton.getAttribute("aria-label")).toBe("Hide");+ expect(openButton.classList.contains("peek-pane-button-action-collapse")).toBe(true);+ });++ function arrow(side: PaneSide, isOpen: boolean) {+ const button = renderButton(side, isOpen, () => {});+ const chevrons = [ ...button.classList ].filter((name) => name.startsWith("bx-chevron-"));+ expect(chevrons).toHaveLength(1);+ return chevrons[0];+ }++ function renderButton(side: PaneSide, isOpen: boolean, onToggle: () => void) {+ act(() => render(+ <PeekPaneButton+ side={side}+ isOpen={isOpen}+ onToggle={onToggle}+ className="my-peek-button"+ hideText="Hide"+ peekText="Peek"+ />,+ host+ ));+ const button = host.querySelector("button");+ if (!button) throw new Error("PeekPaneButton rendered no button");+ return button;+ }+});diff --git a/apps/client/src/widgets/sidebar/RightPanePeekButton.tsx b/apps/client/src/widgets/react/PeekPaneButton.tsxsimilarity index 55%rename from apps/client/src/widgets/sidebar/RightPanePeekButton.tsxrename to apps/client/src/widgets/react/PeekPaneButton.tsxindex 50026342e9..eafc67b9d2 100644--- a/apps/client/src/widgets/sidebar/RightPanePeekButton.tsx+++ b/apps/client/src/widgets/react/PeekPaneButton.tsx@@ -1,23 +1,37 @@-import "./RightPanePeekButton.css";+import "./PeekPaneButton.css";import { Tooltip } from "bootstrap";import clsx from "clsx";import { useCallback, useMemo, useRef } from "preact/hooks";-import { t } from "../../services/i18n";-import { useStaticTooltip } from "../react/hooks";+import { useStaticTooltip } from "./hooks";// Gap (px) between the peek button and its tooltip, so the tooltip can't overlap the button.const TOOLTIP_MARGIN_PX = 8;-interface RightPanePeekButtonProps {- /** Owned and persisted by RightPanelContainer; this component only reflects it. */- rightPaneVisible: boolean;- /** Toggles the right pane (peeks it open, or closes it); owned by RightPanelContainer. */+/** The window edge a pane opens from, in the direction the text runs. */+export type PaneSide = "start" | "end";++interface PeekPaneButtonProps {+ side: PaneSide;+ /** Whether the pane is shown (peeked or docked). The pane owns this state. */+ isOpen: boolean;+ /** Peeks the pane open, or closes it; owned by the pane. */onToggle: () => void;+ /** The instance class, used by the pane's dismissal and stylesheet. */+ className: string;+ /** The label while the pane is open (a click hides it). */+ hideText: string;+ /** The label while the pane is closed (a click peeks it). */+ peekText: string;}-export default function RightPanePeekButton({ rightPaneVisible, onToggle }: RightPanePeekButtonProps) {+/**+ * A full-height button on a window edge that peeks or hides a side pane. It sits in a gutter that+ * the pane's container reserves (see `PeekPaneButton.css`).+ */+export default function PeekPaneButton(props: PeekPaneButtonProps) {+ const { side, isOpen, onToggle, className, hideText, peekText } = props;const buttonRef = useRef<HTMLButtonElement>(null);// Pointer's vertical position captured once on hover; null until the mouse enters// (e.g. on keyboard focus) so the tooltip falls back to the button's centre.@@ -34,8 +48,7 @@ export default function RightPanePeekButton({ rightPaneVisible, onToggle }: Righ}}, [ onToggle ]);- // Open: a click hides it. Closed: a click peeks it (the pin then docks it).- const label = rightPaneVisible ? t("right_pane.hide") : t("right_pane.peek");+ const label = isOpen ? hideText : peekText;// Anchor the tooltip to the pointer's entry height rather than the centre of the// full-height button, by shifting it along the cross axis. Not tracked: `pointerY`@@ -44,24 +57,29 @@ export default function RightPanePeekButton({ rightPaneVisible, onToggle }: Righ// overlap it and cause hover flicker.const tooltipConfig = useMemo(() => ({title: label,- placement: "left" as const,- offset: () => {+ placement: side === "end" ? "left" as const : "right" as const,+ offset: (): [number, number] => {const rect = buttonRef.current?.getBoundingClientRect();- if (!rect || pointerY.current === null) return [ 0, TOOLTIP_MARGIN_PX ] as [number, number];- return [ pointerY.current - (rect.top + rect.height / 2), TOOLTIP_MARGIN_PX ] as [number, number];+ if (!rect || pointerY.current === null) return [ 0, TOOLTIP_MARGIN_PX ];+ return [ pointerY.current - (rect.top + rect.height / 2), TOOLTIP_MARGIN_PX ];}- }), [ label ]);+ }), [ label, side ]);useStaticTooltip(buttonRef, tooltipConfig);+ // The arrow points the way the pane moves: inward to peek it, outward to hide it.+ const pointsRight = (side === "start") !== isOpen;+return (<buttonref={buttonRef}type="button"aria-label={label}class={clsx(- "right-pane-peek-button bx",- rightPaneVisible ? "bx-chevron-right" : "bx-chevron-left",- rightPaneVisible ? "right-pane-peek-button-action-collapse" : "right-pane-peek-button-action-expand"+ "peek-pane-button bx",+ className,+ `side-${side}`,+ pointsRight ? "bx-chevron-right" : "bx-chevron-left",+ isOpen ? "peek-pane-button-action-collapse" : "peek-pane-button-action-expand")}onMouseEnter={(e) => { pointerY.current = e.clientY; }}onMouseLeave={() => { pointerY.current = null; }}diff --git a/apps/client/src/widgets/react/floating_layers.spec.ts b/apps/client/src/widgets/react/floating_layers.spec.tsindex 5e802f3cd5..4c05e03c95 100644--- a/apps/client/src/widgets/react/floating_layers.spec.ts+++ b/apps/client/src/widgets/react/floating_layers.spec.ts@@ -18,9 +18,10 @@ function elementIn(...classNames: string[]) {describe("isWithinFloatingLayer", () => {it("recognises a press on one of the app's portaled layers", () => {// One of each family named in the selector: a menu, a modal, an editor balloon, a picker,- // the context menu (matched by id rather than class), and an autocomplete.+ // the context menu (matched by id rather than class), an autocomplete, and a `Popup`.for (const className of [ "dropdown-menu", "modal", "modal-backdrop", "popover", "tooltip", "gutter",- "ck-balloon-panel", "ck-body", "flatpickr-calendar", "attr-detail", "form-autocomplete-dropdown" ]) {+ "ck-balloon-panel", "ck-body", "flatpickr-calendar", "attr-detail",+ "form-autocomplete-dropdown", "tn-popup" ]) {expect(isWithinFloatingLayer(elementIn(className)), className).toBe(true);}});diff --git a/apps/client/src/widgets/react/floating_layers.ts b/apps/client/src/widgets/react/floating_layers.tsindex 809b97966a..5620d380e9 100644--- a/apps/client/src/widgets/react/floating_layers.ts+++ b/apps/client/src/widgets/react/floating_layers.ts@@ -2,7 +2,7 @@* The app's floating layers: popup roots that render into `document.body` rather than inside* whatever raised them — resize gutters, Bootstrap dropdowns, tooltips, modals and their backdrop,* popovers, CKEditor balloons, Flatpickr calendars, the attribute detail popup, the context menu,- * and the `FormAutocomplete` dropdown.+ * the `FormAutocomplete` dropdown, and `Popup`s such as the tree settings.** A surface that closes on an outside press — the peeked right pane, an anchored popover — cannot* tell "outside" by DOM containment alone. A dropdown opened from within it lives in the body, so@@ -16,7 +16,7 @@*/export const FLOATING_LAYER_SELECTOR = ".gutter, .dropdown-menu, .tooltip, .modal, .modal-backdrop, .popover, "+ ".ck-balloon-panel, .ck-body, .flatpickr-calendar, .attr-detail, #context-menu-container, "- + ".form-autocomplete-dropdown";+ + ".form-autocomplete-dropdown, .tn-popup";/** Whether a press landed in one of the app's floating layers. See {@link FLOATING_LAYER_SELECTOR}. */export function isWithinFloatingLayer(target: EventTarget | null): boolean {diff --git a/apps/client/src/widgets/react/peek_pane.css b/apps/client/src/widgets/react/peek_pane.cssnew file mode 100644index 0000000000..0f75f88289--- /dev/null+++ b/apps/client/src/widgets/react/peek_pane.css@@ -0,0 +1,82 @@+:where(:root) {+ --peek-pane-backdrop-color: #0000000d;+ --peek-pane-shadow-depth: 42px;+ --peek-pane-shadow-color: #0000002b;+}++/* Docked: `.peek-pane` fills the host, which Split sizes against the content.+ Peek: the host covers the content with the pane, a gutter and the `.peek-pane-spacer` backdrop. */+.peek-pane-host {+ display: flex;+ flex-direction: row;++ &.hidden {+ display: none;+ }++ &:not(.peek) {+ > .peek-pane {+ flex: 1 1 0;+ min-width: 0;+ }++ /* Split removes the peek gutter one effect after the host leaves peek mode. */+ > .gutter {+ display: none;+ }+ }++ &.peek {+ position: absolute;+ inset-block: 0;+ z-index: 15;+ background: var(--peek-pane-backdrop-color);+ animation: peek-pane-in 200ms ease-out;++ /* Split sizes both with inline widths. */+ > .peek-pane,+ > .peek-pane-spacer {+ flex: 0 0 auto;+ }++ > .peek-pane-spacer {+ display: block;+ min-width: 0;+ }++ > .peek-pane {+ --peek-pane-shadow-offset: var(--peek-pane-shadow-depth);++ box-shadow: var(--peek-pane-shadow-offset) 0 var(--peek-pane-shadow-depth)+ calc(-1 * var(--peek-pane-shadow-depth)) var(--peek-pane-shadow-color);+ }++ &.side-end > .peek-pane,+ body[dir=rtl] &.side-start > .peek-pane {+ --peek-pane-shadow-offset: calc(-1 * var(--peek-pane-shadow-depth));+ }++ body[dir=rtl] &.side-end > .peek-pane {+ --peek-pane-shadow-offset: var(--peek-pane-shadow-depth);+ }+ }+}++.peek-pane-spacer {+ display: none;+}++/* Keeps the z-index of the note content, such as the active split's outline (500), under a peek. */+#center-pane {+ isolation: isolate;+}++/* The text editor draws the grip of the focused block in `.ck-body`, outside `#center-pane`. */+body:has(.peek-pane-host.peek) .ck-block-toolbar-button {+ visibility: hidden;+}++@keyframes peek-pane-in {+ from { opacity: 0; }+ to { opacity: 1; }+}diff --git a/apps/client/src/widgets/react/peek_pane.spec.tsx b/apps/client/src/widgets/react/peek_pane.spec.tsxindex 31098b71d2..6517896269 100644--- a/apps/client/src/widgets/react/peek_pane.spec.tsx+++ b/apps/client/src/widgets/react/peek_pane.spec.tsx@@ -2,8 +2,14 @@ import { render } from "preact";import { act } from "preact/test-utils";import { afterEach, describe, expect, it, vi } from "vitest";+import type { EventData } from "../../components/app_context";+import type Component from "../../components/component";import options from "../../services/options";-import { isWithinPeek, PaneModeController, persistedPaneVisible, reducePaneMode, usePaneMode, usePeekDismiss } from "./peek_pane";+import {+ isWithinPeek, PaneModeController, persistedPaneVisible, reducePaneMode, usePaneMode,+ usePeekDismiss, watchPeekDismiss+} from "./peek_pane";+import { ParentComponent } from "./react_utils";describe("reducePaneMode", () => {it("opens as peek from closed and closes otherwise", () => {@@ -18,12 +24,14 @@ describe("reducePaneMode", () => {expect(reducePaneMode("docked", "toggleDocked")).toBe("closed");});- it("docks, and both close and dismiss reach closed, unconditionally", () => {+ it("docks and closes unconditionally, and dismisses a peek only", () => {for (const prev of ["closed", "peek", "docked"] as const) {expect(reducePaneMode(prev, "dock")).toBe("docked");expect(reducePaneMode(prev, "close")).toBe("closed");- expect(reducePaneMode(prev, "dismiss")).toBe("closed");}+ expect(reducePaneMode("peek", "dismiss")).toBe("closed");+ expect(reducePaneMode("docked", "dismiss")).toBe("docked");+ expect(reducePaneMode("closed", "dismiss")).toBe("closed");});});@@ -37,7 +45,7 @@ describe("usePaneMode", () => {const host = document.createElement("div");document.body.appendChild(host);function Harness() {- controller = usePaneMode("rightPaneVisible");+ controller = usePaneMode("rightPaneVisible", "right");return null;}act(() => render(<Harness />, host));@@ -80,7 +88,7 @@ describe("usePaneMode", () => {const host = document.createElement("div");document.body.appendChild(host);function Harness() {- controller = usePaneMode("rightPaneVisible");+ controller = usePaneMode("rightPaneVisible", "right");return null;}act(() => render(<Harness />, host));@@ -110,6 +118,56 @@ describe("usePaneMode", () => {isOption.mockRestore();save.mockRestore();});++ it("announces its mode, and gives its peek up to another pane's", () => {+ type Handler = (data: EventData<"paneModeChanged">) => void;+ const handlers = new Set<Handler>();+ const parent = {+ registerHandler: (_name: string, handler: Handler) => handlers.add(handler),+ removeHandler: (_name: string, handler: Handler) => handlers.delete(handler),+ triggerEvent: vi.fn()+ } as unknown as Component;+ const announce = (data: EventData<"paneModeChanged">) => act(() => {+ for (const handler of handlers) {+ handler(data);+ }+ });++ let controller: PaneModeController | undefined;+ const host = document.createElement("div");+ document.body.appendChild(host);+ function Harness() {+ controller = usePaneMode("rightPaneVisible", "right");+ return null;+ }+ act(() => render(+ <ParentComponent.Provider value={parent}><Harness /></ParentComponent.Provider>,+ host+ ));++ act(() => controller?.togglePeek());+ expect(parent.triggerEvent).toHaveBeenCalledWith(+ "paneModeChanged", { pane: "right", mode: "peek" }+ );++ // Its own peek, and the other pane closing or docking, leave it open.+ announce({ pane: "right", mode: "peek" });+ announce({ pane: "left", mode: "closed" });+ announce({ pane: "left", mode: "docked" });+ expect(controller?.mode).toBe("peek");++ // Another pane's peek dismisses it, softly.+ announce({ pane: "left", mode: "peek" });+ expect(controller?.mode).toBe("closed");+ expect(controller?.mounted).toBe(true);++ // A docked pane stays.+ act(() => controller?.dock());+ announce({ pane: "left", mode: "peek" });+ expect(controller?.mode).toBe("docked");++ act(() => render(null, host));+ });});describe("persistedPaneVisible", () => {@@ -227,6 +285,19 @@ describe("usePeekDismiss", () => {unmount();});+ it("stops listening once the watch is stopped, for callers outside Preact", () => {+ const onDismiss = vi.fn();+ const stop = watchPeekDismiss(onDismiss, { keepOpenSelector: "#right-pane" });++ document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape" }));+ expect(onDismiss).toHaveBeenCalledTimes(1);++ stop();+ document.dispatchEvent(new KeyboardEvent("keydown", { key: "Escape" }));+ document.body.dispatchEvent(new MouseEvent("pointerdown", { bubbles: true }));+ expect(onDismiss).toHaveBeenCalledTimes(1);+ });+it("hands the focus back to what opened the peek, where it was told what that is", () => {document.body.innerHTML = `<button class="peek-button"></button>`;const onDismiss = vi.fn();diff --git a/apps/client/src/widgets/react/peek_pane.ts b/apps/client/src/widgets/react/peek_pane.tsindex 6fa9f62f9a..474e562981 100644--- a/apps/client/src/widgets/react/peek_pane.ts+++ b/apps/client/src/widgets/react/peek_pane.ts@@ -1,8 +1,15 @@+import "./peek_pane.css";+import { OptionNames } from "@triliumnext/commons";-import { useCallback, useEffect, useRef, useState } from "preact/hooks";+import {+ useCallback, useContext, useEffect, useLayoutEffect, useRef, useState+} from "preact/hooks";+import type { EventData } from "../../components/app_context";import options from "../../services/options";import { FLOATING_LAYER_SELECTOR } from "./floating_layers";+import { useTriliumEvent } from "./hooks";+import { ParentComponent } from "./react_utils";/*** A reusable side pane that can be in one of three modes:@@ -12,23 +19,32 @@ import { FLOATING_LAYER_SELECTOR } from "./floating_layers";* interaction or Escape.** These primitives are side-agnostic (left/right) and content-agnostic; a consumer supplies the- * persisted option key, the commands/keyboard actions, and the DOM (see RightPanelContainer for the- * reference implementation). Only the docked/closed distinction is persisted — peek is runtime-only.+ * persisted option key, the commands/keyboard actions, and the DOM. `RightPanelContainer` uses the+ * hooks; the jQuery `LeftPaneContainer` uses `reducePaneMode`, `persistedPaneVisible` and+ * `watchPeekDismiss`. Both share `PeekPaneButton` and `peek_pane.css`. Only the docked/closed+ * distinction is persisted; peek is runtime-only.+ *+ * Each pane raises `paneModeChanged` when its mode changes, and dismisses its own peek when another+ * pane starts peeking, so that only one peek is open at a time.*/export type PaneMode = "closed" | "peek" | "docked";+export type PaneId = "left" | "right";// `togglePeek` and `dismiss` are *soft* closes (content stays mounted, hidden, so re-peeking preserves// widget state); `close` (the × button) and the docked toggle are *hard* closes that unmount. The// mode result is the same; the mount distinction lives in usePaneMode.export type PaneAction = "togglePeek" | "toggleDocked" | "dock" | "close" | "dismiss";-/** The next mode for a given action (pure). `toggle*` open from closed and close otherwise. */+/**+ * The next mode for a given action (pure). `toggle*` open from closed and close otherwise;+ * `dismiss` closes a peek only.+ */export function reducePaneMode(prev: PaneMode, action: PaneAction): PaneMode {switch (action) {case "togglePeek": return prev === "closed" ? "peek" : "closed";case "toggleDocked": return prev === "closed" ? "docked" : "closed";case "dock": return "docked";case "close": return "closed";- case "dismiss": return "closed";+ case "dismiss": return prev === "peek" ? "closed" : prev;}}@@ -63,8 +79,11 @@ interface PaneState {* Owns a pane's mode, mount lifecycle and persistence. `visibleOption` stores only the docked/closed* distinction. The state updater stays pure (it can run more than once, e.g. in Strict Mode);* persistence runs in an effect so it isn't duplicated by re-invoked updaters.+ *+ * @param pane the pane's id in `paneModeChanged`.*/-export function usePaneMode(visibleOption: OptionNames): PaneModeController {+export function usePaneMode(visibleOption: OptionNames, pane: PaneId): PaneModeController {+ const parentComponent = useContext(ParentComponent);const [ { mode, mounted }, setState ] = useState<PaneState>(() => {const docked = options.is(visibleOption);return { mode: docked ? "docked" : "closed", mounted: docked };@@ -86,7 +105,8 @@ export function usePaneMode(visibleOption: OptionNames): PaneModeController {}, []);const prevModeRef = useRef<PaneMode>(mode);- useEffect(() => {+ // A layout effect, so that another pane's peek closes before the paint that shows this one.+ useLayoutEffect(() => {const prev = prevModeRef.current;if (prev !== mode) {const persist = persistedPaneVisible(prev, mode);@@ -94,8 +114,15 @@ export function usePaneMode(visibleOption: OptionNames): PaneModeController {options.save(visibleOption, persist.toString());}prevModeRef.current = mode;+ parentComponent?.triggerEvent("paneModeChanged", { pane, mode });+ }+ }, [ mode, visibleOption, pane, parentComponent ]);++ useTriliumEvent("paneModeChanged", useCallback((data: EventData<"paneModeChanged">) => {+ if (data.pane !== pane && data.mode === "peek") {+ apply("dismiss");}- }, [ mode, visibleOption ]);+ }, [ pane, apply ]));const togglePeek = useCallback(() => apply("togglePeek"), [ apply ]);const toggleDocked = useCallback(() => apply("toggleDocked"), [ apply ]);@@ -123,32 +150,39 @@ export interface PeekDismissOptions {}/**- * While `active`, closes the peek on an outside press or Escape. Presses over the content area land- * on the pane's backdrop and so reach this listener; presses on chrome the backdrop doesn't cover- * (tree, toolbar, tabs) are caught directly. Capture phase so a child's `stopPropagation` can't keep- * a stale peek open.+ * While `active`, closes the peek on an outside press or Escape. See {@link watchPeekDismiss}.*/export function usePeekDismiss(active: boolean, onDismiss: () => void, { keepOpenSelector, focusSelector }: PeekDismissOptions) {useEffect(() => {if (!active) return;-- const selector = `${keepOpenSelector}, ${DEFAULT_KEEP_OPEN_SELECTOR}`;- const onPointerDown = (e: PointerEvent) => {- if (!isWithinPeek(e.target, selector)) onDismiss();- };- const onKeyDown = (e: KeyboardEvent) => {- // Skip if an inner element already handled Escape (e.g. closed a dropdown or cleared an input).- if (e.key === "Escape" && !e.defaultPrevented) {- onDismiss();- if (focusSelector) document.querySelector<HTMLElement>(focusSelector)?.focus();- }- };-- document.addEventListener("pointerdown", onPointerDown, true);- document.addEventListener("keydown", onKeyDown);- return () => {- document.removeEventListener("pointerdown", onPointerDown, true);- document.removeEventListener("keydown", onKeyDown);- };+ return watchPeekDismiss(onDismiss, { keepOpenSelector, focusSelector });}, [ active, onDismiss, keepOpenSelector, focusSelector ]);}++/**+ * Closes a peek on an outside press or Escape until the returned function is called; the+ * framework-free core of {@link usePeekDismiss}. Presses over the content area land on the pane's+ * backdrop and so reach this listener; presses on chrome the backdrop doesn't cover (toolbar, tabs)+ * are caught directly. Capture phase so a child's `stopPropagation` can't keep a stale peek open.+ */+export function watchPeekDismiss(onDismiss: () => void, dismissOptions: PeekDismissOptions) {+ const { keepOpenSelector, focusSelector } = dismissOptions;+ const selector = `${keepOpenSelector}, ${DEFAULT_KEEP_OPEN_SELECTOR}`;+ const onPointerDown = (e: PointerEvent) => {+ if (!isWithinPeek(e.target, selector)) onDismiss();+ };+ const onKeyDown = (e: KeyboardEvent) => {+ // Skip an Escape that an inner element handled, e.g. a dropdown closing itself.+ if (e.key === "Escape" && !e.defaultPrevented) {+ onDismiss();+ if (focusSelector) document.querySelector<HTMLElement>(focusSelector)?.focus();+ }+ };++ document.addEventListener("pointerdown", onPointerDown, true);+ document.addEventListener("keydown", onKeyDown);+ return () => {+ document.removeEventListener("pointerdown", onPointerDown, true);+ document.removeEventListener("keydown", onKeyDown);+ };+}diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.css b/apps/client/src/widgets/sidebar/RightPanelContainer.cssindex 361786d876..f1e0c03768 100644--- a/apps/client/src/widgets/sidebar/RightPanelContainer.css+++ b/apps/client/src/widgets/sidebar/RightPanelContainer.css@@ -1,8 +1,4 @@:where(:root) {- --peek-pane-backdrop-color: #0000000d;- --peek-pane-shadow-depth: 42px;- --peek-pane-shadow-color: #0000002b;---right-pane-peek-border-radius: 8px 0 0 8px;--right-pane-peek-background: #ffffffe7;--right-pane-peek-backdrop-filter: blur(12px) saturate(1.5);@@ -13,11 +9,12 @@}/* Reserve a fixed-width gutter on the viewport's right edge for the peek button, which is- absolutely positioned within it (see RightPanePeekButton.css). Split sizes the panes+ absolutely positioned within it (see PeekPaneButton.css). Split sizes the panesinside the padded content box, so they never sit under the button, and the button stays putregardless of whether the right pane is open. */#vertical-main-container {--right-pane-peek-button-width: 12px;+ --peek-pane-button-width: var(--right-pane-peek-button-width);/* +4px leaves a small gap between the right pane (and #center-pane) and the peek button. */--right-pane-peek-button-gutter: calc(var(--right-pane-peek-button-width) + 4px);position: relative;@@ -28,68 +25,14 @@ body.layout-horizontal #vertical-main-container {--right-pane-peek-button-gutter: calc(var(--right-pane-peek-button-width) + 2px);}-/* Persistent host wrapping the spacer + #right-pane (see RightPanelContainer.tsx), so #right-pane- never reparents between modes. A flex row: docked it fills with the pane (spacer hidden); peek- it lays out [spacer | gutter | pane]. */-#right-pane-host {- display: flex;- flex-direction: row;+/* The button follows the translucency of the rightmost split. */+body.desktop.background-effects #center-pane:has(.note-split.last-visible.bgfx) ~ .right-pane-peek-button {+ --peek-button-expand-background-color: var(--center-pane-background-color-bgfx, var(--main-background-color));}-/* A soft-dismissed peek keeps its content mounted (so re-peeking is instant and stateful); this- takes it out of layout/paint without unmounting it. Applied whenever the pane isn't shown. */-#right-pane-host.hidden {- display: none;-}--/* Docked: #right-pane fills the host (which Split sizes against #center-pane). */-#right-pane-host:not(.peek) > #right-pane {- flex: 1 1 0;- min-width: 0;-}--/* When closing the peek, the host goes in-flow a frame before Split.destroy (run in an effect)- removes its resize gutter. Keep any gutter inside a non-peek host out of the flow so that- lingering 5px gutter can't briefly widen the host and reflow the content. */-#right-pane-host:not(.peek) > .gutter {- display: none;-}--/* Peek: float the host above the content as an absolute layer, so the content never reflows. */#right-pane-host.peek {- position: absolute;- inset-block: 0;inset-inline-start: 0;inset-inline-end: var(--right-pane-peek-button-gutter);- z-index: 15;- animation: right-pane-peek-in 200ms ease-out;- background: var(--peek-pane-backdrop-color);-}--@keyframes right-pane-peek-in {- from { opacity: 0; }- to { opacity: 1; }-}--/* Peek: Split sizes the spacer and the pane via inline widths, so flex must not override them. */-#right-pane-host.peek > .right-pane-peek-spacer,-#right-pane-host.peek > #right-pane {- flex: 0 0 auto;-}--#right-pane-host.peek > #right-pane {- box-shadow: calc(-1 * var(--peek-pane-shadow-depth)) 0 var(--peek-pane-shadow-depth) calc(-1 * var(--peek-pane-shadow-depth)) var(--peek-pane-shadow-color) ;-}--/* The spacer is the left Split target and, in peek mode, the faint click-to-dismiss backdrop- over the content (it also shields the PDF iframe during a resize drag). Hidden when docked. */-.right-pane-peek-spacer {- display: none;-}--#right-pane-host.peek > .right-pane-peek-spacer {- display: block;- min-width: 0;}#right-pane {diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.spec.tsx b/apps/client/src/widgets/sidebar/RightPanelContainer.spec.tsxindex f83d9d1cb5..42ce54ca92 100644--- a/apps/client/src/widgets/sidebar/RightPanelContainer.spec.tsx+++ b/apps/client/src/widgets/sidebar/RightPanelContainer.spec.tsx@@ -28,7 +28,7 @@ vi.mock("./pdf/PdfPages", () => stubWidget("pdf-pages-stub"));vi.mock("./pdf/PdfAttachments", () => stubWidget("pdf-attachments-stub"));vi.mock("./pdf/PdfLayers", () => stubWidget("pdf-layers-stub"));vi.mock("./pdf/PdfAnnotations", () => stubWidget("pdf-annotations-stub"));-vi.mock("./RightPanePeekButton", () => stubWidget("peek-button-stub"));+vi.mock("../react/PeekPaneButton", () => stubWidget("peek-button-stub"));vi.mock("../../services/keyboard_actions", () => ({default: { getAction: vi.fn().mockResolvedValue({ effectiveShortcuts: [] }) }}));diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx b/apps/client/src/widgets/sidebar/RightPanelContainer.tsxindex 31367f7ad3..6e86436d95 100644--- a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx+++ b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx@@ -16,6 +16,7 @@ import { useActiveNoteContext, useGetContextData, useLegacyWidget, useNoteProperimport LazyComponent from "../react/LazyComponent";import NoItems from "../react/NoItems";import { PaneMode, usePaneMode, usePeekDismiss } from "../react/peek_pane";+import PeekPaneButton from "../react/PeekPaneButton";import LegacyRightPanelWidget from "../right_panel_widget";import AttributeList from "./AttributeList";import Backlinks from "./Backlinks";@@ -29,7 +30,6 @@ import PdfAttachments from "./pdf/PdfAttachments";import PdfLayers from "./pdf/PdfLayers";import PdfPages from "./pdf/PdfPages";import RightPanelWidget, { CollapsibleWidgets, ExpandWidgetRequest, ExpandWidgetRequests } from "./RightPanelWidget";-import RightPanePeekButton from "./RightPanePeekButton";import RightPaneTabs, { RIGHT_PANE_TABS, RightPaneTabDefinition, RightPaneTabId } from "./RightPaneTabs";import TableOfContents from "./TableOfContents";@@ -50,7 +50,7 @@ export interface RightPaneTabContents extends RightPaneTabDefinition {}export default function RightPanelContainer({ widgetsByParent }: { widgetsByParent: WidgetsByParent }) {- const { mode, visible, mounted, togglePeek, toggleDocked, dock, close, dismiss } = usePaneMode("rightPaneVisible");+ const { mode, visible, mounted, togglePeek, toggleDocked, dock, close, dismiss } = usePaneMode("rightPaneVisible", "right");const tabs = useItems(mounted, widgetsByParent);// This window's own choice, seeded from the option and written back for the next window to start// from — the same treatment usePaneMode gives the pane's visibility. Subscribing to the option@@ -128,19 +128,29 @@ export default function RightPanelContainer({ widgetsByParent }: { widgetsByPare<>{/* Absolutely positioned in a reserved gutter on the viewport's right edge, so itstays put regardless of the right pane's open/collapsed state (see RightPanelContainer.css). */}- <RightPanePeekButton rightPaneVisible={visible} onToggle={togglePeek} />+ <PeekPaneButton+ side="end"+ className="right-pane-peek-button"+ isOpen={visible}+ onToggle={togglePeek}+ hideText={t("right_pane.hide")}+ peekText={t("right_pane.peek")}+ />{/* Persistent host so #right-pane never reparents between modes (which would remount theright pane widgets). Docked: an in-flow flex child Split resizes against #center-pane.Peek: an absolute layer over the content where Split resizes the spacer vs the pane.`hidden` (display:none) keeps soft-dismissed peek content mounted but out of layout. */}- <div id="right-pane-host" class={clsx(mode === "peek" && "peek", !visible && "hidden")}>+ <div+ id="right-pane-host"+ class={clsx("peek-pane-host side-end", mode === "peek" && "peek", !visible && "hidden")}+ >{/* The spacer is both the left Split target and the dismiss backdrop in peek mode:it covers the content (a click dismisses) and shields the PDF iframe so Split'sdrag tracking isn't interrupted. Always rendered + CSS-toggled to keep the host'schild list structurally stable for Split's gutter injection. */}- <div class="right-pane-peek-spacer" />+ <div class="peek-pane-spacer" />{/* Mode class (right-pane-mode-docked / -peek) as a styling hook; none when closed. */}- <div id="right-pane" class={visible ? `right-pane-mode-${mode}` : undefined}>+ <div id="right-pane" class={clsx("peek-pane", visible && `right-pane-mode-${mode}`)}>{mounted && (<>{/* One flex row holding the tab strip and the pane's own actions, so a@@ -396,7 +406,7 @@ function useSplit(mode: PaneMode) {// they're always present; #center-pane is untouched, so it never reflows.const selectors = mode === "docked"? [ "#center-pane", "#right-pane-host" ]- : [ ".right-pane-peek-spacer", "#right-pane" ];+ : [ "#right-pane-host > .peek-pane-spacer", "#right-pane" ];const minSize = mode === "docked" ? [ 300, 230 ] : [ 0, 230 ];const createSplit = () => Split(selectors, {diff --git a/apps/server/src/assets/help/help_content.json b/apps/server/src/assets/help/help_content.jsonindex 10614b2bb5..458b834c67 100644--- a/apps/server/src/assets/help/help_content.json+++ b/apps/server/src/assets/help/help_content.json@@ -35,9 +35,9 @@"_help_ODY7qQn5m2FT": "<p>Trilium supports simple backup scheme where it saves copy of the <a class=\"reference-link\" href=\"#root/_help_wX4HbRucYSDD\">Database</a> on these events:</p><ul><li>once a day</li><li>once a week</li><li>once a month</li><li>before DB migration to newer version</li></ul><p>So in total you'll have at most 4 backups from different points in time which should protect you from various problems. These backups are stored by default in <code>backup</code> directory placed in the <a href=\"#root/_help_tAassRL4RSQL\">data directory</a>.</p><p>This is only very basic backup solution, and you're encouraged to add some better backup solution - e.g. backing up the <a class=\"reference-link\" href=\"#root/_help_wX4HbRucYSDD\">Database</a> to cloud / different computer etc.</p><p>Note that <a class=\"reference-link\" href=\"#root/_help_cbkrhQjrkKrh\">Synchronization</a> provides also some backup capabilities by its nature of distributing the data to other computers.</p><h2>Creating a backup</h2><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bx-desktop\"></span> On the desktop app & web client</p><div class=\"trilium-tab-panel\"><ol><li>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Backup</em> and press the <em>Backup now</em> button.</li><li>The backup creation process may take a few moments, especially for larger databases. A notification will inform you when the backup is complete.</li><li>The backup will be saved as <code>backup-now</code> in the <em>Existing backups</em> list, where you can download it.</li></ol></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bx-globe\"></span> On the standalone client</p><div class=\"trilium-tab-panel\"><ol><li>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Backup</em> and press the <em>Download backup</em> button.</li><li>You will be prompted to restart the app. Confirm, and the app will restart automatically.</li><li>Set a <em>backup name</em> or <em>password</em> (both optional), then press <em>Continue</em>.</li><li>Press the <em>Generate and download</em> button and wait for the download to complete.</li><li>Once you confirm the download is saved on your device, press <em>Finish</em> to complete</li></ol></div></section></div><h2>Downloading a backup</h2><ul><li><strong>Desktop and web client</strong>: to download an existing backup, navigate to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Backup</em> → <em>Existing backups</em> and select <em>Download</em> (<span class=\"tn-icon bx bx-download\"></span>).</li><li><strong>Standalone client</strong>: automatic backups are not supported in this version. You can manually create and download a backup by going to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Backup</em> → <em>Download backup</em>.</li></ul><h2>Restoring a backup</h2><ul><li><strong>For a new Trilium instance</strong>: When setting up a new Trilium instance, use the <em>Restore from backup</em> option in the setup menu to guide you through restoring your existing backup.</li><li><strong>For an existing Trilium instance</strong>: To restore a backup and replace your current database, go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Backup</em> and click <em>Restore a backup</em>. You will be prompted to restart the app for the restoration process to begin. After restarting, you can choose to back up the existing database before overwriting it. Note: For the web client, use the Start Over feature ( <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Database</em> → <em>Start over</em> (<span class=\"tn-icon bx bx-reset\"></span>)) to switch to the setup screen and restore a backup.</li></ul><p>Next, select the backup file (.db or .tnbackup) from your device. The web client is optimized for handling large backups and is resilient to unstable network conditions, similar to the desktop application.</p><p>If your database is encrypted, you will be prompted to enter the password used for encrypting the backup file. Without the correct password, decryption and restoration cannot proceed.</p><p>Restoring a backup may take some time, depending on its size. Once it completes, Trilium will open the freshly restored database.</p><h3>The alternative way for restoring a backup</h3><p>Let's assume you want to restore the weekly backup (only in .db format, .tnbackup files are not supported by this method), here's how to do it:</p><ul><li>find <a href=\"#root/_help_tAassRL4RSQL\">data directory</a> Trilium uses - easy way is to open \"About Trilium Notes\" (<span class=\"tn-icon bx bx-info-circle\"></span>) from \"Menu\" in upper left corner and looking at \"data directory\"<ul><li>I'll refer to <code>~/trilium-data</code> as data directory from now on</li></ul></li><li>find <code>~/trilium-data/backup/backup-weekly.db</code> - this is the <a class=\"reference-link\" href=\"#root/_help_wX4HbRucYSDD\">Database</a> backup.</li><li>at this point stop/kill Trilium</li><li>delete <code>~/trilium-data/document.db</code>, <code>~/trilium-data/document.db-wal</code> and <code>~/trilium-data/document.db-shm</code> (latter two files are auto generated)</li><li>copy and rename this <code>~/trilium-data/backup/backup-weekly.db</code> to <code>~/trilium-data/document.db</code></li><li>make sure that the file is writable, e.g. with <code>chmod 600 document.db</code></li><li>start Trilium again</li></ul><aside class=\"admonition warning\"><p>If you have configured sync then you need to do it across all members of the sync cluster, otherwise older version (restored backup) of the document will be detected and synced to the newer version.</p></aside><h2>Changing the backup location in Trilium (desktop only)</h2><p>Starting with version 0.105, the Trilium desktop client allows users to change the directory where backups are stored. Follow these steps to specify a custom backup directory:</p><ol><li>Navigate to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Backup</em> → <em>Backup location</em>.</li><li>Click the <em>Select location</em> button.</li><li>Choose any writable directory on your file system. This could include network shares, depending on your operating system.</li></ol><p>Once you set a custom directory, all manual and automatic backups will be saved there. If the selected directory becomes unavailable, backups may fail or revert to the default location.</p><aside class=\"admonition tip\"><p>For better privacy when using unsafe backup locations, you can enable backup encryption, which makes the backup file unreadable without the correct password.</p></aside><h2>Backup encryption</h2><p>Trilium can secure the entire content of the database backup, ensuring it remains unreadable unless the correct password is provided. This is particularly useful for storing backups in unsecured locations, like network shares, unencrypted external drives, or cloud services. </p><p>Encrypted database backups use the Trilium Backup Container (.tnbackup) format, which relies on AES-256-GCM. This authenticated encryption mode scrambles the data and generates a tag confirming it hasn't been altered. The password itself isn't directly used as the key; it's processed through scrypt, a key derivation function designed to be slow and memory-intensive, making brute-force password guessing difficult even with powerful hardware. Each backup also receives a random 16-byte salt, ensuring that the same password never produces the same encryption key twice. Additionally, critical metadata such as chunk order, length, and header flags are cryptographically bound into the encryption (via \"additional authenticated data\"), preventing undetected tampering like reorder, truncate, or splice operations.</p><h3>Enabling backup encryption</h3><p>To enable encryption for automatic backups in the Desktop application:</p><ol><li>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Backup</em> → <em>Backup options</em>.</li><li>Click on <em>Turn on encryption</em> and set a password.</li></ol><p>Once encryption is enabled, all newly created backups (both automatic and manual) will be encrypted with the specified password. Backups created prior to enabling encryption will remain unsecured.</p><p>You can change the password anytime using the <em>Change password</em> button. The new password will apply to backups created after the change.</p><p>To disable encryption, uncheck <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Backup</em> → <em>Enable encryption</em>.</p><aside class=\"admonition note\"><p>On some systems, a keyring may not be available for Trilium to securely store the encryption password. In such cases, the encryption option is disabled.</p></aside><h2>Backup compression</h2><p>Database backups can be optionally compressed to minimize storage footprint. This method is effective primarily when the database consists largely of text content. However, media files (images, videos, audio), along with PDF, ODF, and DOCX files, are already compressed in their original formats and won't benefit from further compression.</p><p>Compressed backups are stored using the Trilium Backup Container (.tnbackup), employing RFC 1952 GZIP compression.</p><aside class=\"admonition warning\"><p><strong>Note:</strong> Compression increases the time required for backup creation and restoration. It may also lead to higher CPU usage during automatic backups, potentially draining the battery faster on battery-powered devices. Enable this option only if necessary.</p></aside><h3>Enabling Backup Compression (Desktop Only)</h3><p>To enable compression for new automatic and manual backups, navigate to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Backup</em> → <em>Backup options</em> and toggle <em>Enable compression</em> to on.</p><h2>Disabling backup</h2><p>Although this is not recommended, it is possible to disable backup in <code>config.ini</code> in the <a href=\"#root/_help_tAassRL4RSQL\">data directory</a>:</p><pre><code class=\"language-text-x-trilium-auto\">[General]\n... some other configs\n# set to true to disable backups (e.g. because of limited space on server)\nnoBackup=true</code></pre><p>You can also review the <a href=\"#root/_help_Gzjqa934BdH4\">configuration</a> file to provide all <code>config.ini</code> values as environment variables instead.</p><p>See <a href=\"https://github.com/TriliumNext/Trilium/blob/master/config-sample.ini\">sample config</a>.</p>","_help_tAassRL4RSQL": "<p>Data directory contains:</p><ul><li><code>document.db</code> - <a href=\"#root/_help_wX4HbRucYSDD\">database</a></li><li><code>config.ini</code> - instance level settings like port on which the Trilium application runs</li><li><code>backup</code> - contains automatically <a href=\"#root/_help_ODY7qQn5m2FT\">backup</a> of documents</li><li><code>log</code> - contains application log files</li></ul><h2>Location of the data directory</h2><p>Easy way how to find out which data directory Trilium uses is to look at the \"About Trilium Notes\" dialog (from \"Menu\" in upper left corner):</p><p><img src=\"{{helpAssets}}/User%20Guide/Installation%20%26%20Setup/Data%20directory_image.jpg\"></p><p>Here's how the location is decided:</p><p>Data directory is normally named <code>trilium-data</code> and it is stored in:</p><ul><li><code>/home/[user]/.local/share</code> for Linux</li><li><code>/home/[user]/.var/app/org.triliumnotes.Trilium/data</code> for the Flathub version on Linux</li><li><code>C:\\Users\\[user]\\AppData\\Roaming</code> for Windows Vista and up</li><li><code>/Users/[user]/Library/Application Support</code> for Mac OS</li><li>user's home is a fallback if some of the paths above don't exist</li><li>user's home is also a default setup for [[docker|Docker server installation]]</li></ul><p>If you want to back up your Trilium data, just backup this single directory - it contains everything you need.</p><h3>Changing the location of data directory</h3><p>If you want to use some other location for the data directory than the default one, you may change it via <code>TRILIUM_DATA_DIR</code> environment variable to some other location:</p><div class=\"trilium-tabs\"><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-windows\"></span> Windows</p><div class=\"trilium-tab-panel\"><ol><li>Press the <span class=\"tn-icon bx bxl-windows\"></span> key on your keyboard.</li><li>Search and select <em>Edit the system variables</em>.</li><li>Press the <em>Environment Variables…</em> button in the bottom-right of the newly opened screen.</li><li>On the top section (<em>User variables for [user]</em>), press the <em>New…</em> button.</li><li>In the <em>Variable name</em> field insert <code>TRILIUM_DATA_DIR</code>.</li><li>Press the <em>Browse Directory…</em> button and select the new directory where to store the database.</li><li>Close all the windows by pressing the <em>OK</em> button for each of them.</li></ol></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-tux\"></span> Linux</p><div class=\"trilium-tab-panel\"><p>Trilium reads <code>TRILIUM_DATA_DIR</code> when it starts, so the variable must be set in the environment that launches it.</p><aside class=\"admonition note\"><p>Setting the variable does not move existing notes. To keep them, close Trilium and copy the old data directory to the new location first. Trilium creates the last folder of the path if it is missing, but not its parent folders.</p></aside><p><strong>Desktop application (.deb, .rpm, AppImage or .zip)</strong></p><p>To use the new location however Trilium is started (from the application menu, a desktop shortcut, at login or from a terminal), set the variable for the whole session:</p><ol><li><p>Create the file <code>~/.config/environment.d/trilium.conf</code> with the following content, using the full path (<code>~</code> is not expanded in this file):</p><pre><code class=\"language-text-x-trilium-auto\">TRILIUM_DATA_DIR=/home/myuser/data/my-trilium-data</code></pre></li><li><p>Log out and log back in.</p></li></ol><p>This works on desktops started by <code>systemd</code>, which covers most distributions running GNOME or KDE Plasma. On other systems, add the following line to <code>~/.profile</code> instead, then log out and log back in:</p><pre><code class=\"language-text-x-sh\">export TRILIUM_DATA_DIR=\"$HOME/data/my-trilium-data\"</code></pre><p>The same line in <code>~/.bashrc</code> (or your shell's equivalent) only applies when Trilium is started from a terminal, not from the application menu.</p><p><strong>Flatpak (Flathub)</strong></p><p>The Flathub version runs in a sandbox that cannot see the rest of the file system, so it needs access to the folder as well as the variable:</p><pre><code class=\"language-text-x-sh\">flatpak override --user \\\n --env=TRILIUM_DATA_DIR=/home/myuser/data/my-trilium-data \\\n --filesystem=/home/myuser/data/my-trilium-data:create \\\n org.triliumnotes.Trilium</code></pre><p>To return to the default location, run <code>flatpak override --user --reset org.triliumnotes.Trilium</code>. This also removes any other overrides set for Trilium.</p><p><strong>Server running as a systemd service</strong></p><p>Add an <code>Environment=</code> line to the <code>[Service]</code> section of the unit file described in <a class=\"reference-link\" href=\"#root/_help_3tW6mORuTHnB\">Packaged version for Linux</a>:</p><pre><code class=\"language-text-x-trilium-auto\">[Service]\nEnvironment=TRILIUM_DATA_DIR=/var/lib/trilium-data</code></pre><p>Then reload and restart the service:</p><pre><code class=\"language-text-x-sh\">sudo systemctl daemon-reload\nsudo systemctl restart trilium</code></pre><p>The user set in <code>User=</code> must be able to write to the folder. For Docker, see <a class=\"reference-link\" href=\"#root/_help_rWX5eY045zbE\">Using Docker</a> instead.</p></div></section><section class=\"trilium-tab\"><p class=\"trilium-tab-title\"><span class=\"tn-icon bx bxl-apple\"></span> macOS</p><div class=\"trilium-tab-panel\"><p>You need to create a <code>.plist</code> file under <code>~/Library/LaunchAgents</code> to load it properly each login.</p><p>To load it manually, you need to use <code>launchctl setenv TRILIUM_DATA_DIR <yourpath></code></p><p>Here is a pre-defined template, where you just need to add your path to:</p><pre><code class=\"language-text-xml\"><?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/PropertyList-1.0.dtd\">\n<plist version=\"1.0\">\n<dict>\n <key>Label</key>\n <string>set.trilium.env</string>\n <key>RunAtLoad</key>\n <true/>\n <key>ProgramArguments</key>\n <array>\n <string>/bin/launchctl</string>\n <string>setenv</string>\n <string>TRILIUM_DATA_DIR</string>\n <string>/Users/YourUserName/Library/Application Support/trilium-data</string>\n </array>\n</dict>\n</plist>\n</code></pre></div></section></div><h3>Create a script to run with specific data directory</h3><p>An alternative to globally setting environment variable is to run only the Trilium Notes with this environment variable. This then allows for different setup styles like two <a href=\"#root/_help_wX4HbRucYSDD\">database</a> instances or \"portable\" installation.</p><p>To do this in Unix-based systems simply run <code>trilium</code> like this:</p><pre><code class=\"language-text-x-trilium-auto\">TRILIUM_DATA_DIR=/home/myuser/data/my-trilium-data trilium</code></pre><p>You can then save the above command as a shell script on your path for convenience.</p><h2>Electron user data directory (desktop only)</h2><p>When running the desktop application, Electron stores internal data (caches, spell-check dictionaries, session storage, etc.) separately from the Trilium data directory. By default this goes to the system's application data folder (e.g. <code>%APPDATA%</code> on Windows), which may be undesirable in corporate environments with roaming profiles or when running in portable mode.</p><p>To keep Electron data out of the system's roaming profile, set the <code>TRILIUM_ELECTRON_DATA_DIR</code> environment variable to an explicit path. The <code>trilium-portable</code> script does this automatically, pointing it to <code>trilium-electron-data/</code> next to the application.</p><h2>Fine-grained directory/path location</h2><p>Apart from the data directory, some of the subdirectories of it can be moved elsewhere by changing an environment variable:</p><figure class=\"table\"><table><thead><tr><th>Environment variable</th><th>Default value</th><th>Description</th></tr></thead><tbody><tr><td><code>TRILIUM_DOCUMENT_PATH</code></td><td><code>${TRILIUM_DATA_DIR}/document.db</code></td><td>Path to the <a class=\"reference-link\" href=\"#root/_help_wX4HbRucYSDD\">Database</a> (storing all notes and metadata).</td></tr><tr><td><code>TRILIUM_BACKUP_DIR</code></td><td><code>${TRILIUM_DATA_DIR}/backup</code></td><td>Directory where automated <a class=\"reference-link\" href=\"#root/_help_ODY7qQn5m2FT\">Backup</a> databases are stored.</td></tr><tr><td><code>TRILIUM_LOG_DIR</code></td><td><code>${TRILIUM_DATA_DIR}/log</code></td><td>Directory where daily <a class=\"reference-link\" href=\"#root/_help_bnyigUA2UK7s\">Backend (server) logs</a> are stored.</td></tr><tr><td><code>TRILIUM_TMP_DIR</code></td><td><code>${TRILIUM_DATA_DIR}/tmp</code></td><td>Directory where temporary files are stored (for example when opening in an external app).</td></tr><tr><td><code>TRILIUM_ANONYMIZED_DB_DIR</code></td><td><code>${TRILIUM_DATA_DIR}/anonymized-db</code></td><td>Directory where a <a class=\"reference-link\" href=\"#root/_help_x59R8J8KV5Bp\">Anonymized Database</a> is stored.</td></tr><tr><td><code>TRILIUM_RESOURCES_DIR</code></td><td><code>${TRILIUM_DATA_DIR}/resources</code></td><td>Directory where <a class=\"reference-link\" href=\"#root/_help_ebyr7ES2SwOW\">Downloaded resources</a> are stored, such as the speech recognition models.</td></tr><tr><td><code>TRILIUM_CONFIG_INI_PATH</code></td><td><code>${TRILIUM_DATA_DIR}/config.ini</code></td><td>Path to <a class=\"reference-link\" href=\"#root/_help_Gzjqa934BdH4\">Configuration (config.ini or environment variables)</a> file.</td></tr><tr><td><code>TRILIUM_ELECTRON_DATA_DIR</code></td><td>System appData</td><td>Directory for Electron internal data (caches, spell-check dictionaries, etc.). Set this in portable mode to avoid writing to the system profile (desktop only).</td></tr></tbody></table></figure>","_help_ebyr7ES2SwOW": "<p>Downloaded resources are large files that some features need but that do not ship with Trilium, such as the speech recognition models used to transcribe meetings. Trilium downloads them the first time a feature needs them, and keeps them on the device for later use.</p><p>Currently, only <a class=\"reference-link\" href=\"#root/_help_Y84QCbArmK3z\">Meeting transcription</a> on the desktop application uses downloaded resources:</p><figure class=\"table\"><table><thead><tr><th>Resource</th><th>Size</th><th>License</th><th>Used for</th></tr></thead><tbody><tr><td>Parakeet TDT 0.6B v3 (standard)</td><td>0.6 GB</td><td>CC-BY-4.0</td><td>Recognizing speech, with the <em>Standard</em> model.</td></tr><tr><td>Parakeet TDT 0.6B v3 (high accuracy)</td><td>2.4 GB</td><td>CC-BY-4.0</td><td>Recognizing speech, with the <em>High accuracy</em> model.</td></tr><tr><td>Silero VAD</td><td>0.6 MB</td><td>MIT</td><td>Detecting when someone speaks.</td></tr><tr><td>TitaNet</td><td>40 MB</td><td>Apache-2.0</td><td>Telling speakers apart, while <em>Identify speakers</em> is on.</td></tr></tbody></table></figure><h2>Downloading resources</h2><p>When a feature needs resources that are not on the device yet, Trilium asks before downloading them. The dialog lists each resource with what it is used for, where it is downloaded from, its license and its size, followed by the total download size and the free space on the disk.</p><ul><li>To start the download, press <em>Download</em>. Each resource shows its progress, and the feature continues once all of them are downloaded.</li><li>To stop the download, press <em>Cancel</em> or close the dialog. The files already downloaded are kept, and the next download continues where this one stopped, even within a large file.</li><li>If the disk does not have enough free space, the dialog says so and the download cannot be started.</li></ul><p>Every file is checked against a checksum built into Trilium before it is used, so a file that was damaged or altered during the download is discarded.</p><aside class=\"admonition note\"><p>Downloaded resources are not synchronized. Each device that uses a feature downloads its resources separately, even when the notes are kept in sync through <a class=\"reference-link\" href=\"#root/_help_cbkrhQjrkKrh\">Synchronization</a>.</p></aside><h2>Managing downloaded resources</h2><p>To see the downloaded resources, go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> → <em>Downloaded resources</em>. Each resource that was downloaded, or partly downloaded by an interrupted download, is listed with the space it takes on the disk and its status. Below the list, <em>Space used</em> shows the space they take in total, and how much free space is left on the disk.</p><ul><li>To open the folder of a resource, press the <span class=\"tn-icon bx bx-folder-open\"></span> button (desktop only).</li><li>To delete a resource, press the <span class=\"tn-icon bx bx-trash\"></span> button. If a feature needs it again, it is downloaded again.</li></ul><p>The list also shows, faded out, anything else in the resources folder:</p><ul><li><em>Older version</em>: the files of an earlier version of a resource. When a resource is updated, the new version is downloaded into a new folder, and the old one is left behind.</li><li><em>Not used</em>: a resource that no feature of this installation uses, for example one downloaded by a feature that was removed.</li><li><em>Unknown</em>: any other file or folder, for example one copied there by hand.</li></ul><p>These can be deleted in the same way.</p><aside class=\"admonition warning\"><p>If a server and a desktop application share the same data directory, a resource used by only one of them shows as <em>Not used</em> in the other. Deleting it there removes it for both.</p></aside><h2>Location</h2><p>The resources are stored in the <code>resources</code> folder of the <a class=\"reference-link\" href=\"#root/_help_tAassRL4RSQL\">Data directory</a>, one folder per resource. To store them elsewhere, set the <code>TRILIUM_RESOURCES_DIR</code> environment variable to another folder before starting Trilium.</p><h2>Installing without an Internet connection</h2><p>To install a resource on a device that cannot download it, copy its folder from the <code>resources</code> folder of a device that already has it into the same place on the other device. The next time a feature asks to download it, press <em>Download</em>: the files already in place are checked against their checksums and kept, and only the missing ones are downloaded.</p>",- "_help_x0JgW8UqGXvq": "<p>Trilium supports two different layouts, based on your preference.</p><h3>Vertical layout</h3><p>The vertical layout is Trilium's original layout:</p><ul><li>The <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a> is positioned on the left side of the screen, with buttons being laid out vertically.</li><li>The tab bar is at the top, but to the right of the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>.</li><li>The <a class=\"reference-link\" href=\"#root/_help_Ms1nauBra7gq\">Quick search</a> is at the top of the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>.</li><li>The <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> can be collapsed by pressing the <span class=\"tn-icon bx bx-chevrons-left\"></span> button at the bottom of the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>.</li><li>The <a class=\"reference-link\" href=\"#root/_help_x3i7MxGccDuM\">Global menu</a> can be accessed via the <span class=\"tn-icon cke cke-trilium\"></span> icon at the top of the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>.</li></ul><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/1_Vertical%20and%20horizontal%20layout_image.jpg\"></p><h3>Horizontal layout</h3><p>The horizontal layout is a more traditional layout, since it bears similarity with other applications. In this mode:</p><ul><li>The <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a> is at the top of the screen, with the buttons laid horizontally.</li><li>The tab bar is at the top of the screen, but now covers the entirety of the width, allowing for more tabs to be displayed at once.</li><li>The <a class=\"reference-link\" href=\"#root/_help_Ms1nauBra7gq\">Quick search</a> is now part of the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>. It can be moved around according to preference and even removed if needed.</li><li>The <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> can be collapsed by pressing the small <span class=\"tn-icon bx bx-sidebar\"></span> button to the left of the first tab.</li><li>The <a class=\"reference-link\" href=\"#root/_help_x3i7MxGccDuM\">Global menu</a> can be accessed via the <span class=\"tn-icon bx bx-menu\"></span> button at the end of the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>.</li></ul><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Vertical%20and%20horizontal%20layout_image.jpg\"></p><h2>Changing the layout</h2><p>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> and look for the <em>Appearance</em> option on the left. Then look for the <em>Layout</em> section, where there is the possibility to switch between the two available layouts.</p><p>Clicking an option will immediately apply the selected layout by reloading the window.</p>",+ "_help_x0JgW8UqGXvq": "<p>Trilium supports two different layouts, based on your preference.</p><h3>Vertical layout</h3><p>The vertical layout is Trilium's original layout:</p><ul><li>The <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a> is positioned on the left side of the screen, with buttons being laid out vertically.</li><li>The tab bar is at the top, but to the right of the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>.</li><li>The <a class=\"reference-link\" href=\"#root/_help_Ms1nauBra7gq\">Quick search</a> is at the top of the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>.</li><li>The <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> can be collapsed by pressing the <span class=\"tn-icon bx bx-chevrons-left\"></span> button at the bottom of the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>.</li><li>The <a class=\"reference-link\" href=\"#root/_help_x3i7MxGccDuM\">Global menu</a> can be accessed via the <span class=\"tn-icon cke cke-trilium\"></span> icon at the top of the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>.</li></ul><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/1_Vertical%20and%20horizontal%20layout_image.jpg\"></p><h3>Horizontal layout</h3><p>The horizontal layout is a more traditional layout, since it bears similarity with other applications. In this mode:</p><ul><li>The <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a> is at the top of the screen, with the buttons laid horizontally.</li><li>The tab bar is at the top of the screen, but now covers the entirety of the width, allowing for more tabs to be displayed at once.</li><li>The <a class=\"reference-link\" href=\"#root/_help_Ms1nauBra7gq\">Quick search</a> is now part of the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>. It can be moved around according to preference and even removed if needed.</li><li>The <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> can be collapsed by pressing the small <span class=\"tn-icon bx bx-sidebar\"></span> button to the left of the first tab. While collapsed, it can be peeked temporarily above the content by pressing the strip on the left edge of the app.</li><li>The <a class=\"reference-link\" href=\"#root/_help_x3i7MxGccDuM\">Global menu</a> can be accessed via the <span class=\"tn-icon bx bx-menu\"></span> button at the end of the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>.</li></ul><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Vertical%20and%20horizontal%20layout_image.jpg\"></p><h2>Changing the layout</h2><p>Go to <a class=\"reference-link\" href=\"#root/_help_4TIF1oA4VQRO\">Options</a> and look for the <em>Appearance</em> option on the left. Then look for the <em>Layout</em> section, where there is the possibility to switch between the two available layouts.</p><p>Clicking an option will immediately apply the selected layout by reloading the window.</p>","_help_x3i7MxGccDuM": "<p>The global menu configures the current window (zoom, keeping the window on top) and offers access to some more advanced options.</p><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Global%20menu_image.jpg\"></p><h2>Accessing the global menu</h2><p>See <a href=\"#root/_help_x0JgW8UqGXvq\">Vertical and horizontal layout</a> since the position of the global menu is changed based on which layout has been selected.</p>",- "_help_oPVyFC7WL2Lp": "<p>This page explains how to manipulate the note tree in TriliumNext, focusing on moving notes.</p><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree_image.jpg\"></p><h2>Drag and Drop</h2><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree_drag-and-drop.gif\" alt=\"Drag and drop example\"></p><p>You can easily rearrange the note tree by dragging and dropping notes, as demonstrated in the example above.</p><h3>Importing files</h3><p>A file or archive can easily be imported into Trilium just by dragging it inside the note tree.</p><p>Note that a drag & drop always imports with <em>safe import</em> on, meaning that some features such as scripts are disabled in the upcoming notes. To bypass that, use the dedicated <a href=\"#root/_help_mHbBMPDPkVV5\">import</a> feature (right click → <em>Import into note</em>).</p><p>Unlike the import dialog, the drag & drop also has some basic auto-detection of the import. For example, dragging a .zip file with a <code>.obsidian</code> folder in it will automatically trigger a dedicated <a class=\"reference-link\" href=\"#root/_help_iWD7wiIuMtgV\">Obsidian</a> import.</p><h2>Keyboard Manipulation</h2><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree_move-note-with-keyboard.gif\" alt=\"Example of using keyboard keys to move a note\">Trilium offers efficient keyboard-based manipulation using the following <a href=\"#root/_help_A9Oc6YKKc65v\">shortcuts</a>:</p><ul><li><kbd>Ctrl</kbd> + <kbd>↑</kbd> and <kbd>Ctrl</kbd> +<kbd>↓</kbd>: Move the note up or down in the order.</li><li><kbd>Ctrl</kbd>+<kbd>←</kbd>: Move the note up in the hierarchy by changing its parent to the note's grandparent.</li><li><kbd>Ctrl</kbd>+<kbd>→</kbd>: Move the note down in the hierarchy by setting its parent to the note currently above it (this action is best understood through a demo or hands-on experience).</li><li><kbd>←</kbd> and <kbd>→</kbd>: Expand and collapse a sub-tree.</li></ul><h2>Context Menu</h2><p>You can also move notes using the familiar cut and paste functions available in the context menu, or with the associated keyboard <a href=\"#root/_help_A9Oc6YKKc65v\">shortcuts</a>: <code>CTRL-C</code> ( <a href=\"#root/_help_IakOLONlIfGI\">copy</a>), <kbd>Ctrl</kbd> + <kbd>X</kbd> (cut) and <kbd>Ctrl</kbd> + <kbd>V</kbd> (paste).</p><p>See <a class=\"reference-link\" href=\"#root/_help_YtSN43OrfzaA\">Note tree contextual menu</a> for more information.</p><h2>Tree Settings</h2><p>Click the tree icon in the tree toolbar to open the tree settings popup. Each option is a toggle that takes effect as soon as it is switched:</p><ul><li><em>Hide archived notes</em>: When enabled, archived notes are not shown in the tree.</li><li><em>Automatically collapse notes</em>: When enabled, notes are collapsed after a period of inactivity to keep the tree tidy.</li><li><em>Follow active note</em>: When enabled (default), the tree automatically scrolls and expands parent nodes to keep the currently active note visible. When disabled, the tree is fully detached from navigation — only the background highlight of the active note is updated, but the tree viewport and its expanded/collapsed state are never changed by navigation. Use the crosshair button to manually jump the tree to the active note at any time.</li></ul><h2>Keyboard shortcuts</h2><p>The note tree comes with multiple keyboard shortcuts to make editing faster, consult the dedicated <a class=\"reference-link\" href=\"#root/_help_DvdZhoQZY9Yd\">Keyboard shortcuts</a> section.</p>",+ "_help_oPVyFC7WL2Lp": "<p>This page explains how to manipulate the note tree in TriliumNext, focusing on moving notes.</p><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree_image.jpg\"></p><h2>Drag and Drop</h2><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree_drag-and-drop.gif\" alt=\"Drag and drop example\"></p><p>You can easily rearrange the note tree by dragging and dropping notes, as demonstrated in the example above.</p><h3>Importing files</h3><p>A file or archive can easily be imported into Trilium just by dragging it inside the note tree.</p><p>Note that a drag & drop always imports with <em>safe import</em> on, meaning that some features such as scripts are disabled in the upcoming notes. To bypass that, use the dedicated <a href=\"#root/_help_mHbBMPDPkVV5\">import</a> feature (right click → <em>Import into note</em>).</p><p>Unlike the import dialog, the drag & drop also has some basic auto-detection of the import. For example, dragging a .zip file with a <code>.obsidian</code> folder in it will automatically trigger a dedicated <a class=\"reference-link\" href=\"#root/_help_iWD7wiIuMtgV\">Obsidian</a> import.</p><h2>Keyboard Manipulation</h2><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree_move-note-with-keyboard.gif\" alt=\"Example of using keyboard keys to move a note\">Trilium offers efficient keyboard-based manipulation using the following <a href=\"#root/_help_A9Oc6YKKc65v\">shortcuts</a>:</p><ul><li><kbd>Ctrl</kbd> + <kbd>↑</kbd> and <kbd>Ctrl</kbd> +<kbd>↓</kbd>: Move the note up or down in the order.</li><li><kbd>Ctrl</kbd>+<kbd>←</kbd>: Move the note up in the hierarchy by changing its parent to the note's grandparent.</li><li><kbd>Ctrl</kbd>+<kbd>→</kbd>: Move the note down in the hierarchy by setting its parent to the note currently above it (this action is best understood through a demo or hands-on experience).</li><li><kbd>←</kbd> and <kbd>→</kbd>: Expand and collapse a sub-tree.</li></ul><h2>Context Menu</h2><p>You can also move notes using the familiar cut and paste functions available in the context menu, or with the associated keyboard <a href=\"#root/_help_A9Oc6YKKc65v\">shortcuts</a>: <code>CTRL-C</code> ( <a href=\"#root/_help_IakOLONlIfGI\">copy</a>), <kbd>Ctrl</kbd> + <kbd>X</kbd> (cut) and <kbd>Ctrl</kbd> + <kbd>V</kbd> (paste).</p><p>See <a class=\"reference-link\" href=\"#root/_help_YtSN43OrfzaA\">Note tree contextual menu</a> for more information.</p><h2>Tree Settings</h2><p>Click the tree icon in the tree toolbar to open the tree settings popup. Each option is a toggle that takes effect as soon as it is switched:</p><ul><li><em>Hide archived notes</em>: When enabled, archived notes are not shown in the tree.</li><li><em>Automatically collapse notes</em>: When enabled, notes are collapsed after a period of inactivity to keep the tree tidy.</li><li><em>Follow active note</em>: When enabled (default), the tree automatically scrolls and expands parent nodes to keep the currently active note visible. When disabled, the tree is fully detached from navigation — only the background highlight of the active note is updated, but the tree viewport and its expanded/collapsed state are never changed by navigation. Use the crosshair button to manually jump the tree to the active note at any time.</li></ul><h2>Hiding and peeking the tree</h2><p>To hide or show the note tree, press the <span class=\"tn-icon bx bx-sidebar\"></span> button to the left of the first tab in the horizontal layout, or the <span class=\"tn-icon bx bx-chevrons-left\"></span> button at the bottom of the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a> in the vertical layout. The <em>Toggle Left Pane</em> <a href=\"#root/_help_A9Oc6YKKc65v\">keyboard shortcut</a>, which is not assigned by default, does the same. See <a class=\"reference-link\" href=\"#root/_help_x0JgW8UqGXvq\">Vertical and horizontal layout</a>.</p><p>In the horizontal layout, there is also a small strip on the left edge of the app which shows an arrow icon:</p><ul><li>When the tree is hidden, pressing the edge will <em>peek</em> the tree.<ul><li>In this mode the tree is shown temporarily above the content, without shifting the content of your notes.</li><li>Clicking outside the tree, pressing <kbd>Esc</kbd> or pressing the edge again will hide the tree.</li><li>Pressing the <span class=\"tn-icon bx bx-sidebar\"></span> button to the left of the first tab will dock the tree.</li></ul></li><li>When the tree is docked, pressing the edge will hide the tree.</li></ul><p>The <em>Peek Tree Pane</em> <a href=\"#root/_help_A9Oc6YKKc65v\">keyboard shortcut</a>, <kbd>Alt</kbd>+<kbd>[</kbd> by default, does the same as pressing the edge. Only one panel is peeked at a time: peeking the tree hides a peeked <a class=\"reference-link\" href=\"#root/_help_RnaPdbciOfeq\">Right Sidebar</a>, and the other way around.</p><h2>Keyboard shortcuts</h2><p>The note tree comes with multiple keyboard shortcuts to make editing faster, consult the dedicated <a class=\"reference-link\" href=\"#root/_help_DvdZhoQZY9Yd\">Keyboard shortcuts</a> section.</p>","_help_YtSN43OrfzaA": "<figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:269/608;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree/1_Note%20tree%20contextual%20menu_image.png\" width=\"269\" height=\"608\"></figure><p>The <em>note tree menu</em> can be accessed by right-clicking in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>.</p><h2>Interaction</h2><p>The contextual menu can operate:</p><ul><li>On a single note, by right clicking it in the note tree.</li><li>On multiple notes, by selecting them first. See <a class=\"reference-link\" href=\"#root/_help_yTjUdsOi4CIE\">Multiple selection</a> on how to do so.<ul><li>When right clicking, do note that usually the note being right clicked is also included in the affected notes, regardless of whether it was selected or not.</li></ul></li></ul><h2>Available options</h2><aside class=\"admonition note\"><p>When multiple notes are selected, only a subset of notes will be active. The ones that do support multiple notes will mention this in the list below.</p></aside><p>The most frequent actions stand side by side at the top of the menu, each as an icon over its name. Use <kbd>←</kbd> and <kbd>→</kbd>, or <kbd>↑</kbd> and <kbd>↓</kbd>, to move between them.</p><ul><li><strong>Cut</strong><ul><li>Will place the given notes in clipboard.</li><li>Use one of the two paste functions (or the keyboard shortcuts) to move them to the desired location.</li></ul></li><li><strong>Clone</strong><ul><li>Will place the given notes in clipboard.</li><li>Use one of the two paste functions (or the keyboard shortcuts) to copy them to the desired location.</li><li>Note that the copy function here works according to the <a class=\"reference-link\" href=\"#root/_help_IakOLONlIfGI\">Cloning Notes</a> functionality (i.e. the note itself will be present in two locations at once, and editing it in one place will edit it everywhere).</li><li>To simply create a duplicate note that can be modified independently, look for <em>Duplicate</em>.</li></ul></li><li><strong>Paste into</strong><ul><li>Pastes the notes in clipboard as child notes of the right-clicked one.</li><li>Shown only after notes have been cut or cloned.</li></ul></li><li><strong>Paste after</strong><ul><li>Pastes the notes in clipboard underneath the right-clicked one.</li><li>Shown only after notes have been cut or cloned.</li></ul></li><li><strong>Delete…</strong><ul><li>Will delete the given notes, asking for confirmation first.</li><li>In the dialog, the following options can be configured:<ul><li><em>Delete also all clones</em> to ensure that the note will be deleted everywhere if it has been placed into multiple locations (see <a class=\"reference-link\" href=\"#root/_help_IakOLONlIfGI\">Cloning Notes</a>).</li><li><em>Erase notes permanently</em> will ensure that the note cannot be recovered from <a class=\"reference-link\" href=\"#root/_help_r5JGHN99bVKn\">Recent Changes</a>.</li></ul></li></ul></li></ul><p>The rest of the menu lists its options one per row:</p><ul><li><strong>Open note</strong><ul><li>Clicking it opens the note in a new <a href=\"#root/_help_3seOhtN8uLIY\">tab</a>.</li><li>Hovering it or clicking its arrow opens a submenu with the places the note can be opened in: <em>Open in a new tab</em>, <em>Open in a new split</em> (to the right of the note, within the current tab) and <em>Open in a new window</em>.</li></ul></li><li><strong>Quick edit</strong><ul><li>Opens the note in <a class=\"reference-link\" href=\"#root/_help_ZjLYv08Rp3qC\">Quick edit</a>, over the current one.</li></ul></li><li><strong>Hoist note</strong><ul><li>Will focus the note tree on this note. See <a class=\"reference-link\" href=\"#root/_help_OR8WJ7Iz9K4U\">Note Hoisting</a> for more information.</li></ul></li><li><strong>Insert note after</strong><ul><li>Allows easy creation of a note with a specified <a href=\"#root/_help_KSZ04uQ2D1St\">note type</a>.</li><li>The <em>Code</em> submenu starts with the scripting notes, each a code note set up for its role: <em>Custom CSS</em> (with <code>#appCss</code>), <em>Widget</em> (with <code>#widget</code> and a starting skeleton) and <em>Backend script</em>. The enabled code languages follow.</li><li><a class=\"reference-link\" href=\"#root/_help_GTwFsgaA0lCt\">Collections</a> are grouped in the <em>Collection</em> submenu. The note types created less often, the <a class=\"reference-link\" href=\"#root/_help_B2ORr7OVEZtc\">Snippets</a> and the AI quick action are in the <em>More</em> submenu.</li><li><a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a> will also be present (if any) at the end of the list.</li><li>To find an entry quickly, type into the search box at the top of the submenu, or just start typing while the submenu is open. The submenu then lists every matching entry, including those inside its own submenus (such as a code language or a collection), each with the submenu it comes from. Use <kbd>↑</kbd> and <kbd>↓</kbd> to pick a match, <kbd>Enter</kbd> to create it, and <kbd>Esc</kbd> to clear the search.</li><li>The note will be added on the same level of hierarchy as the note selected.</li></ul></li><li><strong>Insert child note</strong><ul><li>Same as <em>Insert note after</em>, but the note will be created as a child of the selected note.</li></ul></li><li><strong>Move to…</strong><ul><li>Will display a modal to specify where to move the desired notes.</li></ul></li><li><strong>Clone to…</strong><ul><li>Will display a modal to specify where to <a href=\"#root/_help_IakOLONlIfGI\">clone</a> the desired notes.</li></ul></li><li><strong>Duplicate</strong><ul><li>Creates a copy of the note and its descendants, placed right after the original.</li><li>When the note has child notes, the item also has an arrow, set apart by a divider. Hovering the item or clicking the arrow opens a submenu:<ul><li><em>Note and its children</em> does the same as clicking <em>Duplicate</em>.</li><li><em>This note only</em> copies the note with its content and attributes, but without any of its child notes. Links and relations to the original children keep pointing at them.</li></ul></li><li>This process is different from <a class=\"reference-link\" href=\"#root/_help_IakOLONlIfGI\">Cloning Notes</a> since the duplicated note can be edited independently from the original.</li><li>An alternative to this, if done regularly, would be <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a>.</li></ul></li><li><strong>Archive/Unarchive</strong><ul><li>Marks a note as <a href=\"#root/_help_MKmLg5x6xkor\">archived</a>.</li><li>If the note is already archived, it will be unarchived instead.</li><li>Multiple notes can be selected as well. However, all the selected notes must be in the same state (archived or not), otherwise the option will be disabled.</li></ul></li><li><strong>Protect subtree/Unprotect subtree</strong><ul><li>On a note that is not protected, <em>Protect subtree</em> marks this note and all of its descendants as protected. On a protected note, the item reads <em>Unprotect subtree</em> and unprotects them instead. See <a class=\"reference-link\" href=\"#root/_help_bwg0e8ewQMak\">Protected Notes</a> for more information.</li><li>Hovering the item or clicking its arrow opens a submenu with both actions, for instance to unprotect the protected notes below a note that is not protected itself.</li></ul></li><li><strong>Import into note…</strong><ul><li>Opens the <a href=\"#root/_help_mHbBMPDPkVV5\">import</a> dialog and places the imported notes as child notes of the selected one.</li></ul></li><li><strong>Export…</strong><ul><li>Opens the <a href=\"#root/_help_mHbBMPDPkVV5\">export</a> dialog for the selected notes.</li></ul></li><li><strong>Search in subtree</strong><ul><li>Opens a full <a class=\"reference-link\" href=\"#root/_help_eIg8jdvaoNNd\">Search</a> with it preconfigured to only look into this note and its descendants (the <em>Ancestor</em> field).</li></ul></li></ul><h2>Advanced options</h2><figure class=\"image image-style-align-right\"><img style=\"aspect-ratio:231/263;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree/Note%20tree%20contextual%20menu_image.png\" width=\"231\" height=\"263\"></figure><p>The advanced options menu offers some of the less frequently used actions for notes.</p><p>To access these options, first look for the <em>Advanced</em> option at the bottom of the contextual menu to reveal a sub-menu with:</p><ul><li><strong>Apply bulk actions…</strong><ul><li>Opens the <a class=\"reference-link\" href=\"#root/_help_ivYnonVFBxbQ\">Bulk Actions</a> dialog, to apply actions such as adding labels or moving notes to multiple notes at once (see <a class=\"reference-link\" href=\"#root/_help_yTjUdsOi4CIE\">Multiple selection</a>).</li></ul></li><li><strong>Edit branch prefix…</strong><ul><li>Opens a dialog to assign a name to be able to distinguish <a href=\"#root/_help_IakOLONlIfGI\">clones</a>, see <a class=\"reference-link\" href=\"#root/_help_TBwsyfadTA18\">Branch prefix</a> for more information.</li></ul></li><li><strong>Convert to attachment…</strong><ul><li>Converts the selected notes to <a class=\"reference-link\" href=\"#root/_help_0vhv7lsOLy82\">Attachments</a> of their parent notes.</li><li>This functional is most useful when dealing with image <a class=\"reference-link\" href=\"#root/_help_W8vYD3Q1zjCR\">File</a> notes that were imported from an external source or an older version of Trilium.</li></ul></li><li><strong>Expand subtree</strong><ul><li>Expands all the child notes in the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>.</li></ul></li><li><strong>Collapse subtree</strong><ul><li>Collapses all the child notes in the note tree.</li></ul></li><li><strong>Sort by…</strong><ul><li>Opens a dialog to sort all the child notes of the selected note.</li><li>The sorting is done only once, there is an automatic sorting mechanism as well that can be set using <a class=\"reference-link\" href=\"#root/_help_zEY4DaJG4YT5\">Attributes</a>.</li><li>See <a class=\"reference-link\" href=\"#root/_help_aGlEvb9hyDhS\">Sorting Notes</a> for more information.</li></ul></li><li><strong>Copy note path to clipboard</strong><ul><li>Copies a URL fragment representing the full path to this branch for a note, such as <code>#root/Hb2E70L7HPuf/4sRFgMZhYFts/2IVuShedRJ3U/LJVMvKXOFv7n</code>.</li><li>The URL to manually create <a class=\"reference-link\" href=\"#root/_help_QEAPj01N5f7w\">Links</a> within notes, or for note <a class=\"reference-link\" href=\"#root/_help_wArbEsdSae6g\">Navigation</a>.</li></ul></li><li><strong>Recent changes in subtree</strong><ul><li>This will open <a class=\"reference-link\" href=\"#root/_help_r5JGHN99bVKn\">Recent Changes</a>, but filtered to only the changes related to this note or one of its descendants.</li></ul></li></ul>","_help_yTjUdsOi4CIE": "<p>In the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>, it's possible to select multiple notes at one time. This won't affect the currently displayed note, but it allows to do batch operations.</p><h2>Types of multiple selection</h2><figure class=\"image image-style-align-right image_resized\" style=\"width:28.54%;\"><img style=\"aspect-ratio:335/306;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree/Multiple%20selection_image.png\" width=\"335\" height=\"306\"></figure><h3>Selecting notes one by one</h3><p>To individually select each note, press the <kbd>Alt</kbd> key and click on the note to be selected.</p><p>The selected notes will be indicated via a different background color and an icon.</p><h3>Selecting notes in a sequence</h3><figure class=\"image image-style-align-right image_resized\" style=\"width:29.24%;\"><img style=\"aspect-ratio:233/205;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree/Multiple%20selection_image.jpg\" width=\"233\" height=\"205\"></figure><p>When notes are in a sequence (e.g. one underneath the other), the entire selection can be made just by selecting the first and the last item instead of individually clicking all the notes.</p><p>To do so, first select the note to start the selection with. Then hold <kbd>Shift</kbd> and click on the note to end the selection with. All the notes between the start and the end note will be selected as well.</p><h2>Selected notes vs. active note</h2><p>There is a distinction between <em>selected notes</em> and the <em>active note</em>:</p><ul><li><em>Selected notes</em> are simply the notes that were selected in the multiple section process (i.e. either via <kbd>Alt</kbd> or <kbd>Shift</kbd>).</li><li>The <em>active note</em> is simply the note that whose content is being displayed to the right of the tree.<ul><li><p>Visually, it's identified in the tree by having a different background color and a subtle shadow.</p></li><li><p>The active note can also be selected case in which the icon and background will also change:</p><img class=\"image_resized\" style=\"aspect-ratio:317/223;width:35.1%;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/UI%20Elements/Note%20Tree/1_Multiple%20selection_image.png\" width=\"317\" height=\"223\"></li></ul></li></ul>","_help_DvdZhoQZY9Yd": "<p>The <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a> comes with multiple keyboard shortcuts to make editing faster:</p><h2>Navigation within the tree</h2><ul><li><kbd><span>↑</span></kbd> and <kbd><span>↑</span></kbd> to navigate between notes.</li><li><kbd><span>←</span></kbd> to collapse a note with children, or <kbd><span>→</span></kbd> to expand it.</li><li><kbd><span>←</span></kbd> on a note with no children to navigate to its parent.</li></ul><h2>Opening notes</h2><ul><li><kbd>Click</kbd> to open the note in the current tab.</li><li><kbd>Ctrl</kbd>+<kbd>Click</kbd> or <kbd>Middle click</kbd> to open the note in a new tab.</li><li><kbd>Ctrl</kbd>+<kbd>Right click</kbd> to open the note in <a class=\"reference-link\" href=\"#root/_help_ZjLYv08Rp3qC\">Quick edit</a>.</li></ul><h2>Clipboard management</h2><ul><li><kbd>Ctrl</kbd>+<kbd>C</kbd> to copy one or more notes based on selection (see <a class=\"reference-link\" href=\"#root/_help_IakOLONlIfGI\">Cloning Notes</a>).</li><li><kbd>Ctrl</kbd>+<kbd>X</kbd> to cut one or more notes (for moving them).</li><li><kbd>Ctrl</kbd>+<kbd>V</kbd> to paste them somewhere (which results in a copy or move based on the shortcut used).</li></ul><h2>Moving notes</h2><ul><li><kbd>Ctrl</kbd> + <kbd><span>↑</span></kbd> , <kbd>Ctrl</kbd> + <kbd><span>↓</span></kbd> - move note up/down in the note list.</li><li><kbd>Ctrl</kbd> + <kbd><span>←</span></kbd> - move note up in the note tree.</li><li><kbd>Ctrl</kbd>+<kbd><span>→</span></kbd> - move note down in the note tree.</li><li><kbd>Del</kbd> - deletes note and optionally its subtree (asked in the dialog).</li><li><kbd>Alt</kbd>+<kbd>S</kbd> - sorts the child notes of the note (see <a class=\"reference-link\" href=\"#root/_help_aGlEvb9hyDhS\">Sorting Notes</a>).</li></ul><h2>Multiple selection</h2><p>See <a class=\"reference-link\" href=\"#root/_help_yTjUdsOi4CIE\">Multiple selection</a> for more information about how selection works.</p><ul><li><kbd>Alt</kbd>+<kbd>Click</kbd> – add a single note to the current selection.</li><li><kbd>Shift</kbd>+<kbd>Click</kbd> – select a range of notes, starting from the current note (the highlighted one) to the one that is being clicked.</li><li><kbd>Shift</kbd>+<kbd><span>↑</span></kbd>, <kbd>Shift</kbd>+<kbd><span>↓</span></kbd> – multi-select not above/below.</li><li><kbd>Ctrl</kbd>+<kbd>A</kbd> – select all notes in the current level</li></ul>",diff --git a/apps/server/src/assets/translations/en/server.json b/apps/server/src/assets/translations/en/server.jsonindex 5cf059b951..b64f6eccdb 100644--- a/apps/server/src/assets/translations/en/server.json+++ b/apps/server/src/assets/translations/en/server.json@@ -77,7 +77,8 @@"focus-split-right": "Move the focus to the split on the right of the active one","split-view": "Split view","move-split-left": "Swap the active split with the one on its left, so the note moves and the focus follows it",- "move-split-right": "Swap the active split with the one on its right, so the note moves and the focus follows it"+ "move-split-right": "Swap the active split with the one on its right, so the note moves and the focus follows it",+ "peek-left-pane": "Peek the note tree as a temporary panel that floats over the content, in the horizontal layout"},"keyboard_action_names": {"back-in-note-history": "Back in Note History",@@ -187,7 +188,8 @@"move-split-left": "Move Split Left","move-split-right": "Move Split Right","focus-split-left": "Focus Split to the Left",- "focus-split-right": "Focus Split to the Right"+ "focus-split-right": "Focus Split to the Right",+ "peek-left-pane": "Peek Tree Pane"},"login": {"title": "Login",diff --git a/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note Tree.md b/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note Tree.mdindex 4a1c512d6c..c969132e9e 100644--- a/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note Tree.md+++ b/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Note Tree.md@@ -40,6 +40,20 @@ Click the tree icon in the tree toolbar to open the tree settings popup. Each op* _Automatically collapse notes_: When enabled, notes are collapsed after a period of inactivity to keep the tree tidy.* _Follow active note_: When enabled (default), the tree automatically scrolls and expands parent nodes to keep the currently active note visible. When disabled, the tree is fully detached from navigation — only the background highlight of the active note is updated, but the tree viewport and its expanded/collapsed state are never changed by navigation. Use the crosshair button to manually jump the tree to the active note at any time.+## Hiding and peeking the tree++To hide or show the note tree, press the <span class="tn-icon bx bx-sidebar"></span> button to the left of the first tab in the horizontal layout, or the <span class="tn-icon bx bx-chevrons-left"></span> button at the bottom of the <a class="reference-link" href="Launch%20Bar.md">Launch Bar</a> in the vertical layout. The _Toggle Left Pane_ [keyboard shortcut](../Keyboard%20Shortcuts.md), which is not assigned by default, does the same. See <a class="reference-link" href="Vertical%20and%20horizontal%20layout.md">Vertical and horizontal layout</a>.++In the horizontal layout, there is also a small strip on the left edge of the app which shows an arrow icon:++* When the tree is hidden, pressing the edge will _peek_ the tree.+ * In this mode the tree is shown temporarily above the content, without shifting the content of your notes.+ * Clicking outside the tree, pressing <kbd>Esc</kbd> or pressing the edge again will hide the tree.+ * Pressing the <span class="tn-icon bx bx-sidebar"></span> button to the left of the first tab will dock the tree.+* When the tree is docked, pressing the edge will hide the tree.++The _Peek Tree Pane_ [keyboard shortcut](../Keyboard%20Shortcuts.md), <kbd>Alt</kbd>+<kbd>[</kbd> by default, does the same as pressing the edge. Only one panel is peeked at a time: peeking the tree hides a peeked <a class="reference-link" href="Right%20Sidebar.md">Right Sidebar</a>, and the other way around.+## Keyboard shortcutsThe note tree comes with multiple keyboard shortcuts to make editing faster, consult the dedicated <a class="reference-link" href="Note%20Tree/Keyboard%20shortcuts.md">Keyboard shortcuts</a> section.\ No newline at end of filediff --git a/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Vertical and horizontal layout.md b/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Vertical and horizontal layout.mdindex 5d3b1d9866..136e6a51ed 100644--- a/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Vertical and horizontal layout.md+++ b/docs/User Guide/User Guide/Basic Concepts and Features/UI Elements/Vertical and horizontal layout.md@@ -20,7 +20,7 @@ The horizontal layout is a more traditional layout, since it bears similarity wi* The <a class="reference-link" href="Launch%20Bar.md">Launch Bar</a> is at the top of the screen, with the buttons laid horizontally.* The tab bar is at the top of the screen, but now covers the entirety of the width, allowing for more tabs to be displayed at once.* The <a class="reference-link" href="../Navigation/Quick%20search.md">Quick search</a> is now part of the <a class="reference-link" href="Launch%20Bar.md">Launch Bar</a>. It can be moved around according to preference and even removed if needed.-* The <a class="reference-link" href="Note%20Tree.md">Note Tree</a> can be collapsed by pressing the small <span class="tn-icon bx bx-sidebar"></span> button to the left of the first tab.+* The <a class="reference-link" href="Note%20Tree.md">Note Tree</a> can be collapsed by pressing the small <span class="tn-icon bx bx-sidebar"></span> button to the left of the first tab. While collapsed, it can be peeked temporarily above the content by pressing the strip on the left edge of the app.* The <a class="reference-link" href="Global%20menu.md">Global menu</a> can be accessed via the <span class="tn-icon bx bx-menu"></span> button at the end of the <a class="reference-link" href="Launch%20Bar.md">Launch Bar</a>.diff --git a/packages/commons/src/lib/keyboard_actions_interface.ts b/packages/commons/src/lib/keyboard_actions_interface.tsindex 1b48764d09..31746aabf6 100644--- a/packages/commons/src/lib/keyboard_actions_interface.ts+++ b/packages/commons/src/lib/keyboard_actions_interface.ts@@ -101,6 +101,7 @@ const enum KeyboardActionNamesEnum {openDevTools,findInText,toggleLeftPane,+ peekLeftPane,toggleFullscreen,zoomOut,zoomIn,diff --git a/packages/trilium-core/src/services/keyboard_actions.ts b/packages/trilium-core/src/services/keyboard_actions.tsindex 87f42926ac..d3374d1d77 100644--- a/packages/trilium-core/src/services/keyboard_actions.ts+++ b/packages/trilium-core/src/services/keyboard_actions.ts@@ -842,6 +842,14 @@ function getDefaultKeyboardActions() {description: t("keyboard_actions.toggle-left-note-tree-panel"),scope: "window"},+ {+ actionName: "peekLeftPane",+ friendlyName: t("keyboard_action_names.peek-left-pane"),+ iconClass: "bx bx-sidebar",+ defaultShortcuts: ["Alt+["],+ description: t("keyboard_actions.peek-left-pane"),+ scope: "window"+ },{actionName: "toggleFullscreen",friendlyName: t("keyboard_action_names.toggle-full-screen"),