Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
client/text editor: make several performance improvements impacting the editing experience for large text notes
Adorian Doranef884ddb9e14
diff --git a/apps/client/src/services/spaced_update.spec.ts b/apps/client/src/services/spaced_update.spec.tsindex 8d6a48b9fb..eae325a278 100644--- a/apps/client/src/services/spaced_update.spec.ts+++ b/apps/client/src/services/spaced_update.spec.ts@@ -109,6 +109,25 @@ describe("SpacedUpdate", () => {expect(updater).not.toHaveBeenCalled();});+ it("also saves the changes made while it saves", async () => {+ let finishFirstSave = () => {};+ const updater = vi.fn()+ .mockImplementationOnce(() => new Promise<void>((resolve) => {+ finishFirstSave = resolve;+ }))+ .mockResolvedValue(undefined);+ const spacedUpdate = new SpacedUpdate(updater, 50);++ spacedUpdate.scheduleUpdate();+ const flushed = spacedUpdate.updateNowIfNecessary();+ spacedUpdate.scheduleUpdate();+ finishFirstSave();+ await flushed;++ expect(updater).toHaveBeenCalledTimes(2);+ expect(spacedUpdate.hasUnsavedChanges()).toBe(false);+ });+it("re-marks changed, emits error and rethrows when the updater fails", async () => {const states: string[] = [];let shouldFail = true;@@ -230,6 +249,45 @@ describe("SpacedUpdate", () => {await vi.advanceTimersByTimeAsync(500);expect(updater).toHaveBeenCalledTimes(1);});++ it("waits for changes made during a save to pause before saving them", async () => {+ const updater = vi.fn(async () => {+ await new Promise((resolve) => setTimeout(resolve, 100));+ });+ const spacedUpdate = new SpacedUpdate(updater, 50);+ const type = () => {+ spacedUpdate.resetUpdateTimer();+ spacedUpdate.scheduleUpdate();+ };++ // The first save starts at 50 ms and runs until 150 ms.+ type();+ await vi.advanceTimersByTimeAsync(60);+ expect(updater).toHaveBeenCalledTimes(1);++ // Typing continues through the save and after it, until 300 ms.+ for (let i = 0; i < 12; i++) {+ type();+ await vi.advanceTimersByTimeAsync(20);+ }+ expect(updater).toHaveBeenCalledTimes(1);++ await vi.advanceTimersByTimeAsync(60);+ expect(updater).toHaveBeenCalledTimes(2);+ });++ it("saves a change within ten intervals, however often the timer is reset", async () => {+ const updater = vi.fn(async () => {});+ const spacedUpdate = new SpacedUpdate(updater, 50);++ for (let i = 0; i < 30; i++) {+ spacedUpdate.resetUpdateTimer();+ spacedUpdate.scheduleUpdate();+ await vi.advanceTimersByTimeAsync(20);+ }++ expect(updater).toHaveBeenCalledTimes(1);+ });});describe("keyed bindings (prepare/commit)", () => {diff --git a/apps/client/src/services/spaced_update.ts b/apps/client/src/services/spaced_update.tsindex 35020ce053..9d2413bdd8 100644--- a/apps/client/src/services/spaced_update.ts+++ b/apps/client/src/services/spaced_update.ts@@ -31,6 +31,8 @@ interface PendingCommit<T> {}const MAX_RETRY_DELAY = 60_000;+/** The longest that `resetUpdateTimer()` can postpone a pending change, in intervals. */+const MAX_POSTPONED_INTERVALS = 10;export default class SpacedUpdate<T = void> {private bindingKey: string | null;@@ -38,6 +40,8 @@ export default class SpacedUpdate<T = void> {private commit: CommitCallback<T>;private lastUpdated: number;private changed: boolean;+ /** When the oldest change that is not snapshotted yet was made. */+ private changedSince = 0;private updateInterval: number;private changeForbidden?: boolean;private stateCallback?: StateCallback;@@ -77,6 +81,9 @@ export default class SpacedUpdate<T = void> {scheduleUpdate() {if (!this.changeForbidden) {+ if (!this.changed) {+ this.changedSince = Date.now();+ }this.changed = true;this.onStateChanged("unsaved");this.armDebounceTimer();@@ -112,22 +119,21 @@ export default class SpacedUpdate<T = void> {}/**- * Flushes the pending change (if any) and waits until all queued snapshots are persisted. The- * pending change is read at once, also while another save runs, so its source can go away.+ * Flushes the pending change (if any) and waits until all queued snapshots are persisted, with+ * the changes made while they save. The pending change is read at once, also while another+ * save runs, so its source can go away.*/- updateNowIfNecessary(): Promise<void> {- if (this.drainPromise) {- try {+ async updateNowIfNecessary(): Promise<void> {+ do {+ if (this.drainPromise) {// The running save waits for an asynchronous snapshot and handles its failure.const snapshotted = this.snapshotPending();if (snapshotted instanceof Promise) {snapshotted.catch(() => {});}- } catch (e) {- return Promise.reject(e);}- }- return this.drain();+ await this.drain();+ } while (this.changed);}/** Whether a change made under the current binding is not saved yet. */@@ -151,6 +157,8 @@ export default class SpacedUpdate<T = void> {/*** Normally {@link scheduleUpdate()} would actually trigger the update only once per {@link updateInterval}. If the method is called 200 times within 20s, it will execute only 20 times.* Sometimes, if the updates are continuous this would cause a performance impact. Resetting the time ensures that the calls to the update have stopped before actually triggering an update.+ * A pending change is still saved at most {@link MAX_POSTPONED_INTERVALS} intervals after it+ * was made.*/resetUpdateTimer() {this.lastUpdated = Date.now();@@ -190,7 +198,7 @@ export default class SpacedUpdate<T = void> {return;}- const delay = Math.max(1, this.updateInterval - (Date.now() - this.lastUpdated));+ const delay = Math.max(1, this.getTimeUntilDue());this.debounceTimer = setTimeout(() => {this.debounceTimer = undefined;@@ -198,7 +206,7 @@ export default class SpacedUpdate<T = void> {return;}- if (Date.now() - this.lastUpdated >= this.updateInterval) {+ if (this.getTimeUntilDue() <= 0) {this.drain().catch(() => {// Failures are logged in runDrain and retried.});@@ -208,6 +216,18 @@ export default class SpacedUpdate<T = void> {}, delay);}+ /**+ * Milliseconds until the pending change is due: one interval after the last update or reset,+ * but no later than {@link MAX_POSTPONED_INTERVALS} intervals after the change.+ */+ private getTimeUntilDue() {+ const now = Date.now();+ return Math.min(+ this.updateInterval - (now - this.lastUpdated),+ this.updateInterval * MAX_POSTPONED_INTERVALS - (now - this.changedSince)+ );+ }+/*** Snapshots the pending change with the *current* binding and queues it for commit.* Returns a promise only when `prepare` is asynchronous; in the synchronous case the@@ -225,6 +245,7 @@ export default class SpacedUpdate<T = void> {const { bindingKey, commit } = this;const restoreOnError = (e: unknown): never => {this.changed = true;+ this.changedSince = Date.now();this.onStateChanged("error");// Said out loud, as a failed commit is. Every caller of this path swallows what is// rethrown, so a snapshot that cannot be taken would otherwise show as a failing save@@ -282,6 +303,7 @@ export default class SpacedUpdate<T = void> {}private async runDrain(): Promise<void> {+ let isFirstPass = true;while (true) {// Wait for snapshots that were started elsewhere (e.g. by rebind) to be queued.// Their failures restore the `changed` flag and are handled by the fold below.@@ -290,10 +312,14 @@ export default class SpacedUpdate<T = void> {}// Fold any pending change into the queue first, so a queued snapshot and a newer- // pending change for the same key result in a single save, not two.- const snapshotted = this.snapshotPending();- if (snapshotted instanceof Promise) {- await snapshotted;+ // pending change for the same key result in a single save, not two. Changes made+ // after the first pass wait for the debounce timer.+ if (isFirstPass) {+ isFirstPass = false;+ const snapshotted = this.snapshotPending();+ if (snapshotted instanceof Promise) {+ await snapshotted;+ }}if (this.pendingCommits.size === 0) {@@ -338,6 +364,9 @@ export default class SpacedUpdate<T = void> {// successes would shorten the backoff of a still-failing sibling key.this.retryCount = 0;this.onStateChanged(this.changed ? "unsaved" : "saved");+ if (this.changed) {+ this.armDebounceTimer();+ }}private scheduleRetry() {diff --git a/apps/client/src/widgets/note_wrapper.spec.ts b/apps/client/src/widgets/note_wrapper.spec.tsindex f8ec751837..501d9217a7 100644--- a/apps/client/src/widgets/note_wrapper.spec.ts+++ b/apps/client/src/widgets/note_wrapper.spec.ts@@ -1,10 +1,12 @@import { describe, expect, it } from "vitest";+import type NoteContext from "../components/note_context";+import type FNote from "../entities/fnote";import { buildNote } from "../test/easy-froca";import NoteWrapperWidget, { hasBackgroundEffects, isAlwaysFullWidthByType, isFullWidthNote } from "./note_wrapper";describe("NoteWrapperWidget", () => {- it("preserves the classes owned by SplitNoteContainer through the class reset in refresh()", () => {+ it("preserves the classes owned by SplitNoteContainer in refresh()", () => {const widget = new NoteWrapperWidget();widget.render();widget.$widget.addClass("active last-visible");@@ -20,6 +22,39 @@ describe("NoteWrapperWidget", () => {expect(widget.$widget.hasClass("empty-note")).toBe(true);});+ it("changes no class when a refresh produces the same classes", () => {+ const widget = new NoteWrapperWidget();+ widget.render();+ showNote(widget, buildNote({ title: "Styled", type: "text", "#cssClass": "first second" }));+ widget.$widget.addClass("active");++ const observer = new MutationObserver(() => {});+ observer.observe(widget.$widget[0], { attributes: true, attributeFilter: [ "class" ] });+ widget.refresh();+ const records = observer.takeRecords();+ observer.disconnect();++ expect(records).toHaveLength(0);+ for (const cls of [ "active", "visible", "note-split", "type-text", "first", "second" ]) {+ expect(widget.$widget.hasClass(cls)).toBe(true);+ }+ });++ it("drops the classes of the previous note and keeps those of SplitNoteContainer", () => {+ const widget = new NoteWrapperWidget();+ widget.render();+ showNote(widget, buildNote({ title: "Styled", type: "text", "#cssClass": "first second" }));+ widget.$widget.addClass("active last-visible");++ showNote(widget, buildNote({ title: "Plain", type: "code" }));++ expect(widget.$widget.hasClass("first")).toBe(false);+ expect(widget.$widget.hasClass("type-text")).toBe(false);+ expect(widget.$widget.hasClass("type-code")).toBe(true);+ expect(widget.$widget.hasClass("active")).toBe(true);+ expect(widget.$widget.hasClass("last-visible")).toBe(true);+ });+it("marks the split as translucent (bgfx) for the note types that render on a bare background", () => {expect(hasBackgroundEffects(buildNote({ title: "Photo", type: "image" }))).toBe(true);@@ -117,3 +152,8 @@ describe("isFullWidthNote", () => {expect(isFullWidthNote(buildNote({ title: "Calendar", type: "search", "#viewType": "calendar" }))).toBe(true);});});++function showNote(widget: NoteWrapperWidget, note: FNote) {+ const noteContext = { note, viewScope: { viewMode: "default" } } as unknown as NoteContext;+ widget.setNoteContextEvent({ noteContext });+}diff --git a/apps/client/src/widgets/note_wrapper.ts b/apps/client/src/widgets/note_wrapper.tsindex 087a255f22..6822e21483 100644--- a/apps/client/src/widgets/note_wrapper.ts+++ b/apps/client/src/widgets/note_wrapper.ts@@ -46,38 +46,50 @@ export default class NoteWrapperWidget extends FlexContainer<BasicWidget> {}refresh() {- // These are owned by SplitNoteContainer, not by the note — preserve them through the reset below.- const isHiddenExt = this.isHiddenExt();- const containerClasses = CONTAINER_OWNED_CLASSES.filter((cls) => this.$widget.hasClass(cls));-- this.$widget.removeClass();-- this.toggleExt(!isHiddenExt);- this.$widget.addClass(containerClasses.join(" "));+ const classes = new Set(this.getClasses().join(" ").split(" ").filter(Boolean));++ // Only the difference is applied: a class change on the split restyles the whole note.+ const classList = this.$widget[0].classList;+ for (const cls of [ ...classList ]) {+ if (!classes.has(cls)) {+ classList.remove(cls);+ }+ }+ for (const cls of classes) {+ if (!classList.contains(cls)) {+ classList.add(cls);+ }+ }+ }- this.$widget.addClass("component note-split");+ /** The classes of the split, each entry holding one or more space-separated class names. */+ private getClasses() {+ // These are owned by SplitNoteContainer, not by the note, so they are kept as they are.+ const classes = CONTAINER_OWNED_CLASSES.filter((cls) => this.$widget.hasClass(cls));+ classes.push(this.isHiddenExt() ? "hidden-ext" : "visible", "component", "note-split");const note = this.noteContext?.note;if (!note) {- this.$widget.addClass("bgfx empty-note");- return;+ classes.push("bgfx", "empty-note");+ return classes;}- this.$widget.toggleClass("full-content-width", isFullWidthNote(note));-- this.$widget.addClass(note.getCssClass());-- this.$widget.addClass(utils.getNoteTypeClass(note.type));- this.$widget.addClass(utils.getMimeTypeClass(note.mime));- this.$widget.addClass(`view-mode-${this.noteContext?.viewScope?.viewMode ?? "default"}`);- this.$widget.addClass(note.getColorClass());- this.$widget.toggleClass("options", note.isOptions());- this.$widget.toggleClass("bgfx", hasBackgroundEffects(note));- this.$widget.toggleClass("protected", note.isProtected);-+ classes.push(+ note.getCssClass(),+ utils.getNoteTypeClass(note.type),+ utils.getMimeTypeClass(note.mime),+ `view-mode-${this.noteContext?.viewScope?.viewMode ?? "default"}`,+ note.getColorClass()+ );+ if (isFullWidthNote(note)) classes.push("full-content-width");+ if (note.isOptions()) classes.push("options");+ if (hasBackgroundEffects(note)) classes.push("bgfx");+ if (note.isProtected) classes.push("protected");// Resolved rather than read straight off the label: a note with no language of its own// still follows the default content language.- this.$widget.toggleClass("rtl", isContentRightToLeft(note?.getLabelValue("language")));+ if (isContentRightToLeft(note.getLabelValue("language"))) classes.push("rtl");++ return classes;}async entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) {diff --git a/apps/client/src/widgets/sidebar/HighlightsList.spec.tsx b/apps/client/src/widgets/sidebar/HighlightsList.spec.tsxnew file mode 100644index 0000000000..5a03e3b169--- /dev/null+++ b/apps/client/src/widgets/sidebar/HighlightsList.spec.tsx@@ -0,0 +1,116 @@+import type { CKTextEditor } from "@triliumnext/ckeditor5";+import { act } from "preact/test-utils";+import { describe, expect, it, vi } from "vitest";++import appContext from "../../components/app_context";+import Component from "../../components/component";+import NoteContext from "../../components/note_context";+import options from "../../services/options";+import { buildNote } from "../../test/easy-froca";+import { renderInto } from "../../test/render";+import { ParentComponent } from "../react/react_utils";+import HighlightsList from "./HighlightsList";++describe("HighlightsList in an editable text note", () => {+ it("updates the items in place when the highlights are extracted again", async () => {+ const list = await setup([ "alpha", "beta", "gamma" ]);+ const before = list.items();+ expect(before.map((item) => item.textContent)).toEqual([ "alpha", "beta", "gamma" ]);++ await list.editor.change([ "alpha", "beta", "gamma", "delta" ]);++ const after = list.items();+ expect(after.map((item) => item.textContent))+ .toEqual([ "alpha", "beta", "gamma", "delta" ]);+ for (const [ index, item ] of before.entries()) {+ expect(after[index]).toBe(item);+ }+ });+});++async function setup(boldRuns: string[]) {+ options.load({+ rightPaneCollapsedItems: "[]",+ highlightsList: "[\"bold\"]"+ } as Parameters<typeof options.load>[0]);++ const note = buildNote({ title: "Highlights", type: "text" });+ const noteContext = new NoteContext("highlights-ntx");+ noteContext.noteId = note.noteId;+ noteContext.notePath = note.noteId;+ noteContext.viewScope = { viewMode: "default", isReadOnly: false };+ Object.defineProperty(noteContext, "note", { get: () => note });+ appContext.tabManager = { getActiveContext: () => noteContext } as typeof appContext.tabManager;++ const editor = fakeTextEditor(boldRuns);+ vi.spyOn(noteContext, "getTextEditor").mockImplementation(async (callback) => {+ callback?.(editor.editor);+ return editor.editor;+ });++ const parent = new Component();+ appContext.child(parent);+ let container!: HTMLElement;+ await act(async () => {+ container = renderInto(+ <ParentComponent.Provider value={parent}>+ <HighlightsList />+ </ParentComponent.Provider>+ );+ });+ await settle();++ return {+ editor,+ items: () => [ ...container.querySelectorAll<HTMLElement>(".highlights-list li") ]+ };+}++async function settle() {+ for (let i = 0; i < 5; i++) {+ await act(async () => { await new Promise((resolve) => setTimeout(resolve, 0)); });+ }+}++/** A CKEditor instance whose model holds one bold text run per entry of `boldRuns`. */+function fakeTextEditor(boldRuns: string[]) {+ const listeners = new Set<() => void>();+ let runs = boldRuns;++ const editor = {+ model: {+ document: {+ getRoot: () => ({}),+ differ: { getChanges: () => [ { type: "insert" } ] },+ on: (_event: string, callback: () => void) => listeners.add(callback),+ off: (_event: string, callback: () => void) => listeners.delete(callback)+ },+ createRangeIn: () => ({+ getWalker: () => runs.map((text) => ({ item: boldTextProxy(text) }))+ })+ }+ } as unknown as CKTextEditor;++ return {+ editor,+ /** Replaces the runs and reports the change to the listeners. */+ async change(newRuns: string[]) {+ runs = newRuns;+ await act(async () => {+ for (const listener of [ ...listeners ]) listener();+ });+ await settle();+ }+ };+}++function boldTextProxy(text: string) {+ return {+ data: text,+ textNode: {},+ startOffset: 0,+ is: (type: string) => type === "$textProxy",+ hasAttribute: (key: string) => key === "bold",+ getAttribute: () => undefined+ };+}diff --git a/apps/client/src/widgets/sidebar/HighlightsList.tsx b/apps/client/src/widgets/sidebar/HighlightsList.tsxindex 2feb4ee264..d489a2c649 100644--- a/apps/client/src/widgets/sidebar/HighlightsList.tsx+++ b/apps/client/src/widgets/sidebar/HighlightsList.tsx@@ -78,9 +78,10 @@ function AbstractHighlightsList<T extends RawHighlight>({ highlights, scrollToHi<span className="highlights-list">{filteredHighlights.length > 0 ? (<ol>- {filteredHighlights.map(highlight => (+ {/* Keyed by position, so a new extraction updates the items in place. */}+ {filteredHighlights.map((highlight, index) => (<HighlightItem- key={highlight.id}+ key={index}highlight={highlight}onClick={() => scrollToHighlight(highlight)}/>diff --git a/apps/client/src/widgets/sidebar/TableOfContents.spec.tsx b/apps/client/src/widgets/sidebar/TableOfContents.spec.tsxindex c5c606cb15..8a1dec2030 100644--- a/apps/client/src/widgets/sidebar/TableOfContents.spec.tsx+++ b/apps/client/src/widgets/sidebar/TableOfContents.spec.tsx@@ -161,6 +161,17 @@ describe("TableOfContents while an auto-read-only note is temporarily editable",expect(toc.headings()).toEqual([ "Typed while loading" ]);});++ it("reads the headings once per frame, however many changes arrive in it", async () => {+ const toc = await setupUnlockScenario();+ await toc.unlock();+ const createRangeIn = vi.spyOn(toc.editor.editor.model, "createRangeIn");++ await toc.editor.loadNote(toc.noteId, [ [ 2, "Current" ] ], { changes: 3 });++ expect(createRangeIn).toHaveBeenCalledTimes(1);+ expect(toc.headings()).toEqual([ "Current" ]);+ });});async function setupUnlockScenario() {@@ -250,12 +261,17 @@ function fakeTextEditor() {return {editor,- /** Stands in for the note detail feeding the editor a note's content once its blob arrives. */- async loadNote(noteId: string, headings: [ number, string ][]) {+ /**+ * Stands in for the note detail feeding the editor a note's content once its blob arrives,+ * reported as `changes` separate changes within one frame.+ */+ async loadNote(noteId: string, headings: [ number, string ][], { changes = 1 } = {}) {items = headings.map(([ level, text ]) => fakeHeadingItem(level, text));setEditorNoteId(editor, noteId);await act(async () => {- for (const listener of [ ...listeners ]) listener();+ for (let i = 0; i < changes; i++) {+ for (const listener of [ ...listeners ]) listener();+ }await new Promise((resolve) => requestAnimationFrame(resolve));});}diff --git a/apps/client/src/widgets/sidebar/TableOfContents.tsx b/apps/client/src/widgets/sidebar/TableOfContents.tsxindex f7a767ec94..937f201916 100644--- a/apps/client/src/widgets/sidebar/TableOfContents.tsx+++ b/apps/client/src/widgets/sidebar/TableOfContents.tsx@@ -244,6 +244,8 @@ function EditableTextTableOfContents() {affectsHeading = attributeChangeAffectsHeading;});+ // One extraction per frame, however many changes arrive in it.+ let frame: number | undefined;const changeCallback = () => {const changes = textEditor.model.document.differ.getChanges();@@ -253,8 +255,9 @@ function EditableTextTableOfContents() {(change.type === 'attribute' && (affectsHeading?.(change, textEditor) ?? false)));});- if (affectsHeadings) {- requestAnimationFrame(() => {+ if (affectsHeadings && frame === undefined) {+ frame = requestAnimationFrame(() => {+ frame = undefined;setHeadings(extractTocFromTextEditor(textEditor));});}@@ -262,7 +265,12 @@ function EditableTextTableOfContents() {textEditor.model.document.on("change:data", changeCallback);- return () => textEditor.model.document.off("change:data", changeCallback);+ return () => {+ textEditor.model.document.off("change:data", changeCallback);+ if (frame !== undefined) {+ cancelAnimationFrame(frame);+ }+ };}, [ textEditor, note?.noteId ]);useEffect(() => {diff --git a/apps/client/src/widgets/type_widgets/text/EditableText.tsx b/apps/client/src/widgets/type_widgets/text/EditableText.tsxindex a5d21b87b4..293121145b 100644--- a/apps/client/src/widgets/type_widgets/text/EditableText.tsx+++ b/apps/client/src/widgets/type_widgets/text/EditableText.tsx@@ -504,6 +504,8 @@ export default function EditableText({rebuildKey={editorRebuildKey}contentEmbedHandlers={contentEmbedHandlers}onChange={() => {+ // `getData()` serializes the whole note, so saves wait for typing to pause.+ spacedUpdate.resetUpdateTimer();spacedUpdate.scheduleUpdate();const editor = editorRef.current;if (editor) {diff --git a/apps/server/src/assets/help/help_content.json b/apps/server/src/assets/help/help_content.jsonindex 3ac02a73ac..c686d36a91 100644--- a/apps/server/src/assets/help/help_content.json+++ b/apps/server/src/assets/help/help_content.json@@ -78,7 +78,7 @@"_help_5Ct4MAJTS4tQ": "<p>Deleted notes are listed in the <em>Deleted Notes</em> dialog (<a class=\"reference-link\" href=\"#root/_help_x3i7MxGccDuM\">Global menu</a> → <em>Deleted notes</em>) and can be restored by pressing the <em>undelete</em> link.</p><p>If a note has child notes, they will be restored along with it. Should the original location no longer exist (e.g. the parent has been deleted), the note will be restored into the default location for new notes (<a class=\"reference-link\" href=\"#root/_help_S0Fos78ZfcY7\">Note Inbox</a>).</p><aside class=\"admonition note\"><p>When a note is hoisted in the tree, the dialog will only display notes deleted from the subtree of that hoisted note.</p></aside><p>To permanently erase deleted notes and clear the list, press the three-dots menu and select <em>Erase deleted notes now</em>.</p><p>Deleted notes are permanently erased after a certain amount of time (7 days by default). To change this interval, press the three-dots menu and select <em>Deleted Notes Settings</em>.</p>","_help_m3VlURMSeOrd": "<p>When an empty <a class=\"reference-link\" href=\"#root/_help_iPIMuisry3hd\">Text</a> note is created, a note type switcher will appear below the inline <a class=\"reference-link\" href=\"#root/_help_l7pigIGu01K2\">Title</a>. Apart from changing the note type, it's also possible to apply a <a href=\"#root/_help_KC1HB96bqqHX\">template</a>:</p><ul><li><span class=\"tn-icon bx bxl-markdown\"></span> <em>Markdown</em> and <span class=\"tn-icon bx bx-pen\"></span> <em>Canvas</em> switch the note to that type in one click.</li><li><span class=\"tn-icon bx bx-code\"></span> <em>Code</em> lists the scripting notes (<em>Custom CSS</em>, <em>Widget</em> and <em>Backend script</em>), then the enabled code languages.</li><li><span class=\"tn-icon bx bx-book\"></span> <em>Collection</em> and <span class=\"tn-icon bx bx-copy-alt\"></span><em>Template</em> list the collections and the templates.</li><li><span class=\"tn-icon bx bx-dots-vertical-rounded\"></span> <em>All types</em> displays the same menu as <em>Insert note after</em> in the <a class=\"reference-link\" href=\"#root/_help_YtSN43OrfzaA\">Note tree contextual menu</a>, with every note type and template.</li></ul><p>Typing while the <span class=\"tn-icon bx bx-code\"></span> <em>Code</em>, <span class=\"tn-icon bx bx-copy-alt\"></span> <em>Template</em> or <span class=\"tn-icon bx bx-dots-vertical-rounded\"></span> <em>All types</em> menu is open narrows it down to the matching entries.</p><p>The switcher will disappear as soon as a text is entered.</p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Notes/New%20note%20type%20switcher_image.png\" width=\"735\" height=\"143\">","_help_B5dihXRDksTk": "<p>Note badges appear near the fixed note title and indicate important information about the note such as whether it is read-only. Some of the badges are also interactive.</p><figure class=\"image\"><img style=\"aspect-ratio:910/49;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Notes/Note%20badges_image.png\" width=\"910\" height=\"49\"></figure><p>The following badges are available:</p><ul><li><span class=\"tn-icon bx bx-lock-alt\"></span> <strong>Read-only badge</strong>, which will be shown if the note is not editable due to either automatic read-only or manual read-only. Clicking on the badge will temporarily edit the note. On the pages of the built-in user guide, which cannot be edited, the badge does nothing when clicked.</li><li><span class=\"tn-icon bx bx-share-alt\"></span> <strong>Share badge</strong>, which will indicate that the current note is shared. The badge will also indicate if the share is on the local network (for the desktop application without <a class=\"reference-link\" href=\"#root/_help_cbkrhQjrkKrh\">Synchronization</a> set up) or publicly accessible (for the server).</li><li><span class=\"tn-icon bx bx-globe\"></span> <strong>Web clip badge</strong>, which will indicate if the note was clipped using the <a class=\"reference-link\" href=\"#root/_help_MtPxeAWVAzMg\">Web Clipper</a>. The badge acts as a link, so it can be clicked on to navigate to the page or right clicked for more options. When the clipper also saved the page's description, its author, or the dates it was published and last updated, clicking the badge shows these details instead, with a link to the page at the top.</li><li><span class=\"tn-icon bx bx-play\"></span> <strong>Execute badge</strong>, for <a href=\"#root/_help_CdNpE2pqjmI6\">scripts</a> or <a href=\"#root/_help_YKWqdJhzi2VY\">saved SQL queries</a> which have an execute button or a description.</li><li><span class=\"tn-icon bx bx-copy-alt\"></span> <strong>Template badge</strong>, for <a class=\"reference-link\" href=\"#root/_help_KC1HB96bqqHX\">Templates</a> (including workspace templates, for which the badge reads <em>Workspace template</em>). Notes created from a template inherit its attributes, so the badge is a reminder that changing them affects every such note. Clicking the badge switches the template between being offered everywhere and only while hoisted into its workspace, the latter only for a template inside a workspace (see <a class=\"reference-link\" href=\"#root/_help_9sRHySam5fXb\">Workspaces</a>). It also opens <em>Template properties...</em>, where the default title and location of new notes are set.</li><li>For <a class=\"reference-link\" href=\"#root/_help_YzMcWlCVeW09\">Active content</a> (e.g. scripts, styles), a dedicated badge will be shown indicating the type of note and with an option to easily enable or disable it.</li></ul>",- "_help_Bsm4fyzPJkSc": "<p><img class=\"image-style-align-right\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Notes/Save%20status%20indicator_image.png\" width=\"168\" height=\"47\">To the right of the note title, a temporary indicator appears after making a change to the document which shows whether the document has been saved.</p><p>It indicates the following states:</p><ul><li><span class=\"tn-icon bx bx-pencil\"></span> <em>Unsaved</em>, if the changes will be saved soon.</li><li><span class=\"tn-icon bx bx-loader\"></span> <em>Saving</em>, if the changes are being saved.</li><li><span class=\"tn-icon bx bx-check\"></span> <em>Saved</em>, if all the changes were successfully saved to the server.</li><li><span class=\"tn-icon bx bx-error\"></span> <em>Error</em>, if the changes could not be saved, for example due to a communication server with the server.</li></ul><p>After all changes have been saved, the indicator will hide automatically after a few seconds.</p>",+ "_help_Bsm4fyzPJkSc": "<p><img class=\"image-style-align-right\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Notes/Save%20status%20indicator_image.png\" width=\"168\" height=\"47\">To the right of the note title, a temporary indicator appears after making a change to the document which shows whether the document has been saved.</p><p>It indicates the following states:</p><ul><li><span class=\"tn-icon bx bx-pencil\"></span> <em>Unsaved</em>, if the changes will be saved soon.</li><li><span class=\"tn-icon bx bx-loader\"></span> <em>Saving</em>, if the changes are being saved.</li><li><span class=\"tn-icon bx bx-check\"></span> <em>Saved</em>, if all the changes were successfully saved to the server.</li><li><span class=\"tn-icon bx bx-error\"></span> <em>Error</em>, if the changes could not be saved, for example due to a communication server with the server.</li></ul><p>In a text note, the changes are saved once typing pauses for a second, and at least every ten seconds while typing continues.</p><p>After all changes have been saved, the indicator will hide automatically after a few seconds.</p>","_help_kBrnXNG3Hplm": "<p>This page explains the basic concepts related to the tree structure of notes in TriliumNext.</p><h2>Note</h2><p>A note is the central entity in TriliumNext. For more details, see <a class=\"reference-link\" href=\"#root/_help_BFs8mudNFgCS\">Notes</a>.</p><h2>Branch</h2><p>A branch describes the placement of a note within the note tree. Essentially, it is a tuple of <code>parentNoteId</code> and <code>noteId</code>, indicating that the given note is placed as a child under the specified parent note.</p><p>Each note can have multiple branches, meaning any note can be placed in multiple locations within the tree. This concept is referred to as <a class=\"reference-link\" href=\"#root/_help_IakOLONlIfGI\">Cloning Notes</a>.</p><h2>Prefix</h2><p>A prefix is a branch-specific title modifier for a note. If you place your note in two different locations within the tree and want to alter the title slightly in one of those placements, you can use a prefix.</p><p>To edit a prefix, right-click on the note in the tree pane and select <em>Edit branch prefix</em>.</p><p>The prefix is not part of the note itself and is not encrypted when the note is protected. This can be useful if you want part of the title to remain visible in the tree for easier navigation, even when the note is protected.</p><h2>Subtree</h2><p>A subtree consists of a particular note (the subtree root) and all its children and descendants. Some operations, such as exporting, work on entire subtrees.</p>","_help_MMiBEQljMQh2": "<p>One of the Trilium's goals is to provide fast and comfortable navigation between notes.</p><h2>Backwards and forward</h2><p>To move back and forward in the history of viewed notes, press <kbd>Alt</kbd>+<kbd>←</kbd> and <kbd>Alt</kbd>+<kbd>→</kbd>, or use the <span class=\"tn-icon bx bx-left-arrow-alt\"></span> and <span class=\"tn-icon bx bx-right-arrow-alt\"></span> buttons to the left of the <a class=\"reference-link\" href=\"#root/_help_3seOhtN8uLIY\">Tabs</a>.</p><p>This works identically to browser backwards / forwards, it's actually using built-in browser support for this.</p><p>To go several notes back or forward at once, right-click one of the buttons or press and hold it. The back button lists the notes before the current one and the forward button the notes after it, the nearest first. Each entry shows the note's title, with the path of its parent notes at the end of the row. Selecting a note goes straight to it.</p><p>The <em>Go to Previous Note</em> and <em>Go to Next Note</em> launchers of the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a> list the same notes, below the launch bar's own items.</p><p><img src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Navigation/Note%20Navigation_image.jpg\"></p><h2>Jump to note</h2><p>This is useful to quickly find and view arbitrary notes - click on <code>Jump to</code> button on the top or press <kbd>Ctrl</kbd> + <kbd>J</kbd> . Then type part of the note name and autocomplete will help you pick the desired note.</p><p>See <a class=\"reference-link\" href=\"#root/_help_F1r9QtzQLZqm\">Jump to Note</a> for more information.</p>","_help_Ms1nauBra7gq": "<figure class=\"image image-style-align-center\"><img style=\"aspect-ratio:659/256;\" src=\"{{helpAssets}}/User%20Guide/Basic%20Concepts%20and%20Features/Navigation/Quick%20search_image.png\" width=\"659\" height=\"256\"></figure><p>The <em>Quick search</em> function does a full-text search (that is, it searches through the content of notes and not just the title of a note) and displays the result in an easy-to-access manner.</p><p>The alternative to the quick search is the <a class=\"reference-link\" href=\"#root/_help_eIg8jdvaoNNd\">Search</a> function, which opens in a dedicated tab and has support for advanced queries.</p><p>For even faster navigation, it's possible to use <a class=\"reference-link\" href=\"#root/_help_F1r9QtzQLZqm\">Jump to & command palette</a> which will only search through the note titles instead of the content.</p><h2>Layout</h2><p>Based on the <a class=\"reference-link\" href=\"#root/_help_x0JgW8UqGXvq\">Vertical and horizontal layout</a>, the quick search is placed:</p><ul><li>On the vertical layout, it is displayed right above the <a class=\"reference-link\" href=\"#root/_help_oPVyFC7WL2Lp\">Note Tree</a>.</li><li>On the horizontal layout, it is displayed in the <a class=\"reference-link\" href=\"#root/_help_xYmIYSP6wE3F\">Launch Bar</a>, where it can be positioned just like any other icon.</li></ul><h2>Search Features</h2><p>Quick search includes the following features:</p><h3>Content Previews</h3><p>Search results now display a 200-character preview of the note content below the note title. This preview shows the context where your search terms appear, making it easier to identify the right note without opening it.</p><h3>All results in one list</h3><p>Quick search lists up to 200 matching notes in a single scrollable list, so the scrollbar shows how many results there are and how far through them you are.</p><h3>Continuing in the full search</h3><p>To refine a query with the options of the full <a class=\"reference-link\" href=\"#root/_help_eIg8jdvaoNNd\">Search</a>, click <em>Show in full search</em> below the results, or press <kbd>Ctrl</kbd>+<kbd>Enter</kbd> in the search field. The full search opens in a new tab with the same query. The button stays below the list, however far the results are scrolled.</p><h3>Visual Features</h3><ul><li><strong>Highlighting</strong>: Search terms appear in bold with accent colors</li><li><strong>Separation</strong>: Results are separated with dividers</li><li><strong>Theme Support</strong>: Highlighting colors adapt to light/dark themes</li></ul><h3>Search Behavior</h3><p>Quick search uses progressive search:</p><ol><li>Shows exact matches first</li><li>Includes fuzzy matches when exact results are fewer than 5</li><li>Exact matches appear before fuzzy matches</li></ol><h3>Search Scope</h3><p>Quick search covers only the subtree you are currently working in:</p><ul><li>Without hoisting, it covers the whole note tree.</li><li>Under a <a href=\"#root/_help_OR8WJ7Iz9K4U\">hoisted note</a> or inside a <a href=\"#root/_help_9sRHySam5fXb\">workspace</a>, it covers only that subtree.</li><li>Notes that exist only in the hidden tree, such as the built-in help pages and the launch bar configuration, are not returned. Hoist into the help to search it, or use <a href=\"#root/_help_F1r9QtzQLZqm\">Jump to…</a>, which searches titles across the hidden tree.</li></ul><p>To search the whole database while hoisted, use the full <a class=\"reference-link\" href=\"#root/_help_eIg8jdvaoNNd\">Search</a> and leave <em>Ancestor</em> field empty.</p><h3>Keyboard Navigation</h3><ul><li>Press <kbd>Enter</kbd> in the search field to search, or to refresh the results already shown.</li><li>Press <kbd>Down</kbd> in the search field to move to the first result, then <kbd>Up</kbd> and <kbd>Down</kbd> to move between results. <kbd>Up</kbd> on the first result returns to the search field.</li><li>Press <kbd>Page Down</kbd> and <kbd>Page Up</kbd> to move through the results a page at a time.</li><li>Press <kbd>Enter</kbd> on a result to open it.</li><li>Press <kbd>Ctrl</kbd>+<kbd>Enter</kbd> to open the query in the full search.</li><li>Press <kbd>Escape</kbd> to close the results.</li></ul><p>To see these shortcuts on screen, click the <kbd>?</kbd> button below the results, or press <kbd>Alt</kbd>+<kbd>F1</kbd> while the search field is focused.</p><h2>Using Quick Search</h2><ol><li><strong>Typo tolerance</strong>: Search finds results despite minor typos</li><li><strong>Content previews</strong>: 200-character snippets show match context</li><li><strong>Specific terms</strong>: Specific search terms return more focused results</li><li><strong>Match locations</strong>: Bold text indicates where matches occur</li></ol><h2>Quick Search - Exact Match Operator</h2><p>Quick Search shares the same search engine as the full <a class=\"reference-link\" href=\"#root/_help_eIg8jdvaoNNd\">Search</a>, so the exact match operator (<code>=</code>) behaves identically in both. Start your query with <code>=</code> (no space after it) to switch from the default \"contains\" behavior to exact whole-word or phrase matching.</p><p><strong>What</strong> <code>**=**</code> <strong>actually does:</strong> it finds notes where the title or content contains your term as a <strong>whole word or phrase</strong>, ignoring surrounding punctuation. It does <strong>not</strong> require the whole note to equal your term, and it does <strong>not</strong> do substring or fuzzy matching.</p><figure class=\"table\"><table><thead><tr><th>Query</th><th>Example note content</th><th>Matches?</th><th>Why</th></tr></thead><tbody><tr><td><code>sync</code></td><td><code>synchronize the database now</code></td><td>Yes</td><td>default search matches the substring</td></tr><tr><td><code>=sync</code></td><td><code>see (sync) mode</code></td><td>Yes</td><td><code>=</code> matches the whole word <code>sync</code>, punctuation ignored</td></tr><tr><td><code>=sync</code></td><td><code>synchronize the database now</code></td><td>No</td><td><code>=</code> never matches substrings</td></tr><tr><td><code>=\"project plan\"</code></td><td><code>the (project plan) is ready to share</code></td><td>Yes</td><td>quote a multi-word phrase to match it exactly</td></tr></tbody></table></figure><p>The search is case- and diacritic-insensitive. For the complete explanation of the three matching modes, fuzzy operators and relevance ranking, see <a href=\"#root/_help_eIg8jdvaoNNd\">How search matches your text</a> in the full Search documentation.</p><h3>Limitations</h3><ul><li>The <code>=</code> operator must be at the very beginning of the search query.</li><li>A space immediately after <code>=</code> is treated as a regular search.</li><li>Multiple <code>=</code> operators (like <code>==example</code>) are treated as regular text search.</li></ul><h3>Related Features</h3><ul><li>For attribute, property, boolean and ordering queries, use the full <a href=\"#root/_help_eIg8jdvaoNNd\">Search</a> functionality.</li><li>For fuzzy matching (finding results despite typos), use the <code>~=</code> or <code>~*</code> operators in the full search.</li><li>For partial matches with wildcards, use operators like <code>*=*</code>, <code>=*</code>, or <code>*=</code> in the full search.</li></ul>",diff --git a/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Save status indicator.md b/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Save status indicator.mdindex 81f44eaf01..01ef6eb268 100644--- a/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Save status indicator.md+++ b/docs/User Guide/User Guide/Basic Concepts and Features/Notes/Save status indicator.md@@ -8,4 +8,6 @@ It indicates the following states:* <span class="tn-icon bx bx-check"></span> _Saved_, if all the changes were successfully saved to the server.* <span class="tn-icon bx bx-error"></span> _Error_, if the changes could not be saved, for example due to a communication server with the server.+In a text note, the changes are saved once typing pauses for a second, and at least every ten seconds while typing continues.+After all changes have been saved, the indicator will hide automatically after a few seconds.\ No newline at end of filediff --git a/packages/ckeditor5/src/plugins/multicolumn/constants.ts b/packages/ckeditor5/src/plugins/multicolumn/constants.tsindex a53577c24c..62c04b5069 100644--- a/packages/ckeditor5/src/plugins/multicolumn/constants.ts+++ b/packages/ckeditor5/src/plugins/multicolumn/constants.ts@@ -11,6 +11,8 @@ export const RATIOS_ATTRIBUTE = "columnRatios";export const LAYOUT_CLASS = MULTICOLUMN_LAYOUT_CLASS;export const COLUMN_CLASS = MULTICOLUMN_COLUMN_CLASS;+/** Editing-view class of a layout that holds the focused column. */+export const FOCUSED_LAYOUT_CLASS = "trilium-multicolumn-layout--focused";export const RATIOS_DATA_ATTRIBUTE = "data-trilium-column-ratios";/** Custom property that marks the editing-view widget element of a layout. */diff --git a/packages/ckeditor5/src/plugins/multicolumn/multicolumn_editing.ts b/packages/ckeditor5/src/plugins/multicolumn/multicolumn_editing.tsindex ccc3305b1a..7adad9dca5 100644--- a/packages/ckeditor5/src/plugins/multicolumn/multicolumn_editing.ts+++ b/packages/ckeditor5/src/plugins/multicolumn/multicolumn_editing.ts@@ -14,9 +14,11 @@ import {} from "ckeditor5";import NestedLimitSelection from "../nested_limit_selection.js";+import { markFocusedContainers } from "../widget_utils.js";import {- COLUMN_CLASS, COLUMN_RATIOS, ELEMENTS, getColumnCount, getDefaultRatios, LAYOUT_CLASS,- LAYOUT_WIDGET_PROPERTY, MAX_COLUMNS, MIN_COLUMNS, RATIOS_ATTRIBUTE, RATIOS_DATA_ATTRIBUTE+ COLUMN_CLASS, COLUMN_RATIOS, ELEMENTS, FOCUSED_LAYOUT_CLASS, getColumnCount, getDefaultRatios,+ LAYOUT_CLASS, LAYOUT_WIDGET_PROPERTY, MAX_COLUMNS, MIN_COLUMNS, RATIOS_ATTRIBUTE,+ RATIOS_DATA_ATTRIBUTE} from "./constants.js";import {ColumnLayoutCommand, InsertLayoutColumnCommand, InsertMulticolumnLayoutCommand,@@ -50,6 +52,8 @@ export default class MulticolumnEditing extends Plugin {this.registerSchema();this.registerConversion();this.registerPostFixer();+ markFocusedContainers(editor, FOCUSED_LAYOUT_CLASS,+ element => element.hasClass(LAYOUT_CLASS));}private registerSchema() {diff --git a/packages/ckeditor5/src/plugins/multicolumn/multicolumn_layout.spec.ts b/packages/ckeditor5/src/plugins/multicolumn/multicolumn_layout.spec.tsindex 7030587868..ef41468343 100644--- a/packages/ckeditor5/src/plugins/multicolumn/multicolumn_layout.spec.ts+++ b/packages/ckeditor5/src/plugins/multicolumn/multicolumn_layout.spec.ts@@ -174,10 +174,12 @@ describe("multicolumn layout styles", () => {}});await expect.poll(outline).toBe("solid 3px rgb(12, 34, 56)");+ expect(widget.classList.contains("trilium-multicolumn-layout--focused")).toBe(true);viewDocument.isFocused = false;editor.editing.view.forceRender();await expect.poll(outline).toBe("solid 3px rgba(0, 0, 0, 0)");+ expect(widget.classList.contains("trilium-multicolumn-layout--focused")).toBe(false);});it("lines the text of saved content up with the content around it, 2em apart", () => {diff --git a/packages/ckeditor5/src/plugins/tabs/constants.ts b/packages/ckeditor5/src/plugins/tabs/constants.tsindex 467ec67889..c807109610 100644--- a/packages/ckeditor5/src/plugins/tabs/constants.ts+++ b/packages/ckeditor5/src/plugins/tabs/constants.ts@@ -14,6 +14,7 @@ export const CLASSES = {tabPanel: "trilium-tab-panel",activeTab: "trilium-tab--active",activeTitle: "trilium-tab-title--active",+ focusedTabs: "trilium-tabs--focused",titleBar: "trilium-tabs-bar"} as const;diff --git a/packages/ckeditor5/src/plugins/tabs/tabs_editing.ts b/packages/ckeditor5/src/plugins/tabs/tabs_editing.tsindex c001bbc611..f059c2cfaf 100644--- a/packages/ckeditor5/src/plugins/tabs/tabs_editing.ts+++ b/packages/ckeditor5/src/plugins/tabs/tabs_editing.ts@@ -17,6 +17,7 @@ import {import { BLOCK_ID } from "../block_reference/block_reference_editing.js";import FindReveal from "../find_reveal.js";+import { markFocusedContainers } from "../widget_utils.js";import {ALIGNMENT_ATTRIBUTE, ALIGNMENT_DATA_ATTRIBUTE, CLASSES, DEFAULT_TAB_ALIGNMENT, ELEMENTS,parseTabAlignment, TABS_WIDGET_PROPERTY@@ -66,6 +67,8 @@ export default class TabsEditing extends Plugin {this.registerConversion();this.registerPostFixer();this.registerActiveTabTracking();+ markFocusedContainers(editor, CLASSES.focusedTabs,+ element => element.hasClass(CLASSES.tabs), { isInnermostOnly: true });this.registerEnterInTitle();this.registerFindReveal();}diff --git a/packages/ckeditor5/src/plugins/tabs/tabs_layout.spec.ts b/packages/ckeditor5/src/plugins/tabs/tabs_layout.spec.tsindex b29a1ab58f..917b14d241 100644--- a/packages/ckeditor5/src/plugins/tabs/tabs_layout.spec.ts+++ b/packages/ckeditor5/src/plugins/tabs/tabs_layout.spec.ts@@ -259,6 +259,8 @@ describe("tabs layout styles", () => {);const blocks = [...editable.querySelectorAll<HTMLElement>(".trilium-tabs.ck-widget")];const outlines = () => blocks.map(block => getComputedStyle(block).outlineColor);+ const focused = () => blocks.map(block =>+ block.classList.contains("trilium-tabs--focused"));const ring = (element: Element | null) => {expect(element).not.toBeNull();const style = getComputedStyle(element as Element);@@ -277,12 +279,14 @@ describe("tabs layout styles", () => {const innerPanel = blocks[1].querySelector(".trilium-tab-panel");expect(ring(innerPanel)).toEqual(["rgba(0, 0, 0, 0)", "none", "0s"]);await expect.poll(outlines).toEqual(["rgba(0, 0, 0, 0)", "rgb(65, 43, 21)"]);+ expect(focused()).toEqual([false, true]);select([1, 0, 0, 0]);const outerTitle = blocks[0].querySelector(".trilium-tab-title");expect(ring(outerTitle).filter((_, index) => index !== 1)).toEqual(["rgb(12, 34, 56)", "0s"]);await expect.poll(outlines).toEqual(["rgb(65, 43, 21)", "rgba(0, 0, 0, 0)"]);+ expect(focused()).toEqual([true, false]);});it("keeps overflowing titles on one scrolling row and rounds the panel corners", async () => {diff --git a/packages/ckeditor5/src/plugins/widget_utils.ts b/packages/ckeditor5/src/plugins/widget_utils.tsindex 9b12d46304..2ac84183bc 100644--- a/packages/ckeditor5/src/plugins/widget_utils.ts+++ b/packages/ckeditor5/src/plugins/widget_utils.ts@@ -93,3 +93,46 @@ export function findSelectedWidget(function isMarkedWidget(element: ViewElement, property: string) {return !!element.getCustomProperty(property) && isWidget(element);}++/**+ * Keeps `className` on the view elements that `isContainer` accepts and that hold the focused+ * nested editable, like CKEditor keeps `ck-editor__nested-editable_focused` on the editable.+ * With `isInnermostOnly`, only the closest such element gets it. Stylesheets match this class+ * instead of a `:has()` on CKEditor's: that `:has()` re-checks large ancestors on each caret move.+ */+export function markFocusedContainers(+ editor: Editor,+ className: string,+ isContainer: (element: ViewElement) => boolean,+ { isInnermostOnly = false } = {}+) {+ const viewDocument = editor.editing.view.document;+ let marked = new Set<ViewElement>();++ viewDocument.registerPostFixer(writer => {+ const containers = new Set<ViewElement>();+ const editable = viewDocument.isFocused ? viewDocument.selection.editableElement : null;+ for (const ancestor of editable?.getAncestors({ parentFirst: true }) ?? []) {+ if (ancestor.is("element") && isContainer(ancestor)) {+ containers.add(ancestor);+ if (isInnermostOnly) break;+ }+ }++ let isChanged = false;+ for (const element of marked) {+ if (!containers.has(element) && element.hasClass(className)) {+ writer.removeClass(className, element);+ isChanged = true;+ }+ }+ for (const element of containers) {+ if (!element.hasClass(className)) {+ writer.addClass(className, element);+ isChanged = true;+ }+ }+ marked = containers;+ return isChanged;+ });+}diff --git a/packages/ckeditor5/src/theme/multicolumn.css b/packages/ckeditor5/src/theme/multicolumn.cssindex e389251680..069110e462 100644--- a/packages/ckeditor5/src/theme/multicolumn.css+++ b/packages/ckeditor5/src/theme/multicolumn.css@@ -50,7 +50,7 @@column-gap: 12px;border-radius: var(--multicolumn-layout-border-radius);- &:has(.ck-editor__nested-editable_focused) {+ &.trilium-multicolumn-layout--focused {outline: var(--ck-widget-outline-thickness, 3px) solidvar(--multicolumn-layout-focus-border-color);}diff --git a/packages/ckeditor5/src/theme/tabs.css b/packages/ckeditor5/src/theme/tabs.cssindex 16e85d66b2..ccf5a46295 100644--- a/packages/ckeditor5/src/theme/tabs.css+++ b/packages/ckeditor5/src/theme/tabs.css@@ -149,10 +149,8 @@}}-.ck-editor__editable .trilium-tabs:has(.ck-editor__nested-editable_focused) {- &:not(:has(.trilium-tabs .ck-editor__nested-editable_focused)) {- outline: var(--ck-widget-outline-thickness, 3px) solid var(--tabs-focus-border-color);- }+.ck-editor__editable .trilium-tabs.ck-widget.trilium-tabs--focused {+ outline: var(--ck-widget-outline-thickness, 3px) solid var(--tabs-focus-border-color);}.ck-editor__editable .trilium-tabs > .trilium-tab > .trilium-tab-panel {