refactor(react/type_widgets): extract full height to note types

This commit is contained in:
Elian Doran 2025-10-05 16:45:26 +03:00
parent d90043e586
commit 763bcbd394
No known key found for this signature in database
2 changed files with 16 additions and 8 deletions

View File

@ -229,7 +229,7 @@ function checkFullHeight(noteContext: NoteContext | undefined, type: ExtendedNot
// https://github.com/zadam/trilium/issues/2522 // https://github.com/zadam/trilium/issues/2522
const isBackendNote = noteContext?.noteId === "_backendLog"; const isBackendNote = noteContext?.noteId === "_backendLog";
const isSqlNote = noteContext.note?.mime === "text/x-sqlite;schema=trilium"; 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) return (!noteContext?.hasNoteList() && isFullHeightNoteType && !isSqlNote)
|| noteContext?.viewScope?.viewMode === "attachments" || noteContext?.viewScope?.viewMode === "attachments"
|| isBackendNote; || isBackendNote;

View File

@ -21,6 +21,7 @@ interface NoteTypeMapping {
printable?: boolean; printable?: boolean;
/** The class name to assign to the note type wrapper */ /** The class name to assign to the note type wrapper */
className: string; className: string;
isFullHeight?: boolean;
} }
export const TYPE_MAPPINGS: Record<ExtendedNoteType, NoteTypeMapping> = { export const TYPE_MAPPINGS: Record<ExtendedNoteType, NoteTypeMapping> = {
@ -56,12 +57,14 @@ export const TYPE_MAPPINGS: Record<ExtendedNoteType, NoteTypeMapping> = {
webView: { webView: {
view: () => import("./type_widgets/WebView"), view: () => import("./type_widgets/WebView"),
className: "note-detail-web-view", className: "note-detail-web-view",
printable: true printable: true,
isFullHeight: true
}, },
file: { file: {
view: () => import("./type_widgets/File"), view: () => import("./type_widgets/File"),
className: "note-detail-file", className: "note-detail-file",
printable: true printable: true,
isFullHeight: true
}, },
image: { image: {
view: () => import("./type_widgets/Image"), view: () => import("./type_widgets/Image"),
@ -81,12 +84,14 @@ export const TYPE_MAPPINGS: Record<ExtendedNoteType, NoteTypeMapping> = {
mermaid: { mermaid: {
view: () => import("./type_widgets/Mermaid"), view: () => import("./type_widgets/Mermaid"),
className: "note-detail-mermaid", className: "note-detail-mermaid",
printable: true printable: true,
isFullHeight: true
}, },
mindMap: { mindMap: {
view: () => import("./type_widgets/MindMap"), view: () => import("./type_widgets/MindMap"),
className: "note-detail-mind-map", className: "note-detail-mind-map",
printable: true printable: true,
isFullHeight: true
}, },
attachmentList: { attachmentList: {
view: async () => (await import("./type_widgets/Attachment")).AttachmentList, view: async () => (await import("./type_widgets/Attachment")).AttachmentList,
@ -115,7 +120,8 @@ export const TYPE_MAPPINGS: Record<ExtendedNoteType, NoteTypeMapping> = {
canvas: { canvas: {
view: () => import("./type_widgets/Canvas"), view: () => import("./type_widgets/Canvas"),
className: "note-detail-canvas", className: "note-detail-canvas",
printable: true printable: true,
isFullHeight: true
}, },
relationMap: { relationMap: {
view: () => import("./type_widgets/relation_map/RelationMap"), view: () => import("./type_widgets/relation_map/RelationMap"),
@ -125,10 +131,12 @@ export const TYPE_MAPPINGS: Record<ExtendedNoteType, NoteTypeMapping> = {
noteMap: { noteMap: {
view: () => import("./type_widgets/NoteMap"), view: () => import("./type_widgets/NoteMap"),
className: "note-detail-note-map", className: "note-detail-note-map",
printable: true printable: true,
isFullHeight: true
}, },
aiChat: { aiChat: {
view: () => import("./type_widgets/AiChat"), view: () => import("./type_widgets/AiChat"),
className: "ai-chat-widget-container" className: "ai-chat-widget-container",
isFullHeight: true
} }
}; };