mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 02:16:05 +01:00 
			
		
		
		
	fix deleting
This commit is contained in:
		| @@ -123,7 +123,7 @@ $detail.on("click", ".note-menu-button", async e => { | |||||||
|                 noteCreateService.createNote(node.data.noteId); |                 noteCreateService.createNote(node.data.noteId); | ||||||
|             } |             } | ||||||
|             else if (cmd === "delete") { |             else if (cmd === "delete") { | ||||||
|                 if (await treeChangesService.deleteNodes([node])) { |                 if (await treeChangesService.deleteNotes([node])) { | ||||||
|                     // move to the tree |                     // move to the tree | ||||||
|                     togglePanes(); |                     togglePanes(); | ||||||
|                 } |                 } | ||||||
|   | |||||||
| @@ -65,7 +65,7 @@ async function moveToParentNote(branchIdsToMove, newParentNoteId) { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
| async function deleteNodes(branchIdsToDelete) { | async function deleteNotes(treeWidget, branchIdsToDelete) { | ||||||
|     branchIdsToDelete = filterRootNote(branchIdsToDelete); |     branchIdsToDelete = filterRootNote(branchIdsToDelete); | ||||||
|  |  | ||||||
|     if (branchIdsToDelete.length === 0) { |     if (branchIdsToDelete.length === 0) { | ||||||
| @@ -119,6 +119,8 @@ async function deleteNodes(branchIdsToDelete) { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     treeWidget.clearSelectedNodes(); | ||||||
|  |  | ||||||
|     return true; |     return true; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -202,6 +204,6 @@ export default { | |||||||
|     moveBeforeBranch, |     moveBeforeBranch, | ||||||
|     moveAfterBranch, |     moveAfterBranch, | ||||||
|     moveToParentNote, |     moveToParentNote, | ||||||
|     deleteNodes, |     deleteNotes, | ||||||
|     moveNodeUpInHierarchy |     moveNodeUpInHierarchy | ||||||
| }; | }; | ||||||
| @@ -160,7 +160,7 @@ class TreeContextMenu { | |||||||
|             clipboard.pasteInto(noteId); |             clipboard.pasteInto(noteId); | ||||||
|         } |         } | ||||||
|         else if (cmd === "delete") { |         else if (cmd === "delete") { | ||||||
|             treeChangesService.deleteNodes(this.getSelectedOrActiveBranchIds()); |             treeChangesService.deleteNotes(this.treeWidget, this.getSelectedOrActiveBranchIds()); | ||||||
|         } |         } | ||||||
|         else if (cmd === "export") { |         else if (cmd === "export") { | ||||||
|             const exportDialog = await import('../dialogs/export.js'); |             const exportDialog = await import('../dialogs/export.js'); | ||||||
|   | |||||||
| @@ -53,7 +53,9 @@ function getSelectedOrActiveBranchIds(treeWidget, node) { | |||||||
| function getTemplates(treeWidget) { | function getTemplates(treeWidget) { | ||||||
|     return { |     return { | ||||||
|         "DeleteNotes": node => { |         "DeleteNotes": node => { | ||||||
|             treeChangesService.deleteNodes(getSelectedOrActiveBranchIds(treeWidget, node)); |             const branchIds = getSelectedOrActiveBranchIds(treeWidget, node); | ||||||
|  |  | ||||||
|  |             treeChangesService.deleteNotes(treeWidget, branchIds); | ||||||
|         }, |         }, | ||||||
|         "MoveNoteUp": node => { |         "MoveNoteUp": node => { | ||||||
|             const beforeNode = node.getPrevSibling(); |             const beforeNode = node.getPrevSibling(); | ||||||
|   | |||||||
| @@ -432,6 +432,8 @@ export default class NoteTreeWidget extends TabAwareWidget { | |||||||
|                 } |                 } | ||||||
|  |  | ||||||
|                 newActiveNode.setActive(true, {noEvents: true}); |                 newActiveNode.setActive(true, {noEvents: true}); | ||||||
|  |  | ||||||
|  |                 newActiveNode.makeVisible({scrollIntoView: true}); | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| @@ -458,27 +460,19 @@ export default class NoteTreeWidget extends TabAwareWidget { | |||||||
|         for (const branch of loadResults.getBranches()) { |         for (const branch of loadResults.getBranches()) { | ||||||
|             for (const node of this.getNodesByBranchId(branch.branchId)) { |             for (const node of this.getNodesByBranchId(branch.branchId)) { | ||||||
|                 if (branch.isDeleted) { |                 if (branch.isDeleted) { | ||||||
|                     node.data.toBeRemoved = true; |  | ||||||
|  |  | ||||||
|                     if (node.isActive()) { |                     if (node.isActive()) { | ||||||
|                         let curNode = node; |                         const newActiveNode = node.getNextSibling() | ||||||
|  |                             || node.getPrevSibling() | ||||||
|  |                             || node.getParent(); | ||||||
|  |  | ||||||
|                         while (curNode.data.toBeRemoved) { |                         if (newActiveNode) { | ||||||
|                             if (curNode.getNextSibling() && !curNode.getNextSibling().data.toBeRemoved) { |                             newActiveNode.setActive(true, {noEvents: true, noFocus: true}); | ||||||
|                                 curNode = curNode.getNextSibling(); |  | ||||||
|                             } |  | ||||||
|                             else if (curNode.getPrevSibling() && !curNode.getPrevSibling().data.toBeRemoved) { |  | ||||||
|                                 curNode = curNode.getPrevSibling(); |  | ||||||
|                             } |  | ||||||
|                             else { |  | ||||||
|                                 curNode = curNode.getParent(); |  | ||||||
|                         } |                         } | ||||||
|                     } |                     } | ||||||
|  |  | ||||||
|                         curNode.setActive(true, {noEvents:true, noFocus:true}); |                     node.remove(); | ||||||
|                     } |  | ||||||
|  |  | ||||||
|                     noteIdsToReload.add(branch.parentNoteId); |                     noteIdsToUpdate.add(branch.parentNoteId); | ||||||
|                 } |                 } | ||||||
|                 else { |                 else { | ||||||
|                     noteIdsToUpdate.add(branch.noteId); |                     noteIdsToUpdate.add(branch.noteId); | ||||||
|   | |||||||
| @@ -136,7 +136,7 @@ export default class TextTypeWidget extends TypeWidget { | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     async doRefresh(note) {console.trace("UPDATE###" + this.componentId); |     async doRefresh(note) { | ||||||
|         this.textEditor.isReadOnly = await note.hasLabel('readOnly'); |         this.textEditor.isReadOnly = await note.hasLabel('readOnly'); | ||||||
|  |  | ||||||
|         const noteComplement = await this.tabContext.getNoteComplement(); |         const noteComplement = await this.tabContext.getNoteComplement(); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user