Skip to content

Build your personal knowledge base with Trilium Notes

feat(client): prototype a note map section in the connections tab

Elian Dorana069c250c605
diff --git a/apps/client/src/widgets/sidebar/NoteMap.css b/apps/client/src/widgets/sidebar/NoteMap.css
new file mode 100644
index 0000000000..7cee83aed2
--- /dev/null
+++ b/apps/client/src/widgets/sidebar/NoteMap.css
@@ -0,0 +1,10 @@
+.sidebar-note-map {
+ /* Anchors the map's floating buttons (map type, fix nodes), same as the ribbon wrapper. */
+ position: relative;
+ height: 300px;
+ overflow: hidden;
+
+ .note-map-container {
+ height: 100%;
+ }
+}
diff --git a/apps/client/src/widgets/sidebar/NoteMap.tsx b/apps/client/src/widgets/sidebar/NoteMap.tsx
new file mode 100644
index 0000000000..46d326e3ee
--- /dev/null
+++ b/apps/client/src/widgets/sidebar/NoteMap.tsx
@@ -0,0 +1,28 @@
+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 RightPanelWidget from "./RightPanelWidget";
+
+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}>
+ {/* "ribbon" 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). */}
+ <NoteMapEl note={note} widgetMode="ribbon" parentRef={containerRef} />
+ </div>
+ )}
+ </RightPanelWidget>
+ );
+}
diff --git a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx
index 6ea6a821eb..97d8ad8a70 100644
--- a/apps/client/src/widgets/sidebar/RightPanelContainer.tsx
+++ b/apps/client/src/widgets/sidebar/RightPanelContainer.tsx
@@ -204,6 +204,13 @@ 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()),