Skip to content

Commit

Permalink
Finished shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
jameskerr committed Apr 3, 2024
1 parent f89834a commit 67270b8
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
16 changes: 16 additions & 0 deletions modules/react-arborist/src/commands/default-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,19 @@ export function moveSelectionEnd(tree: Tree) {
tree.selectContiguous(next.id);
}
}

export function select(tree: Tree) {
const node = tree.focusedNode;
if (node) tree.select(node.id);
}

export function selectAll(tree: Tree) {
tree.selectAll();
}

export function toggle(tree: Tree) {
const node = tree.focusedNode;
if (node) {
node.isOpen ? tree.close(node.id) : tree.open(node.id);
}
}
17 changes: 4 additions & 13 deletions modules/react-arborist/src/shortcuts/default-shortcuts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,8 @@ export const defaultShortcuts: ShortcutAttrs[] = [
/* Selection */
{ key: "Shift+ArrowUp", command: "moveSelectionStart" },
{ key: "Shift+ArrowDown", command: "moveSelectionEnd" },

/* Activation */
// { key: "Meta+ArrowDown", command: "activate" },
// { key: "ArrowLeft", command: "close", when: "isOpen" },
// { key: "ArrowLeft", command: "focusParent", when: "isLeaf || isClosed" },
// { key: "ArrowRight", command: "focusChildren" },
// { key: "Meta+A", command: "selectAll" },
// { key: "Control+A", command: "selectAll" },
// { key: "a", command: "createLeaf" },
// { key: "Shift+A", command: "createInternal" },
// { key: "Home", command: "focusFirst" },
// { key: "End", command: "focusLast" },
// { key: "Enter", command: "" },
{ key: " ", command: "toggle", when: "isInternal" },
{ key: " ", command: "select", when: "isLeaf" },
{ key: "Meta+a", command: "selectAll" },
{ key: "Control+a", command: "selectAll" },
];

0 comments on commit 67270b8

Please sign in to comment.