@jupyter-notebook/notebook-extension 7.0.0-alpha.4 → 7.0.0-alpha.6

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.
Files changed (3) hide show
  1. package/lib/index.js +17 -19
  2. package/package.json +13 -13
  3. package/style/base.css +142 -31
package/lib/index.js CHANGED
@@ -211,29 +211,27 @@ const scrollOutput = {
211
211
  const scroll = height > lineHeight * autoScrollThreshold;
212
212
  cell.toggleClass(SCROLLED_OUTPUTS_CLASS, scroll);
213
213
  };
214
+ const handlers = {};
215
+ const setAutoScroll = (cell) => {
216
+ if (cell.model.type === 'code') {
217
+ const codeCell = cell;
218
+ const id = codeCell.model.id;
219
+ autoScroll(codeCell);
220
+ if (handlers[id]) {
221
+ codeCell.outputArea.model.changed.disconnect(handlers[id]);
222
+ }
223
+ handlers[id] = () => autoScroll(codeCell);
224
+ codeCell.outputArea.model.changed.connect(handlers[id]);
225
+ }
226
+ };
214
227
  tracker.widgetAdded.connect((sender, notebook) => {
215
228
  var _a;
216
- (_a = notebook.model) === null || _a === void 0 ? void 0 : _a.cells.changed.connect((sender, changed) => {
217
- // process new cells only
218
- if (!(changed.type === 'add')) {
219
- return;
220
- }
221
- const [cellModel] = changed.newValues;
222
- notebook.content.widgets.forEach(cell => {
223
- if (cell.model.id === cellModel.id && cell.model.type === 'code') {
224
- const codeCell = cell;
225
- codeCell.outputArea.model.changed.connect(() => autoScroll(codeCell));
226
- }
227
- });
228
- });
229
229
  // when the notebook widget is created, process all the cells
230
- // TODO: investigate why notebook.content.fullyRendered is not enough
231
230
  notebook.sessionContext.ready.then(() => {
232
- notebook.content.widgets.forEach(cell => {
233
- if (cell.model.type === 'code') {
234
- autoScroll(cell);
235
- }
236
- });
231
+ notebook.content.widgets.forEach(setAutoScroll);
232
+ });
233
+ (_a = notebook.model) === null || _a === void 0 ? void 0 : _a.cells.changed.connect((sender, args) => {
234
+ notebook.content.widgets.forEach(setAutoScroll);
237
235
  });
238
236
  });
239
237
  if (settingRegistry) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jupyter-notebook/notebook-extension",
3
- "version": "7.0.0-alpha.4",
3
+ "version": "7.0.0-alpha.6",
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.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
- "@lumino/polling": "^1.10.0",
51
- "@lumino/widgets": "^1.32.0"
42
+ "@jupyter-notebook/application": "^7.0.0-alpha.6",
43
+ "@jupyterlab/application": "^4.0.0-alpha.14",
44
+ "@jupyterlab/apputils": "^4.0.0-alpha.14",
45
+ "@jupyterlab/cells": "^4.0.0-alpha.14",
46
+ "@jupyterlab/docmanager": "^4.0.0-alpha.14",
47
+ "@jupyterlab/notebook": "^4.0.0-alpha.14",
48
+ "@jupyterlab/settingregistry": "^4.0.0-alpha.14",
49
+ "@jupyterlab/translation": "^4.0.0-alpha.14",
50
+ "@lumino/polling": "^2.0.0-alpha.6",
51
+ "@lumino/widgets": "^2.0.0-alpha.6"
52
52
  },
53
53
  "devDependencies": {
54
- "rimraf": "~3.0.0",
55
- "typescript": "~4.6.3"
54
+ "rimraf": "^3.0.2",
55
+ "typescript": "~4.7.3"
56
56
  },
