mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
apply color label also on note map, #3443
This commit is contained in:
parent
9d9305300c
commit
50faa40bad
@ -94,8 +94,8 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
|
||||
.onZoom(zoom => this.setZoomLevel(zoom.k))
|
||||
.d3AlphaDecay(0.01)
|
||||
.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))
|
||||
.nodeCanvasObject((node, ctx) => this.paintNode(node, this.getColorForNode(node), ctx))
|
||||
.nodePointerAreaPaint((node, ctx) => this.paintNode(node, this.getColorForNode(node), ctx))
|
||||
.nodePointerAreaPaint((node, color, ctx) => {
|
||||
ctx.fillStyle = color;
|
||||
ctx.beginPath();
|
||||
@ -151,7 +151,17 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
|
||||
return mapRootNoteId;
|
||||
}
|
||||
|
||||
stringToColor(str) {
|
||||
getColorForNode(node) {
|
||||
if (node.color) {
|
||||
return node.color;
|
||||
} else if (this.widgetMode === 'ribbon' && node.id === this.noteId) {
|
||||
return 'red'; // subtree root mark as red
|
||||
} else {
|
||||
return this.generateColorFromString(node.type);
|
||||
}
|
||||
}
|
||||
|
||||
generateColorFromString(str) {
|
||||
if (this.themeStyle === "dark") {
|
||||
str = "0" + str; // magic lightening modifier
|
||||
}
|
||||
@ -185,7 +195,7 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
|
||||
const {x, y} = node;
|
||||
const size = this.noteIdToSizeMap[node.id];
|
||||
|
||||
ctx.fillStyle = (this.widgetMode === 'ribbon' && node.id === this.noteId) ? 'red' : color;
|
||||
ctx.fillStyle = color;
|
||||
ctx.beginPath();
|
||||
ctx.arc(x, y, size, 0, 2 * Math.PI, false);
|
||||
ctx.fill();
|
||||
@ -253,10 +263,11 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
|
||||
|
||||
const links = this.getGroupedLinks(resp.links);
|
||||
|
||||
this.nodes = resp.notes.map(([noteId, title, type]) => ({
|
||||
this.nodes = resp.notes.map(([noteId, title, type, color]) => ({
|
||||
id: noteId,
|
||||
name: title,
|
||||
type: type,
|
||||
color: color
|
||||
}));
|
||||
|
||||
return {
|
||||
|
@ -116,7 +116,8 @@ function getLinkMap(req) {
|
||||
return [
|
||||
note.noteId,
|
||||
note.getTitleOrProtected(),
|
||||
note.type
|
||||
note.type,
|
||||
note.getLabelValue('color')
|
||||
];
|
||||
});
|
||||
|
||||
@ -175,7 +176,8 @@ function getTreeMap(req) {
|
||||
.map(note => [
|
||||
note.noteId,
|
||||
note.getTitleOrProtected(),
|
||||
note.type
|
||||
note.type,
|
||||
note.getLabelValue('color')
|
||||
]);
|
||||
|
||||
const noteIds = new Set();
|
||||
|
Loading…
x
Reference in New Issue
Block a user