diff --git a/packages/coreutils/src/settingregistry.ts b/packages/coreutils/src/settingregistry.ts index 1f9c7edef234..311281ff86e8 100644 --- a/packages/coreutils/src/settingregistry.ts +++ b/packages/coreutils/src/settingregistry.ts @@ -5,6 +5,8 @@ import Ajv from 'ajv'; import * as json from 'json5'; +import { CommandRegistry } from '@lumino/commands'; + import { JSONExt, JSONObject, @@ -913,11 +915,16 @@ export namespace SettingRegistry { // If a user shortcut collides with another user shortcut warn and filter. user = user.filter(shortcut => { - const keys = shortcut.keys.join(RECORD_SEPARATOR); + const keys = CommandRegistry.normalizeKeys(shortcut).join( + RECORD_SEPARATOR + ); const { selector } = shortcut; if (!keys) { - console.warn('Shortcut skipped because `keys` are [""].', shortcut); + console.warn( + 'Skipping this shortcut because there are no actionable keys on this platform', + shortcut + ); return false; } if (!(keys in memo)) { @@ -928,7 +935,10 @@ export namespace SettingRegistry { return true; } - console.warn('Shortcut skipped due to collision.', shortcut); + console.warn( + 'Skipping this shortcut because it collides with another shortcut.', + shortcut + ); return false; }); @@ -937,7 +947,9 @@ export namespace SettingRegistry { // out too (this includes shortcuts that are disabled by user preferences). defaults = defaults.filter(shortcut => { const { disabled } = shortcut; - const keys = shortcut.keys.join(RECORD_SEPARATOR); + const keys = CommandRegistry.normalizeKeys(shortcut).join( + RECORD_SEPARATOR + ); if (disabled || !keys) { return false; @@ -955,7 +967,10 @@ export namespace SettingRegistry { // Only warn if a default shortcut collides with another default shortcut. if (memo[keys][selector]) { - console.warn('Shortcut skipped due to collision.', shortcut); + console.warn( + 'Skipping this shortcut because it collides with another shortcut.', + shortcut + ); } return false; diff --git a/packages/shortcuts-extension/schema/shortcuts.json b/packages/shortcuts-extension/schema/shortcuts.json index d4c849594d7c..f7cfe7ac6b26 100644 --- a/packages/shortcuts-extension/schema/shortcuts.json +++ b/packages/shortcuts-extension/schema/shortcuts.json @@ -8,7 +8,6 @@ "additionalProperties": false, "properties": { "shortcuts": { - "title": "Keyboard Shortcuts", "description": "The list of keyboard shortcuts.", "items": { "$ref": "#/definitions/shortcut" }, "type": "array", @@ -22,7 +21,18 @@ "command": { "type": "string" }, "keys": { "items": { "type": "string" }, - "minItems": 1, + "type": "array" + }, + "winKeys": { + "items": { "type": "string" }, + "type": "array" + }, + "macKeys": { + "items": { "type": "string" }, + "type": "array" + }, + "linuxKeys": { + "items": { "type": "string" }, "type": "array" }, "selector": { "type": "string" } diff --git a/packages/shortcuts-extension/src/index.ts b/packages/shortcuts-extension/src/index.ts index 3f4576a4b238..742129b20f57 100644 --- a/packages/shortcuts-extension/src/index.ts +++ b/packages/shortcuts-extension/src/index.ts @@ -71,10 +71,8 @@ const shortcuts: JupyterFrontEndPlugin = { }) .reduce((acc, val) => acc.concat(val), []) .sort((a, b) => a.command.localeCompare(b.command)); - schema.properties!.shortcuts.title = - 'List of Commands (followed by shortcuts)'; - const disableShortcutInstructions = `Note: To disable a system default shortcut, + schema.properties!.shortcuts.description = `Note: To disable a system default shortcut, copy it to User Preferences and add the "disabled" key, for example: { @@ -84,12 +82,12 @@ copy it to User Preferences and add the ], "selector": "body", "disabled": true -}`; - schema.properties!.shortcuts.description = `${commands} +} -${disableShortcutInstructions} +List of commands followed by keyboard shortcuts: +${commands} -List of Keyboard Shortcuts`; +List of keyboard shortcuts:`; } registry.pluginChanged.connect(async (sender, plugin) => {