From 3990bb109ae3fdd5332346221bfc955349bfe3f9 Mon Sep 17 00:00:00 2001 From: Tim Daniel Metzler Date: Fri, 15 Mar 2024 18:37:58 +0100 Subject: [PATCH 1/2] Use spread operator to remove shortcuts --- .../src/disable-shortcuts.js | 8 ++++++-- packages/utils/src/shortcuts.js | 12 ++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/packages/restricted-exam-notebook/src/disable-shortcuts.js b/packages/restricted-exam-notebook/src/disable-shortcuts.js index 7bb49735..29eee897 100644 --- a/packages/restricted-exam-notebook/src/disable-shortcuts.js +++ b/packages/restricted-exam-notebook/src/disable-shortcuts.js @@ -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", diff --git a/packages/utils/src/shortcuts.js b/packages/utils/src/shortcuts.js index b8a360c3..8a1b5843 100644 --- a/packages/utils/src/shortcuts.js +++ b/packages/utils/src/shortcuts.js @@ -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; } } @@ -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) { From eaea3e8fe7b44a21b220308b9b1ee82cabaa3415 Mon Sep 17 00:00:00 2001 From: Tim Daniel Metzler Date: Fri, 15 Mar 2024 18:38:10 +0100 Subject: [PATCH 2/2] Update package-lock.json --- package-lock.json | 128 +++++++++++++++++++++++----------------------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/package-lock.json b/package-lock.json index bcb2f07c..0e76a72c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "e2xgrader", - "version": "0.2.3", + "version": "0.3.0-dev1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "e2xgrader", - "version": "0.2.3", + "version": "0.3.0-dev1", "hasInstallScript": true, "license": "MIT", "workspaces": [ @@ -13685,7 +13685,7 @@ }, "packages/api": { "name": "@e2xgrader/api", - "version": "0.2.3", + "version": "0.3.0-dev1", "license": "MIT", "devDependencies": { "webpack": "^5.73.0", @@ -13694,11 +13694,11 @@ }, "packages/assignment-view-celltoolbar": { "name": "@e2xgrader/assignment-view-celltoolbar", - "version": "0.2.3", + "version": "0.3.0-dev1", "license": "ISC", "dependencies": { - "@e2xgrader/cells": "0.2.3", - "@e2xgrader/utils": "0.2.3" + "@e2xgrader/cells": "0.3.0-dev1", + "@e2xgrader/utils": "0.3.0-dev1" }, "devDependencies": { "@babel/preset-env": "^7.16.11", @@ -13731,12 +13731,12 @@ }, "packages/authoring-menubar": { "name": "@e2xgrader/authoring-menubar", - "version": "0.2.3", + "version": "0.3.0-dev1", "license": "MIT", "dependencies": { - "@e2xgrader/api": "0.2.3", - "@e2xgrader/menubar": "0.2.3", - "@e2xgrader/utils": "0.2.3" + "@e2xgrader/api": "0.3.0-dev1", + "@e2xgrader/menubar": "0.3.0-dev1", + "@e2xgrader/utils": "0.3.0-dev1" }, "devDependencies": { "webpack": "^5.73.0", @@ -13745,10 +13745,10 @@ }, "packages/cell-extension": { "name": "@e2xgrader/cell-extension", - "version": "0.2.3", + "version": "0.3.0-dev1", "license": "ISC", "dependencies": { - "@e2xgrader/cells": "0.2.3" + "@e2xgrader/cells": "0.3.0-dev1" }, "devDependencies": { "@babel/preset-env": "^7.16.11", @@ -13760,10 +13760,10 @@ }, "packages/cells": { "name": "@e2xgrader/cells", - "version": "0.2.3", + "version": "0.3.0-dev1", "license": "ISC", "dependencies": { - "@e2xgrader/api": "0.2.3" + "@e2xgrader/api": "0.3.0-dev1" }, "devDependencies": { "@babel/preset-env": "^7.16.11", @@ -13775,11 +13775,11 @@ }, "packages/create-assignment-celltoolbar": { "name": "@e2xgrader/create-assignment-celltoolbar", - "version": "0.2.3", + "version": "0.3.0-dev1", "license": "ISC", "dependencies": { - "@e2xgrader/cells": "0.2.3", - "@e2xgrader/utils": "0.2.3" + "@e2xgrader/cells": "0.3.0-dev1", + "@e2xgrader/utils": "0.3.0-dev1" }, "devDependencies": { "@babel/preset-env": "^7.16.11", @@ -13805,11 +13805,11 @@ }, "packages/exam-menubar": { "name": "@e2xgrader/exam-menubar", - "version": "0.2.3", + "version": "0.3.0-dev1", "license": "MIT", "dependencies": { - "@e2xgrader/api": "0.2.3", - "@e2xgrader/menubar": "0.2.3" + "@e2xgrader/api": "0.3.0-dev1", + "@e2xgrader/menubar": "0.3.0-dev1" }, "devDependencies": { "webpack": "^5.73.0", @@ -13818,10 +13818,10 @@ }, "packages/help-tab": { "name": "@e2xgrader/help-tab", - "version": "0.2.3", + "version": "0.3.0-dev1", "license": "ISC", "dependencies": { - "@e2xgrader/api": "0.2.3" + "@e2xgrader/api": "0.3.0-dev1" }, "devDependencies": { "@babel/preset-env": "^7.16.11", @@ -13833,7 +13833,7 @@ }, "packages/menubar": { "name": "@e2xgrader/menubar", - "version": "0.2.3", + "version": "0.3.0-dev1", "license": "MIT", "devDependencies": { "webpack": "^5.73.0", @@ -13864,17 +13864,17 @@ }, "packages/notebook-extensions": { "name": "@e2xgrader/notebook-extensions", - "version": "0.2.3", + "version": "0.3.0-dev1", "license": "ISC", "dependencies": { - "@e2xgrader/assignment-view-celltoolbar": "0.2.3", - "@e2xgrader/authoring-menubar": "0.2.3", - "@e2xgrader/cell-extension": "0.2.3", - "@e2xgrader/create-assignment-celltoolbar": "0.2.3", - "@e2xgrader/exam-menubar": "0.2.3", - "@e2xgrader/restricted-assignment-notebook": "0.2.3", - "@e2xgrader/restricted-exam-notebook": "0.2.3", - "@e2xgrader/utils": "0.2.3" + "@e2xgrader/assignment-view-celltoolbar": "0.3.0-dev1", + "@e2xgrader/authoring-menubar": "0.3.0-dev1", + "@e2xgrader/cell-extension": "0.3.0-dev1", + "@e2xgrader/create-assignment-celltoolbar": "0.3.0-dev1", + "@e2xgrader/exam-menubar": "0.3.0-dev1", + "@e2xgrader/restricted-assignment-notebook": "0.3.0-dev1", + "@e2xgrader/restricted-exam-notebook": "0.3.0-dev1", + "@e2xgrader/utils": "0.3.0-dev1" }, "devDependencies": { "@babel/preset-env": "^7.16.11", @@ -13886,10 +13886,10 @@ }, "packages/restricted-assignment-notebook": { "name": "@e2xgrader/restricted-assignment-notebook", - "version": "0.2.3", + "version": "0.3.0-dev1", "license": "MIT", "dependencies": { - "@e2xgrader/utils": "0.2.3" + "@e2xgrader/utils": "0.3.0-dev1" }, "devDependencies": { "webpack": "^5.73.0", @@ -13898,10 +13898,10 @@ }, "packages/restricted-exam-notebook": { "name": "@e2xgrader/restricted-exam-notebook", - "version": "0.2.3", + "version": "0.3.0-dev1", "license": "MIT", "dependencies": { - "@e2xgrader/utils": "0.2.3" + "@e2xgrader/utils": "0.3.0-dev1" }, "devDependencies": { "webpack": "^5.73.0", @@ -13910,10 +13910,10 @@ }, "packages/tree-extensions": { "name": "@e2xgrader/tree-extensions", - "version": "0.2.3", + "version": "0.3.0-dev1", "license": "ISC", "dependencies": { - "@e2xgrader/help-tab": "0.2.3" + "@e2xgrader/help-tab": "0.3.0-dev1" }, "devDependencies": { "@babel/preset-env": "^7.16.11", @@ -13925,10 +13925,10 @@ }, "packages/utils": { "name": "@e2xgrader/utils", - "version": "0.2.3", + "version": "0.3.0-dev1", "license": "MIT", "dependencies": { - "@e2xgrader/api": "0.2.3" + "@e2xgrader/api": "0.3.0-dev1" }, "devDependencies": { "webpack": "^5.73.0", @@ -15200,8 +15200,8 @@ "version": "file:packages/assignment-view-celltoolbar", "requires": { "@babel/preset-env": "^7.16.11", - "@e2xgrader/cells": "0.2.3", - "@e2xgrader/utils": "0.2.3", + "@e2xgrader/cells": "0.3.0-dev1", + "@e2xgrader/utils": "0.3.0-dev1", "css-loader": "^6.6.0", "style-loader": "^3.3.1", "webpack": "^5.70.0", @@ -15211,9 +15211,9 @@ "@e2xgrader/authoring-menubar": { "version": "file:packages/authoring-menubar", "requires": { - "@e2xgrader/api": "0.2.3", - "@e2xgrader/menubar": "0.2.3", - "@e2xgrader/utils": "0.2.3", + "@e2xgrader/api": "0.3.0-dev1", + "@e2xgrader/menubar": "0.3.0-dev1", + "@e2xgrader/utils": "0.3.0-dev1", "webpack": "^5.73.0", "webpack-cli": "^4.9.2" } @@ -15222,7 +15222,7 @@ "version": "file:packages/cell-extension", "requires": { "@babel/preset-env": "^7.16.11", - "@e2xgrader/cells": "0.2.3", + "@e2xgrader/cells": "0.3.0-dev1", "css-loader": "^6.6.0", "style-loader": "^3.3.1", "webpack": "^5.70.0", @@ -15233,7 +15233,7 @@ "version": "file:packages/cells", "requires": { "@babel/preset-env": "^7.16.11", - "@e2xgrader/api": "0.2.3", + "@e2xgrader/api": "0.3.0-dev1", "css-loader": "^6.6.0", "style-loader": "^3.3.1", "webpack": "^5.70.0", @@ -15244,8 +15244,8 @@ "version": "file:packages/create-assignment-celltoolbar", "requires": { "@babel/preset-env": "^7.16.11", - "@e2xgrader/cells": "0.2.3", - "@e2xgrader/utils": "0.2.3", + "@e2xgrader/cells": "0.3.0-dev1", + "@e2xgrader/utils": "0.3.0-dev1", "css-loader": "^6.6.0", "style-loader": "^3.3.1", "webpack": "^5.70.0", @@ -15255,8 +15255,8 @@ "@e2xgrader/exam-menubar": { "version": "file:packages/exam-menubar", "requires": { - "@e2xgrader/api": "0.2.3", - "@e2xgrader/menubar": "0.2.3", + "@e2xgrader/api": "0.3.0-dev1", + "@e2xgrader/menubar": "0.3.0-dev1", "webpack": "^5.73.0", "webpack-cli": "^4.9.2" } @@ -15265,7 +15265,7 @@ "version": "file:packages/help-tab", "requires": { "@babel/preset-env": "^7.16.11", - "@e2xgrader/api": "0.2.3", + "@e2xgrader/api": "0.3.0-dev1", "css-loader": "^6.6.0", "style-loader": "^3.3.1", "webpack": "^5.70.0", @@ -15283,14 +15283,14 @@ "version": "file:packages/notebook-extensions", "requires": { "@babel/preset-env": "^7.16.11", - "@e2xgrader/assignment-view-celltoolbar": "0.2.3", - "@e2xgrader/authoring-menubar": "0.2.3", - "@e2xgrader/cell-extension": "0.2.3", - "@e2xgrader/create-assignment-celltoolbar": "0.2.3", - "@e2xgrader/exam-menubar": "0.2.3", - "@e2xgrader/restricted-assignment-notebook": "0.2.3", - "@e2xgrader/restricted-exam-notebook": "0.2.3", - "@e2xgrader/utils": "0.2.3", + "@e2xgrader/assignment-view-celltoolbar": "0.3.0-dev1", + "@e2xgrader/authoring-menubar": "0.3.0-dev1", + "@e2xgrader/cell-extension": "0.3.0-dev1", + "@e2xgrader/create-assignment-celltoolbar": "0.3.0-dev1", + "@e2xgrader/exam-menubar": "0.3.0-dev1", + "@e2xgrader/restricted-assignment-notebook": "0.3.0-dev1", + "@e2xgrader/restricted-exam-notebook": "0.3.0-dev1", + "@e2xgrader/utils": "0.3.0-dev1", "css-loader": "^6.6.0", "style-loader": "^3.3.1", "webpack": "^5.70.0", @@ -15300,7 +15300,7 @@ "@e2xgrader/restricted-assignment-notebook": { "version": "file:packages/restricted-assignment-notebook", "requires": { - "@e2xgrader/utils": "0.2.3", + "@e2xgrader/utils": "0.3.0-dev1", "webpack": "^5.73.0", "webpack-cli": "^4.9.2" } @@ -15308,7 +15308,7 @@ "@e2xgrader/restricted-exam-notebook": { "version": "file:packages/restricted-exam-notebook", "requires": { - "@e2xgrader/utils": "0.2.3", + "@e2xgrader/utils": "0.3.0-dev1", "webpack": "^5.73.0", "webpack-cli": "^4.9.2" } @@ -15317,7 +15317,7 @@ "version": "file:packages/tree-extensions", "requires": { "@babel/preset-env": "^7.16.11", - "@e2xgrader/help-tab": "0.2.3", + "@e2xgrader/help-tab": "0.3.0-dev1", "css-loader": "^6.6.0", "style-loader": "^3.3.1", "webpack": "^5.70.0", @@ -15327,7 +15327,7 @@ "@e2xgrader/utils": { "version": "file:packages/utils", "requires": { - "@e2xgrader/api": "0.2.3", + "@e2xgrader/api": "0.3.0-dev1", "webpack": "^5.73.0", "webpack-cli": "^4.9.2" }