@jupyter-notebook/documentsearch-extension 7.7.0-alpha.2 → 7.7.0-beta.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 CHANGED
@@ -1,3 +1,7 @@
1
+ /**
2
+ * @packageDocumentation
3
+ * @module documentsearch-extension
4
+ */
1
5
  import { JupyterFrontEndPlugin } from '@jupyterlab/application';
2
6
  /**
3
7
  * Export the plugins as default.
package/lib/index.js CHANGED
@@ -1,3 +1,9 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ /**
4
+ * @packageDocumentation
5
+ * @module documentsearch-extension
6
+ */
1
7
  import { ISearchProviderRegistry } from '@jupyterlab/documentsearch';
2
8
  import { INotebookShell } from '@jupyter-notebook/application';
3
9
  const SEARCHABLE_CLASS = 'jp-mod-searchable';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyter-notebook/documentsearch-extension",
3
- "version": "7.7.0-alpha.2",
3
+ "version": "7.7.0-beta.1",
4
4
  "description": "Jupyter Notebook - Document Search Extension",
5
5
  "homepage": "https://github.com/jupyter/notebook",
6
6
  "bugs": {
@@ -26,9 +26,9 @@
26
26
  "lib/*.d.ts",
27
27
  "lib/*.js.map",
28
28
  "lib/*.js",
29
- "schema/*.json",
30
29
  "style/**/*.css",
31
- "style/index.js"
30
+ "style/index.js",
31
+ "src/**/*.{ts,tsx}"
32
32
  ],
33
33
  "scripts": {
34
34
  "build": "tsc -b",
@@ -38,9 +38,9 @@
38
38
  "watch": "tsc -b --watch"
39
39
  },
40
40
  "dependencies": {
41
- "@jupyter-notebook/application": "^7.7.0-alpha.2",
42
- "@jupyterlab/application": "~4.7.0-alpha.2",
43
- "@jupyterlab/documentsearch": "~4.7.0-alpha.2",
41
+ "@jupyter-notebook/application": "^7.7.0-beta.1",
42
+ "@jupyterlab/application": "~4.7.0-beta.1",
43
+ "@jupyterlab/documentsearch": "~4.7.0-beta.1",
44
44
  "@lumino/widgets": "^2.7.2"
45
45
  },
46
46
  "devDependencies": {
@@ -51,8 +51,7 @@
51
51
  "access": "public"
52
52
  },
53
53
  "jupyterlab": {
54
- "extension": true,
55
- "schemaDir": "schema"
54
+ "extension": true
56
55
  },
57
56
  "styleModule": "style/index.js"
58
57
  }
package/src/index.ts ADDED
@@ -0,0 +1,70 @@
1
+ // Copyright (c) Jupyter Development Team.
2
+ // Distributed under the terms of the Modified BSD License.
3
+ /**
4
+ * @packageDocumentation
5
+ * @module documentsearch-extension
6
+ */
7
+
8
+ import {
9
+ JupyterFrontEnd,
10
+ JupyterFrontEndPlugin,
11
+ } from '@jupyterlab/application';
12
+
13
+ import { ISearchProviderRegistry } from '@jupyterlab/documentsearch';
14
+
15
+ import { Widget } from '@lumino/widgets';
16
+
17
+ import { INotebookShell } from '@jupyter-notebook/application';
18
+
19
+ const SEARCHABLE_CLASS = 'jp-mod-searchable';
20
+
21
+ /**
22
+ * A plugin to add document search functionalities.
23
+ */
24
+ const notebookShellWidgetListener: JupyterFrontEndPlugin<void> = {
25
+ id: '@jupyter-notebook/documentsearch-extension:notebookShellWidgetListener',
26
+ requires: [INotebookShell, ISearchProviderRegistry],
27
+ autoStart: true,
28
+ description: 'A plugin to add document search functionalities',
29
+ activate: (
30
+ app: JupyterFrontEnd,
31
+ notebookShell: INotebookShell,
32
+ registry: ISearchProviderRegistry
33
+ ) => {
34
+ // If a given widget is searchable, apply the searchable class.
35
+ // If it's not searchable, remove the class.
36
+ const transformWidgetSearchability = (widget: Widget | null) => {
37
+ if (!widget) {
38
+ return;
39
+ }
40
+ if (registry.hasProvider(widget)) {
41
+ widget.addClass(SEARCHABLE_CLASS);
42
+ } else {
43
+ widget.removeClass(SEARCHABLE_CLASS);
44
+ }
45
+ };
46
+
47
+ // Update searchability of the active widget when the registry
48
+ // changes, in case a provider for the current widget was added
49
+ // or removed
50
+ registry.changed.connect(() =>
51
+ transformWidgetSearchability(notebookShell.currentWidget)
52
+ );
53
+
54
+ // Apply the searchable class only to the active widget if it is actually
55
+ // searchable. Remove the searchable class from a widget when it's
56
+ // no longer active.
57
+ notebookShell.currentChanged.connect((_, args) => {
58
+ if (notebookShell.currentWidget) {
59
+ transformWidgetSearchability(notebookShell.currentWidget);
60
+ }
61
+ });
62
+ },
63
+ };
64
+
65
+ /**
66
+ * Export the plugins as default.
67
+ */
68
+ const plugins: JupyterFrontEndPlugin<any>[] = [notebookShellWidgetListener];
69
+
70
+ export default plugins;
package/style/index.css CHANGED
@@ -1 +1,7 @@
1
+ /*-----------------------------------------------------------------------------
2
+ | Copyright (c) Jupyter Development Team.
3
+ | Distributed under the terms of the Modified BSD License.
4
+ |----------------------------------------------------------------------------*/
5
+
6
+ /* This file was auto-generated by ensurePackage() in @jupyterlab/buildutils */
1
7
  @import url('./base.css');
package/style/index.js CHANGED
@@ -1 +1,8 @@
1
+ /*-----------------------------------------------------------------------------
2
+ | Copyright (c) Jupyter Development Team.
3
+ | Distributed under the terms of the Modified BSD License.
4
+ |----------------------------------------------------------------------------*/
5
+
6
+ /* This file was auto-generated by ensurePackage() in @jupyterlab/buildutils */
7
+
1
8
  import './base.css';