57
57
  "publishConfig": {
58
58
  "access": "public"
package/style/base.css CHANGED
@@ -6,16 +6,53 @@
6
6
 
7
7
  @import './variables.css';
8
8
 
9
- /* Document oriented look for the notebook (scrollbar to the right of the page) */
9
+ /**
10
+ Document oriented look for the notebook.
11
+ This includes changes to the look and feel of the JupyterLab Notebook
12
+ component like:
13
+ - scrollbar to the right of the page
14
+ - drop shadow on the notebook
15
+ - smaller empty space at the bottom of the notebook
16
+ - compact view on mobile
17
+ */
18
+
19
+ /* Keep the notebook centered on the page */
10
20
 
11
21
  body[data-notebook='notebooks'] .jp-NotebookPanel-toolbar {
12
22
  padding-left: calc(calc(100% - var(--jp-notebook-max-width)) * 0.5);
13
23
  padding-right: calc(calc(100% - var(--jp-notebook-max-width)) * 0.5);
14
24
  }
15
25
 
26
+ body[data-notebook='notebooks'] .jp-Notebook {
27
+ padding-top: unset;
28
+ padding-left: calc(calc(100% - var(--jp-notebook-max-width)) * 0.5);
29
+ padding-right: calc(
30
+ calc(
31
+ 100% - var(--jp-notebook-max-width) - var(--jp-notebook-padding-offset)
32
+ ) * 0.5
33
+ );
34
+ background: var(--jp-layout-color2);
35
+ }
36
+
37
+ body[data-notebook='notebooks'] .jp-WindowedPanel-inner {
38
+ margin-top: var(--jp-notebook-toolbar-margin-bottom);
39
+ }
40
+
41
+ body[data-notebook='notebooks'] .jp-Notebook-cell {
42
+ background: var(--jp-layout-color0);
43
+ padding-left: calc(2 * var(--jp-cell-padding));
44
+ padding-right: calc(2 * var(--jp-cell-padding));
45
+ }
46
+
47
+ /* Empty space at the bottom of the notebook (similar to classic) */
48
+ body[data-notebook='notebooks'] .jp-Notebook.jp-mod-scrollPastEnd::after {
49
+ min-height: 100px;
50
+ }
51
+
52
+ /* Fix background colors */
53
+
16
54
  body[data-notebook='notebooks'] .jp-Notebook > * {
17
55
  background: var(--jp-layout-color0);
18
- padding: var(--jp-notebook-padding);
19
56
  }
20
57
 
21
58
  body[data-notebook='notebooks']
@@ -24,42 +61,126 @@ body[data-notebook='notebooks']
24
61
  background: var(--jp-layout-color0) !important;
25
62
  }
26
63
 
