@fails-components/jupyter-applet-view 0.0.1-alpha.9 → 0.0.3
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/avoutputarea.js +14 -2
- package/lib/splitviewnotebookpanel.js +11 -3
- package/package.json +37 -31
- package/src/avoutputarea.ts +15 -4
- package/src/splitviewnotebookpanel.ts +11 -3
- package/style/index.css +1 -1
package/lib/avoutputarea.js
CHANGED
|
@@ -48,7 +48,7 @@ export class AppletViewOutputArea extends AccordionPanel {
|
|
|
48
48
|
this.addApplet({ appid, appname: 'Applet 1' });
|
|
49
49
|
}
|
|
50
50
|
this.id = `AppletView-${UUID.uuid4()}`;
|
|
51
|
-
this.title.label = '
|
|
51
|
+
this.title.label = 'Applet area';
|
|
52
52
|
this.title.icon = notebookIcon;
|
|
53
53
|
this.title.caption = this._notebook.title.label
|
|
54
54
|
? trans.__('For Notebook: %1', this._notebook.title.label)
|
|
@@ -171,6 +171,9 @@ export class AppletViewOutputArea extends AccordionPanel {
|
|
|
171
171
|
}
|
|
172
172
|
const app = this.widgets[appIndex];
|
|
173
173
|
const clone = this.cloneCell(cell, cellid);
|
|
174
|
+
clone.node.addEventListener('contextmenu', e => {
|
|
175
|
+
e.preventDefault();
|
|
176
|
+
});
|
|
174
177
|
this.addToObserver(appIndex, clone);
|
|
175
178
|
app.addWidget(clone);
|
|
176
179
|
// this.informResize(this._applets[appIndex]) // not neccessary
|
|
@@ -358,7 +361,9 @@ export class AppletViewOutputArea extends AccordionPanel {
|
|
|
358
361
|
// clear applets
|
|
359
362
|
this._applets = [];
|
|
360
363
|
if (this.layout) {
|
|
361
|
-
|
|
364
|
+
// we need a copy, as forEach does not work, if an item is removed
|
|
365
|
+
const widgetCopy = [...this.layout.widgets];
|
|
366
|
+
widgetCopy.forEach((widget) => { var _a; return (_a = this.layout) === null || _a === void 0 ? void 0 : _a.removeWidget(widget); });
|
|
362
367
|
}
|
|
363
368
|
if (applets.length === 0) {
|
|
364
369
|
// we need a minimum of 1 applet!
|
|
@@ -721,11 +726,18 @@ export class AppletViewRenderer extends AccordionPanel.Renderer {
|
|
|
721
726
|
handle.appendChild(editLabel);
|
|
722
727
|
});
|
|
723
728
|
editLabel.addEventListener('blur', (ev) => {
|
|
729
|
+
// Firefox and Safari needs this
|
|
730
|
+
if (editLabel.value !== title) {
|
|
731
|
+
editLabel.dispatchEvent(new Event('change', { bubbles: true }));
|
|
732
|
+
}
|
|
724
733
|
handle.removeChild(editLabel);
|
|
725
734
|
handle.appendChild(staticLabel);
|
|
726
735
|
});
|
|
727
736
|
editLabel.addEventListener('keydown', (ev) => {
|
|
728
737
|
if (ev.key === 'Enter') {
|
|
738
|
+
if (editLabel.value !== title) {
|
|
739
|
+
editLabel.dispatchEvent(new Event('change', { bubbles: true }));
|
|
740
|
+
}
|
|
729
741
|
handle.removeChild(editLabel);
|
|
730
742
|
handle.appendChild(staticLabel);
|
|
731
743
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NotebookPanel, NotebookHistory, NotebookWidgetFactory } from '@jupyterlab/notebook';
|
|
2
|
-
import { BoxLayout,
|
|
2
|
+
import { BoxLayout, AccordionPanel } from '@lumino/widgets';
|
|
3
3
|
import { AppletViewOutputArea } from './avoutputarea';
|
|
4
4
|
export class SplitViewNotebookPanel extends NotebookPanel {
|
|
5
5
|
constructor(options, failsLauncherInfo, failsInterceptor) {
|
|
@@ -11,9 +11,10 @@ export class SplitViewNotebookPanel extends NotebookPanel {
|
|
|
11
11
|
const layout = this.layout;
|
|
12
12
|
layout.removeWidget(content);
|
|
13
13
|
// 2. add a BoxLayout instead
|
|
14
|
-
const splitPanel = new
|
|
14
|
+
const splitPanel = new AccordionPanel({
|
|
15
15
|
spacing: 1,
|
|
16
|
-
orientation: 'horizontal'
|
|
16
|
+
orientation: 'horizontal',
|
|
17
|
+
alignment: 'justify'
|
|
17
18
|
});
|
|
18
19
|
BoxLayout.setStretch(splitPanel, 1);
|
|
19
20
|
// 3. add content to the BoxLayout, as well as a applet view area
|
|
@@ -26,6 +27,8 @@ export class SplitViewNotebookPanel extends NotebookPanel {
|
|
|
26
27
|
}));
|
|
27
28
|
splitPanel.addWidget(widget);
|
|
28
29
|
layout.addWidget(splitPanel);
|
|
30
|
+
const splitLayout = splitPanel.layout;
|
|
31
|
+
splitLayout.titleSpace = 22;
|
|
29
32
|
// move to separate handler
|
|
30
33
|
if (failsLauncherInfo === null || failsLauncherInfo === void 0 ? void 0 : failsLauncherInfo.inLecture) {
|
|
31
34
|
this.toolbar.hide();
|
|
@@ -33,6 +36,7 @@ export class SplitViewNotebookPanel extends NotebookPanel {
|
|
|
33
36
|
this._appletviewWidget.inLecture = true;
|
|
34
37
|
content.hide();
|
|
35
38
|
splitPanel.setRelativeSizes([0, 1]); // change sizes
|
|
39
|
+
splitLayout.titleSpace = 0;
|
|
36
40
|
}
|
|
37
41
|
if (failsLauncherInfo) {
|
|
38
42
|
failsLauncherInfo.inLectureChanged.connect((sender, newInLecture) => {
|
|
@@ -41,6 +45,8 @@ export class SplitViewNotebookPanel extends NotebookPanel {
|
|
|
41
45
|
this.addClass('fl-jl-notebook-inlecture');
|
|
42
46
|
this._appletviewWidget.inLecture = true;
|
|
43
47
|
content.hide();
|
|
48
|
+
widget.show();
|
|
49
|
+
splitLayout.titleSpace = 0;
|
|
44
50
|
splitPanel.setRelativeSizes([0, 1]); // change sizes
|
|
45
51
|
}
|
|
46
52
|
else {
|
|
@@ -48,8 +54,10 @@ export class SplitViewNotebookPanel extends NotebookPanel {
|
|
|
48
54
|
this.removeClass('fl-jl-notebook-inlecture');
|
|
49
55
|
this._appletviewWidget.inLecture = false;
|
|
50
56
|
content.show();
|
|
57
|
+
splitLayout.titleSpace = 22;
|
|
51
58
|
splitPanel.setRelativeSizes([1, 1]); // change sizes
|
|
52
59
|
widget.unselectApplet();
|
|
60
|
+
setTimeout(() => splitPanel.setRelativeSizes([1, 1]), 1);
|
|
53
61
|
}
|
|
54
62
|
});
|
|
55
63
|
if (failsLauncherInfo.inLecture &&
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fails-components/jupyter-applet-view",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "A collection of extensions, that let's you select cell and switch to an applet mode, where only the selected cells are visible. This is used for fails-components to have jupyter applets in interactive teaching. ",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"jupyter",
|
|
@@ -58,32 +58,29 @@
|
|
|
58
58
|
"watch:labextension": "jupyter labextension watch ."
|
|
59
59
|
},
|
|
60
60
|
"dependencies": {
|
|
61
|
-
"@fails-components/jupyter-interceptor": "^0.0.
|
|
62
|
-
"@fails-components/jupyter-launcher": "^0.0.
|
|
63
|
-
"@jupyter-notebook/application": "^7.
|
|
64
|
-
"@jupyter-widgets/jupyterlab-manager": "^5.0.
|
|
65
|
-
"@jupyterlab/application": "^4.3
|
|
66
|
-
"@jupyterlab/apputils": "^4.3
|
|
67
|
-
"@jupyterlab/cells": "^4.3
|
|
68
|
-
"@jupyterlab/docmanager": "^4.3
|
|
69
|
-
"@jupyterlab/docregistry": "^4.3
|
|
70
|
-
"@jupyterlab/notebook": "^4.3
|
|
71
|
-
"@jupyterlab/observables": "^5.3
|
|
72
|
-
"@jupyterlab/outputarea": "^4.3
|
|
73
|
-
"@jupyterlab/statedb": "^4.3
|
|
74
|
-
"@jupyterlab/translation": "^4.3
|
|
75
|
-
"@jupyterlab/ui-components": "^4.3
|
|
76
|
-
"@jupyterlite/application-extension": "^0.
|
|
77
|
-
"@jupyterlite/
|
|
78
|
-
"@
|
|
79
|
-
"@
|
|
80
|
-
"@lumino/
|
|
81
|
-
"@lumino/
|
|
82
|
-
"@lumino/
|
|
83
|
-
"@lumino/
|
|
84
|
-
"@lumino/signaling": "^2.1.3",
|
|
85
|
-
"@lumino/widgets": "^2.5.0",
|
|
86
|
-
"json5": "^2.2.3",
|
|
61
|
+
"@fails-components/jupyter-interceptor": "^0.0.3",
|
|
62
|
+
"@fails-components/jupyter-launcher": "^0.0.3",
|
|
63
|
+
"@jupyter-notebook/application": "^7.4.3",
|
|
64
|
+
"@jupyter-widgets/jupyterlab-manager": "^5.0.15",
|
|
65
|
+
"@jupyterlab/application": "^4.4.3",
|
|
66
|
+
"@jupyterlab/apputils": "^4.5.3",
|
|
67
|
+
"@jupyterlab/cells": "^4.4.3",
|
|
68
|
+
"@jupyterlab/docmanager": "^4.4.3",
|
|
69
|
+
"@jupyterlab/docregistry": "^4.4.3",
|
|
70
|
+
"@jupyterlab/notebook": "^4.4.3",
|
|
71
|
+
"@jupyterlab/observables": "^5.4.3",
|
|
72
|
+
"@jupyterlab/outputarea": "^4.4.3",
|
|
73
|
+
"@jupyterlab/statedb": "^4.4.3",
|
|
74
|
+
"@jupyterlab/translation": "^4.4.3",
|
|
75
|
+
"@jupyterlab/ui-components": "^4.4.3",
|
|
76
|
+
"@jupyterlite/application-extension": "^0.6.1",
|
|
77
|
+
"@jupyterlite/server": "^0.6.1",
|
|
78
|
+
"@lumino/algorithm": "^2.0.3",
|
|
79
|
+
"@lumino/commands": "^2.3.2",
|
|
80
|
+
"@lumino/coreutils": "^2.2.1",
|
|
81
|
+
"@lumino/disposable": "^2.1.4",
|
|
82
|
+
"@lumino/signaling": "^2.1.4",
|
|
83
|
+
"@lumino/widgets": "^2.7.1",
|
|
87
84
|
"modern-screenshot": "^4.5.5"
|
|
88
85
|
},
|
|
89
86
|
"devDependencies": {
|
|
@@ -124,10 +121,19 @@
|
|
|
124
121
|
"jupyterlab": {
|
|
125
122
|
"extension": true,
|
|
126
123
|
"outputDir": "fails_components_jupyter_applet_view/labextension",
|
|
127
|
-
"schemaDir": "schema"
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
124
|
+
"schemaDir": "schema",
|
|
125
|
+
"sharedPackages": {
|
|
126
|
+
"@fails-components/jupyter-launcher": {
|
|
127
|
+
"singleton": true,
|
|
128
|
+
"requiredVersion": "^0.0.1-alpha.18",
|
|
129
|
+
"import": false
|
|
130
|
+
},
|
|
131
|
+
"@fails-components/jupyter-interceptor": {
|
|
132
|
+
"singleton": true,
|
|
133
|
+
"requiredVersion": "^0.0.1-alpha.18",
|
|
134
|
+
"import": false
|
|
135
|
+
}
|
|
136
|
+
}
|
|
131
137
|
},
|
|
132
138
|
"eslintIgnore": [
|
|
133
139
|
"node_modules",
|
package/src/avoutputarea.ts
CHANGED
|
@@ -72,7 +72,7 @@ export class AppletViewOutputArea extends AccordionPanel {
|
|
|
72
72
|
this.addApplet({ appid, appname: 'Applet 1' });
|
|
73
73
|
}
|
|
74
74
|
this.id = `AppletView-${UUID.uuid4()}`;
|
|
75
|
-
this.title.label = '
|
|
75
|
+
this.title.label = 'Applet area';
|
|
76
76
|
this.title.icon = notebookIcon;
|
|
77
77
|
this.title.caption = this._notebook.title.label
|
|
78
78
|
? trans.__('For Notebook: %1', this._notebook.title.label)
|
|
@@ -205,6 +205,9 @@ export class AppletViewOutputArea extends AccordionPanel {
|
|
|
205
205
|
}
|
|
206
206
|
const app = this.widgets[appIndex] as Panel;
|
|
207
207
|
const clone = this.cloneCell(cell, cellid);
|
|
208
|
+
clone.node.addEventListener('contextmenu', e => {
|
|
209
|
+
e.preventDefault();
|
|
210
|
+
});
|
|
208
211
|
this.addToObserver(appIndex, clone);
|
|
209
212
|
app.addWidget(clone);
|
|
210
213
|
|
|
@@ -409,9 +412,9 @@ export class AppletViewOutputArea extends AccordionPanel {
|
|
|
409
412
|
// clear applets
|
|
410
413
|
this._applets = [];
|
|
411
414
|
if (this.layout) {
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
);
|
|
415
|
+
// we need a copy, as forEach does not work, if an item is removed
|
|
416
|
+
const widgetCopy = [...(this.layout as PanelLayout).widgets];
|
|
417
|
+
widgetCopy.forEach((widget: Widget) => this.layout?.removeWidget(widget));
|
|
415
418
|
}
|
|
416
419
|
|
|
417
420
|
if (applets.length === 0) {
|
|
@@ -935,11 +938,19 @@ export class AppletViewRenderer extends AccordionPanel.Renderer {
|
|
|
935
938
|
handle.appendChild(editLabel);
|
|
936
939
|
});
|
|
937
940
|
editLabel.addEventListener('blur', (ev: FocusEvent) => {
|
|
941
|
+
// Firefox and Safari needs this
|
|
942
|
+
if (editLabel.value !== title) {
|
|
943
|
+
editLabel.dispatchEvent(new Event('change', { bubbles: true }));
|
|
944
|
+
}
|
|
945
|
+
|
|
938
946
|
handle.removeChild(editLabel);
|
|
939
947
|
handle.appendChild(staticLabel);
|
|
940
948
|
});
|
|
941
949
|
editLabel.addEventListener('keydown', (ev: KeyboardEvent) => {
|
|
942
950
|
if (ev.key === 'Enter') {
|
|
951
|
+
if (editLabel.value !== title) {
|
|
952
|
+
editLabel.dispatchEvent(new Event('change', { bubbles: true }));
|
|
953
|
+
}
|
|
943
954
|
handle.removeChild(editLabel);
|
|
944
955
|
handle.appendChild(staticLabel);
|
|
945
956
|
}
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
NotebookWidgetFactory,
|
|
8
8
|
StaticNotebook
|
|
9
9
|
} from '@jupyterlab/notebook';
|
|
10
|
-
import { BoxLayout,
|
|
10
|
+
import { BoxLayout, AccordionPanel, AccordionLayout } from '@lumino/widgets';
|
|
11
11
|
import { AppletViewOutputArea } from './avoutputarea';
|
|
12
12
|
import {
|
|
13
13
|
IFailsLauncherInfo,
|
|
@@ -39,9 +39,10 @@ export class SplitViewNotebookPanel
|
|
|
39
39
|
const layout = this.layout as BoxLayout;
|
|
40
40
|
layout.removeWidget(content);
|
|
41
41
|
// 2. add a BoxLayout instead
|
|
42
|
-
const splitPanel = new
|
|
42
|
+
const splitPanel = new AccordionPanel({
|
|
43
43
|
spacing: 1,
|
|
44
|
-
orientation: 'horizontal'
|
|
44
|
+
orientation: 'horizontal',
|
|
45
|
+
alignment: 'justify'
|
|
45
46
|
});
|
|
46
47
|
BoxLayout.setStretch(splitPanel, 1);
|
|
47
48
|
|
|
@@ -55,6 +56,8 @@ export class SplitViewNotebookPanel
|
|
|
55
56
|
}));
|
|
56
57
|
splitPanel.addWidget(widget);
|
|
57
58
|
layout.addWidget(splitPanel);
|
|
59
|
+
const splitLayout = splitPanel.layout as AccordionLayout;
|
|
60
|
+
splitLayout.titleSpace = 22;
|
|
58
61
|
// move to separate handler
|
|
59
62
|
if (failsLauncherInfo?.inLecture) {
|
|
60
63
|
this.toolbar.hide();
|
|
@@ -62,6 +65,7 @@ export class SplitViewNotebookPanel
|
|
|
62
65
|
this._appletviewWidget.inLecture = true;
|
|
63
66
|
content.hide();
|
|
64
67
|
splitPanel.setRelativeSizes([0, 1]); // change sizes
|
|
68
|
+
splitLayout.titleSpace = 0;
|
|
65
69
|
}
|
|
66
70
|
if (failsLauncherInfo) {
|
|
67
71
|
failsLauncherInfo.inLectureChanged.connect(
|
|
@@ -71,14 +75,18 @@ export class SplitViewNotebookPanel
|
|
|
71
75
|
this.addClass('fl-jl-notebook-inlecture');
|
|
72
76
|
this._appletviewWidget.inLecture = true;
|
|
73
77
|
content.hide();
|
|
78
|
+
widget.show();
|
|
79
|
+
splitLayout.titleSpace = 0;
|
|
74
80
|
splitPanel.setRelativeSizes([0, 1]); // change sizes
|
|
75
81
|
} else {
|
|
76
82
|
this.toolbar.show();
|
|
77
83
|
this.removeClass('fl-jl-notebook-inlecture');
|
|
78
84
|
this._appletviewWidget.inLecture = false;
|
|
79
85
|
content.show();
|
|
86
|
+
splitLayout.titleSpace = 22;
|
|
80
87
|
splitPanel.setRelativeSizes([1, 1]); // change sizes
|
|
81
88
|
widget.unselectApplet();
|
|
89
|
+
setTimeout(() => splitPanel.setRelativeSizes([1, 1]), 1);
|
|
82
90
|
}
|
|
83
91
|
}
|
|
84
92
|
);
|