mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
fix deleting
This commit is contained in:
parent
789f62267c
commit
380bb0cd01
@ -123,7 +123,7 @@ $detail.on("click", ".note-menu-button", async e => {
|
||||
noteCreateService.createNote(node.data.noteId);
|
||||
}
|
||||
else if (cmd === "delete") {
|
||||
if (await treeChangesService.deleteNodes([node])) {
|
||||
if (await treeChangesService.deleteNotes([node])) {
|
||||
// move to the tree
|
||||
togglePanes();
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ async function moveToParentNote(branchIdsToMove, newParentNoteId) {
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteNodes(branchIdsToDelete) {
|
||||
async function deleteNotes(treeWidget, branchIdsToDelete) {
|
||||
branchIdsToDelete = filterRootNote(branchIdsToDelete);
|
||||
|
||||
if (branchIdsToDelete.length === 0) {
|
||||
@ -119,6 +119,8 @@ async function deleteNodes(branchIdsToDelete) {
|
||||
}
|
||||
}
|
||||
|
||||
treeWidget.clearSelectedNodes();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -202,6 +204,6 @@ export default {
|
||||
moveBeforeBranch,
|
||||
moveAfterBranch,
|
||||
moveToParentNote,
|
||||
deleteNodes,
|
||||
deleteNotes,
|
||||
moveNodeUpInHierarchy
|
||||
};
|
@ -160,7 +160,7 @@ class TreeContextMenu {
|
||||
clipboard.pasteInto(noteId);
|
||||
}
|
||||
else if (cmd === "delete") {
|
||||
treeChangesService.deleteNodes(this.getSelectedOrActiveBranchIds());
|
||||
treeChangesService.deleteNotes(this.treeWidget, this.getSelectedOrActiveBranchIds());
|
||||
}
|
||||
else if (cmd === "export") {
|
||||
const exportDialog = await import('../dialogs/export.js');
|
||||
|
@ -53,7 +53,9 @@ function getSelectedOrActiveBranchIds(treeWidget, node) {
|
||||
function getTemplates(treeWidget) {
|
||||
return {
|
||||
"DeleteNotes": node => {
|
||||
treeChangesService.deleteNodes(getSelectedOrActiveBranchIds(treeWidget, node));
|
||||
const branchIds = getSelectedOrActiveBranchIds(treeWidget, node);
|
||||
|
||||
treeChangesService.deleteNotes(treeWidget, branchIds);
|
||||
},
|
||||
"MoveNoteUp": node => {
|
||||
const beforeNode = node.getPrevSibling();
|
||||
|
@ -432,6 +432,8 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
||||
}
|
||||
|
||||
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 node of this.getNodesByBranchId(branch.branchId)) {
|
||||
if (branch.isDeleted) {
|
||||
node.data.toBeRemoved = true;
|
||||
|
||||
if (node.isActive()) {
|
||||
let curNode = node;
|
||||
const newActiveNode = node.getNextSibling()
|
||||
|| node.getPrevSibling()
|
||||
|| node.getParent();
|
||||
|
||||
while (curNode.data.toBeRemoved) {
|
||||
if (curNode.getNextSibling() && !curNode.getNextSibling().data.toBeRemoved) {
|
||||
curNode = curNode.getNextSibling();
|
||||
}
|
||||
else if (curNode.getPrevSibling() && !curNode.getPrevSibling().data.toBeRemoved) {
|
||||
curNode = curNode.getPrevSibling();
|
||||
}
|
||||
else {
|
||||
curNode = curNode.getParent();
|
||||
}
|
||||
if (newActiveNode) {
|
||||
newActiveNode.setActive(true, {noEvents: true, noFocus: true});
|
||||
}
|
||||
|
||||
curNode.setActive(true, {noEvents:true, noFocus:true});
|
||||
}
|
||||
|
||||
noteIdsToReload.add(branch.parentNoteId);
|
||||
node.remove();
|
||||
|
||||
noteIdsToUpdate.add(branch.parentNoteId);
|
||||
}
|
||||
else {
|
||||
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');
|
||||
|
||||
const noteComplement = await this.tabContext.getNoteComplement();
|
||||
|
Loading…
x
Reference in New Issue
Block a user