From a4d6da72a103ccb7b41f7db28448e5ceafb4e420 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 4 Oct 2025 13:17:57 +0300 Subject: [PATCH] chore(react): bring back interaction with nodes --- apps/client/src/widgets/note_map.ts | 11 +---------- apps/client/src/widgets/note_map/NoteMap.tsx | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/apps/client/src/widgets/note_map.ts b/apps/client/src/widgets/note_map.ts index 77780e83b..36b4ec98e 100644 --- a/apps/client/src/widgets/note_map.ts +++ b/apps/client/src/widgets/note_map.ts @@ -84,16 +84,7 @@ export default class NoteMapWidget extends NoteContextAwareWidget { // Rendering code was here - .onNodeClick((node) => { - if (node.id) { - appContext.tabManager.getActiveContext()?.setNote((node as Node).id); - } - }) - .onNodeRightClick((node, e) => { - if (node.id) { - linkContextMenuService.openContextMenu((node as Node).id, e); - } - }); + const nodeLinkRatio = data.nodes.length / data.links.length; const magnifiedRatio = Math.pow(nodeLinkRatio, 1.5); diff --git a/apps/client/src/widgets/note_map/NoteMap.tsx b/apps/client/src/widgets/note_map/NoteMap.tsx index 8b0193896..87462499c 100644 --- a/apps/client/src/widgets/note_map/NoteMap.tsx +++ b/apps/client/src/widgets/note_map/NoteMap.tsx @@ -5,10 +5,12 @@ import { RefObject } from "preact"; import FNote from "../../entities/fnote"; import { useElementSize, useNoteContext, useNoteLabel } from "../react/hooks"; import ForceGraph, { LinkObject, NodeObject } from "force-graph"; -import { loadNotesAndRelations, NotesAndRelationsData } from "./data"; +import { loadNotesAndRelations, Node, NotesAndRelationsData } from "./data"; import { CssData, setupRendering } from "./rendering"; import ActionButton from "../react/ActionButton"; import { t } from "../../services/i18n"; +import link_context_menu from "../../menus/link_context_menu"; +import appContext from "../../components/app_context"; interface NoteMapProps { note: FNote; @@ -42,6 +44,8 @@ export default function NoteMap({ note, widgetMode, parentRef }: NoteMapProps) { loadNotesAndRelations(mapRootId, excludeRelations, includeRelations, mapType).then((notesAndRelations) => { if (!containerRef.current || !styleResolverRef.current) return; const cssData = getCssData(containerRef.current, styleResolverRef.current); + + // Configure rendering properties. setupRendering(graph, { cssData, noteId: note.noteId, @@ -51,6 +55,19 @@ export default function NoteMap({ note, widgetMode, parentRef }: NoteMapProps) { widgetMode, mapType }); + + // Interaction + graph + .onNodeClick((node) => { + if (!node.id) return; + appContext.tabManager.getActiveContext()?.setNote((node as Node).id); + }) + .onNodeRightClick((node, e) => { + if (!node.id) return; + link_context_menu.openContextMenu((node as Node).id, e); + }); + + // Set data graph.graphData(notesAndRelations); });