mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 05:28:59 +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[]} */
 | 
			
		||||
    getSubtreeNotes(includeArchived = true) {
 | 
			
		||||
        if (this.isArchived) {
 | 
			
		||||
            return [];
 | 
			
		||||
        const noteSet = new Set();
 | 
			
		||||
 | 
			
		||||
        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) {
 | 
			
		||||
            arr.push(childNote.getSubtreeNotes(includeArchived));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return arr.flat();
 | 
			
		||||
        return Array.from(noteSet);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /** @return {String[]} */
 | 
			
		||||
 | 
			
		||||
@ -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");
 | 
			
		||||
 | 
			
		||||
@ -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
 | 
			
		||||
        });
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user