Skip to content

Commit

Permalink
Merge pull request #180 from DigiKlausur/fix_remove_shortcuts
Browse files Browse the repository at this point in the history
Fix remove shortcuts
  • Loading branch information
tmetzl authored Mar 15, 2024
2 parents e3877fc + eaea3e8 commit 339f527
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 68 deletions.
128 changes: 64 additions & 64 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions packages/restricted-exam-notebook/src/disable-shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@ export function disable_shortcuts() {
"d,d",
];

utils.remove_shortcuts("command", shortcuts);
utils.remove_shortcuts("edit", shortcuts);
const modes = ["command", "edit"];

for (let mode of modes) {
utils.remove_shortcuts(mode, ...shortcuts);
}

utils.remove_shortcuts("command", "crtl-v");

utils.disable_add_cell_on_execute();

utils.add_shortcut(
"command",
"ctrl-v",
Expand Down
12 changes: 10 additions & 2 deletions packages/utils/src/shortcuts.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ export function remove_shortcuts(mode, ...shortcuts) {
try {
manager.remove_shortcut(shortcut);
} catch (e) {
console.log(
"Error removing shortcut",
shortcut,
"from",
mode,
"mode:",
e.message
);
// Shortcut does not exist and can't be removed;
}
}
Expand Down Expand Up @@ -83,8 +91,8 @@ export function add_shortcut(mode, key, handler, help, help_index = "zz") {
export function disable_add_cell_on_execute() {
add_Notebook_execute_cell_and_select();
const shortcut_keys = ["alt-enter", "shift-enter"];
remove_shortcuts("edit", shortcut_keys);
remove_shortcuts("command", shortcut_keys);
remove_shortcuts("edit", ...shortcut_keys);
remove_shortcuts("command", ...shortcut_keys);

const help = "run cell";
const handler = function (event) {
Expand Down

0 comments on commit 339f527

Please sign in to comment.