From 8f8493f3ec9866ecb8dae43ffcf41b65f27ec4db Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Fri, 2 Jan 2026 23:06:08 +0200 Subject: [PATCH] client/note split: allow enabling background effects according to the MIME type --- apps/client/src/widgets/note_wrapper.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/apps/client/src/widgets/note_wrapper.ts b/apps/client/src/widgets/note_wrapper.ts index 2b8959d11..fa912e25a 100644 --- a/apps/client/src/widgets/note_wrapper.ts +++ b/apps/client/src/widgets/note_wrapper.ts @@ -64,7 +64,8 @@ export default class NoteWrapperWidget extends FlexContainer { 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(["bgfx", "options"], note.isOptions()); + this.$widget.toggleClass("options", note.isOptions()); + this.$widget.toggleClass("bgfx", this.#hasBackgroundEffects(note)); this.$widget.toggleClass("protected", note.isProtected); const noteLanguage = note?.getLabelValue("language"); @@ -88,6 +89,22 @@ export default class NoteWrapperWidget extends FlexContainer { return !!note?.isLabelTruthy("fullContentWidth"); } + #hasBackgroundEffects(note: FNote): boolean { + const MIME_TYPES_WITH_BACKGROUND_EFFECTS = [ + "application/pdf" + ] + + if (note.isOptions()) { + return true; + } + + if (note.type === "file" && MIME_TYPES_WITH_BACKGROUND_EFFECTS.includes(note.mime)) { + return true; + } + + return false; + } + async entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) { // listening on changes of note.type and CSS class const LABELS_CAUSING_REFRESH = ["cssClass", "language", "viewType", "color"];