mirror of
https://github.com/zadam/trilium.git
synced 2025-11-11 07:45:51 +01:00
chore(react): bring back interaction with nodes
This commit is contained in:
@@ -84,16 +84,7 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
|
|||||||
// Rendering code was here
|
// 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 nodeLinkRatio = data.nodes.length / data.links.length;
|
||||||
const magnifiedRatio = Math.pow(nodeLinkRatio, 1.5);
|
const magnifiedRatio = Math.pow(nodeLinkRatio, 1.5);
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ import { RefObject } from "preact";
|
|||||||
import FNote from "../../entities/fnote";
|
import FNote from "../../entities/fnote";
|
||||||
import { useElementSize, useNoteContext, useNoteLabel } from "../react/hooks";
|
import { useElementSize, useNoteContext, useNoteLabel } from "../react/hooks";
|
||||||
import ForceGraph, { LinkObject, NodeObject } from "force-graph";
|
import ForceGraph, { LinkObject, NodeObject } from "force-graph";
|
||||||
import { loadNotesAndRelations, NotesAndRelationsData } from "./data";
|
import { loadNotesAndRelations, Node, NotesAndRelationsData } from "./data";
|
||||||
import { CssData, setupRendering } from "./rendering";
|
import { CssData, setupRendering } from "./rendering";
|
||||||
import ActionButton from "../react/ActionButton";
|
import ActionButton from "../react/ActionButton";
|
||||||
import { t } from "../../services/i18n";
|
import { t } from "../../services/i18n";
|
||||||
|
import link_context_menu from "../../menus/link_context_menu";
|
||||||
|
import appContext from "../../components/app_context";
|
||||||
|
|
||||||
interface NoteMapProps {
|
interface NoteMapProps {
|
||||||
note: FNote;
|
note: FNote;
|
||||||
@@ -42,6 +44,8 @@ export default function NoteMap({ note, widgetMode, parentRef }: NoteMapProps) {
|
|||||||
loadNotesAndRelations(mapRootId, excludeRelations, includeRelations, mapType).then((notesAndRelations) => {
|
loadNotesAndRelations(mapRootId, excludeRelations, includeRelations, mapType).then((notesAndRelations) => {
|
||||||
if (!containerRef.current || !styleResolverRef.current) return;
|
if (!containerRef.current || !styleResolverRef.current) return;
|
||||||
const cssData = getCssData(containerRef.current, styleResolverRef.current);
|
const cssData = getCssData(containerRef.current, styleResolverRef.current);
|
||||||
|
|
||||||
|
// Configure rendering properties.
|
||||||
setupRendering(graph, {
|
setupRendering(graph, {
|
||||||
cssData,
|
cssData,
|
||||||
noteId: note.noteId,
|
noteId: note.noteId,
|
||||||
@@ -51,6 +55,19 @@ export default function NoteMap({ note, widgetMode, parentRef }: NoteMapProps) {
|
|||||||
widgetMode,
|
widgetMode,
|
||||||
mapType
|
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);
|
graph.graphData(notesAndRelations);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user