mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
link map contains also backward references and tree map contains parents as well, closes #2270
This commit is contained in:
parent
21dedff9bf
commit
a9df0c485f
@ -31,8 +31,13 @@ function getNeighbors(note, depth) {
|
||||
|
||||
const retNoteIds = [];
|
||||
|
||||
function isIgnoredRelation(relation) {
|
||||
return ['relationMapLink', 'template', 'image'].includes(relation.name);
|
||||
}
|
||||
|
||||
// forward links
|
||||
for (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]',
|
||||
|
Loading…
x
Reference in New Issue
Block a user