Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
fix(client): note map card missing the styling the pane gives its cards
Elian Doran893a9aafde5d
diff --git a/apps/client/src/widgets/sidebar/NoteMap.tsx b/apps/client/src/widgets/sidebar/NoteMap.tsxindex 14abbc9fb3..3dd1688ef9 100644--- a/apps/client/src/widgets/sidebar/NoteMap.tsx+++ b/apps/client/src/widgets/sidebar/NoteMap.tsx@@ -1,29 +1,18 @@-import "./NoteMap.css";--import { useRef } from "preact/hooks";-import { t } from "../../services/i18n";-// The map itself is shared with the ribbon's note map tab and the note map note type;-// only the framing differs here.-import NoteMapEl from "../note_map/NoteMap";-import { useActiveNoteContext } from "../react/hooks";+import LazyComponent from "../react/LazyComponent";import RightPanelWidget from "./RightPanelWidget";+/**+ * The card is rendered here and the map itself loaded on demand from within it, rather than the whole+ * widget being loaded on demand from the pane: the lazy wrapper is a `display: contents` element, which+ * leaves no box but is still an element as far as selectors are concerned, so a card behind it is no+ * longer a child of the tab body and misses everything the pane styles by that relation — its dividing+ * border, the first card's header padding, the sharing out of the tab's height.+ */export default function NoteMap() {- const { note } = useActiveNoteContext();- const containerRef = useRef<HTMLDivElement>(null);-return (<RightPanelWidget id="noteMap" title={t("note_map.title")}>- {note && (- <div class="sidebar-note-map" ref={containerRef}>- {/* "sidebar" mode roots the map at the note being read, which is what a- connections panel is about (the other modes root it at a configured- or hoisted note), and drops the notes nothing links to — see- loadNotesAndRelations. */}- <NoteMapEl note={note} widgetMode="sidebar" parentRef={containerRef} />- </div>- )}+ <LazyComponent loader={() => import("./NoteMapGraph.jsx")} /></RightPanelWidget>);}diff --git a/apps/client/src/widgets/sidebar/NoteMapGraph.tsx b/apps/client/src/widgets/sidebar/NoteMapGraph.tsxnew file mode 100644index 0000000000..a9d3a6f505--- /dev/null+++ b/apps/client/src/widgets/sidebar/NoteMapGraph.tsx@@ -0,0 +1,31 @@+import "./NoteMap.css";++import { useRef } from "preact/hooks";++// The map itself is shared with the ribbon's note map tab and the note map note type;+// only the framing differs here.+import NoteMapEl from "../note_map/NoteMap";+import { useActiveNoteContext } from "../react/hooks";++/**+ * The map of the connections tab, kept in a module of its own so that the card around it (see+ * NoteMap.tsx) can load it on demand: it pulls in force-graph, which is deliberately kept out of the+ * boot bundle.+ */+export default function NoteMapGraph() {+ const { note } = useActiveNoteContext();+ const containerRef = useRef<HTMLDivElement>(null);++ if (!note) {+ return null;+ }++ return (+ <div class="sidebar-note-map" ref={containerRef}>+ {/* "sidebar" mode roots the map at the note being read, which is what a connections panel+ is about (the other modes root it at a configured or hoisted note), and drops the+ notes nothing links to — see loadNotesAndRelations. */}+ <NoteMapEl note={note} widgetMode="sidebar" parentRef={containerRef} />+ </div>+ );+}diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx b/apps/client/src/widgets/sidebar/RightPanelContainer.tsxindex 484a3bca0b..104f417e1f 100644--- a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx+++ b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx@@ -23,6 +23,7 @@ import AttributeList from "./AttributeList";import Backlinks from "./Backlinks";import ChatHighlightsList from "./ChatHighlightsList";import HighlightsList from "./HighlightsList";+import NoteMap from "./NoteMap";import NotePaths from "./NotePaths";import PdfAnnotations from "./pdf/PdfAnnotations";import PdfAttachments from "./pdf/PdfAttachments";@@ -214,6 +215,18 @@ function useItems(rightPaneVisible: boolean, widgetsByParent: WidgetsByParent):enabled: !!note,tab: "attributes"},+ {+ // The map goes above the lists rather than under them: it is the one card of the tab+ // held to a height of its own, so the room the rest are measured for is what it leaves+ // over — which reads as a heading over them rather than as a block wedged below.+ //+ // The card is rendered here and only the map within it loaded on demand (force-graph is+ // kept out of the boot bundle), so that the card stays a child of the tab body — see+ // NoteMap.tsx.+ el: <NoteMap />,+ enabled: !!note,+ tab: "connections"+ },{// Where the note sits in the tree, above what points at it: placements first, then the// backlinks below take whatever height is left.@@ -231,13 +244,6 @@ function useItems(rightPaneVisible: boolean, widgetsByParent: WidgetsByParent):enabled: !!note,tab: "connections"},- {- // Loaded lazily because the map pulls in force-graph, which is deliberately- // kept out of the boot bundle.- el: <LazyComponent loader={() => import("./NoteMap.jsx")} />,- enabled: !!note,- tab: "connections"- },{el: <TableOfContents />,enabled: (noteType === "text" || noteType === "doc" || isPdf || noteType === "llmChat" || !!note?.isMarkdown()),