Switch back to shortcut override plugin

This commit is contained in:
Jeremy Tuloup 2021-12-28 12:13:21 +01:00
parent 37b0c2e41f
commit 7c0b058372
3 changed files with 31 additions and 19 deletions

View File

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

View File

@ -1,15 +0,0 @@
{
"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

@ -5,12 +5,37 @@ import {
import { ISearchProviderRegistry } from '@jupyterlab/documentsearch';
import { IRetroShell } from '@retrolab/application';
import { ISettingRegistry } from '@jupyterlab/settingregistry';
import { Widget } from '@lumino/widgets';
import { IRetroShell } from '@retrolab/application';
const SEARCHABLE_CLASS = 'jp-mod-searchable';
/**
* A plugin to programmatically disable the Crtl-F shortcut in RetroLab
* See https://github.com/jupyterlab/retrolab/pull/294 and
* https://github.com/jupyterlab/jupyterlab/issues/11754 for more context.
*/
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;
docSearchShortcut.keys = [];
}
}
};
/**
* A plugin to add document search functionalities.
*/
@ -59,6 +84,9 @@ const retroShellWidgetListener: JupyterFrontEndPlugin<void> = {
/**
* Export the plugins as default.
*/
const plugins: JupyterFrontEndPlugin<any>[] = [retroShellWidgetListener];
const plugins: JupyterFrontEndPlugin<any>[] = [
disableShortcut,
retroShellWidgetListener
];
export default plugins;