implement shift-click to select notes in between clicked and active note, closes #2647

This commit is contained in:
zadam 2022-06-03 09:42:35 +02:00
parent 27b55eb3ee
commit e1cd09df36

View File

@ -309,13 +309,39 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
if (targetType === 'title' || targetType === 'icon') { if (targetType === 'title' || targetType === 'icon') {
if (event.shiftKey) { if (event.shiftKey) {
node.setSelected(!node.isSelected()); const activeNode = this.getActiveNode();
if (activeNode.getParent() !== node.getParent()) {
return;
}
this.clearSelectedNodes();
function selectInBetween(first, second) {
for (let i = 0; first && first !== second && i < 10000; i++) {
first.setSelected(true);
first = first.getNextSibling();
}
second.setSelected();
}
if (activeNode.getIndex() < node.getIndex()) {
selectInBetween(activeNode, node);
} else {
selectInBetween(node, activeNode);
}
node.setFocus(true); node.setFocus(true);
} }
else if (event.ctrlKey) { else if (event.ctrlKey) {
const notePath = treeService.getNotePath(node); const notePath = treeService.getNotePath(node);
appContext.tabManager.openTabWithNoteWithHoisting(notePath); appContext.tabManager.openTabWithNoteWithHoisting(notePath);
} }
else if (event.altKey) {
node.setSelected(!node.isSelected());
node.setFocus(true);
}
else if (data.node.isActive()) { else if (data.node.isActive()) {
// this is important for single column mobile view, otherwise it's not possible to see again previously displayed note // this is important for single column mobile view, otherwise it's not possible to see again previously displayed note
this.tree.reactivate(true); this.tree.reactivate(true);