mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-04 13:39:01 +01:00 
			
		
		
		
	added "add child note" button to note tree
This commit is contained in:
		
							parent
							
								
									6df6fe03fa
								
							
						
					
					
						commit
						2338a13749
					
				@ -142,6 +142,22 @@ const TPL = `
 | 
				
			|||||||
    span.fancytree-node.archived {
 | 
					    span.fancytree-node.archived {
 | 
				
			||||||
        opacity: 0.6;
 | 
					        opacity: 0.6;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    .add-note-button {
 | 
				
			||||||
 | 
					        display: none;
 | 
				
			||||||
 | 
					        font-size: 120%;
 | 
				
			||||||
 | 
					        padding: 2px;
 | 
				
			||||||
 | 
					        cursor: pointer;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    .add-note-button:hover {
 | 
				
			||||||
 | 
					        border: 1px solid var(--main-border-color);
 | 
				
			||||||
 | 
					        border-radius: 3px;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    span.fancytree-node:hover .add-note-button {
 | 
				
			||||||
 | 
					        display: inline;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    </style>
 | 
					    </style>
 | 
				
			||||||
    
 | 
					    
 | 
				
			||||||
    <button class="btn btn-sm icon-button bx bx-layer-minus collapse-tree-button" title="Collapse note tree" data-trigger-command="collapseTree"></button>
 | 
					    <button class="btn btn-sm icon-button bx bx-layer-minus collapse-tree-button" title="Collapse note tree" data-trigger-command="collapseTree"></button>
 | 
				
			||||||
@ -189,7 +205,14 @@ export default class NoteTreeWidget extends TabAwareWidget {
 | 
				
			|||||||
        this.$tree = this.$widget.find('.tree');
 | 
					        this.$tree = this.$widget.find('.tree');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        this.$tree.on("click", ".unhoist-button", hoistedNoteService.unhoist);
 | 
					        this.$tree.on("click", ".unhoist-button", hoistedNoteService.unhoist);
 | 
				
			||||||
        this.$tree.on("click", ".refresh-search-button", () => this.refreshSearch());
 | 
					        this.$tree.on("click", ".refresh-search-button", e => this.refreshSearch(e));
 | 
				
			||||||
 | 
					        this.$tree.on("click", ".add-note-button", e => {
 | 
				
			||||||
 | 
					            const node = $.ui.fancytree.getNode(e);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            noteCreateService.createNote(node.data.noteId, {
 | 
				
			||||||
 | 
					                isProtected: node.data.isProtected
 | 
				
			||||||
 | 
					            });
 | 
				
			||||||
 | 
					        });
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // fancytree doesn't support middle click so this is a way to support it
 | 
					        // fancytree doesn't support middle click so this is a way to support it
 | 
				
			||||||
        this.$tree.on('mousedown', '.fancytree-title', e => {
 | 
					        this.$tree.on('mousedown', '.fancytree-title', e => {
 | 
				
			||||||
@ -469,12 +492,24 @@ export default class NoteTreeWidget extends TabAwareWidget {
 | 
				
			|||||||
                const node = data.node;
 | 
					                const node = data.node;
 | 
				
			||||||
                const $span = $(node.span);
 | 
					                const $span = $(node.span);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (node.enhanced) {
 | 
				
			||||||
 | 
					                    return;
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                node.enhanced = true;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                const note = await treeCache.getNote(node.data.noteId);
 | 
					                const note = await treeCache.getNote(node.data.noteId);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                if (note.type === 'search' && $span.find('.refresh-search-button').length === 0) {
 | 
					                if (note.type === 'search') {
 | 
				
			||||||
                    const refreshSearchButton = $('<span>  <span class="refresh-search-button bx bx-refresh" title="Refresh saved search results"></span></span>');
 | 
					                    const $refreshSearchButton = $('<span>  <span class="refresh-search-button bx bx-refresh" title="Refresh saved search results"></span></span>');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                    $span.append(refreshSearchButton);
 | 
					                    $span.append($refreshSearchButton);
 | 
				
			||||||
 | 
					                }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                if (note.type !== 'search') {
 | 
				
			||||||
 | 
					                    const $createChildNoteButton = $('<span>  <span class="add-note-button bx bx-plus" title="Create child note"></span></span>');
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					                    $span.append($createChildNoteButton);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
            },
 | 
					            },
 | 
				
			||||||
            // this is done to automatically lazy load all expanded notes after tree load
 | 
					            // this is done to automatically lazy load all expanded notes after tree load
 | 
				
			||||||
@ -885,8 +920,8 @@ export default class NoteTreeWidget extends TabAwareWidget {
 | 
				
			|||||||
        this.filterHoistedBranch();
 | 
					        this.filterHoistedBranch();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    async refreshSearch() {
 | 
					    async refreshSearch(e) {
 | 
				
			||||||
        const activeNode = this.getActiveNode();
 | 
					        const activeNode = $.ui.fancytree.getNode(e);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        activeNode.load(true);
 | 
					        activeNode.load(true);
 | 
				
			||||||
        activeNode.setExpanded(true);
 | 
					        activeNode.setExpanded(true);
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user