27
- body[data-notebook='notebooks'] .jp-Notebook > *:first-child {
28
- padding-top: var(--jp-notebook-padding-offset);
29
- margin-top: var(--jp-notebook-toolbar-margin-bottom);
64
+ /**
65
+ Extra padding to the first and and last cell of the notebook.
66
+ TODO: revisit when https://github.com/jupyterlab/jupyterlab/issues/13151 is fixed
67
+ */
68
+ .jp-Notebook-cell[data-windowed-list-index='0'] {
69
+ padding-top: calc(2 * var(--jp-notebook-padding));
30
70
  }
31
71
 
32
- body[data-notebook='notebooks'] .jp-Notebook {
33
- padding-top: unset;
34
- padding-bottom: unset;
35
- padding-left: calc(calc(100% - var(--jp-notebook-max-width)) * 0.5);
36
- padding-right: calc(
37
- calc(
38
- 100% - var(--jp-notebook-max-width) - var(--jp-notebook-padding-offset)
39
- ) * 0.5
40
- );
41
- background: var(--jp-layout-color2);
72
+ body[data-notebook='notebooks'] .jp-WindowedPanel-window > *:last-child {
73
+ padding-bottom: calc(2 * var(--jp-notebook-padding));
42
74
  }
43
75
 
44
- body[data-notebook='notebooks'] .jp-Notebook.jp-mod-scrollPastEnd::after {
45
- background: var(--jp-layout-color0);
46
- min-height: var(--jp-notebook-padding);
76
+ body[data-notebook='notebooks']
77
+ .jp-Notebook
78
+ .jp-Notebook-cell:not(:first-child)::before {
79
+ content: ' ';
80
+ height: 100%;
81
+ position: absolute;
82
+ top: 0;
83
+ width: 11px;
47
84
  }
48
85
 
49
86
  /* Cell toolbar adjustements */
50
87
 
51
88
  body[data-notebook='notebooks'] .jp-cell-toolbar {
52
89
  background: unset;
90
+ box-shadow: unset;
91
+ }
92
+
93
+ body[data-notebook='notebooks']
94
+ .jp-RawCell[data-windowed-list-index='0']
95
+ .jp-cell-toolbar,
96
+ body[data-notebook='notebooks']
97
+ .jp-MarkdownCell[data-windowed-list-index='0']
98
+ .jp-cell-toolbar {
99
+ top: calc(2 * var(--jp-notebook-padding));
100
+ }
101
+
102
+ /** first code cell on mobile
103
+ (keep the selector above the media query)
104
+ */
105
+ body[data-notebook='notebooks']
106
+ .jp-CodeCell[data-windowed-list-index='0']
107
+ .jp-cell-toolbar {
53
108
  top: unset;
54
109
  }
55
110
 
56
111
  @media only screen and (max-width: 760px) {
57
- body[data-notebook='notebooks'] .jp-cell-toolbar {
58
- top: 5px;
112
+ /* first code cell on mobile */
113
+ body[data-notebook='notebooks']
114
+ .jp-CodeCell[data-windowed-list-index='0']
115
+ .jp-cell-toolbar {
116
+ top: var(--jp-notebook-padding);
117
+ }
118
+
119
+ body[data-notebook='notebooks'] .jp-MarkdownCell .jp-cell-toolbar,
120
+ body[data-notebook='notebooks'] .jp-RawCell .jp-cell-toolbar {
121
+ top: calc(0.5 * var(--jp-notebook-padding));
59
122
  }
60
123
  }
61
124
 
62
- /* ---- */
125
+ /* Mobile View */
126
+
127
+ body[data-format='mobile'] .jp-NotebookCheckpoint {
128
+ display: none;
129
+ }
130
+
131
+ body[data-format='mobile'] .jp-Notebook > *:first-child {
132
+ margin-top: 0;
133
+ }
134
+
135
+ /* Virtual Notebook fixes */
136
+
137
+ body[data-notebook='notebooks'] .jp-WindowedPanel-window {
138
+ background: var(--jp-layout-color0);
139
+ /* TODO: remove when https://github.com/jupyterlab/jupyterlab/pull/13154 is released */
140
+ width: unset;
141
+ }
142
+
143
+ body[data-notebook='notebooks'] .jp-WindowedPanel-inner {
144
+ /* TODO: remove when https://github.com/jupyterlab/jupyterlab/pull/13157 is released */
145
+ width: unset;
146
+ }
147
+
148
+ /* Notebook box shadow */
149
+
150
+ body[data-notebook='notebooks'] .jp-Notebook > *:first-child:not(:last-child) {
151
+ box-shadow: 0px 0px 12px 1px var(--jp-shadow-umbra-color);
152
+ }
153
+
154
+ body[data-notebook='notebooks'] .jp-Notebook > *:first-child:not(:last-child) {
155
+ box-shadow: 0px 0px 12px 1px var(--jp-shadow-umbra-color);
156
+ }
157
+
158
+ body[data-notebook='notebooks']
159
+ .jp-Notebook
160
+ > *:first-child:last-child::before {
161
+ content: '';
162
+ position: absolute;
163
+ top: 0;
164
+ bottom: 0;
165
+ left: 0;
166
+ right: 0;
167
+ box-shadow: 0px 0px 12px 1px var(--jp-shadow-umbra-color);
168
+ }
169
+
170
+ body[data-notebook='notebooks']
171
+ .jp-Notebook
172
+ .jp-Notebook-cell:not(:first-child)::after,
173
+ body[data-notebook='notebooks']
174
+ .jp-Notebook
175
+ .jp-Notebook-cell:not(:first-child)::before {
176
+ content: ' ';
177
+ height: 100%;
178
+ position: absolute;
179
+ top: 0;
180
+ width: 11px;
181
+ }
182
+
183
+ /* Additional customizations of the components on the notebook page */
63
184
 
64
185
  .jp-NotebookKernelLogo {
65
186
  flex: 0 0 auto;
@@ -140,13 +261,3 @@ body[data-notebook='notebooks'] .jp-cell-toolbar {
140
261
  overflow: hidden;
141
262
  white-space: nowrap;
142
263
  }
143
-
144
- /* Mobile View */
145
-
146
- body[data-format='mobile'] .jp-NotebookCheckpoint {
147
- display: none;
148
- }
149
-
150
- body[data-format='mobile'] .jp-Notebook > *:first-child {
151
- margin-top: 0;
152
- }