Skip to content
This repository has been archived by the owner on Feb 16, 2023. It is now read-only.

Commit

Permalink
Switch to declarative keyboard shortcuts
Browse files Browse the repository at this point in the history
  • Loading branch information
jtpio committed Dec 24, 2021
1 parent 38a6166 commit 55915e6
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 25 deletions.
7 changes: 5 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion packages/documentsearch-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"access": "public"
},
"jupyterlab": {
"extension": true
"extension": true,
"schemaDir": "schema"
},
"styleModule": "style/index.js"
}
Original file line number Diff line number Diff line change
@@ -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"
}
28 changes: 6 additions & 22 deletions packages/documentsearch-extension/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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;

0 comments on commit 55915e6

Please sign in to comment.