@jupyterlab/cell-toolbar-extension 4.3.0-alpha.2 → 4.3.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.js CHANGED
@@ -10,15 +10,39 @@ import { ISettingRegistry } from '@jupyterlab/settingregistry';
10
10
  import { CellBarExtension } from '@jupyterlab/cell-toolbar';
11
11
  import { createToolbarFactory, IToolbarWidgetRegistry } from '@jupyterlab/apputils';
12
12
  import { ITranslator, nullTranslator } from '@jupyterlab/translation';
13
+ const PLUGIN_ID = '@jupyterlab/cell-toolbar-extension:plugin';
13
14
  const cellToolbar = {
14
- id: '@jupyterlab/cell-toolbar-extension:plugin',
15
+ id: PLUGIN_ID,
15
16
  description: 'Add the cells toolbar.',
16
17
  autoStart: true,
17
18
  activate: async (app, settingRegistry, toolbarRegistry, translator) => {
19
+ /**
20
+ * Load the settings for this extension
21
+ *
22
+ * @param setting Extension settings
23
+ */
24
+ function loadSetting(setting) {
25
+ // Read the setting and convert to the correct type
26
+ const showCellToolbar = setting === null
27
+ ? true
28
+ : setting.get('showToolbar').composite;
29
+ extension.enabled = showCellToolbar;
30
+ }
18
31
  const toolbarItems = settingRegistry && toolbarRegistry
19
32
  ? createToolbarFactory(toolbarRegistry, settingRegistry, CellBarExtension.FACTORY_NAME, cellToolbar.id, translator !== null && translator !== void 0 ? translator : nullTranslator)
20
33
  : undefined;
21
- app.docRegistry.addWidgetExtension('Notebook', new CellBarExtension(app.commands, toolbarItems));
34
+ const extension = new CellBarExtension(app.commands, toolbarItems);
35
+ // Wait for the application to be restored and
36
+ // for the settings for this plugin to be loaded
37
+ if (settingRegistry !== null) {
38
+ void Promise.all([app.restored, settingRegistry.load(PLUGIN_ID)]).then(([, setting]) => {
39
+ // Read the settings
40
+ loadSetting(setting);
41
+ // Listen for your plugin setting changes using Signal
42
+ setting.changed.connect(loadSetting);
43
+ });
44
+ }
45
+ app.docRegistry.addWidgetExtension('Notebook', extension);
22
46
  },
23
47
  optional: [ISettingRegistry, IToolbarWidgetRegistry, ITranslator]
24
48
  };
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;+EAG+E;AAC/E;;;GAGG;AAMH,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EACL,oBAAoB,EACpB,sBAAsB,EACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAEtE,MAAM,WAAW,GAAgC;IAC/C,EAAE,EAAE,2CAA2C;IAC/C,WAAW,EAAE,wBAAwB;IACrC,SAAS,EAAE,IAAI;IACf,QAAQ,EAAE,KAAK,EACb,GAAoB,EACpB,eAAwC,EACxC,eAA8C,EAC9C,UAA8B,EAC9B,EAAE;QACF,MAAM,YAAY,GAChB,eAAe,IAAI,eAAe;YAChC,CAAC,CAAC,oBAAoB,CAClB,eAAe,EACf,eAAe,EACf,gBAAgB,CAAC,YAAY,EAC7B,WAAW,CAAC,EAAE,EACd,UAAU,aAAV,UAAU,cAAV,UAAU,GAAI,cAAc,CAC7B;YACH,CAAC,CAAC,SAAS,CAAC;QAEhB,GAAG,CAAC,WAAW,CAAC,kBAAkB,CAChC,UAAU,EACV,IAAI,gBAAgB,CAAC,GAAG,CAAC,QAAQ,EAAE,YAAY,CAAC,CACjD,CAAC;IACJ,CAAC;IACD,QAAQ,EAAE,CAAC,gBAAgB,EAAE,sBAAsB,EAAE,WAAW,CAAC;CAClE,CAAC;AAEF,eAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;+EAG+E;AAC/E;;;GAGG;AAMH,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,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;gBACd,oBAAoB;gBACpB,WAAW,CAAC,OAAO,CAAC,CAAC;gBAErB,sDAAsD;gBACtD,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;YACvC,CAAC,CACF,CAAC;SACH;QAED,GAAG,CAAC,WAAW,CAAC,kBAAkB,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;IAC5D,CAAC;IACD,QAAQ,EAAE,CAAC,gBAAgB,EAAE,sBAAsB,EAAE,WAAW,CAAC;CAClE,CAAC;AAEF,eAAe,WAAW,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyterlab/cell-toolbar-extension",
3
- "version": "4.3.0-alpha.2",
3
+ "version": "4.3.0-beta.1",
4
4
  "description": "Extension for cell toolbar adapted from jlab-enhanced-cell-toolbar",
