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 contains also backward references and tree map contains parents as well, closes #2270
zadama9df0c485f07
diff --git a/src/routes/api/note_map.js b/src/routes/api/note_map.jsindex 9437e13f5c..a14922b1d6 100644--- a/src/routes/api/note_map.js+++ b/src/routes/api/note_map.js@@ -31,8 +31,13 @@ function getNeighbors(note, depth) {const retNoteIds = [];+ function isIgnoredRelation(relation) {+ return ['relationMapLink', 'template', 'image'].includes(relation.name);+ }++ // forward linksfor (const relation of note.getRelations()) {- if (['relationMapLink', 'template', 'image'].includes(relation.name)) {+ if (isIgnoredRelation(relation)) {continue;}@@ -44,6 +49,20 @@ function getNeighbors(note, depth) {}}+ // backward links+ for (const relation of note.getTargetRelations()) {+ if (isIgnoredRelation(relation)) {+ continue;+ }++ const sourceNote = relation.getNote();+ retNoteIds.push(sourceNote.noteId);++ for (const noteId of getNeighbors(sourceNote, depth - 1)) {+ retNoteIds.push(noteId);+ }+ }+return retNoteIds;}@@ -125,6 +144,7 @@ function getTreeMap(req) {return !note.getParentNotes().find(parentNote => parentNote.noteId === imageLinkRelation.noteId);})+ .concat(...mapRootNote.getParentNotes()).map(note => [note.noteId,note.isContentAvailable() ? note.title : '[protected]',