@jupyterlab/notebook-extension 4.6.2 → 4.7.0-alpha.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 +18 -0
- package/lib/index.js +224 -43
- package/lib/index.js.map +1 -1
- package/package.json +39 -38
- package/schema/tracker.json +6 -0
- package/src/index.ts +302 -52
- package/style/index.css +1 -0
- package/style/index.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jupyterlab/notebook-extension",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.7.0-alpha.1",
|
|
4
4
|
"description": "JupyterLab - Notebook Extension",
|
|
5
5
|
"homepage": "https://github.com/jupyterlab/jupyterlab",
|
|
6
6
|
"bugs": {
|
|
@@ -37,43 +37,44 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@jupyter/ydoc": "^4.0.0",
|
|
40
|
-
"@jupyterlab/application": "^4.
|
|
41
|
-
"@jupyterlab/apputils": "^4.
|
|
42
|
-
"@jupyterlab/cell-toolbar": "^4.
|
|
43
|
-
"@jupyterlab/cells": "^4.
|
|
44
|
-
"@jupyterlab/codeeditor": "^4.
|
|
45
|
-
"@jupyterlab/codemirror": "^4.
|
|
46
|
-
"@jupyterlab/completer": "^4.
|
|
47
|
-
"@jupyterlab/coreutils": "^6.
|
|
48
|
-
"@jupyterlab/docmanager": "^4.
|
|
49
|
-
"@jupyterlab/docmanager-extension": "^4.
|
|
50
|
-
"@jupyterlab/docregistry": "^4.
|
|
51
|
-
"@jupyterlab/documentsearch": "^4.
|
|
52
|
-
"@jupyterlab/filebrowser": "^4.
|
|
53
|
-
"@jupyterlab/launcher": "^4.
|
|
54
|
-
"@jupyterlab/logconsole": "^4.
|
|
55
|
-
"@jupyterlab/lsp": "^4.
|
|
56
|
-
"@jupyterlab/mainmenu": "^4.
|
|
57
|
-
"@jupyterlab/metadataform": "^4.
|
|
58
|
-
"@jupyterlab/nbformat": "^4.
|
|
59
|
-
"@jupyterlab/notebook": "^4.
|
|
60
|
-
"@jupyterlab/observables": "^5.
|
|
61
|
-
"@jupyterlab/
|
|
62
|
-
"@jupyterlab/
|
|
63
|
-
"@jupyterlab/
|
|
64
|
-
"@jupyterlab/
|
|
65
|
-
"@jupyterlab/
|
|
66
|
-
"@jupyterlab/
|
|
67
|
-
"@jupyterlab/
|
|
68
|
-
"@jupyterlab/
|
|
69
|
-
"@jupyterlab/
|
|
70
|
-
"@
|
|
71
|
-
"@lumino/
|
|
72
|
-
"@lumino/
|
|
73
|
-
"@lumino/
|
|
74
|
-
"@lumino/
|
|
75
|
-
"@lumino/
|
|
76
|
-
"@lumino/
|
|
40
|
+
"@jupyterlab/application": "^4.7.0-alpha.1",
|
|
41
|
+
"@jupyterlab/apputils": "^4.8.0-alpha.1",
|
|
42
|
+
"@jupyterlab/cell-toolbar": "^4.7.0-alpha.1",
|
|
43
|
+
"@jupyterlab/cells": "^4.7.0-alpha.1",
|
|
44
|
+
"@jupyterlab/codeeditor": "^4.7.0-alpha.1",
|
|
45
|
+
"@jupyterlab/codemirror": "^4.7.0-alpha.1",
|
|
46
|
+
"@jupyterlab/completer": "^4.7.0-alpha.1",
|
|
47
|
+
"@jupyterlab/coreutils": "^6.7.0-alpha.1",
|
|
48
|
+
"@jupyterlab/docmanager": "^4.7.0-alpha.1",
|
|
49
|
+
"@jupyterlab/docmanager-extension": "^4.7.0-alpha.1",
|
|
50
|
+
"@jupyterlab/docregistry": "^4.7.0-alpha.1",
|
|
51
|
+
"@jupyterlab/documentsearch": "^4.7.0-alpha.1",
|
|
52
|
+
"@jupyterlab/filebrowser": "^4.7.0-alpha.1",
|
|
53
|
+
"@jupyterlab/launcher": "^4.7.0-alpha.1",
|
|
54
|
+
"@jupyterlab/logconsole": "^4.7.0-alpha.1",
|
|
55
|
+
"@jupyterlab/lsp": "^4.7.0-alpha.1",
|
|
56
|
+
"@jupyterlab/mainmenu": "^4.7.0-alpha.1",
|
|
57
|
+
"@jupyterlab/metadataform": "^4.7.0-alpha.1",
|
|
58
|
+
"@jupyterlab/nbformat": "^4.7.0-alpha.1",
|
|
59
|
+
"@jupyterlab/notebook": "^4.7.0-alpha.1",
|
|
60
|
+
"@jupyterlab/observables": "^5.7.0-alpha.1",
|
|
61
|
+
"@jupyterlab/outputarea": "^4.7.0-alpha.1",
|
|
62
|
+
"@jupyterlab/property-inspector": "^4.7.0-alpha.1",
|
|
63
|
+
"@jupyterlab/rendermime": "^4.7.0-alpha.1",
|
|
64
|
+
"@jupyterlab/services": "^7.7.0-alpha.1",
|
|
65
|
+
"@jupyterlab/settingregistry": "^4.7.0-alpha.1",
|
|
66
|
+
"@jupyterlab/statedb": "^4.7.0-alpha.1",
|
|
67
|
+
"@jupyterlab/statusbar": "^4.7.0-alpha.1",
|
|
68
|
+
"@jupyterlab/toc": "^6.7.0-alpha.1",
|
|
69
|
+
"@jupyterlab/translation": "^4.7.0-alpha.1",
|
|
70
|
+
"@jupyterlab/ui-components": "^4.7.0-alpha.1",
|
|
71
|
+
"@lumino/algorithm": "^2.0.5",
|
|
72
|
+
"@lumino/commands": "^2.3.4",
|
|
73
|
+
"@lumino/coreutils": "^2.2.3",
|
|
74
|
+
"@lumino/disposable": "^2.1.6",
|
|
75
|
+
"@lumino/messaging": "^2.0.5",
|
|
76
|
+
"@lumino/polling": "^2.1.6",
|
|
77
|
+
"@lumino/widgets": "^2.9.0",
|
|
77
78
|
"@rjsf/utils": "^5.13.4",
|
|
78
79
|
"react": "^18.2.0"
|
|
79
80
|
},
|
package/schema/tracker.json
CHANGED
|
@@ -899,6 +899,12 @@
|
|
|
899
899
|
"description": "When enabled, pasting code cells will only paste the cell content, not the outputs.",
|
|
900
900
|
"type": "boolean",
|
|
901
901
|
"default": false
|
|
902
|
+
},
|
|
903
|
+
"helpInBottomPanel": {
|
|
904
|
+
"title": "Show Help in Bottom Panel",
|
|
905
|
+
"description": "Whether to display help output (e.g. pager output from 'source: page' payloads) in a bottom panel inspector instead of inlining it.",
|
|
906
|
+
"type": "boolean",
|
|
907
|
+
"default": false
|
|
902
908
|
}
|
|
903
909
|
},
|
|
904
910
|
"additionalProperties": false,
|
package/src/index.ts
CHANGED
|
@@ -90,9 +90,14 @@ import {
|
|
|
90
90
|
ToolbarItems
|
|
91
91
|
} from '@jupyterlab/notebook';
|
|
92
92
|
import type { IObservableList } from '@jupyterlab/observables';
|
|
93
|
+
import { IPageHandler } from '@jupyterlab/outputarea';
|
|
93
94
|
import { IPropertyInspectorProvider } from '@jupyterlab/property-inspector';
|
|
95
|
+
import {
|
|
96
|
+
IMarkdownParser,
|
|
97
|
+
IRenderMimeRegistry,
|
|
98
|
+
MimeModel
|
|
99
|
+
} from '@jupyterlab/rendermime';
|
|
94
100
|
import type { IRenderMime } from '@jupyterlab/rendermime';
|
|
95
|
-
import { IMarkdownParser, IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
96
101
|
import type { NbConvert } from '@jupyterlab/services';
|
|
97
102
|
import { ISettingRegistry } from '@jupyterlab/settingregistry';
|
|
98
103
|
import { IStateDB } from '@jupyterlab/statedb';
|
|
@@ -113,6 +118,7 @@ import {
|
|
|
113
118
|
duplicateIcon,
|
|
114
119
|
fastForwardIcon,
|
|
115
120
|
IFormRendererRegistry,
|
|
121
|
+
infoIcon,
|
|
116
122
|
moveDownIcon,
|
|
117
123
|
moveUpIcon,
|
|
118
124
|
notebookIcon,
|
|
@@ -125,10 +131,11 @@ import { ArrayExt } from '@lumino/algorithm';
|
|
|
125
131
|
import type { CommandRegistry } from '@lumino/commands';
|
|
126
132
|
import type {
|
|
127
133
|
JSONObject,
|
|
134
|
+
ReadonlyJSONObject,
|
|
128
135
|
ReadonlyJSONValue,
|
|
129
136
|
ReadonlyPartialJSONObject
|
|
130
137
|
} from '@lumino/coreutils';
|
|
131
|
-
import { JSONExt, UUID } from '@lumino/coreutils';
|
|
138
|
+
import { JSONExt, Token, UUID } from '@lumino/coreutils';
|
|
132
139
|
import type { IDisposable } from '@lumino/disposable';
|
|
133
140
|
import { DisposableSet } from '@lumino/disposable';
|
|
134
141
|
import type { Message } from '@lumino/messaging';
|
|
@@ -182,6 +189,8 @@ namespace CommandIDs {
|
|
|
182
189
|
|
|
183
190
|
export const exportToFormat = 'notebook:export-to-format';
|
|
184
191
|
|
|
192
|
+
export const showExportGuidance = 'notebook:show-export-guidance';
|
|
193
|
+
|
|
185
194
|
export const run = 'notebook:run-cell';
|
|
186
195
|
|
|
187
196
|
export const runAndAdvance = 'notebook:run-cell-and-select-next';
|
|
@@ -365,6 +374,30 @@ const FACTORY = 'Notebook';
|
|
|
365
374
|
*/
|
|
366
375
|
const FORMAT_EXCLUDE = ['notebook', 'python', 'custom'];
|
|
367
376
|
|
|
377
|
+
/**
|
|
378
|
+
* Documentation page describing notebook export support.
|
|
379
|
+
*/
|
|
380
|
+
const NOTEBOOK_EXPORT_DOCS_URL =
|
|
381
|
+
'https://jupyterlab.readthedocs.io/en/stable/user/export.html';
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* An interface describing how export guidance is presented to users.
|
|
385
|
+
*/
|
|
386
|
+
export interface INotebookExportGuidance {
|
|
387
|
+
/**
|
|
388
|
+
* Show guidance for enabling notebook exports.
|
|
389
|
+
*/
|
|
390
|
+
showExportHelp(): Promise<void>;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* A token describing a service for showing notebook export guidance.
|
|
395
|
+
*/
|
|
396
|
+
export const INotebookExportGuidance = new Token<INotebookExportGuidance>(
|
|
397
|
+
'@jupyterlab/notebook-extension:INotebookExportGuidance',
|
|
398
|
+
'A service for showing notebook export guidance.'
|
|
399
|
+
);
|
|
400
|
+
|
|
368
401
|
/**
|
|
369
402
|
* Setting Id storing the customized toolbar definition.
|
|
370
403
|
*/
|
|
@@ -641,13 +674,14 @@ export const exportPlugin: JupyterFrontEndPlugin<void> = {
|
|
|
641
674
|
description: 'Adds the export notebook commands.',
|
|
642
675
|
autoStart: true,
|
|
643
676
|
requires: [ITranslator, INotebookTracker],
|
|
644
|
-
optional: [IMainMenu, ICommandPalette],
|
|
677
|
+
optional: [IMainMenu, ICommandPalette, INotebookExportGuidance],
|
|
645
678
|
activate: (
|
|
646
679
|
app: JupyterFrontEnd,
|
|
647
680
|
translator: ITranslator,
|
|
648
681
|
tracker: INotebookTracker,
|
|
649
682
|
mainMenu: IMainMenu | null,
|
|
650
|
-
palette: ICommandPalette | null
|
|
683
|
+
palette: ICommandPalette | null,
|
|
684
|
+
exportGuidance: INotebookExportGuidance | null
|
|
651
685
|
) => {
|
|
652
686
|
const trans = translator.load('jupyterlab');
|
|
653
687
|
const { commands, shell } = app;
|
|
@@ -738,21 +772,91 @@ export const exportPlugin: JupyterFrontEndPlugin<void> = {
|
|
|
738
772
|
}
|
|
739
773
|
});
|
|
740
774
|
|
|
775
|
+
commands.addCommand(CommandIDs.showExportGuidance, {
|
|
776
|
+
label: trans.__('Enable notebook exports'),
|
|
777
|
+
execute: () => {
|
|
778
|
+
if (exportGuidance) {
|
|
779
|
+
return exportGuidance.showExportHelp();
|
|
780
|
+
}
|
|
781
|
+
window.open(NOTEBOOK_EXPORT_DOCS_URL, '_blank', 'noopener,noreferrer');
|
|
782
|
+
return undefined;
|
|
783
|
+
},
|
|
784
|
+
describedBy: {
|
|
785
|
+
args: {
|
|
786
|
+
type: 'object',
|
|
787
|
+
properties: {}
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
|
|
741
792
|
// Add a notebook group to the File menu.
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
item
|
|
748
|
-
|
|
749
|
-
|
|
793
|
+
const fileMenu = mainMenu?.fileMenu as Menu | undefined;
|
|
794
|
+
|
|
795
|
+
const getExportMenu = (): Menu | undefined => {
|
|
796
|
+
return (
|
|
797
|
+
fileMenu?.items.find(
|
|
798
|
+
item =>
|
|
799
|
+
item.type === 'submenu' &&
|
|
800
|
+
item.submenu?.id === 'jp-mainmenu-file-notebookexport'
|
|
801
|
+
)?.submenu ?? undefined
|
|
802
|
+
);
|
|
803
|
+
};
|
|
750
804
|
|
|
751
805
|
let formatsInitialized = false;
|
|
806
|
+
let paletteInitialized = false;
|
|
807
|
+
let exportFormats: Array<{ format: string; label: string }> | null = null;
|
|
808
|
+
|
|
809
|
+
const updateExportMenu = () => {
|
|
810
|
+
const exportTo = getExportMenu();
|
|
811
|
+
if (!exportTo || !exportFormats) {
|
|
812
|
+
return;
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
exportTo.clearItems();
|
|
816
|
+
|
|
817
|
+
if (exportFormats.length === 0) {
|
|
818
|
+
exportTo.addItem({
|
|
819
|
+
command: CommandIDs.showExportGuidance
|
|
820
|
+
});
|
|
821
|
+
return;
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
exportFormats.forEach(({ format, label }) => {
|
|
825
|
+
exportTo.addItem({
|
|
826
|
+
command: CommandIDs.exportToFormat,
|
|
827
|
+
args: {
|
|
828
|
+
format,
|
|
829
|
+
label,
|
|
830
|
+
isPalette: false
|
|
831
|
+
}
|
|
832
|
+
});
|
|
833
|
+
});
|
|
834
|
+
|
|
835
|
+
if (palette && !paletteInitialized) {
|
|
836
|
+
const category = trans.__('Notebook Operations');
|
|
837
|
+
exportFormats.forEach(({ format, label }) => {
|
|
838
|
+
palette.addItem({
|
|
839
|
+
command: CommandIDs.exportToFormat,
|
|
840
|
+
category,
|
|
841
|
+
args: {
|
|
842
|
+
format,
|
|
843
|
+
label,
|
|
844
|
+
isPalette: true
|
|
845
|
+
}
|
|
846
|
+
});
|
|
847
|
+
});
|
|
848
|
+
paletteInitialized = true;
|
|
849
|
+
}
|
|
850
|
+
};
|
|
752
851
|
|
|
753
852
|
/** Request formats only when a notebook might use them. */
|
|
754
853
|
const maybeInitializeFormats = async () => {
|
|
755
854
|
if (formatsInitialized) {
|
|
855
|
+
updateExportMenu();
|
|
856
|
+
return;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
if (tracker.size === 0) {
|
|
756
860
|
return;
|
|
757
861
|
}
|
|
758
862
|
|
|
@@ -760,53 +864,96 @@ export const exportPlugin: JupyterFrontEndPlugin<void> = {
|
|
|
760
864
|
|
|
761
865
|
formatsInitialized = true;
|
|
762
866
|
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
867
|
+
let response: NbConvert.IExportFormats | null = null;
|
|
868
|
+
try {
|
|
869
|
+
response = await services.nbconvert.getExportFormats(false);
|
|
870
|
+
} catch {
|
|
871
|
+
// Ignore fetch errors and fallback to export guidance.
|
|
767
872
|
}
|
|
768
873
|
|
|
769
|
-
const formatLabels
|
|
874
|
+
const formatLabels = Private.getFormatLabels(translator);
|
|
770
875
|
|
|
771
|
-
// Convert export list to
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
command: CommandIDs.exportToFormat,
|
|
786
|
-
args: args
|
|
787
|
-
});
|
|
788
|
-
}
|
|
789
|
-
if (palette) {
|
|
790
|
-
args = {
|
|
791
|
-
format: key,
|
|
792
|
-
label: labelStr,
|
|
793
|
-
isPalette: true
|
|
794
|
-
};
|
|
795
|
-
const category = trans.__('Notebook Operations');
|
|
796
|
-
palette.addItem({
|
|
797
|
-
command: CommandIDs.exportToFormat,
|
|
798
|
-
category,
|
|
799
|
-
args
|
|
800
|
-
});
|
|
801
|
-
}
|
|
802
|
-
}
|
|
803
|
-
});
|
|
876
|
+
// Convert export list to menu and palette items.
|
|
877
|
+
exportFormats = Object.keys(response ?? {})
|
|
878
|
+
.filter(key => !FORMAT_EXCLUDE.includes(key))
|
|
879
|
+
.map(key => {
|
|
880
|
+
const formattedKey = key[0].toLocaleUpperCase() + key.slice(1);
|
|
881
|
+
const capCaseKey = trans.__(formattedKey);
|
|
882
|
+
const labelStr = formatLabels[key] ? formatLabels[key] : capCaseKey;
|
|
883
|
+
return {
|
|
884
|
+
format: key,
|
|
885
|
+
label: labelStr
|
|
886
|
+
};
|
|
887
|
+
});
|
|
888
|
+
|
|
889
|
+
updateExportMenu();
|
|
804
890
|
};
|
|
805
891
|
|
|
806
892
|
tracker.widgetAdded.connect(maybeInitializeFormats);
|
|
893
|
+
if (tracker.size > 0) {
|
|
894
|
+
void maybeInitializeFormats();
|
|
895
|
+
}
|
|
896
|
+
void app.restored.then(() => {
|
|
897
|
+
void maybeInitializeFormats();
|
|
898
|
+
});
|
|
807
899
|
}
|
|
808
900
|
};
|
|
809
901
|
|
|
902
|
+
/**
|
|
903
|
+
* A plugin providing the default notebook export guidance service.
|
|
904
|
+
*/
|
|
905
|
+
export const exportGuidanceDialogPlugin: JupyterFrontEndPlugin<INotebookExportGuidance> =
|
|
906
|
+
{
|
|
907
|
+
id: '@jupyterlab/notebook-extension:export-guidance-dialog',
|
|
908
|
+
description:
|
|
909
|
+
'Provides the default notebook export guidance shown when no exporters are available.',
|
|
910
|
+
provides: INotebookExportGuidance,
|
|
911
|
+
autoStart: true,
|
|
912
|
+
requires: [ITranslator],
|
|
913
|
+
activate: (
|
|
914
|
+
app: JupyterFrontEnd,
|
|
915
|
+
translator: ITranslator
|
|
916
|
+
): INotebookExportGuidance => {
|
|
917
|
+
const trans = translator.load('jupyterlab');
|
|
918
|
+
const { commands } = app;
|
|
919
|
+
|
|
920
|
+
const openExportDocs = (url: string, docsLabel: string) => {
|
|
921
|
+
if (commands.hasCommand('help:open')) {
|
|
922
|
+
return commands.execute('help:open', {
|
|
923
|
+
url,
|
|
924
|
+
text: docsLabel,
|
|
925
|
+
newBrowserTab: true
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
window.open(url, '_blank', 'noopener,noreferrer');
|
|
930
|
+
return undefined;
|
|
931
|
+
};
|
|
932
|
+
|
|
933
|
+
return {
|
|
934
|
+
showExportHelp: async () => {
|
|
935
|
+
const result = await showDialog({
|
|
936
|
+
title: trans.__('Notebook exports are unavailable'),
|
|
937
|
+
body: trans.__(
|
|
938
|
+
'No notebook export formats are currently available. To enable exports, install nbconvert in the server environment or use another exporter supported by your deployment.'
|
|
939
|
+
),
|
|
940
|
+
buttons: [
|
|
941
|
+
Dialog.cancelButton({ label: trans.__('Close') }),
|
|
942
|
+
Dialog.okButton({ label: trans.__('Open Documentation') })
|
|
943
|
+
]
|
|
944
|
+
});
|
|
945
|
+
|
|
946
|
+
if (result.button.accept) {
|
|
947
|
+
void openExportDocs(
|
|
948
|
+
NOTEBOOK_EXPORT_DOCS_URL,
|
|
949
|
+
trans.__('Notebook Export Documentation')
|
|
950
|
+
);
|
|
951
|
+
}
|
|
952
|
+
}
|
|
953
|
+
};
|
|
954
|
+
}
|
|
955
|
+
};
|
|
956
|
+
|
|
810
957
|
/**
|
|
811
958
|
* A plugin that adds a notebook trust status item to the status bar.
|
|
812
959
|
*/
|
|
@@ -864,11 +1011,29 @@ const widgetFactoryPlugin: JupyterFrontEndPlugin<NotebookWidgetFactory.IFactory>
|
|
|
864
1011
|
IRenderMimeRegistry,
|
|
865
1012
|
IToolbarWidgetRegistry
|
|
866
1013
|
],
|
|
867
|
-
optional: [
|
|
1014
|
+
optional: [
|
|
1015
|
+
ISettingRegistry,
|
|
1016
|
+
ISessionContextDialogs,
|
|
1017
|
+
ITranslator,
|
|
1018
|
+
IPageHandler
|
|
1019
|
+
],
|
|
868
1020
|
activate: activateWidgetFactory,
|
|
869
1021
|
autoStart: true
|
|
870
1022
|
};
|
|
871
1023
|
|
|
1024
|
+
/**
|
|
1025
|
+
* The pager output handler provider.
|
|
1026
|
+
*/
|
|
1027
|
+
const pageHandlerPlugin: JupyterFrontEndPlugin<IPageHandler> = {
|
|
1028
|
+
id: '@jupyterlab/notebook-extension:page-handler',
|
|
1029
|
+
description: 'Provides a handler for pager output payloads.',
|
|
1030
|
+
autoStart: true,
|
|
1031
|
+
provides: IPageHandler,
|
|
1032
|
+
requires: [IRenderMimeRegistry],
|
|
1033
|
+
optional: [ISettingRegistry, ITranslator],
|
|
1034
|
+
activate: activatePageHandler
|
|
1035
|
+
};
|
|
1036
|
+
|
|
872
1037
|
/**
|
|
873
1038
|
* The cloned output provider.
|
|
874
1039
|
*/
|
|
@@ -1288,7 +1453,9 @@ const plugins: JupyterFrontEndPlugin<any>[] = [
|
|
|
1288
1453
|
cellExecutor,
|
|
1289
1454
|
factory,
|
|
1290
1455
|
trackerPlugin,
|
|
1456
|
+
pageHandlerPlugin,
|
|
1291
1457
|
executionIndicator,
|
|
1458
|
+
exportGuidanceDialogPlugin,
|
|
1292
1459
|
exportPlugin,
|
|
1293
1460
|
tools,
|
|
1294
1461
|
cellCounterItem,
|
|
@@ -1363,6 +1530,86 @@ function activateNotebookTools(
|
|
|
1363
1530
|
return notebookTools;
|
|
1364
1531
|
}
|
|
1365
1532
|
|
|
1533
|
+
/**
|
|
1534
|
+
* Activate the pager output handler provider.
|
|
1535
|
+
*/
|
|
1536
|
+
function activatePageHandler(
|
|
1537
|
+
app: JupyterFrontEnd,
|
|
1538
|
+
rendermime: IRenderMimeRegistry,
|
|
1539
|
+
settingRegistry: ISettingRegistry | null,
|
|
1540
|
+
translator_: ITranslator | null
|
|
1541
|
+
): IPageHandler {
|
|
1542
|
+
const translator = translator_ ?? nullTranslator;
|
|
1543
|
+
const trans = translator.load('jupyterlab');
|
|
1544
|
+
|
|
1545
|
+
let helpInBottomPanel = false;
|
|
1546
|
+
let helpWidget: MainAreaWidget<Panel> | null = null;
|
|
1547
|
+
|
|
1548
|
+
const fetchSettings = settingRegistry
|
|
1549
|
+
? settingRegistry.load(trackerPlugin.id)
|
|
1550
|
+
: Promise.reject(new Error(`No setting registry for ${trackerPlugin.id}`));
|
|
1551
|
+
|
|
1552
|
+
const updateConfig = (settings: ISettingRegistry.ISettings): void => {
|
|
1553
|
+
helpInBottomPanel = settings.get('helpInBottomPanel').composite as boolean;
|
|
1554
|
+
};
|
|
1555
|
+
|
|
1556
|
+
void fetchSettings
|
|
1557
|
+
.then(settings => {
|
|
1558
|
+
updateConfig(settings);
|
|
1559
|
+
settings.changed.connect(() => {
|
|
1560
|
+
updateConfig(settings);
|
|
1561
|
+
});
|
|
1562
|
+
})
|
|
1563
|
+
.catch((reason: Error) => {
|
|
1564
|
+
console.warn(reason.message);
|
|
1565
|
+
});
|
|
1566
|
+
|
|
1567
|
+
return {
|
|
1568
|
+
handlePage: payload => {
|
|
1569
|
+
if (!helpInBottomPanel) {
|
|
1570
|
+
return false;
|
|
1571
|
+
}
|
|
1572
|
+
|
|
1573
|
+
const data = payload['data'];
|
|
1574
|
+
if (!data || typeof data !== 'object') {
|
|
1575
|
+
return false;
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
const mimeData = data as nbformat.IMimeBundle;
|
|
1579
|
+
const metadata = (payload['metadata'] ?? {}) as ReadonlyJSONObject;
|
|
1580
|
+
const mimeType = rendermime.preferredMimeType(mimeData, 'any');
|
|
1581
|
+
if (!mimeType) {
|
|
1582
|
+
return false;
|
|
1583
|
+
}
|
|
1584
|
+
|
|
1585
|
+
if (!helpWidget || helpWidget.isDisposed) {
|
|
1586
|
+
const content = new Panel();
|
|
1587
|
+
content.addClass('jp-HelpPanel');
|
|
1588
|
+
helpWidget = new MainAreaWidget({ content });
|
|
1589
|
+
helpWidget.id = 'jp-help-panel';
|
|
1590
|
+
helpWidget.title.label = trans.__('Help');
|
|
1591
|
+
helpWidget.title.icon = infoIcon;
|
|
1592
|
+
helpWidget.title.closable = true;
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
const content = helpWidget.content;
|
|
1596
|
+
content.widgets.forEach(widget => widget.dispose());
|
|
1597
|
+
|
|
1598
|
+
const renderer = rendermime.createRenderer(mimeType);
|
|
1599
|
+
void renderer.renderModel(
|
|
1600
|
+
new MimeModel({ data: mimeData, metadata, trusted: true })
|
|
1601
|
+
);
|
|
1602
|
+
content.addWidget(renderer);
|
|
1603
|
+
|
|
1604
|
+
if (!helpWidget.isAttached) {
|
|
1605
|
+
app.shell.add(helpWidget, 'down');
|
|
1606
|
+
}
|
|
1607
|
+
app.shell.activateById(helpWidget.id);
|
|
1608
|
+
return true;
|
|
1609
|
+
}
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1612
|
+
|
|
1366
1613
|
/**
|
|
1367
1614
|
* Activate the notebook widget factory.
|
|
1368
1615
|
*/
|
|
@@ -1374,7 +1621,8 @@ function activateWidgetFactory(
|
|
|
1374
1621
|
toolbarRegistry: IToolbarWidgetRegistry,
|
|
1375
1622
|
settingRegistry: ISettingRegistry | null,
|
|
1376
1623
|
sessionContextDialogs_: ISessionContextDialogs | null,
|
|
1377
|
-
translator_: ITranslator | null
|
|
1624
|
+
translator_: ITranslator | null,
|
|
1625
|
+
pageHandler: IPageHandler | null
|
|
1378
1626
|
): NotebookWidgetFactory.IFactory {
|
|
1379
1627
|
const translator = translator_ ?? nullTranslator;
|
|
1380
1628
|
const sessionContextDialogs =
|
|
@@ -1455,6 +1703,7 @@ function activateWidgetFactory(
|
|
|
1455
1703
|
contentFactory,
|
|
1456
1704
|
editorConfig: StaticNotebook.defaultEditorConfig,
|
|
1457
1705
|
notebookConfig: StaticNotebook.defaultNotebookConfig,
|
|
1706
|
+
pageHandler: pageHandler ?? undefined,
|
|
1458
1707
|
mimeTypeService: editorServices.mimeTypeService,
|
|
1459
1708
|
toolbarFactory,
|
|
1460
1709
|
translator
|
|
@@ -1921,6 +2170,7 @@ function activateNotebookHandler(
|
|
|
1921
2170
|
fetchSettings
|
|
1922
2171
|
.then(settings => {
|
|
1923
2172
|
updateConfig(settings);
|
|
2173
|
+
|
|
1924
2174
|
settings.changed.connect(() => {
|
|
1925
2175
|
updateConfig(settings);
|
|
1926
2176
|
commands.notifyCommandChanged(CommandIDs.virtualScrollbar);
|
package/style/index.css
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
@import url('~@jupyterlab/codemirror/style/index.css');
|
|
17
17
|
@import url('~@jupyterlab/docmanager/style/index.css');
|
|
18
18
|
@import url('~@jupyterlab/filebrowser/style/index.css');
|
|
19
|
+
@import url('~@jupyterlab/outputarea/style/index.css');
|
|
19
20
|
@import url('~@jupyterlab/toc/style/index.css');
|
|
20
21
|
@import url('~@jupyterlab/cells/style/index.css');
|
|
21
22
|
@import url('~@jupyterlab/lsp/style/index.css');
|
package/style/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import '@jupyterlab/documentsearch/style/index.js';
|
|
|
16
16
|
import '@jupyterlab/codemirror/style/index.js';
|
|
17
17
|
import '@jupyterlab/docmanager/style/index.js';
|
|
18
18
|
import '@jupyterlab/filebrowser/style/index.js';
|
|
19
|
+
import '@jupyterlab/outputarea/style/index.js';
|
|
19
20
|
import '@jupyterlab/toc/style/index.js';
|
|
20
21
|
import '@jupyterlab/cells/style/index.js';
|
|
21
22
|
import '@jupyterlab/lsp/style/index.js';
|