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
tweaks to note map
zadam208492bee1ed
diff --git a/src/becca/entities/note.js b/src/becca/entities/note.jsindex e0b2227723..083eac7f98 100644--- a/src/becca/entities/note.js+++ b/src/becca/entities/note.js@@ -746,17 +746,23 @@ class Note extends AbstractEntity {/** @return {Note[]} */getSubtreeNotes(includeArchived = true) {- if (this.isArchived) {- return [];- }+ const noteSet = new Set();- const arr = [[this]];+ function addSubtreeNotesInner(note) {+ if (!includeArchived && note.isArchived) {+ return;+ }- for (const childNote of this.children) {- arr.push(childNote.getSubtreeNotes(includeArchived));+ noteSet.add(note);++ for (const childNote of note.children) {+ addSubtreeNotesInner(childNote);+ }}- return arr.flat();+ addSubtreeNotesInner(this);++ return Array.from(noteSet);}/** @return {String[]} */diff --git a/src/public/app/widgets/type_widgets/note_map.js b/src/public/app/widgets/type_widgets/note_map.jsindex e44c4dbdb1..ff723db112 100644--- a/src/public/app/widgets/type_widgets/note_map.js+++ b/src/public/app/widgets/type_widgets/note_map.js@@ -87,33 +87,31 @@ export default class NoteMapTypeWidget extends TypeWidget {.d3VelocityDecay(0.08).nodeCanvasObject((node, ctx) => this.paintNode(node, this.stringToColor(node.type), ctx)).nodePointerAreaPaint((node, ctx) => this.paintNode(node, this.stringToColor(node.type), ctx))- .nodeLabel(node => node.name)- .maxZoom(7).nodePointerAreaPaint((node, color, ctx) => {ctx.fillStyle = color;ctx.beginPath();ctx.arc(node.x, node.y, this.noteIdToSizeMap[node.id], 0, 2 * Math.PI, false);ctx.fill();})- .linkLabel(l => `${l.source.name} - <strong>${l.name}</strong> - ${l.target.name}`)- .linkCanvasObject((link, ctx) => this.paintLink(link, ctx))- .linkCanvasObjectMode(() => "after")+ .nodeLabel(node => node.name)+ .maxZoom(7).warmupTicks(10)-// .linkDirectionalArrowLength(5)+ .linkDirectionalArrowLength(5).linkDirectionalArrowRelPos(1).linkWidth(1).linkColor(() => this.css.mutedTextColor)-// .d3VelocityDecay(0.2)-// .dagMode("radialout").onNodeClick(node => this.nodeClicked(node));+ if (this.mapType === 'link') {+ this.graph+ .linkLabel(l => `${l.source.name} - <strong>${l.name}</strong> - ${l.target.name}`)+ .linkCanvasObject((link, ctx) => this.paintLink(link, ctx))+ .linkCanvasObjectMode(() => "after");+ }+this.graph.d3Force('link').distance(40);- //this.graph.d3Force('center').strength(0.01);- //this.graph.d3Force('charge').strength(-30);--this.graph.d3Force('charge').distanceMax(1000);let mapRootNoteId = this.note.getLabelValue("mapRootNoteId");diff --git a/src/routes/api/link_map.js b/src/routes/api/link_map.jsindex 91fe31a0ad..8ef959e201 100644--- a/src/routes/api/link_map.js+++ b/src/routes/api/link_map.js@@ -151,6 +151,19 @@ function getGlobalTreeMap(req) {const notes = mapRootNote.getSubtreeNotes(false).filter(note => !note.hasLabel('excludeFromTreeMap'))+ .filter(note => {+ if (note.type !== 'image' || note.getChildNotes().length > 0) {+ return true;+ }++ const imageLinkRelation = note.getTargetRelations().find(rel => rel.name === 'imageLink');++ if (!imageLinkRelation) {+ return true;+ }++ return !note.getParentNotes().find(parentNote => parentNote.noteId === imageLinkRelation.noteId);+ }).map(note => [note.noteId,note.isContentAvailable() ? note.title : '[protected]',@@ -169,8 +182,7 @@ function getGlobalTreeMap(req) {links.push({id: branch.branchId,sourceNoteId: branch.parentNoteId,- targetNoteId: branch.noteId,- name: 'branch'+ targetNoteId: branch.noteId});}