@jupyter-notebook/notebook-extension 7.0.0-alpha.1 → 7.0.0-alpha.4
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 +26 -53
- package/package.json +11 -11
- package/schema/checkpoints.json +10 -0
- package/schema/kernel-logo.json +10 -0
- package/style/base.css +14 -0
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 {
|
|
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
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
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
|
-
|
|
88
|
+
optional: [IToolbarWidgetRegistry],
|
|
89
|
+
activate: (app, shell, toolbarRegistry) => {
|
|
85
90
|
const { serviceManager } = app;
|
|
86
|
-
|
|
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.
|
|
3
|
+
"version": "7.0.0-alpha.4",
|
|
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.
|
|
43
|
-
"@jupyterlab/application": "^4.0.0-alpha.
|
|
44
|
-
"@jupyterlab/apputils": "^4.0.0-alpha.
|
|
45
|
-
"@jupyterlab/cells": "^4.0.0-alpha.
|
|
46
|
-
"@jupyterlab/docmanager": "^4.0.0-alpha.
|
|
47
|
-
"@jupyterlab/notebook": "^4.0.0-alpha.
|
|
48
|
-
"@jupyterlab/settingregistry": "^4.0.0-alpha.
|
|
49
|
-
"@jupyterlab/translation": "^4.0.0-alpha.
|
|
42
|
+
"@jupyter-notebook/application": "^7.0.0-alpha.4",
|
|
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.
|
|
51
|
+
"@lumino/widgets": "^1.32.0"
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
54
|
"rimraf": "~3.0.0",
|
|
55
|
-
"typescript": "~4.
|
|
55
|
+
"typescript": "~4.6.3"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|
package/style/base.css
CHANGED
|
@@ -43,6 +43,20 @@ body[data-notebook='notebooks'] .jp-Notebook {
|
|
|
43
43
|
|
|
44
44
|
body[data-notebook='notebooks'] .jp-Notebook.jp-mod-scrollPastEnd::after {
|
|
45
45
|
background: var(--jp-layout-color0);
|
|
46
|
+
min-height: var(--jp-notebook-padding);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/* Cell toolbar adjustements */
|
|
50
|
+
|
|
51
|
+
body[data-notebook='notebooks'] .jp-cell-toolbar {
|
|
52
|
+
background: unset;
|
|
53
|
+
top: unset;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
@media only screen and (max-width: 760px) {
|
|
57
|
+
body[data-notebook='notebooks'] .jp-cell-toolbar {
|
|
58
|
+
top: 5px;
|
|
59
|
+
}
|
|
46
60
|
}
|
|
47
61
|
|
|
48
62
|
/* ---- */
|