Skip to content

Build your personal knowledge base with Trilium Notes

client/note split: allow enabling background effects according to the MIME type

Adorian Doran8f8493f3ec98
diff --git a/apps/client/src/widgets/note_wrapper.ts b/apps/client/src/widgets/note_wrapper.ts
index 2b8959d113..fa912e25a8 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<BasicWidget> {
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<BasicWidget> {
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"];