mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 10:26:08 +01:00 
			
		
		
		
	link map improvements
This commit is contained in:
		| @@ -329,7 +329,7 @@ export default class NoteMapWidget extends NoteContextAwareWidget { | |||||||
|     renderData(data) { |     renderData(data) { | ||||||
|         this.graph.graphData(data); |         this.graph.graphData(data); | ||||||
|  |  | ||||||
|         if (this.widgetMode === 'ribbon') { |         if (this.widgetMode === 'ribbon' && this.note?.type !== 'search') { | ||||||
|             setTimeout(() => { |             setTimeout(() => { | ||||||
|                 this.setDimensions(); |                 this.setDimensions(); | ||||||
|  |  | ||||||
| @@ -342,14 +342,18 @@ export default class NoteMapWidget extends NoteContextAwareWidget { | |||||||
|                 } |                 } | ||||||
|             }, 1000); |             }, 1000); | ||||||
|         } |         } | ||||||
|         else if (this.widgetMode === 'type') { |         else { | ||||||
|             if (data.nodes.length > 1) { |             if (data.nodes.length > 1) { | ||||||
|                 setTimeout(() => { |                 setTimeout(() => { | ||||||
|                     this.setDimensions(); |                     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); |                         this.graph.d3VelocityDecay(0.4); | ||||||
|                     } |                     } | ||||||
|                 }, 1000); |                 }, 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) { |     getSubGraphConnectedToCurrentNote(data) { | ||||||
|         function getGroupedLinks(links, type) { |         function getGroupedLinks(links, type) { | ||||||
|             const map = {}; |             const map = {}; | ||||||
|   | |||||||
| @@ -94,6 +94,10 @@ function getLinkMap(req) { | |||||||
|             .map(note => note.noteId) |             .map(note => note.noteId) | ||||||
|     ); |     ); | ||||||
|  |  | ||||||
|  |     if (mapRootNote.type === 'search') { | ||||||
|  |         noteIds.delete(mapRootNote.noteId); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     for (const noteId of getNeighbors(mapRootNote, 3)) { |     for (const noteId of getNeighbors(mapRootNote, 3)) { | ||||||
|         noteIds.add(noteId); |         noteIds.add(noteId); | ||||||
|     } |     } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user