@jupyter-notebook/documentsearch-extension 7.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { JupyterFrontEndPlugin } from '@jupyterlab/application';
2
+ /**
3
+ * Export the plugins as default.
4
+ */
5
+ declare const plugins: JupyterFrontEndPlugin<any>[];
6
+ export default plugins;
package/lib/index.js ADDED
@@ -0,0 +1,66 @@
1
+ import { ISearchProviderRegistry } from '@jupyterlab/documentsearch';
2
+ import { ISettingRegistry } from '@jupyterlab/settingregistry';
3
+ import { INotebookShell } from '@jupyter-notebook/application';
4
+ const SEARCHABLE_CLASS = 'jp-mod-searchable';
5
+ /**
6
+ * A plugin to programmatically disable the Crtl-F shortcut in Jupyter Notebook
7
+ * See https://github.com/jupyterlab/retrolab/pull/294 and
8
+ * https://github.com/jupyterlab/jupyterlab/issues/11754 for more context.
9
+ */
10
+ const disableShortcut = {
11
+ id: '@jupyter-notebook/documentsearch-extension:disableShortcut',
12
+ requires: [ISettingRegistry],
13
+ autoStart: true,
14
+ activate: async (app, registry) => {
15
+ var _a, _b;
16
+ const docSearchShortcut = (_b = (_a = registry.plugins['@jupyterlab/documentsearch-extension:plugin']) === null || _a === void 0 ? void 0 : _a.schema['jupyter.lab.shortcuts']) === null || _b === void 0 ? void 0 : _b.find(shortcut => shortcut.command === 'documentsearch:start');
17
+ if (docSearchShortcut) {
18
+ docSearchShortcut.disabled = true;
19
+ docSearchShortcut.keys = [];
20
+ }
21
+ }
22
+ };
23
+ /**
24
+ * A plugin to add document search functionalities.
25
+ */
26
+ const notebookShellWidgetListener = {
27
+ id: '@jupyter-notebook/documentsearch-extension:notebookShellWidgetListener',
28
+ requires: [INotebookShell, ISearchProviderRegistry],
29
+ autoStart: true,
30
+ activate: (app, notebookShell, registry) => {
31
+ // If a given widget is searchable, apply the searchable class.
32
+ // If it's not searchable, remove the class.
33
+ const transformWidgetSearchability = (widget) => {
34
+ if (!widget) {
35
+ return;
36
+ }
37
+ const providerForWidget = registry.getProviderForWidget(widget);
38
+ if (providerForWidget) {
39
+ widget.addClass(SEARCHABLE_CLASS);
40
+ }
41
+ if (!providerForWidget) {
42
+ widget.removeClass(SEARCHABLE_CLASS);
43
+ }
44
+ };
45
+ // Update searchability of the active widget when the registry
46
+ // changes, in case a provider for the current widget was added
47
+ // or removed
48
+ registry.changed.connect(() => transformWidgetSearchability(notebookShell.currentWidget));
49
+ // Apply the searchable class only to the active widget if it is actually
50
+ // searchable. Remove the searchable class from a widget when it's
51
+ // no longer active.
52
+ notebookShell.currentChanged.connect((_, args) => {
53
+ if (notebookShell.currentWidget) {
54
+ transformWidgetSearchability(notebookShell.currentWidget);
55
+ }
56
+ });
57
+ }
58
+ };
59
+ /**
60
+ * Export the plugins as default.
61
+ */
62
+ const plugins = [
63
+ disableShortcut,
64
+ notebookShellWidgetListener
65
+ ];
66
+ export default plugins;
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@jupyter-notebook/documentsearch-extension",
3
+ "version": "7.0.0-alpha.1",
4
+ "description": "Jupyter Notebook - Document Search Extension",
5
+ "homepage": "https://github.com/jupyter/notebook",
6
+ "bugs": {
7
+ "url": "https://github.com/jupyter/notebook/issues"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "https://github.com/jupyter/notebook.git"
12
+ },
13
+ "license": "BSD-3-Clause",
14
+ "author": "Project Jupyter",
15
+ "sideEffects": [
16
+ "style/**/*.css",
17
+ "style/index.js"
18
+ ],
19
+ "main": "lib/index.js",
20
+ "types": "lib/index.d.ts",
21
+ "style": "style/index.css",
22
+ "directories": {
23
+ "lib": "lib/"
24
+ },
25
+ "files": [
26
+ "lib/*.d.ts",
27
+ "lib/*.js.map",
28
+ "lib/*.js",
29
+ "schema/*.json",
30
+ "style/**/*.css",
31
+ "style/index.js"
32
+ ],
33
+ "scripts": {
34
+ "build": "tsc -b",
35
+ "build:prod": "tsc -b",
36
+ "clean": "rimraf lib && rimraf tsconfig.tsbuildinfo",
37
+ "docs": "typedoc src",
38
+ "prepublishOnly": "npm run build",
39
+ "watch": "tsc -b --watch"
40
+ },
41
+ "dependencies": {
42
+ "@jupyter-notebook/application": "^7.0.0-alpha.1",
43
+ "@jupyterlab/application": "^4.0.0-alpha.4",
44
+ "@jupyterlab/documentsearch": "^4.0.0-alpha.4",
45
+ "@lumino/widgets": "^1.31.1"
46
+ },
47
+ "devDependencies": {
48
+ "rimraf": "~3.0.0",
49
+ "typescript": "~4.1.3"
50
+ },
51
+ "publishConfig": {
52
+ "access": "public"
53
+ },
54
+ "jupyterlab": {
55
+ "extension": true
56
+ },
57
+ "styleModule": "style/index.js"
58
+ }
package/style/base.css ADDED
File without changes
@@ -0,0 +1 @@
1
+ @import url('./base.css');
package/style/index.js ADDED
@@ -0,0 +1 @@
1
+ import './base.css';