mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
fix delete with keyboard and context menu regarding the selection
This commit is contained in:
parent
f1967fd466
commit
943b35fb7d
@ -453,12 +453,6 @@ function initFancyTree(tree) {
|
|||||||
$tree.on('contextmenu', '.fancytree-node', function(e) {
|
$tree.on('contextmenu', '.fancytree-node', function(e) {
|
||||||
const node = $.ui.fancytree.getNode(e);
|
const node = $.ui.fancytree.getNode(e);
|
||||||
|
|
||||||
// right click resets selection to just this node
|
|
||||||
// this is important when e.g. you right click on a note while having different note active
|
|
||||||
// and then click on delete - obviously you want to delete only that one right-clicked
|
|
||||||
node.setSelected(true);
|
|
||||||
clearSelectedNodes();
|
|
||||||
|
|
||||||
contextMenuWidget.initContextMenu(e, new TreeContextMenu(node));
|
contextMenuWidget.initContextMenu(e, new TreeContextMenu(node));
|
||||||
|
|
||||||
return false; // blocks default browser right click menu
|
return false; // blocks default browser right click menu
|
||||||
|
@ -122,7 +122,13 @@ class TreeContextMenu {
|
|||||||
clipboard.pasteInto(this.node);
|
clipboard.pasteInto(this.node);
|
||||||
}
|
}
|
||||||
else if (cmd === "delete") {
|
else if (cmd === "delete") {
|
||||||
treeChangesService.deleteNodes(treeService.getSelectedNodes(true));
|
let notesToDelete = treeService.getSelectedNodes(true);
|
||||||
|
|
||||||
|
if (notesToDelete.length === 0) {
|
||||||
|
notesToDelete.push(this.node);
|
||||||
|
}
|
||||||
|
|
||||||
|
treeChangesService.deleteNodes(notesToDelete);
|
||||||
}
|
}
|
||||||
else if (cmd === "export") {
|
else if (cmd === "export") {
|
||||||
exportDialog.showDialog("subtree");
|
exportDialog.showDialog("subtree");
|
||||||
|
@ -7,7 +7,13 @@ import clipboard from "./clipboard.js";
|
|||||||
|
|
||||||
const keyBindings = {
|
const keyBindings = {
|
||||||
"del": node => {
|
"del": node => {
|
||||||
treeChangesService.deleteNodes(treeService.getSelectedNodes(true));
|
let notesToDelete = treeService.getSelectedNodes(true);
|
||||||
|
|
||||||
|
if (notesToDelete.length === 0) {
|
||||||
|
notesToDelete.push(node);
|
||||||
|
}
|
||||||
|
|
||||||
|
treeChangesService.deleteNodes(notesToDelete);
|
||||||
},
|
},
|
||||||
"ctrl+up": node => {
|
"ctrl+up": node => {
|
||||||
const beforeNode = node.getPrevSibling();
|
const beforeNode = node.getPrevSibling();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user