@jupyter-notebook/notebook-extension 7.7.0-alpha.0 → 7.7.0-alpha.2
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 +61 -19
- package/package.json +13 -11
package/lib/index.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
// Copyright (c) Jupyter Development Team.
|
|
2
2
|
// Distributed under the terms of the Modified BSD License.
|
|
3
3
|
import { Dialog, DOMUtils, IToolbarWidgetRegistry, ICommandPalette, showDialog, } from '@jupyterlab/apputils';
|
|
4
|
-
import {
|
|
4
|
+
import { Time, URLExt } from '@jupyterlab/coreutils';
|
|
5
5
|
import { IDebuggerSidebar } from '@jupyterlab/debugger';
|
|
6
6
|
import { IDocumentManager } from '@jupyterlab/docmanager';
|
|
7
7
|
import { IMainMenu } from '@jupyterlab/mainmenu';
|
|
8
|
+
import { IMetadataFormProvider } from '@jupyterlab/metadataform';
|
|
8
9
|
import { NotebookPanel, INotebookTracker, INotebookTools, } from '@jupyterlab/notebook';
|
|
9
10
|
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
10
11
|
import { ITableOfContentsTracker } from '@jupyterlab/toc';
|
|
11
12
|
import { ITranslator, nullTranslator } from '@jupyterlab/translation';
|
|
13
|
+
import { Collapser } from '@jupyterlab/ui-components';
|
|
12
14
|
import { INotebookShell } from '@jupyter-notebook/application';
|
|
13
15
|
import { find } from '@lumino/algorithm';
|
|
14
16
|
import { Poll } from '@lumino/polling';
|
|
@@ -245,7 +247,7 @@ const openTreeTab = {
|
|
|
245
247
|
commands.addCommand(id, {
|
|
246
248
|
label: trans.__('Open…'),
|
|
247
249
|
execute: async () => {
|
|
248
|
-
const url = URLExt.join(
|
|
250
|
+
const url = URLExt.join(app.serviceManager.serverSettings.baseUrl, 'tree');
|
|
249
251
|
window.open(url);
|
|
250
252
|
},
|
|
251
253
|
describedBy: {
|
|
@@ -395,9 +397,26 @@ const kernelStatus = {
|
|
|
395
397
|
widget.removeClass(KERNEL_STATUS_INFO_CLASS);
|
|
396
398
|
widget.removeClass(KERNEL_STATUS_FADE_OUT_CLASS);
|
|
397
399
|
};
|
|
400
|
+
// The labels are enumerated explicitly so the translation extractor picks
|
|
401
|
+
// them up, since msgids must be literal strings.
|
|
402
|
+
const statusLabels = {
|
|
403
|
+
unknown: trans.__('Kernel Unknown'),
|
|
404
|
+
starting: trans.__('Kernel Starting'),
|
|
405
|
+
idle: trans.__('Kernel Idle'),
|
|
406
|
+
busy: trans.__('Kernel Busy'),
|
|
407
|
+
terminating: trans.__('Kernel Terminating'),
|
|
408
|
+
restarting: trans.__('Kernel Restarting'),
|
|
409
|
+
autorestarting: trans.__('Kernel Autorestarting'),
|
|
410
|
+
dead: trans.__('Kernel Dead'),
|
|
411
|
+
connected: trans.__('Kernel Connected'),
|
|
412
|
+
connecting: trans.__('Kernel Connecting'),
|
|
413
|
+
disconnected: trans.__('Kernel Disconnected'),
|
|
414
|
+
initializing: trans.__('Kernel Initializing'),
|
|
415
|
+
'': '',
|
|
416
|
+
};
|
|
398
417
|
const onStatusChanged = (sessionContext) => {
|
|
399
418
|
const status = sessionContext.kernelDisplayStatus;
|
|
400
|
-
let text =
|
|
419
|
+
let text = statusLabels[status];
|
|
401
420
|
removeClasses();
|
|
402
421
|
switch (status) {
|
|
403
422
|
case 'busy':
|
|
@@ -417,7 +436,7 @@ const kernelStatus = {
|
|
|
417
436
|
widget.addClass(KERNEL_STATUS_FADE_OUT_CLASS);
|
|
418
437
|
break;
|
|
419
438
|
}
|
|
420
|
-
widget.node.textContent =
|
|
439
|
+
widget.node.textContent = text;
|
|
421
440
|
};
|
|
422
441
|
const onChange = async () => {
|
|
423
442
|
const current = shell.currentWidget;
|
|
@@ -467,6 +486,17 @@ const scrollOutput = {
|
|
|
467
486
|
cell.toggleClass(SCROLLED_OUTPUTS_CLASS, scroll);
|
|
468
487
|
};
|
|
469
488
|
const handlers = {};
|
|
489
|
+
// outputs render asynchronously, so the height measured on a model
|
|
490
|
+
// change can be stale: check again whenever the output area is resized
|
|
491
|
+
const observedCells = new WeakMap();
|
|
492
|
+
const resizeObserver = new ResizeObserver((entries) => {
|
|
493
|
+
entries.forEach((entry) => {
|
|
494
|
+
const cell = observedCells.get(entry.target);
|
|
495
|
+
if (cell && !cell.isDisposed) {
|
|
496
|
+
autoScroll(cell);
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
});
|
|
470
500
|
const setAutoScroll = (cell) => {
|
|
471
501
|
if (cell.model.type === 'code') {
|
|
472
502
|
const codeCell = cell;
|
|
@@ -477,6 +507,12 @@ const scrollOutput = {
|
|
|
477
507
|
}
|
|
478
508
|
handlers[id] = () => autoScroll(codeCell);
|
|
479
509
|
codeCell.outputArea.model.changed.connect(handlers[id]);
|
|
510
|
+
const { node } = codeCell.outputArea;
|
|
511
|
+
if (!observedCells.has(node)) {
|
|
512
|
+
observedCells.set(node, codeCell);
|
|
513
|
+
resizeObserver.observe(node);
|
|
514
|
+
codeCell.disposed.connect(() => resizeObserver.unobserve(node));
|
|
515
|
+
}
|
|
480
516
|
}
|
|
481
517
|
};
|
|
482
518
|
tracker.widgetAdded.connect((sender, notebook) => {
|
|
@@ -541,7 +577,7 @@ const tabIcon = {
|
|
|
541
577
|
requires: [INotebookTracker],
|
|
542
578
|
activate: (app, tracker) => {
|
|
543
579
|
// the favicons are provided by Jupyter Server
|
|
544
|
-
const baseURL =
|
|
580
|
+
const baseURL = app.serviceManager.serverSettings.baseUrl;
|
|
545
581
|
const notebookIcon = URLExt.join(baseURL, 'static/favicons/favicon-notebook.ico');
|
|
546
582
|
const busyIcon = URLExt.join(baseURL, 'static/favicons/favicon-busy-1.ico');
|
|
547
583
|
const updateBrowserFavicon = (status) => {
|
|
@@ -600,8 +636,13 @@ const editNotebookMetadata = {
|
|
|
600
636
|
id: '@jupyter-notebook/notebook-extension:edit-notebook-metadata',
|
|
601
637
|
description: 'Add a command to open right sidebar for Editing Notebook Metadata when clicking on "Edit Notebook Metadata" under Edit menu',
|
|
602
638
|
autoStart: true,
|
|
603
|
-
optional: [
|
|
604
|
-
|
|
639
|
+
optional: [
|
|
640
|
+
ICommandPalette,
|
|
641
|
+
ITranslator,
|
|
642
|
+
INotebookTools,
|
|
643
|
+
IMetadataFormProvider,
|
|
644
|
+
],
|
|
645
|
+
activate: (app, palette, translator, notebookTools, metadataForms) => {
|
|
605
646
|
const { commands, shell } = app;
|
|
606
647
|
translator = translator !== null && translator !== void 0 ? translator : nullTranslator;
|
|
607
648
|
const trans = translator.load('notebook');
|
|
@@ -611,23 +652,24 @@ const editNotebookMetadata = {
|
|
|
611
652
|
const command = 'application:toggle-panel';
|
|
612
653
|
const args = {
|
|
613
654
|
side: 'right',
|
|
614
|
-
title: '
|
|
655
|
+
title: trans.__('Notebook Tools'),
|
|
615
656
|
id: 'notebook-tools',
|
|
616
657
|
};
|
|
617
658
|
// Check if Show Notebook Tools (Right Sidebar) is open (expanded)
|
|
618
659
|
if (!commands.isToggled(command, args)) {
|
|
619
|
-
await commands.execute(command, args)
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
660
|
+
await commands.execute(command, args);
|
|
661
|
+
// For expanding the 'Advanced Tools' section (default: collapsed)
|
|
662
|
+
const advancedToolsForm = metadataForms === null || metadataForms === void 0 ? void 0 : metadataForms.get('advancedToolsSection');
|
|
663
|
+
if (notebookTools && advancedToolsForm) {
|
|
664
|
+
const layout = notebookTools.layout;
|
|
665
|
+
for (const section of layout.widgets) {
|
|
666
|
+
if (section instanceof Collapser &&
|
|
667
|
+
section.widget === advancedToolsForm.parent &&
|
|
668
|
+
section.collapsed) {
|
|
669
|
+
section.toggle();
|
|
670
|
+
}
|
|
629
671
|
}
|
|
630
|
-
}
|
|
672
|
+
}
|
|
631
673
|
}
|
|
632
674
|
},
|
|
633
675
|
isVisible: () => shell.currentWidget !== null &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyter-notebook/notebook-extension",
|
|
3
|
-
"version": "7.7.0-alpha.
|
|
3
|
+
"version": "7.7.0-alpha.2",
|
|
4
4
|
"description": "Jupyter Notebook - Notebook Extension",
|
|
5
5
|
"homepage": "https://github.com/jupyter/notebook",
|
|
6
6
|
"bugs": {
|
|
@@ -38,16 +38,18 @@
|
|
|
38
38
|
"watch": "tsc -b --watch"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@jupyter-notebook/application": "^7.7.0-alpha.
|
|
42
|
-
"@jupyterlab/application": "~4.7.0-alpha.
|
|
43
|
-
"@jupyterlab/apputils": "~4.8.0-alpha.
|
|
44
|
-
"@jupyterlab/cells": "~4.7.0-alpha.
|
|
45
|
-
"@jupyterlab/debugger": "~4.7.0-alpha.
|
|
46
|
-
"@jupyterlab/docmanager": "~4.7.0-alpha.
|
|
47
|
-
"@jupyterlab/
|
|
48
|
-
"@jupyterlab/
|
|
49
|
-
"@jupyterlab/
|
|
50
|
-
"@jupyterlab/
|
|
41
|
+
"@jupyter-notebook/application": "^7.7.0-alpha.2",
|
|
42
|
+
"@jupyterlab/application": "~4.7.0-alpha.2",
|
|
43
|
+
"@jupyterlab/apputils": "~4.8.0-alpha.2",
|
|
44
|
+
"@jupyterlab/cells": "~4.7.0-alpha.2",
|
|
45
|
+
"@jupyterlab/debugger": "~4.7.0-alpha.2",
|
|
46
|
+
"@jupyterlab/docmanager": "~4.7.0-alpha.2",
|
|
47
|
+
"@jupyterlab/metadataform": "~4.7.0-alpha.2",
|
|
48
|
+
"@jupyterlab/notebook": "~4.7.0-alpha.2",
|
|
49
|
+
"@jupyterlab/settingregistry": "~4.7.0-alpha.2",
|
|
50
|
+
"@jupyterlab/toc": "~6.7.0-alpha.2",
|
|
51
|
+
"@jupyterlab/translation": "~4.7.0-alpha.2",
|
|
52
|
+
"@jupyterlab/ui-components": "~4.7.0-alpha.2",
|
|
51
53
|
"@lumino/algorithm": "2.0.4",
|
|
52
54
|
"@lumino/polling": "^2.1.5",
|
|
53
55
|
"@lumino/widgets": "^2.7.2",
|