Skip to content

Build your personal knowledge base with Trilium Notes

client/content hints: hide in zen mode

Adorian Doraned2253925283
diff --git a/apps/client/src/stylesheets/style.css b/apps/client/src/stylesheets/style.css
index 23adf75053..dac1272d33 100644
--- a/apps/client/src/stylesheets/style.css
+++ b/apps/client/src/stylesheets/style.css
@@ -2244,6 +2244,7 @@ body.zen .inline-title,
body.zen .promoted-attributes-widget,
body.zen .floating-buttons-children > *:not(.bx-edit-alt),
body.zen .action-button,
+body.zen .tooltip.content-hint, /* content-area hints (task states, collapsible summaries, drag handles) */
body.zen .note-split:not(.type-book) .note-list-widget {
display: none !important;
}
diff --git a/packages/ckeditor5-utils/src/content_hint_manager.spec.ts b/packages/ckeditor5-utils/src/content_hint_manager.spec.ts
index 840e46abba..e4ef66198f 100644
--- a/packages/ckeditor5-utils/src/content_hint_manager.spec.ts
+++ b/packages/ckeditor5-utils/src/content_hint_manager.spec.ts
@@ -1,7 +1,7 @@
import { Tooltip } from "bootstrap";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
-import { ContentHintManager, type HintHandle } from "./content_hint_manager.js";
+import { CONTENT_HINT_CLASS, ContentHintManager, type HintHandle } from "./content_hint_manager.js";
/**
* The visible `.tooltip` popup that Bootstrap adds to the body when a tooltip
@@ -219,16 +219,25 @@ describe("ContentHintManager", () => {
});
describe("tooltip options", () => {
- it("applies the base options to every popup", () => {
+ it("applies the base options to every popup, alongside the content-hint marker class", () => {
const scoped = new ContentHintManager({
tooltipOptions: { customClass: "test-scope" }
});
const handle = scoped.createHandle(a, "hello");
handle.show();
expect(livePopup()?.classList.contains("test-scope")).toBe(true);
+ expect(livePopup()?.classList.contains(CONTENT_HINT_CLASS)).toBe(true);
scoped.destroy();
});
+ it("marks the popup as a content hint even when the consumer passes no customClass", () => {
+ // Zen mode hides content hints as a group via this class, so it can't depend on
+ // consumers opting in — the collapsible drag-handle hints pass no customClass.
+ const handle = manager.createHandle(a, "hello");
+ handle.show();
+ expect(livePopup()?.classList.contains(CONTENT_HINT_CLASS)).toBe(true);
+ });
+
it("uses `manual` trigger regardless of what the caller passes", () => {
const scoped = new ContentHintManager({
tooltipOptions: { trigger: "hover" as Tooltip.Options["trigger"] }
diff --git a/packages/ckeditor5-utils/src/content_hint_manager.ts b/packages/ckeditor5-utils/src/content_hint_manager.ts
index ec82780b3b..c115141f84 100644
--- a/packages/ckeditor5-utils/src/content_hint_manager.ts
+++ b/packages/ckeditor5-utils/src/content_hint_manager.ts
@@ -92,12 +92,21 @@ export interface HintHandle {
dispose(): void;
}
+/**
+ * Stamped on every popup a manager renders, on top of whatever `customClass` the
+ * consumer asked for. Gives content hints — which are spread across several plugins
+ * and use different placements — a single hook to address as a group (zen mode hides
+ * them with it).
+ */
+export const CONTENT_HINT_CLASS = "content-hint";
+
export interface ContentHintManagerOptions {
/**
* Bootstrap Tooltip config applied to the popup this manager renders each
* hint into. `trigger` is always forced to `"manual"` because the stack,
* not Bootstrap's hover/focus event bindings, decides when a hint is
- * visible. `html` is always forced to `true`.
+ * visible. `html` is always forced to `true`, and {@link CONTENT_HINT_CLASS}
+ * is always added to `customClass`.
*/
tooltipOptions?: Partial<Tooltip.Options>;
/**
@@ -336,6 +345,7 @@ export class ContentHintManager {
if (top) {
this._currentTooltip = new Tooltip(top.element, {
...this._baseOptions,
+ customClass: this._customClass(),
title: top.content,
html: true,
trigger: "manual"
@@ -345,6 +355,20 @@ export class ContentHintManager {
this._resetAutoHide();
}
+ /**
+ * The consumer's `customClass` with {@link CONTENT_HINT_CLASS} prepended.
+ * Bootstrap also accepts a function form, so preserve that shape when given one.
+ */
+ private _customClass(): Tooltip.Options["customClass"] {
+ const base = this._baseOptions.customClass;
+ if (typeof base === "function") {
+ return function (this: unknown) {
+ return `${CONTENT_HINT_CLASS} ${base.call(this)}`;
+ };
+ }
+ return base ? `${CONTENT_HINT_CLASS} ${base}` : CONTENT_HINT_CLASS;
+ }
+
/**
* (Re)start the auto-hide countdown. Called after every `_render` that
* leaves state stable, so any push / setContent / re-order effectively
diff --git a/packages/ckeditor5-utils/src/index.ts b/packages/ckeditor5-utils/src/index.ts
index c2f564fb0d..822c62507f 100644
--- a/packages/ckeditor5-utils/src/index.ts
+++ b/packages/ckeditor5-utils/src/index.ts
@@ -1 +1 @@
-export { ContentHintManager, type ContentHintManagerOptions, type HintHandle } from "./content_hint_manager.js";
+export { CONTENT_HINT_CLASS, ContentHintManager, type ContentHintManagerOptions, type HintHandle } from "./content_hint_manager.js";