Const default
default: JupyterFrontEndPlugin<void> = {id: '@jupyterlab/shortcuts-extension:shortcuts',requires: [ISettingRegistry, ITranslator],activate: async (app: JupyterFrontEnd,registry: ISettingRegistry,translator: ITranslator) => {const trans = translator.load('jupyterlab');const { commands } = app;let canonical: ISettingRegistry.ISchema | null;let loaded: { [name: string]: ISettingRegistry.IShortcut[] } = {};/*** Populate the plugin's schema defaults.*/function populate(schema: ISettingRegistry.ISchema) {const commands = app.commands.listCommands().join('\n');loaded = {};schema.properties!.shortcuts.default = Object.keys(registry.plugins).map(plugin => {const shortcuts =registry.plugins[plugin]!.schema['jupyter.lab.shortcuts'] || [];loaded[plugin] = shortcuts;return shortcuts;}).reduce((acc, val) => acc.concat(val), []).sort((a, b) => a.command.localeCompare(b.command));schema.properties!.shortcuts.description = trans.__(`Note: To disable a system default shortcut,copy it to User Preferences and add the"disabled" key, for example:{"command": "application:activate-next-tab","keys": ["Ctrl Shift ]"],"selector": "body","disabled": true}List of commands followed by keyboard shortcuts:%1List of keyboard shortcuts:`,commands);}registry.pluginChanged.connect(async (sender, plugin) => {if (plugin !== shortcuts.id) {// If the plugin changed its shortcuts, reload everything.const oldShortcuts = loaded[plugin];const newShortcuts =registry.plugins[plugin]!.schema['jupyter.lab.shortcuts'] || [];if (oldShortcuts === undefined ||!JSONExt.deepEqual(oldShortcuts, newShortcuts)) {canonical = null;await registry.reload(shortcuts.id);}}});// Transform the plugin object to return different schema than the default.registry.transform(shortcuts.id, {compose: plugin => {// Only override the canonical schema the first time.if (!canonical) {canonical = JSONExt.deepCopy(plugin.schema);populate(canonical);}const defaults = canonical.properties?.shortcuts?.default ?? [];const user = {shortcuts: plugin.data.user.shortcuts ?? []};const composite = {shortcuts: SettingRegistry.reconcileShortcuts(defaults as ISettingRegistry.IShortcut[],user.shortcuts as ISettingRegistry.IShortcut[])};plugin.data = { composite, user };return plugin;},fetch: plugin => {// Only override the canonical schema the first time.if (!canonical) {canonical = JSONExt.deepCopy(plugin.schema);populate(canonical);}return {data: plugin.data,id: plugin.id,raw: plugin.raw,schema: canonical,version: plugin.version};}});try {// Repopulate the canonical variable after the setting registry has// preloaded all initial plugins.canonical = null;const settings = await registry.load(shortcuts.id);Private.loadShortcuts(commands, settings.composite);settings.changed.connect(() => {Private.loadShortcuts(commands, settings.composite);});} catch (error) {console.error(`Loading ${shortcuts.id} failed.`, error);}},autoStart: true}