@jupyterlab/notebook 4.6.0-rc.1 → 4.7.0-alpha.0
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/actions.d.ts +16 -0
- package/lib/actions.js +225 -46
- package/lib/actions.js.map +1 -1
- package/lib/panel.js +0 -3
- package/lib/panel.js.map +1 -1
- package/lib/searchprovider.js +0 -1
- package/lib/searchprovider.js.map +1 -1
- package/lib/widget.d.ts +10 -0
- package/lib/widget.js +43 -8
- package/lib/widget.js.map +1 -1
- package/lib/widgetfactory.d.ts +6 -0
- package/lib/widgetfactory.js +2 -0
- package/lib/widgetfactory.js.map +1 -1
- package/package.json +21 -20
- package/src/actions.tsx +286 -51
- package/src/panel.ts +1 -3
- package/src/searchprovider.ts +1 -3
- package/src/widget.ts +59 -10
- package/src/widgetfactory.ts +9 -0
- package/style/index.css +1 -0
- package/style/index.js +1 -0
package/src/widget.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { IEditorMimeTypeService } from '@jupyterlab/codeeditor';
|
|
|
15
15
|
import type { IChangedArgs } from '@jupyterlab/coreutils';
|
|
16
16
|
import type * as nbformat from '@jupyterlab/nbformat';
|
|
17
17
|
import type { IObservableList } from '@jupyterlab/observables';
|
|
18
|
+
import type { IPageHandler } from '@jupyterlab/outputarea';
|
|
18
19
|
import type { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
19
20
|
import type { IMapChange } from '@jupyter/ydoc';
|
|
20
21
|
import { TableOfContentsUtils } from '@jupyterlab/toc';
|
|
@@ -245,6 +246,7 @@ export class StaticNotebook extends WindowedList<NotebookViewModel> {
|
|
|
245
246
|
this.notebookConfig =
|
|
246
247
|
options.notebookConfig || StaticNotebook.defaultNotebookConfig;
|
|
247
248
|
this._updateNotebookConfig();
|
|
249
|
+
this._pageHandler = options.pageHandler;
|
|
248
250
|
this._mimetypeService = options.mimeTypeService;
|
|
249
251
|
this.renderingLayout = options.notebookConfig?.renderingLayout;
|
|
250
252
|
this.kernelHistory = options.kernelHistory;
|
|
@@ -729,6 +731,7 @@ export class StaticNotebook extends WindowedList<NotebookViewModel> {
|
|
|
729
731
|
maxNumberOutputs: this.notebookConfig.maxNumberOutputs,
|
|
730
732
|
model,
|
|
731
733
|
placeholder: this._notebookConfig.windowingMode !== 'none',
|
|
734
|
+
pageHandler: this._pageHandler,
|
|
732
735
|
rendermime,
|
|
733
736
|
translator: this.translator
|
|
734
737
|
};
|
|
@@ -1222,6 +1225,7 @@ export class StaticNotebook extends WindowedList<NotebookViewModel> {
|
|
|
1222
1225
|
private _renderingLayout: RenderingLayout | undefined;
|
|
1223
1226
|
private _renderingLayoutChanged = new Signal<this, RenderingLayout>(this);
|
|
1224
1227
|
private _contentVisibilityObserver: IntersectionObserver | null = null;
|
|
1228
|
+
private _pageHandler: IPageHandler | undefined;
|
|
1225
1229
|
}
|
|
1226
1230
|
|
|
1227
1231
|
/**
|
|
@@ -1276,6 +1280,11 @@ export namespace StaticNotebook {
|
|
|
1276
1280
|
* The renderer used by the underlying windowed list.
|
|
1277
1281
|
*/
|
|
1278
1282
|
renderer?: WindowedList.IRenderer;
|
|
1283
|
+
|
|
1284
|
+
/**
|
|
1285
|
+
* Optional handler for pager payloads (`source: page`).
|
|
1286
|
+
*/
|
|
1287
|
+
pageHandler?: IPageHandler;
|
|
1279
1288
|
}
|
|
1280
1289
|
|
|
1281
1290
|
/**
|
|
@@ -1991,6 +2000,7 @@ export class Notebook extends StaticNotebook {
|
|
|
1991
2000
|
}
|
|
1992
2001
|
|
|
1993
2002
|
this._ensureFocus();
|
|
2003
|
+
|
|
1994
2004
|
if (newValue === oldValue) {
|
|
1995
2005
|
return;
|
|
1996
2006
|
}
|
|
@@ -2085,16 +2095,25 @@ export class Notebook extends StaticNotebook {
|
|
|
2085
2095
|
if (newActiveCellIndex >= 0) {
|
|
2086
2096
|
this.activeCellIndex = newActiveCellIndex;
|
|
2087
2097
|
}
|
|
2098
|
+
|
|
2099
|
+
// Deselect all cells first to clear any stale selection state.
|
|
2100
|
+
this.deselectAll();
|
|
2088
2101
|
if (from > to) {
|
|
2089
2102
|
isSelected.forEach((selected, idx) => {
|
|
2090
2103
|
if (selected) {
|
|
2091
|
-
this.
|
|
2104
|
+
const widget = this.widgets[to + idx];
|
|
2105
|
+
if (widget) {
|
|
2106
|
+
this.select(widget);
|
|
2107
|
+
}
|
|
2092
2108
|
}
|
|
2093
2109
|
});
|
|
2094
2110
|
} else {
|
|
2095
2111
|
isSelected.forEach((selected, idx) => {
|
|
2096
2112
|
if (selected) {
|
|
2097
|
-
this.
|
|
2113
|
+
const widget = this.widgets[to - n + 1 + idx];
|
|
2114
|
+
if (widget) {
|
|
2115
|
+
this.select(widget);
|
|
2116
|
+
}
|
|
2098
2117
|
}
|
|
2099
2118
|
});
|
|
2100
2119
|
}
|
|
@@ -2112,6 +2131,7 @@ export class Notebook extends StaticNotebook {
|
|
|
2112
2131
|
return;
|
|
2113
2132
|
}
|
|
2114
2133
|
Private.selectedProperty.set(widget, true);
|
|
2134
|
+
this._selectCollapsedSection(widget);
|
|
2115
2135
|
this._selectionChanged.emit(void 0);
|
|
2116
2136
|
this.update();
|
|
2117
2137
|
}
|
|
@@ -2127,6 +2147,19 @@ export class Notebook extends StaticNotebook {
|
|
|
2127
2147
|
if (!Private.selectedProperty.get(widget)) {
|
|
2128
2148
|
return;
|
|
2129
2149
|
}
|
|
2150
|
+
// Deselect all children if widget is a collapsed heading
|
|
2151
|
+
if (
|
|
2152
|
+
widget instanceof MarkdownCell &&
|
|
2153
|
+
widget.headingCollapsed &&
|
|
2154
|
+
widget.numberChildNodes > 0
|
|
2155
|
+
) {
|
|
2156
|
+
const idx = this.widgets.indexOf(widget);
|
|
2157
|
+
for (let i = idx + 1; i <= idx + widget.numberChildNodes; i++) {
|
|
2158
|
+
if (this.widgets[i]) {
|
|
2159
|
+
Private.selectedProperty.set(this.widgets[i], false);
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2130
2163
|
Private.selectedProperty.set(widget, false);
|
|
2131
2164
|
this._selectionChanged.emit(void 0);
|
|
2132
2165
|
this.update();
|
|
@@ -2162,11 +2195,8 @@ export class Notebook extends StaticNotebook {
|
|
|
2162
2195
|
}
|
|
2163
2196
|
if (changed) {
|
|
2164
2197
|
this._selectionChanged.emit(void 0);
|
|
2198
|
+
this.update();
|
|
2165
2199
|
}
|
|
2166
|
-
// Make sure we have a valid active cell.
|
|
2167
|
-
// eslint-disable-next-line no-self-assign
|
|
2168
|
-
this.activeCellIndex = this.activeCellIndex;
|
|
2169
|
-
this.update();
|
|
2170
2200
|
}
|
|
2171
2201
|
|
|
2172
2202
|
/**
|
|
@@ -2264,6 +2294,25 @@ export class Notebook extends StaticNotebook {
|
|
|
2264
2294
|
}
|
|
2265
2295
|
}
|
|
2266
2296
|
|
|
2297
|
+
/**
|
|
2298
|
+
* Select all child cells of a collapsed heading, if applicable.
|
|
2299
|
+
*/
|
|
2300
|
+
private _selectCollapsedSection(cell: Cell | null): void {
|
|
2301
|
+
if (
|
|
2302
|
+
cell instanceof MarkdownCell &&
|
|
2303
|
+
cell.headingCollapsed &&
|
|
2304
|
+
cell.numberChildNodes > 0
|
|
2305
|
+
) {
|
|
2306
|
+
const idx = this.widgets.indexOf(cell);
|
|
2307
|
+
for (let i = idx; i <= idx + cell.numberChildNodes; i++) {
|
|
2308
|
+
if (this.widgets[i]) {
|
|
2309
|
+
Private.selectedProperty.set(this.widgets[i], true);
|
|
2310
|
+
}
|
|
2311
|
+
}
|
|
2312
|
+
this._selectionChanged.emit(void 0);
|
|
2313
|
+
}
|
|
2314
|
+
}
|
|
2315
|
+
|
|
2267
2316
|
/**
|
|
2268
2317
|
* Get the head and anchor of a contiguous cell selection.
|
|
2269
2318
|
*
|
|
@@ -2958,9 +3007,9 @@ export class Notebook extends StaticNotebook {
|
|
|
2958
3007
|
(this.rendermime.sanitizer.allowNamedProperties ?? false)
|
|
2959
3008
|
? 'id'
|
|
2960
3009
|
: 'data-jupyter-id';
|
|
2961
|
-
const element = this.node.querySelector(
|
|
3010
|
+
const element = this.node.querySelector<HTMLElement>(
|
|
2962
3011
|
`h${heading.level}[${attribute}="${CSS.escape(id)}"]`
|
|
2963
|
-
)
|
|
3012
|
+
)!;
|
|
2964
3013
|
|
|
2965
3014
|
return {
|
|
2966
3015
|
cell,
|
|
@@ -3374,8 +3423,8 @@ export class Notebook extends StaticNotebook {
|
|
|
3374
3423
|
return;
|
|
3375
3424
|
}
|
|
3376
3425
|
|
|
3377
|
-
// Move the cells
|
|
3378
|
-
|
|
3426
|
+
// Move the selected block of cells, preserving in-flight executions.
|
|
3427
|
+
NotebookActions.moveCells(this, fromIndex, toIndex, toMove.length);
|
|
3379
3428
|
} else {
|
|
3380
3429
|
// Handle the case where we are copying cells between
|
|
3381
3430
|
// notebooks.
|
package/src/widgetfactory.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import type { IEditorMimeTypeService } from '@jupyterlab/codeeditor';
|
|
6
6
|
import type { DocumentRegistry } from '@jupyterlab/docregistry';
|
|
7
7
|
import { ABCWidgetFactory } from '@jupyterlab/docregistry';
|
|
8
|
+
import type { IPageHandler } from '@jupyterlab/outputarea';
|
|
8
9
|
import type { IRenderMimeRegistry } from '@jupyterlab/rendermime';
|
|
9
10
|
import type { ITranslator } from '@jupyterlab/translation';
|
|
10
11
|
import type { INotebookModel } from './model';
|
|
@@ -33,6 +34,7 @@ export class NotebookWidgetFactory extends ABCWidgetFactory<
|
|
|
33
34
|
options.editorConfig || StaticNotebook.defaultEditorConfig;
|
|
34
35
|
this._notebookConfig =
|
|
35
36
|
options.notebookConfig || StaticNotebook.defaultNotebookConfig;
|
|
37
|
+
this._pageHandler = options.pageHandler;
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
/*
|
|
@@ -95,6 +97,7 @@ export class NotebookWidgetFactory extends ABCWidgetFactory<
|
|
|
95
97
|
notebookConfig: source
|
|
96
98
|
? source.content.notebookConfig
|
|
97
99
|
: this._notebookConfig,
|
|
100
|
+
pageHandler: this._pageHandler,
|
|
98
101
|
translator,
|
|
99
102
|
kernelHistory
|
|
100
103
|
};
|
|
@@ -105,6 +108,7 @@ export class NotebookWidgetFactory extends ABCWidgetFactory<
|
|
|
105
108
|
|
|
106
109
|
private _editorConfig: StaticNotebook.IEditorConfig;
|
|
107
110
|
private _notebookConfig: StaticNotebook.INotebookConfig;
|
|
111
|
+
private _pageHandler: IPageHandler | undefined;
|
|
108
112
|
}
|
|
109
113
|
|
|
110
114
|
/**
|
|
@@ -142,6 +146,11 @@ export namespace NotebookWidgetFactory {
|
|
|
142
146
|
*/
|
|
143
147
|
notebookConfig?: StaticNotebook.INotebookConfig;
|
|
144
148
|
|
|
149
|
+
/**
|
|
150
|
+
* Optional handler for pager payloads (`source: page`).
|
|
151
|
+
*/
|
|
152
|
+
pageHandler?: IPageHandler;
|
|
153
|
+
|
|
145
154
|
/**
|
|
146
155
|
* The application language translator.
|
|
147
156
|
*/
|
package/style/index.css
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
@import url('~@jupyterlab/documentsearch/style/index.css');
|
|
15
15
|
@import url('~@jupyterlab/codemirror/style/index.css');
|
|
16
16
|
@import url('~@jupyterlab/docregistry/style/index.css');
|
|
17
|
+
@import url('~@jupyterlab/outputarea/style/index.css');
|
|
17
18
|
@import url('~@jupyterlab/toc/style/index.css');
|
|
18
19
|
@import url('~@jupyterlab/cells/style/index.css');
|
|
19
20
|
@import url('~@jupyterlab/lsp/style/index.css');
|
package/style/index.js
CHANGED
|
@@ -14,6 +14,7 @@ import '@jupyterlab/codeeditor/style/index.js';
|
|
|
14
14
|
import '@jupyterlab/documentsearch/style/index.js';
|
|
15
15
|
import '@jupyterlab/codemirror/style/index.js';
|
|
16
16
|
import '@jupyterlab/docregistry/style/index.js';
|
|
17
|
+
import '@jupyterlab/outputarea/style/index.js';
|
|
17
18
|
import '@jupyterlab/toc/style/index.js';
|
|
18
19
|
import '@jupyterlab/cells/style/index.js';
|
|
19
20
|
import '@jupyterlab/lsp/style/index.js';
|