Skip to content

Build your personal knowledge base with Trilium Notes

client: add an option to control whether content hints are enabled or disabled

Adorian Doran16dc26819e6e
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index 2d4467be8f..6cfe9f9aae 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -2587,7 +2587,9 @@
"note_completion_enabled": "Note auto-completion",
"note_completion_description": "Links to notes can be created by typing `@` followed by the title of a note.",
"slash_commands_enabled": "Slash commands",
- "slash_commands_description": "Editing commands such as inserting line breaks or headings can be toggled by typing `/`."
+ "slash_commands_description": "Editing commands such as inserting line breaks or headings can be toggled by typing `/`.",
+ "content_hints_enabled": "Content hints",
+ "content_hints_description": "Show short hints in the bottom corner of the editor that explain how to interact with the element under the caret or pointer."
},
"table_view": {
"new-row": "New row",
diff --git a/apps/client/src/widgets/type_widgets/options/text_notes.tsx b/apps/client/src/widgets/type_widgets/options/text_notes.tsx
index 9e5b16dea2..6c6d828f73 100644
--- a/apps/client/src/widgets/type_widgets/options/text_notes.tsx
+++ b/apps/client/src/widgets/type_widgets/options/text_notes.tsx
@@ -129,6 +129,7 @@ function EditorFeatures() {
const [emojiCompletionEnabled, setEmojiCompletionEnabled] = useTriliumOptionBool("textNoteEmojiCompletionEnabled");
const [noteCompletionEnabled, setNoteCompletionEnabled] = useTriliumOptionBool("textNoteCompletionEnabled");
const [slashCommandsEnabled, setSlashCommandsEnabled] = useTriliumOptionBool("textNoteSlashCommandsEnabled");
+ const [contentHintsEnabled, setContentHintsEnabled] = useTriliumOptionBool("textNoteContentHintsEnabled");
return (
<OptionsSection title={t("editorfeatures.title")}>
@@ -155,6 +156,14 @@ function EditorFeatures() {
currentValue={slashCommandsEnabled}
onChange={setSlashCommandsEnabled}
/>
+
+ <OptionsRowWithToggle
+ name="content-hints-enabled"
+ label={t("editorfeatures.content_hints_enabled")}
+ description={t("editorfeatures.content_hints_description")}
+ currentValue={contentHintsEnabled}
+ onChange={setContentHintsEnabled}
+ />
</OptionsSection>
);
}
diff --git a/apps/client/src/widgets/type_widgets/text/config.ts b/apps/client/src/widgets/type_widgets/text/config.ts
index 6e064717ec..3fca387cb1 100644
--- a/apps/client/src/widgets/type_widgets/text/config.ts
+++ b/apps/client/src/widgets/type_widgets/text/config.ts
@@ -192,6 +192,12 @@ export async function buildConfig(opts: BuildEditorOptions): Promise<EditorConfi
// The app's i18n translate function, so plugins can resolve Trilium translation keys.
(config as Record<string, unknown>).translate = (key: string, params?: Record<string, unknown>) => t(key, params);
+ // Global on/off switch for content-area hints (bottom-corner popups on task
+ // checkboxes, collapsible summaries, drag handles). Plugins consult this via
+ // `editor.config.get("contentHintsEnabled")` and skip registering their hint
+ // managers when it's false.
+ (config as Record<string, unknown>).contentHintsEnabled = options.get("textNoteContentHintsEnabled") === "true";
+
// Image toolbar actions (copy / download), handled by the ImageActions plugin. The copy
// button is only added where copying the raw image is supported (Electron or a secure
// context); elsewhere the browser's own context menu still offers a "Copy image" entry.
diff --git a/packages/ckeditor5-collapsible/src/collapsible-editing.ts b/packages/ckeditor5-collapsible/src/collapsible-editing.ts
index 9a7b97deed..69bfec0d28 100644
--- a/packages/ckeditor5-collapsible/src/collapsible-editing.ts
+++ b/packages/ckeditor5-collapsible/src/collapsible-editing.ts
@@ -105,8 +105,14 @@ export default class CollapsibleEditing extends Plugin {
this.registerDomListeners();
this.registerAutoOpenNewDetails();
this.registerPostFixers();
- this.registerSummaryHints();
- this.registerHandleHints();
+ // Global user preference: skip all content-hint wiring when off. The
+ // rest of `init()` (schema, key handlers, drag, post-fixers) stays
+ // intact — hints are additive UX, not a load-bearing feature. Missing
+ // config (external CKEditor consumers, tests) → hints on.
+ if (this.editor.config.get("contentHintsEnabled") !== false) {
+ this.registerSummaryHints();
+ this.registerHandleHints();
+ }
}
public override destroy(): void {
diff --git a/packages/ckeditor5/src/plugins/todo_list_multistate/todo_list_multistate_editing.spec.ts b/packages/ckeditor5/src/plugins/todo_list_multistate/todo_list_multistate_editing.spec.ts
index 94157696bb..59b4c89745 100644
--- a/packages/ckeditor5/src/plugins/todo_list_multistate/todo_list_multistate_editing.spec.ts
+++ b/packages/ckeditor5/src/plugins/todo_list_multistate/todo_list_multistate_editing.spec.ts
@@ -774,6 +774,51 @@ describe("TodoListMultistateEditing", () => {
});
});
+ describe("contentHintsEnabled config", () => {
+ // With hints off, neither the hover nor the caret flow should spawn
+ // a popup — the plugin's core editing behavior (state cycle, native
+ // toggle) must still work, but the on-screen hint is fully muted.
+ beforeEach(async () => {
+ editor = await createEditor({
+ taskStates: CUSTOM_STATES,
+ contentHintsEnabled: false
+ });
+ setModelData(editor.model,
+ '<paragraph>plain[]</paragraph>' +
+ '<paragraph listIndent="0" listItemId="t-a" listType="todo">A</paragraph>');
+ vi.useFakeTimers({ shouldAdvanceTime: false });
+ });
+
+ it("no popup appears when the caret enters a todo (dwell elapses silently)", () => {
+ editor.model.change((writer) => {
+ writer.setSelection(writer.createPositionAt(getBlock(editor, 1), 0));
+ });
+ vi.advanceTimersByTime(TOOLTIP_DWELL_MS * 5);
+ expect(livePopup()).toBeNull();
+
+ vi.runOnlyPendingTimers();
+ vi.useRealTimers();
+ });
+
+ it("no popup appears on hover, and the core state-cycle still works", () => {
+ const domRoot = editor.editing.view.getDomRoot();
+ const input = domRoot?.querySelector<HTMLInputElement>('.todo-list__label input[type="checkbox"]');
+ input?.dispatchEvent(new MouseEvent("mouseenter", { bubbles: true }));
+ vi.advanceTimersByTime(TOOLTIP_DWELL_MS * 5);
+ expect(livePopup()).toBeNull();
+
+ // Core editing surface still functions — hints are additive UX only.
+ editor.model.change((writer) => {
+ writer.setSelection(writer.createPositionAt(getBlock(editor, 1), 0));
+ });
+ editor.execute("setTaskState", { state: "doing" });
+ expect(getBlock(editor, 1).getAttribute(TASK_STATE_ATTRIBUTE)).toBe("doing");
+
+ vi.runOnlyPendingTimers();
+ vi.useRealTimers();
+ });
+ });
+
// Pure-function tests for the tooltip HTML builder. Assert against the
// returned string directly rather than introspecting Bootstrap Tooltip
// instances — no `_config` peeking, no editor scaffolding needed.
diff --git a/packages/ckeditor5/src/plugins/todo_list_multistate/todo_list_multistate_editing.ts b/packages/ckeditor5/src/plugins/todo_list_multistate/todo_list_multistate_editing.ts
index 9dd270569c..efec714f14 100644
--- a/packages/ckeditor5/src/plugins/todo_list_multistate/todo_list_multistate_editing.ts
+++ b/packages/ckeditor5/src/plugins/todo_list_multistate/todo_list_multistate_editing.ts
@@ -43,7 +43,7 @@ export default class TodoListMultistateEditing extends Plugin {
* against it — only the top of the stack is on screen at a time. See
* {@link ContentHintManager} for the rationale.
*/
- private _hintManager!: ContentHintManager;
+ private _hintManager?: ContentHintManager;
/** Hover-driven handle per rendered checkbox. Disposed when the checkbox detaches. */
private readonly _hoverHandles = new Map<HTMLInputElement, HintHandle>();
@@ -83,21 +83,28 @@ export default class TodoListMultistateEditing extends Plugin {
this._translate = (editor.config.get("translate") as TranslateFn | undefined)
?? ((key: string) => key);
const stateByName = this._stateByName;
- this._hintManager = new ContentHintManager({
- tooltipOptions: {
- // Bootstrap's default sanitizer strips `data-*` attributes, which
- // the state-icon span in the tooltip relies on to render the
- // correct colour/glyph.
- sanitize: false,
- customClass: "text-editor-content-tooltip"
- },
- // Self-dismiss the tooltip 1s after the last relevant event (push,
- // content update, top change). Anything that would legitimately
- // keep the hint alive — hover crossing, caret movement, state
- // change — pushes to the manager, so the timer resets and the
- // popup stays. When events stop, it fades on its own.
- autoHideAfterMs: 2000
- });
+ // Global user preference: skip all content-hint wiring when off. The
+ // rest of `init()` (schema, keystroke, downcast/upcast, post-fixer)
+ // stays intact — hints are additive UX, not a load-bearing feature.
+ // Missing config (external CKEditor consumers, tests) → hints on.
+ const hintsEnabled = editor.config.get("contentHintsEnabled") !== false;
+ if (hintsEnabled) {
+ this._hintManager = new ContentHintManager({
+ tooltipOptions: {
+ // Bootstrap's default sanitizer strips `data-*` attributes, which
+ // the state-icon span in the tooltip relies on to render the
+ // correct colour/glyph.
+ sanitize: false,
+ customClass: "text-editor-content-tooltip"
+ },
+ // Self-dismiss the tooltip 1s after the last relevant event (push,
+ // content update, top change). Anything that would legitimately
+ // keep the hint alive — hover crossing, caret movement, state
+ // change — pushes to the manager, so the timer resets and the
+ // popup stays. When events stop, it fades on its own.
+ autoHideAfterMs: 2000
+ });
+ }
editor.model.schema.extend("$block", {allowAttributes: TASK_STATE_ATTRIBUTE});
@@ -171,25 +178,27 @@ export default class TodoListMultistateEditing extends Plugin {
}
});
- this.listenTo(editor.editing.view, "render", () => {
- const domRoot = editor.editing.view.getDomRoot();
- if (!domRoot) {
- return;
- }
- // Refresh handles first; the return value tells `_syncCaretTooltip`
- // whether the caret's item changed state on this render (Ctrl+Shift+Enter,
- // native toggle, etc.) so it can force an immediate `show()` instead
- // of waiting out the dwell timer again.
- const caretItemStateChanged = this._refreshHoverHandles(domRoot);
- this._syncCaretTooltip({ forceShowIfSameTarget: caretItemStateChanged });
- });
-
- // Keyboard-only navigation into an <li> doesn't move DOM focus (the editable
- // root keeps it), so the manager needs to be driven from model-selection
- // changes to catch the keyboard-into-todo case.
- this.listenTo(editor.model.document.selection, "change:range", () => {
- this._syncCaretTooltip({ forceShowIfSameTarget: false });
- });
+ if (hintsEnabled) {
+ this.listenTo(editor.editing.view, "render", () => {
+ const domRoot = editor.editing.view.getDomRoot();
+ if (!domRoot) {
+ return;
+ }
+ // Refresh handles first; the return value tells `_syncCaretTooltip`
+ // whether the caret's item changed state on this render (Ctrl+Shift+Enter,
+ // native toggle, etc.) so it can force an immediate `show()` instead
+ // of waiting out the dwell timer again.
+ const caretItemStateChanged = this._refreshHoverHandles(domRoot);
+ this._syncCaretTooltip({ forceShowIfSameTarget: caretItemStateChanged });
+ });
+
+ // Keyboard-only navigation into an <li> doesn't move DOM focus (the editable
+ // root keeps it), so the manager needs to be driven from model-selection
+ // changes to catch the keyboard-into-todo case.
+ this.listenTo(editor.model.document.selection, "change:range", () => {
+ this._syncCaretTooltip({ forceShowIfSameTarget: false });
+ });
+ }
// A new row split off with Enter inherits the previous row's `taskState` (writer.split
// copies block attributes). Drop it so each new task starts in the plain "none" state.
@@ -283,6 +292,14 @@ export default class TodoListMultistateEditing extends Plugin {
* immediately, per the "reappear on state change" spec).
*/
private _refreshHoverHandles(domRoot: HTMLElement): boolean {
+ const manager = this._hintManager;
+ // The two callers that reach this method are gated on `hintsEnabled`
+ // in `init()`, so `_hintManager` is set here in practice. The guard
+ // keeps TypeScript happy and documents the contract.
+ /* v8 ignore next 3 */
+ if (!manager) {
+ return false;
+ }
// Reap detached checkboxes.
for (const input of Array.from(this._hoverHandles.keys())) {
if (!input.isConnected) {
@@ -308,7 +325,7 @@ export default class TodoListMultistateEditing extends Plugin {
this._knownState.set(input, currentState);
if (isNew) {
- const handle = this._hintManager.createHandle(input, this._computeContent(input));
+ const handle = manager.createHandle(input, this._computeContent(input));
this._hoverHandles.set(input, handle);
// Cache the enclosing item's id — stable for this input's life, and we
// need it on every hover event to decide whether to yield to the caret.
@@ -366,6 +383,11 @@ export default class TodoListMultistateEditing extends Plugin {
* `showAfter(TOOLTIP_DWELL_MS)`, so drive-throughs don't spawn a tooltip.
*/
private _syncCaretTooltip(options: { forceShowIfSameTarget: boolean }): void {
+ const manager = this._hintManager;
+ /* v8 ignore next 3 -- gated same as _refreshHoverHandles, see there. */
+ if (!manager) {
+ return;
+ }
const target = this._findCaretCheckbox();
const targetItemId = target?.closest<HTMLElement>("li")?.getAttribute("data-list-item-id") ?? null;
const itemChanged = targetItemId !== this._caretItemId;
@@ -386,7 +408,7 @@ export default class TodoListMultistateEditing extends Plugin {
but then `_caretInput` was null too, so `inputChanged`
would be false and we wouldn't be in this branch. */
if (target) {
- this._caretHandle = this._hintManager.createHandle(target, this._computeContent(target));
+ this._caretHandle = manager.createHandle(target, this._computeContent(target));
this._caretHandle.show();
}
/* v8 ignore start -- reachable only when `forceShowIfSameTarget`
@@ -407,7 +429,7 @@ export default class TodoListMultistateEditing extends Plugin {
this._caretInput = target;
this._caretItemId = targetItemId;
if (target) {
- this._caretHandle = this._hintManager.createHandle(target, this._computeContent(target));
+ this._caretHandle = manager.createHandle(target, this._computeContent(target));
this._caretHandle.showAfter(TOOLTIP_DWELL_MS);
}
}
diff --git a/packages/commons/src/lib/options_interface.ts b/packages/commons/src/lib/options_interface.ts
index 4b51fe8d48..3bc4e1a051 100644
--- a/packages/commons/src/lib/options_interface.ts
+++ b/packages/commons/src/lib/options_interface.ts
@@ -187,6 +187,8 @@ export interface OptionDefinitions extends KeyboardShortcutsOptions<KeyboardActi
textNoteCompletionEnabled: boolean;
/** Whether keyboard auto-completion for editing commands is triggered when typing `/`. */
textNoteSlashCommandsEnabled: boolean;
+ /** Whether the editor surfaces content-area hints (bottom-corner popups that document how to interact with the element under the caret or pointer, e.g. task-state cycle, collapsible-summary shortcut, drag-handle label). */
+ textNoteContentHintsEnabled: boolean;
backgroundEffects: boolean;
newLayout: boolean;
diff --git a/packages/trilium-core/src/routes/api/options.ts b/packages/trilium-core/src/routes/api/options.ts
index c17ef81d02..d7cbb52a0f 100644
--- a/packages/trilium-core/src/routes/api/options.ts
+++ b/packages/trilium-core/src/routes/api/options.ts
@@ -111,6 +111,7 @@ const ALLOWED_OPTIONS = new Set<OptionNames>([
"textNoteEmojiCompletionEnabled",
"textNoteCompletionEnabled",
"textNoteSlashCommandsEnabled",
+ "textNoteContentHintsEnabled",
"includeNoteDefaultBoxSize",
"layoutOrientation",
"backgroundEffects",
diff --git a/packages/trilium-core/src/services/options_init.ts b/packages/trilium-core/src/services/options_init.ts
index e3a4a2a18b..f2f9c68c79 100644
--- a/packages/trilium-core/src/services/options_init.ts
+++ b/packages/trilium-core/src/services/options_init.ts
@@ -248,6 +248,7 @@ const defaultOptions: DefaultOption[] = [
{ name: "textNoteEmojiCompletionEnabled", value: "true", isSynced: true },
{ name: "textNoteCompletionEnabled", value: "true", isSynced: true },
{ name: "textNoteSlashCommandsEnabled", value: "true", isSynced: true },
+ { name: "textNoteContentHintsEnabled", value: "true", isSynced: true },
{ name: "includeNoteDefaultBoxSize", value: "medium", isSynced: true },
// HTML import configuration