mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
tweaks to note map
This commit is contained in:
parent
b0d767df69
commit
208492bee1
@ -746,17 +746,23 @@ class Note extends AbstractEntity {
|
|||||||
|
|
||||||
/** @return {Note[]} */
|
/** @return {Note[]} */
|
||||||
getSubtreeNotes(includeArchived = true) {
|
getSubtreeNotes(includeArchived = true) {
|
||||||
if (this.isArchived) {
|
const noteSet = new Set();
|
||||||
return [];
|
|
||||||
|
function addSubtreeNotesInner(note) {
|
||||||
|
if (!includeArchived && note.isArchived) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
noteSet.add(note);
|
||||||
|
|
||||||
|
for (const childNote of note.children) {
|
||||||
|
addSubtreeNotesInner(childNote);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const arr = [[this]];
|
addSubtreeNotesInner(this);
|
||||||
|
|
||||||
for (const childNote of this.children) {
|
return Array.from(noteSet);
|
||||||
arr.push(childNote.getSubtreeNotes(includeArchived));
|
|
||||||
}
|
|
||||||
|
|
||||||
return arr.flat();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {String[]} */
|
/** @return {String[]} */
|
||||||
|
@ -87,33 +87,31 @@ export default class NoteMapTypeWidget extends TypeWidget {
|
|||||||
.d3VelocityDecay(0.08)
|
.d3VelocityDecay(0.08)
|
||||||
.nodeCanvasObject((node, ctx) => this.paintNode(node, this.stringToColor(node.type), ctx))
|
.nodeCanvasObject((node, ctx) => this.paintNode(node, this.stringToColor(node.type), ctx))
|
||||||
.nodePointerAreaPaint((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) => {
|
.nodePointerAreaPaint((node, color, ctx) => {
|
||||||
ctx.fillStyle = color;
|
ctx.fillStyle = color;
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
ctx.arc(node.x, node.y, this.noteIdToSizeMap[node.id], 0, 2 * Math.PI, false);
|
ctx.arc(node.x, node.y, this.noteIdToSizeMap[node.id], 0, 2 * Math.PI, false);
|
||||||
ctx.fill();
|
ctx.fill();
|
||||||
})
|
})
|
||||||
.linkLabel(l => `${l.source.name} - <strong>${l.name}</strong> - ${l.target.name}`)
|
.nodeLabel(node => node.name)
|
||||||
.linkCanvasObject((link, ctx) => this.paintLink(link, ctx))
|
.maxZoom(7)
|
||||||
.linkCanvasObjectMode(() => "after")
|
|
||||||
.warmupTicks(10)
|
.warmupTicks(10)
|
||||||
// .linkDirectionalArrowLength(5)
|
.linkDirectionalArrowLength(5)
|
||||||
.linkDirectionalArrowRelPos(1)
|
.linkDirectionalArrowRelPos(1)
|
||||||
.linkWidth(1)
|
.linkWidth(1)
|
||||||
.linkColor(() => this.css.mutedTextColor)
|
.linkColor(() => this.css.mutedTextColor)
|
||||||
// .d3VelocityDecay(0.2)
|
|
||||||
// .dagMode("radialout")
|
|
||||||
.onNodeClick(node => this.nodeClicked(node));
|
.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('link').distance(40);
|
||||||
//
|
|
||||||
this.graph.d3Force('center').strength(0.01);
|
this.graph.d3Force('center').strength(0.01);
|
||||||
//
|
|
||||||
this.graph.d3Force('charge').strength(-30);
|
this.graph.d3Force('charge').strength(-30);
|
||||||
|
|
||||||
|
|
||||||
this.graph.d3Force('charge').distanceMax(1000);
|
this.graph.d3Force('charge').distanceMax(1000);
|
||||||
|
|
||||||
let mapRootNoteId = this.note.getLabelValue("mapRootNoteId");
|
let mapRootNoteId = this.note.getLabelValue("mapRootNoteId");
|
||||||
|
@ -151,6 +151,19 @@ function getGlobalTreeMap(req) {
|
|||||||
|
|
||||||
const notes = mapRootNote.getSubtreeNotes(false)
|
const notes = mapRootNote.getSubtreeNotes(false)
|
||||||
.filter(note => !note.hasLabel('excludeFromTreeMap'))
|
.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 => [
|
.map(note => [
|
||||||
note.noteId,
|
note.noteId,
|
||||||
note.isContentAvailable() ? note.title : '[protected]',
|
note.isContentAvailable() ? note.title : '[protected]',
|
||||||
@ -169,8 +182,7 @@ function getGlobalTreeMap(req) {
|
|||||||
links.push({
|
links.push({
|
||||||
id: branch.branchId,
|
id: branch.branchId,
|
||||||
sourceNoteId: branch.parentNoteId,
|
sourceNoteId: branch.parentNoteId,
|
||||||
targetNoteId: branch.noteId,
|
targetNoteId: branch.noteId
|
||||||
name: 'branch'
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user