5
5
  "homepage": "https://github.com/jupyterlab/jupyterlab",
6
6
  "bugs": {
@@ -34,11 +34,11 @@
34
34
  "watch": "tsc -b --watch"
35
35
  },
36
36
  "dependencies": {
37
- "@jupyterlab/application": "^4.3.0-alpha.2",
38
- "@jupyterlab/apputils": "^4.4.0-alpha.2",
39
- "@jupyterlab/cell-toolbar": "^4.3.0-alpha.2",
40
- "@jupyterlab/settingregistry": "^4.3.0-alpha.2",
41
- "@jupyterlab/translation": "^4.3.0-alpha.2"
37
+ "@jupyterlab/application": "^4.3.0-beta.1",
38
+ "@jupyterlab/apputils": "^4.4.0-beta.1",
39
+ "@jupyterlab/cell-toolbar": "^4.3.0-beta.1",
40
+ "@jupyterlab/settingregistry": "^4.3.0-beta.1",
41
+ "@jupyterlab/translation": "^4.3.0-beta.1"
42
42
  },
43
43
  "devDependencies": {
44
44
  "rimraf": "~5.0.5",
@@ -27,6 +27,12 @@
27
27
  },
28
28
  "jupyter.lab.transform": true,
29
29
  "properties": {
30
+ "showToolbar": {
31
+ "title": "Show cell toolbar",
32
+ "description": "Show a toolbar inside the active cell, if there is enough room for one",
33
+ "type": "boolean",
34
+ "default": true
35
+ },
30
36
  "toolbar": {
31
37
  "title": "List of toolbar items",
32
38
  "description": "An item is defined by a 'name', a 'command' name, and an 'icon' name",
package/src/index.ts CHANGED
@@ -19,8 +19,10 @@ import {
19
19
  } from '@jupyterlab/apputils';
20
20
  import { ITranslator, nullTranslator } from '@jupyterlab/translation';
21
21
 
22
+ const PLUGIN_ID = '@jupyterlab/cell-toolbar-extension:plugin';
23
+
22
24
  const cellToolbar: JupyterFrontEndPlugin<void> = {
23
- id: '@jupyterlab/cell-toolbar-extension:plugin',
25
+ id: PLUGIN_ID,
24
26
  description: 'Add the cells toolbar.',
25
27
  autoStart: true,
26
28
  activate: async (
@@ -29,6 +31,21 @@ const cellToolbar: JupyterFrontEndPlugin<void> = {
29
31
  toolbarRegistry: IToolbarWidgetRegistry | null,
30
32
  translator: ITranslator | null
31
33
  ) => {
34
+ /**
35
+ * Load the settings for this extension
36
+ *
37
+ * @param setting Extension settings
38
+ */
39
+ function loadSetting(setting: ISettingRegistry.ISettings | null): void {
40
+ // Read the setting and convert to the correct type
41
+ const showCellToolbar: boolean | null =
42
+ setting === null
43
+ ? true
44
+ : (setting.get('showToolbar').composite as boolean);
45
+
46
+ extension.enabled = showCellToolbar;
47
+ }
48
+
32
49
  const toolbarItems =
33
50
  settingRegistry && toolbarRegistry
34
51
  ? createToolbarFactory(
@@ -40,10 +57,23 @@ const cellToolbar: JupyterFrontEndPlugin<void> = {
40
57
  )
41
58
  : undefined;
42
59
 
43
- app.docRegistry.addWidgetExtension(
44
- 'Notebook',
45
- new CellBarExtension(app.commands, toolbarItems)
46
- );
60
+ const extension = new CellBarExtension(app.commands, toolbarItems);
61
+
62
+ // Wait for the application to be restored and
63
+ // for the settings for this plugin to be loaded
64
+ if (settingRegistry !== null) {
65
+ void Promise.all([app.restored, settingRegistry.load(PLUGIN_ID)]).then(
66
+ ([, setting]) => {
67
+ // Read the settings
68
+ loadSetting(setting);
69
+
70
+ // Listen for your plugin setting changes using Signal
71
+ setting.changed.connect(loadSetting);
72
+ }
73
+ );
74
+ }
75
+
76
+ app.docRegistry.addWidgetExtension('Notebook', extension);
47
77
  },
48
78
  optional: [ISettingRegistry, IToolbarWidgetRegistry, ITranslator]
49
79
  };