@fails-components/jupyter-applet-view 0.0.1-alpha.8 → 0.0.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.
@@ -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 = 'Applets Preview';
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)
@@ -358,7 +358,9 @@ export class AppletViewOutputArea extends AccordionPanel {
358
358
  // clear applets
359
359
  this._applets = [];
360
360
  if (this.layout) {
361
- this.layout.widgets.forEach((widget) => { var _a; return (_a = this.layout) === null || _a === void 0 ? void 0 : _a.removeWidget(widget); });
361
+ // we need a copy, as forEach does not work, if an item is removed
362
+ const widgetCopy = [...this.layout.widgets];
363
+ widgetCopy.forEach((widget) => { var _a; return (_a = this.layout) === null || _a === void 0 ? void 0 : _a.removeWidget(widget); });
362
364
  }
363
365
  if (applets.length === 0) {
364
366
  // we need a minimum of 1 applet!
@@ -721,11 +723,18 @@ export class AppletViewRenderer extends AccordionPanel.Renderer {
721
723
  handle.appendChild(editLabel);
722
724
  });
723
725
  editLabel.addEventListener('blur', (ev) => {
726
+ // Firefox and Safari needs this
727
+ if (editLabel.value !== title) {
728
+ editLabel.dispatchEvent(new Event('change', { bubbles: true }));
729
+ }
724
730
  handle.removeChild(editLabel);
725
731
  handle.appendChild(staticLabel);
726
732
  });
727
733
  editLabel.addEventListener('keydown', (ev) => {
728
734
  if (ev.key === 'Enter') {
735
+ if (editLabel.value !== title) {
736
+ editLabel.dispatchEvent(new Event('change', { bubbles: true }));
737
+ }
729
738
  handle.removeChild(editLabel);
730
739
  handle.appendChild(staticLabel);
731
740
  }
@@ -1,5 +1,5 @@
1
1
  import { NotebookPanel, NotebookHistory, NotebookWidgetFactory } from '@jupyterlab/notebook';
2
- import { BoxLayout, SplitPanel } from '@lumino/widgets';
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 SplitPanel({
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.1-alpha.8",
3
+ "version": "0.0.2",
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.1-alpha.8",
62
- "@fails-components/jupyter-launcher": "^0.0.1-alpha.8",
63
- "@jupyter-notebook/application": "^7.2.0",
64
- "@jupyter-widgets/jupyterlab-manager": "^5.0.13",
65
- "@jupyterlab/application": "^4.3.4",
66
- "@jupyterlab/apputils": "^4.3.4",
67
- "@jupyterlab/cells": "^4.3.4",
68
- "@jupyterlab/docmanager": "^4.3.4",
69
- "@jupyterlab/docregistry": "^4.3.4",
70
- "@jupyterlab/notebook": "^4.3.4",
71
- "@jupyterlab/observables": "^5.3.4",
72
- "@jupyterlab/outputarea": "^4.3.4",
73
- "@jupyterlab/statedb": "^4.3.4",
74
- "@jupyterlab/translation": "^4.3.4",
75
- "@jupyterlab/ui-components": "^4.3.4",
76
- "@jupyterlite/application-extension": "^0.5.0",
77
- "@jupyterlite/contents": "^0.5.0",
78
- "@jupyterlite/server": "^0.5.0",
79
- "@jupyterlite/settings": "^0.5.0",
80
- "@lumino/algorithm": "^2.0.1",
81
- "@lumino/commands": "^2.1.2",
82
- "@lumino/coreutils": "^2.2.0",
83
- "@lumino/disposable": "^2.1.3",
84
- "@lumino/signaling": "^2.1.3",
85
- "@lumino/widgets": "^2.5.0",
86
- "json5": "^2.2.3",
61
+ "@fails-components/jupyter-interceptor": "^0.0.2",
62
+ "@fails-components/jupyter-launcher": "^0.0.2",
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
- "jupyterlite": {
130
- "liteExtension": false
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",
@@ -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 = 'Applets Preview';
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)
@@ -409,9 +409,9 @@ export class AppletViewOutputArea extends AccordionPanel {
409
409
  // clear applets
410
410
  this._applets = [];
411
411
  if (this.layout) {
412
- (this.layout as PanelLayout).widgets.forEach((widget: Widget) =>
413
- this.layout?.removeWidget(widget)
414
- );
412
+ // we need a copy, as forEach does not work, if an item is removed
413
+ const widgetCopy = [...(this.layout as PanelLayout).widgets];
414
+ widgetCopy.forEach((widget: Widget) => this.layout?.removeWidget(widget));
415
415
  }
416
416
 
417
417
  if (applets.length === 0) {
@@ -935,11 +935,19 @@ export class AppletViewRenderer extends AccordionPanel.Renderer {
935
935
  handle.appendChild(editLabel);
936
936
  });
937
937
  editLabel.addEventListener('blur', (ev: FocusEvent) => {
938
+ // Firefox and Safari needs this
939
+ if (editLabel.value !== title) {
940
+ editLabel.dispatchEvent(new Event('change', { bubbles: true }));
941
+ }
942
+
938
943
  handle.removeChild(editLabel);
939
944
  handle.appendChild(staticLabel);
940
945
  });
941
946
  editLabel.addEventListener('keydown', (ev: KeyboardEvent) => {
942
947
  if (ev.key === 'Enter') {
948
+ if (editLabel.value !== title) {
949
+ editLabel.dispatchEvent(new Event('change', { bubbles: true }));
950
+ }
943
951
  handle.removeChild(editLabel);
944
952
  handle.appendChild(staticLabel);
945
953
  }
@@ -7,7 +7,7 @@ import {
7
7
  NotebookWidgetFactory,
8
8
  StaticNotebook
9
9
  } from '@jupyterlab/notebook';
10
- import { BoxLayout, SplitPanel } from '@lumino/widgets';
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 SplitPanel({
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
  );
package/style/index.css CHANGED
@@ -114,7 +114,7 @@
114
114
  }
115
115
 
116
116
  .fl-jl-notebook-inlecture .lm-AccordionPanel-title {
117
- display: none;
117
+ display: none !important;
118
118
  }
119
119
 
120
120
  .fl-jl-notebook-inlecture .lm-SplitPanel-handle {