From 659e551cddf5638e8ee18d62a5864f6bd80a7cb0 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 8 Feb 2025 21:49:30 +0200 Subject: [PATCH] feat(client): display PDFs as full width --- src/public/app/widgets/note_wrapper.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/public/app/widgets/note_wrapper.ts b/src/public/app/widgets/note_wrapper.ts index 0dc7580a2..b7df269fe 100644 --- a/src/public/app/widgets/note_wrapper.ts +++ b/src/public/app/widgets/note_wrapper.ts @@ -4,6 +4,7 @@ import attributeService from "../services/attributes.js"; import type BasicWidget from "./basic_widget.js"; import type { EventData } from "../components/app_context.js"; import type NoteContext from "../components/note_context.js"; +import type FNote from "../entities/fnote.js"; export default class NoteWrapperWidget extends FlexContainer { @@ -47,7 +48,7 @@ export default class NoteWrapperWidget extends FlexContainer { return; } - this.$widget.toggleClass("full-content-width", ["image", "mermaid", "book", "render", "canvas", "webView", "mindMap", "geoMap"].includes(note.type) || !!note?.isLabelTruthy("fullContentWidth")); + this.$widget.toggleClass("full-content-width", this.#isFullWidthNote(note)); this.$widget.addClass(note.getCssClass()); @@ -57,6 +58,18 @@ export default class NoteWrapperWidget extends FlexContainer { this.$widget.toggleClass("protected", note.isProtected); } + #isFullWidthNote(note: FNote) { + if (["image", "mermaid", "book", "render", "canvas", "webView", "mindMap", "geoMap"].includes(note.type)) { + return true; + } + + if (note.type === "file" && note.mime === "application/pdf") { + return true; + } + + return !!note?.isLabelTruthy("fullContentWidth"); + } + async entitiesReloadedEvent({ loadResults }: EventData<"entitiesReloaded">) { // listening on changes of note.type and CSS class