mirror of
https://github.com/zadam/trilium.git
synced 2025-02-20 21:13:11 +08:00
link map improvements
This commit is contained in:
parent
b3c87156c2
commit
df9f6ce33a
2 changed files with 23 additions and 4 deletions
|
@ -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 (data.nodes.length < 30) {
|
||||
if (noteIdsWithLinks.size > 0) {
|
||||
this.graph.zoomToFit(400, 30, node => noteIdsWithLinks.has(node.id));
|
||||
}
|
||||
|
||||
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 = {};
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue