@jupyter-notebook/notebook-extension 7.0.0-alpha.2 → 7.0.0-alpha.5

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
@@ -1,15 +1,14 @@
1
1
  // Copyright (c) Jupyter Development Team.
2
2
  // Distributed under the terms of the Modified BSD License.
3
- import { DOMUtils } from '@jupyterlab/apputils';
3
+ import { DOMUtils, IToolbarWidgetRegistry } from '@jupyterlab/apputils';
4
4
  import { Text, Time } from '@jupyterlab/coreutils';
5
5
  import { IDocumentManager } from '@jupyterlab/docmanager';
6
- import { IMainMenu } from '@jupyterlab/mainmenu';
7
6
  import { NotebookPanel, INotebookTracker } from '@jupyterlab/notebook';
8
7
  import { ISettingRegistry } from '@jupyterlab/settingregistry';
9
8
  import { ITranslator } from '@jupyterlab/translation';
10
9
  import { INotebookShell } from '@jupyter-notebook/application';
11
10
  import { Poll } from '@lumino/polling';
12
- import { Menu, Widget } from '@lumino/widgets';
11
+ import { Widget } from '@lumino/widgets';
13
12
  /**
14
13
  * The class for kernel status errors.
15
14
  */
@@ -37,14 +36,19 @@ const checkpoints = {
37
36
  id: '@jupyter-notebook/notebook-extension:checkpoints',
38
37
  autoStart: true,
39
38
  requires: [IDocumentManager, ITranslator],
40
- optional: [INotebookShell],
41
- activate: (app, docManager, translator, notebookShell) => {
39
+ optional: [INotebookShell, IToolbarWidgetRegistry],
40
+ activate: (app, docManager, translator, notebookShell, toolbarRegistry) => {
42
41
  const { shell } = app;
43
42
  const trans = translator.load('notebook');
44
- const widget = new Widget();
45
- widget.id = DOMUtils.createDomID();
46
- widget.addClass('jp-NotebookCheckpoint');
47
- app.shell.add(widget, 'top', { rank: 100 });
43
+ const node = document.createElement('div');
44
+ if (toolbarRegistry) {
45
+ toolbarRegistry.addFactory('TopBar', 'checkpoint', toolbar => {
46
+ const widget = new Widget({ node });
47
+ widget.id = DOMUtils.createDomID();
48
+ widget.addClass('jp-NotebookCheckpoint');
49
+ return widget;
50
+ });
51
+ }
48
52
  const onChange = async () => {
49
53
  const current = shell.currentWidget;
50
54
  if (!current) {
@@ -58,7 +62,7 @@ const checkpoints = {
58
62
  return;
59
63
  }
60
64
  const checkpoint = checkpoints[checkpoints.length - 1];
61
- widget.node.textContent = trans.__('Last Checkpoint: %1', Time.formatHuman(new Date(checkpoint.last_modified)));
65
+ node.textContent = trans.__('Last Checkpoint: %1', Time.formatHuman(new Date(checkpoint.last_modified)));
62
66
  };
63
67
  if (notebookShell) {
64
68
  notebookShell.currentChanged.connect(onChange);
@@ -81,15 +85,14 @@ const kernelLogo = {
81
85
  id: '@jupyter-notebook/notebook-extension:kernel-logo',
82
86
  autoStart: true,
83
87
  requires: [INotebookShell],
84
- activate: (app, shell) => {
88
+ optional: [IToolbarWidgetRegistry],
89
+ activate: (app, shell, toolbarRegistry) => {
85
90
  const { serviceManager } = app;
86
- let widget;
91
+ const node = document.createElement('div');
92
+ const img = document.createElement('img');
93
+ node.appendChild(img);
87
94
  const onChange = async () => {
88
95
  var _a, _b, _c, _d, _e;
89
- if (widget) {
90
- widget.dispose();
91
- widget.parent = null;
92
- }
93
96
  const current = shell.currentWidget;
94
97
  if (!(current instanceof NotebookPanel)) {
95
98
  return;
@@ -106,15 +109,16 @@ const kernelLogo = {
106
109
  if (!kernelIconUrl) {
107
110
  return;
108
111
  }
109
- const node = document.createElement('div');
110
- const img = document.createElement('img');
111
112
  img.src = kernelIconUrl;
112
113
  img.title = spec.display_name;
113
- node.appendChild(img);
114
- widget = new Widget({ node });
115
- widget.addClass('jp-NotebookKernelLogo');
116
- app.shell.add(widget, 'top', { rank: 10010 });
117
114
  };
115
+ if (toolbarRegistry) {
116
+ toolbarRegistry.addFactory('TopBar', 'kernelLogo', toolbar => {
117
+ const widget = new Widget({ node });
118
+ widget.addClass('jp-NotebookKernelLogo');
119
+ return widget;
120
+ });
121
+ }
118
122
  app.started.then(() => {
119
123
  shell.currentChanged.connect(onChange);
120
124
  });
@@ -173,36 +177,6 @@ const kernelStatus = {
173
177
  shell.currentChanged.connect(onChange);
174
178
  }
175
179
  };
176
- /**
177
- * A plugin to customize notebook related menu entries
178
- * TODO: switch to settings define menus when fixed upstream: https://github.com/jupyterlab/jupyterlab/issues/11754
179
- */
180
- const menuPlugin = {
181
- id: '@jupyter-notebook/notebook-extension:menu-plugin',
182
- autoStart: true,
183
- requires: [IMainMenu, ITranslator],
184
- activate: (app, mainMenu, translator) => {
185
- const { commands } = app;
186
- const trans = translator.load('notebook');
187
- const cellTypeSubmenu = new Menu({ commands });
188
- cellTypeSubmenu.title.label = trans._p('menu', 'Cell Type');
189
- [
190
- 'notebook:change-cell-to-code',
191
- 'notebook:change-cell-to-markdown',
192
- 'notebook:change-cell-to-raw'
193
- ].forEach(command => {
194
- cellTypeSubmenu.addItem({
195
- command
196
- });
197
- });
198
- mainMenu.runMenu.addItem({ type: 'separator', rank: 1000 });
199
- mainMenu.runMenu.addItem({
200
- type: 'submenu',
201
- submenu: cellTypeSubmenu,
202
- rank: 1010
203
- });
204
- }
205
- };
206
180
  /**
207
181
  * A plugin to enable scrolling for outputs by default.
208
182
  * Mimic the logic from the classic notebook, as found here:
@@ -288,7 +262,6 @@ const plugins = [
288
262
  checkpoints,
289
263
  kernelLogo,
290
264
  kernelStatus,
291
- menuPlugin,
292
265
  scrollOutput
293
266
  ];
294
267
  export default plugins;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyter-notebook/notebook-extension",
3
- "version": "7.0.0-alpha.2",
3
+ "version": "7.0.0-alpha.5",
4
4
  "description": "Jupyter Notebook - Notebook Extension",
5
5
  "homepage": "https://github.com/jupyter/notebook",
6
6
  "bugs": {
@@ -39,20 +39,20 @@
39
39
  "watch": "tsc -b --watch"
40
40
  },
41
41
  "dependencies": {
42
- "@jupyter-notebook/application": "^7.0.0-alpha.2",
43
- "@jupyterlab/application": "^4.0.0-alpha.7",
44
- "@jupyterlab/apputils": "^4.0.0-alpha.7",
45
- "@jupyterlab/cells": "^4.0.0-alpha.7",
46
- "@jupyterlab/docmanager": "^4.0.0-alpha.7",
47
- "@jupyterlab/notebook": "^4.0.0-alpha.7",
48
- "@jupyterlab/settingregistry": "^4.0.0-alpha.7",
49
- "@jupyterlab/translation": "^4.0.0-alpha.7",
42
+ "@jupyter-notebook/application": "^7.0.0-alpha.5",
43
+ "@jupyterlab/application": "^4.0.0-alpha.10",
44
+ "@jupyterlab/apputils": "^4.0.0-alpha.10",
45
+ "@jupyterlab/cells": "^4.0.0-alpha.10",
46
+ "@jupyterlab/docmanager": "^4.0.0-alpha.10",
47
+ "@jupyterlab/notebook": "^4.0.0-alpha.10",
48
+ "@jupyterlab/settingregistry": "^4.0.0-alpha.10",
49
+ "@jupyterlab/translation": "^4.0.0-alpha.10",
50
50
  "@lumino/polling": "^1.10.0",
51
- "@lumino/widgets": "^1.31.1"
51
+ "@lumino/widgets": "^1.32.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "rimraf": "~3.0.0",
55
- "typescript": "~4.1.3"
55
+ "typescript": "~4.6.3"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public"
@@ -0,0 +1,10 @@
1
+ {
2
+ "title": "Notebook checkpoint indicator",
3
+ "description": "Notebook checkpoint indicator",
4
+ "jupyter.lab.toolbars": {
5
+ "TopBar": [{ "name": "checkpoint", "rank": 20 }]
6
+ },
7
+ "properties": {},
8
+ "additionalProperties": false,
9
+ "type": "object"
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "title": "Kernel logo",
3
+ "description": "Kernel logo in the top area",
4
+ "jupyter.lab.toolbars": {
5
+ "TopBar": [{ "name": "kernelLogo", "rank": 110 }]
6
+ },
7
+ "properties": {},
8
+ "additionalProperties": false,
9
+ "type": "object"
10
+ }
package/style/base.css CHANGED
@@ -29,6 +29,23 @@ body[data-notebook='notebooks'] .jp-Notebook > *:first-child {
29
29
  margin-top: var(--jp-notebook-toolbar-margin-bottom);
30
30
  }
31
31
 
32
+ body[data-notebook='notebooks'] .jp-Notebook > *:first-child:not(:last-child) {
33
+ box-shadow: 0px 0px 12px 1px rgb(87 87 87 / 20%);
34
+ }
35
+
36
+ body[data-notebook='notebooks']
37
+ .jp-Notebook
38
+ > *:first-child:last-child::before {
39
+ content: '';
40
+ position: absolute;
41
+ top: 0;
42
+ bottom: 0;
43
+ left: 0;
44
+ right: 0;
45
+ box-shadow: 0px 0px 12px 1px rgb(87 87 87 / 20%);
46
+ margin-bottom: -11px;
47
+ }
48
+
32
49
  body[data-notebook='notebooks'] .jp-Notebook {
33
50
  padding-top: unset;
34
51
  padding-bottom: unset;
@@ -43,6 +60,49 @@ body[data-notebook='notebooks'] .jp-Notebook {
43
60
 
44
61
  body[data-notebook='notebooks'] .jp-Notebook.jp-mod-scrollPastEnd::after {
45
62
  background: var(--jp-layout-color0);
63
+ min-height: var(--jp-notebook-padding);
64
+ box-shadow: 0px 0px 12px 1px rgb(87 87 87 / 20%);
65
+ }
66
+
67
+ body[data-notebook='notebooks']
68
+ .jp-Notebook
69
+ .jp-Notebook-cell:not(:first-child)::after,
70
+ body[data-notebook='notebooks']
71
+ .jp-Notebook
72
+ .jp-Notebook-cell:not(:first-child)::before {
73
+ content: ' ';
74
+ height: 100%;
75
+ position: absolute;
76
+ top: 0;
77
+ width: 11px;
78
+ }
79
+
80
+ body[data-notebook='notebooks']
81
+ .jp-Notebook
82
+ .jp-Notebook-cell:not(:first-child)::before {
83
+ box-shadow: -11px 0 11px -11px rgb(87 87 87 / 20%) inset;
84
+ left: -11px;
85
+ }
86
+
87
+ body[data-notebook='notebooks']
88
+ .jp-Notebook
89
+ .jp-Notebook-cell:not(:first-child)::after {
90
+ box-shadow: 12px 0 11px -11px rgb(87 87 87 / 20%) inset;
91
+ right: -11px;
92
+ }
93
+
94
+ /* Cell toolbar adjustements */
95
+
96
+ body[data-notebook='notebooks'] .jp-cell-toolbar {
97
+ background: unset;
98
+ top: unset;
99
+ box-shadow: unset;
100
+ }
101
+
102
+ @media only screen and (max-width: 760px) {
103
+ body[data-notebook='notebooks'] .jp-cell-toolbar {
104
+ top: 5px;
105
+ }
46
106
  }
47
107
 
48
108
  /* ---- */