Switch to declarative keyboard shortcuts

This commit is contained in:
Jeremy Tuloup 2021-12-24 15:19:41 +01:00
parent 38a6166b23
commit 55915e63e8
4 changed files with 28 additions and 25 deletions

View File

@ -27,8 +27,8 @@
"@jupyterlab/docmanager-extension": "~3.2.0",
"@jupyterlab/docprovider": "~3.2.0",
"@jupyterlab/docprovider-extension": "~3.2.0",
"@jupyterlab/documentsearch": "~3.2.0",
"@jupyterlab/documentsearch-extension": "~3.2.0",
"@jupyterlab/documentsearch": "~3.2.4",
"@jupyterlab/documentsearch-extension": "~3.2.4",
"@jupyterlab/filebrowser": "~3.2.0",
"@jupyterlab/filebrowser-extension": "~3.2.0",
"@jupyterlab/fileeditor": "~3.2.0",
@ -80,6 +80,7 @@
"@retrolab/application-extension": "~0.3.13",
"@retrolab/console-extension": "~0.3.13",
"@retrolab/docmanager-extension": "~0.3.13",
"@retrolab/documentsearch-extension": "~0.3.13",
"@retrolab/help-extension": "~0.3.13",
"@retrolab/notebook-extension": "~0.3.13",
"@retrolab/terminal-extension": "~0.3.13",
@ -122,6 +123,7 @@
"@retrolab/application-extension": "^0.3.13",
"@retrolab/console-extension": "^0.3.13",
"@retrolab/docmanager-extension": "^0.3.13",
"@retrolab/documentsearch-extension": "^0.3.13",
"@retrolab/help-extension": "^0.3.13",
"@retrolab/notebook-extension": "^0.3.13",
"@retrolab/terminal-extension": "^0.3.13",
@ -156,6 +158,7 @@
"@retrolab/application-extension",
"@retrolab/console-extension",
"@retrolab/docmanager-extension",
"@retrolab/documentsearch-extension",
"@retrolab/help-extension",
"@retrolab/notebook-extension",
"@retrolab/terminal-extension",

View File

@ -52,7 +52,8 @@
"access": "public"
},
"jupyterlab": {
"extension": true
"extension": true,
"schemaDir": "schema"
},
"styleModule": "style/index.js"
}

View File

@ -0,0 +1,15 @@
{
"title": "RetroLab DocumentSearch Settings",
"description": "RetroLab DocumentSearch Settings",
"jupyter.lab.shortcuts": [
{
"command": "documentsearch:start",
"keys": ["Accel F"],
"selector": ".jp-mod-searchable",
"disabled": true
}
],
"properties": {},
"additionalProperties": false,
"type": "object"
}

View File

@ -2,14 +2,18 @@ import {
JupyterFrontEnd,
JupyterFrontEndPlugin
} from '@jupyterlab/application';
import { ISearchProviderRegistry } from '@jupyterlab/documentsearch';
import { ISettingRegistry } from '@jupyterlab/settingregistry';
import { IRetroShell } from '@retrolab/application';
import { Widget } from '@lumino/widgets';
const SEARCHABLE_CLASS = 'jp-mod-searchable';
/**
* A plugin to add document search functionalities.
*/
const retroShellWidgetListener: JupyterFrontEndPlugin<void> = {
id: '@retrolab/documentsearch-extension:retroShellWidgetListener',
requires: [IRetroShell, ISearchProviderRegistry],
@ -52,29 +56,9 @@ const retroShellWidgetListener: JupyterFrontEndPlugin<void> = {
}
};
const disableShortcut: JupyterFrontEndPlugin<void> = {
id: '@retrolab/documentsearch-extension:disableShortcut',
requires: [ISettingRegistry],
autoStart: true,
activate: async (app: JupyterFrontEnd, registry: ISettingRegistry) => {
const docSearchShortcut = registry.plugins[
'@jupyterlab/documentsearch-extension:plugin'
]?.schema['jupyter.lab.shortcuts']?.find(
shortcut => shortcut.command === 'documentsearch:start'
);
if (docSearchShortcut) {
docSearchShortcut.disabled = true;
}
}
};
/**
* Export the plugins as default.
*/
const plugins: JupyterFrontEndPlugin<any>[] = [
retroShellWidgetListener,
disableShortcut
];
const plugins: JupyterFrontEndPlugin<any>[] = [retroShellWidgetListener];
export default plugins;