From 763bcbd394feee330a3997b799c1ad5b4d3bd720 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 5 Oct 2025 16:45:26 +0300 Subject: [PATCH] refactor(react/type_widgets): extract full height to note types --- apps/client/src/widgets/NoteDetail.tsx | 2 +- apps/client/src/widgets/note_types.tsx | 22 +++++++++++++++------- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/apps/client/src/widgets/NoteDetail.tsx b/apps/client/src/widgets/NoteDetail.tsx index db936228d..617380c76 100644 --- a/apps/client/src/widgets/NoteDetail.tsx +++ b/apps/client/src/widgets/NoteDetail.tsx @@ -229,7 +229,7 @@ function checkFullHeight(noteContext: NoteContext | undefined, type: ExtendedNot // https://github.com/zadam/trilium/issues/2522 const isBackendNote = noteContext?.noteId === "_backendLog"; const isSqlNote = noteContext.note?.mime === "text/x-sqlite;schema=trilium"; - const isFullHeightNoteType = ["canvas", "webView", "noteMap", "mindMap", "mermaid", "file", "aiChat"].includes(type ?? ""); + const isFullHeightNoteType = type && TYPE_MAPPINGS[type].isFullHeight; return (!noteContext?.hasNoteList() && isFullHeightNoteType && !isSqlNote) || noteContext?.viewScope?.viewMode === "attachments" || isBackendNote; diff --git a/apps/client/src/widgets/note_types.tsx b/apps/client/src/widgets/note_types.tsx index a8e3086b9..7045ac57b 100644 --- a/apps/client/src/widgets/note_types.tsx +++ b/apps/client/src/widgets/note_types.tsx @@ -21,6 +21,7 @@ interface NoteTypeMapping { printable?: boolean; /** The class name to assign to the note type wrapper */ className: string; + isFullHeight?: boolean; } export const TYPE_MAPPINGS: Record = { @@ -56,12 +57,14 @@ export const TYPE_MAPPINGS: Record = { webView: { view: () => import("./type_widgets/WebView"), className: "note-detail-web-view", - printable: true + printable: true, + isFullHeight: true }, file: { view: () => import("./type_widgets/File"), className: "note-detail-file", - printable: true + printable: true, + isFullHeight: true }, image: { view: () => import("./type_widgets/Image"), @@ -81,12 +84,14 @@ export const TYPE_MAPPINGS: Record = { mermaid: { view: () => import("./type_widgets/Mermaid"), className: "note-detail-mermaid", - printable: true + printable: true, + isFullHeight: true }, mindMap: { view: () => import("./type_widgets/MindMap"), className: "note-detail-mind-map", - printable: true + printable: true, + isFullHeight: true }, attachmentList: { view: async () => (await import("./type_widgets/Attachment")).AttachmentList, @@ -115,7 +120,8 @@ export const TYPE_MAPPINGS: Record = { canvas: { view: () => import("./type_widgets/Canvas"), className: "note-detail-canvas", - printable: true + printable: true, + isFullHeight: true }, relationMap: { view: () => import("./type_widgets/relation_map/RelationMap"), @@ -125,10 +131,12 @@ export const TYPE_MAPPINGS: Record = { noteMap: { view: () => import("./type_widgets/NoteMap"), className: "note-detail-note-map", - printable: true + printable: true, + isFullHeight: true }, aiChat: { view: () => import("./type_widgets/AiChat"), - className: "ai-chat-widget-container" + className: "ai-chat-widget-container", + isFullHeight: true } };