Skip to content

Commit

Permalink
implement shift-click to select notes in between clicked and active n…
Browse files Browse the repository at this point in the history
…ote, closes #2647
  • Loading branch information
zadam committed Jun 3, 2022
1 parent 27b55eb commit e1cd09d
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/public/app/widgets/note_tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,13 +309,39 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {

if (targetType === 'title' || targetType === 'icon') {
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);
}
else if (event.ctrlKey) {
const notePath = treeService.getNotePath(node);
appContext.tabManager.openTabWithNoteWithHoisting(notePath);
}
else if (event.altKey) {
node.setSelected(!node.isSelected());
node.setFocus(true);
}
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.tree.reactivate(true);
Expand Down

0 comments on commit e1cd09d

Please sign in to comment.