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
link map improvements
zadamdf9f6ce33aa2
diff --git a/src/public/app/widgets/note_map.js b/src/public/app/widgets/note_map.jsindex b3126f1721..2ab8f7d51f 100644--- a/src/public/app/widgets/note_map.js+++ b/src/public/app/widgets/note_map.js@@ -329,7 +329,7 @@ export default class NoteMapWidget extends NoteContextAwareWidget {renderData(data) {this.graph.graphData(data);- if (this.widgetMode === 'ribbon') {+ if (this.widgetMode === 'ribbon' && this.note?.type !== 'search') {setTimeout(() => {this.setDimensions();@@ -342,14 +342,18 @@ export default class NoteMapWidget extends NoteContextAwareWidget {}}, 1000);}- else if (this.widgetMode === 'type') {+ else {if (data.nodes.length > 1) {setTimeout(() => {this.setDimensions();- this.graph.zoomToFit(400, 10);+ const noteIdsWithLinks = this.getNoteIdsWithLinks(data);++ if (noteIdsWithLinks.size > 0) {+ this.graph.zoomToFit(400, 30, node => noteIdsWithLinks.has(node.id));+ }- if (data.nodes.length < 30) {+ if (noteIdsWithLinks.size < 30) {this.graph.d3VelocityDecay(0.4);}}, 1000);@@ -357,6 +361,17 @@ export default class NoteMapWidget extends NoteContextAwareWidget {}}+ getNoteIdsWithLinks(data) {+ const noteIds = new Set();++ for (const link of data.links) {+ noteIds.add(link.source.id);+ noteIds.add(link.target.id);+ }++ return noteIds;+ }+getSubGraphConnectedToCurrentNote(data) {function getGroupedLinks(links, type) {const map = {};diff --git a/src/routes/api/note_map.js b/src/routes/api/note_map.jsindex da3d00f057..9b49c8d3c1 100644--- a/src/routes/api/note_map.js+++ b/src/routes/api/note_map.js@@ -94,6 +94,10 @@ function getLinkMap(req) {.map(note => note.noteId));+ if (mapRootNote.type === 'search') {+ noteIds.delete(mapRootNote.noteId);+ }+for (const noteId of getNeighbors(mapRootNote, 3)) {noteIds.add(noteId);}