@jupyterlab/notebook 4.2.0-alpha.0 → 4.2.0-alpha.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.
- package/lib/actions.d.ts +5 -4
- package/lib/actions.js +20 -7
- package/lib/actions.js.map +1 -1
- package/lib/searchprovider.js +3 -7
- package/lib/searchprovider.js.map +1 -1
- package/lib/toc.d.ts +8 -0
- package/lib/toc.js +11 -0
- package/lib/toc.js.map +1 -1
- package/lib/widget.js +29 -1
- package/lib/widget.js.map +1 -1
- package/lib/windowing.js +1 -1
- package/lib/windowing.js.map +1 -1
- package/package.json +20 -20
- package/src/actions.tsx +30 -7
- package/src/searchprovider.ts +3 -14
- package/src/toc.ts +17 -0
- package/src/widget.ts +29 -1
- package/src/windowing.ts +1 -1
- package/style/base.css +2 -2
package/src/searchprovider.ts
CHANGED
|
@@ -9,10 +9,7 @@ import {
|
|
|
9
9
|
ICellModel,
|
|
10
10
|
MarkdownCell
|
|
11
11
|
} from '@jupyterlab/cells';
|
|
12
|
-
import {
|
|
13
|
-
CodeMirrorEditor,
|
|
14
|
-
IHighlightAdjacentMatchOptions
|
|
15
|
-
} from '@jupyterlab/codemirror';
|
|
12
|
+
import { IHighlightAdjacentMatchOptions } from '@jupyterlab/codemirror';
|
|
16
13
|
import { CodeEditor } from '@jupyterlab/codeeditor';
|
|
17
14
|
import { IChangedArgs } from '@jupyterlab/coreutils';
|
|
18
15
|
import {
|
|
@@ -289,16 +286,8 @@ export class NotebookSearchProvider extends SearchProvider<NotebookPanel> {
|
|
|
289
286
|
* @returns Initial value used to populate the search box.
|
|
290
287
|
*/
|
|
291
288
|
getInitialQuery(): string {
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
if (!editor) {
|
|
295
|
-
return '';
|
|
296
|
-
}
|
|
297
|
-
const selection = editor.state.sliceDoc(
|
|
298
|
-
editor.state.selection.main.from,
|
|
299
|
-
editor.state.selection.main.to
|
|
300
|
-
);
|
|
301
|
-
return selection;
|
|
289
|
+
// Get whatever is selected in the browser window.
|
|
290
|
+
return window.getSelection()?.toString() || '';
|
|
302
291
|
}
|
|
303
292
|
|
|
304
293
|
/**
|
package/src/toc.ts
CHANGED
|
@@ -295,6 +295,23 @@ export class NotebookToCModel extends TableOfContentsModel<
|
|
|
295
295
|
return Promise.resolve(headings);
|
|
296
296
|
}
|
|
297
297
|
|
|
298
|
+
/**
|
|
299
|
+
* Test if two headings are equal or not.
|
|
300
|
+
*
|
|
301
|
+
* @param heading1 First heading
|
|
302
|
+
* @param heading2 Second heading
|
|
303
|
+
* @returns Whether the headings are equal.
|
|
304
|
+
*/
|
|
305
|
+
protected override isHeadingEqual(
|
|
306
|
+
heading1: INotebookHeading,
|
|
307
|
+
heading2: INotebookHeading
|
|
308
|
+
): boolean {
|
|
309
|
+
return (
|
|
310
|
+
super.isHeadingEqual(heading1, heading2) &&
|
|
311
|
+
heading1.cellRef === heading2.cellRef
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
|
|
298
315
|
/**
|
|
299
316
|
* Read table of content configuration from notebook metadata.
|
|
300
317
|
*
|
package/src/widget.ts
CHANGED
|
@@ -2132,6 +2132,34 @@ export class Notebook extends StaticNotebook {
|
|
|
2132
2132
|
cell.editor!.edgeRequested.connect(this._onEdgeRequest, this);
|
|
2133
2133
|
}
|
|
2134
2134
|
});
|
|
2135
|
+
cell.scrollRequested.connect((_emitter, scrollRequest) => {
|
|
2136
|
+
if (cell !== this.activeCell) {
|
|
2137
|
+
// Do nothing for cells other than the active cell
|
|
2138
|
+
// to avoid scroll requests from editor extensions
|
|
2139
|
+
// stealing user focus (this may be revisited).
|
|
2140
|
+
return;
|
|
2141
|
+
}
|
|
2142
|
+
if (!scrollRequest.defaultPrevented) {
|
|
2143
|
+
// Nothing to do if scroll request was already handled.
|
|
2144
|
+
return;
|
|
2145
|
+
}
|
|
2146
|
+
if (cell.inViewport) {
|
|
2147
|
+
// If cell got scrolled to the viewport in the meantime,
|
|
2148
|
+
// proceed with scrolling within the cell.
|
|
2149
|
+
return scrollRequest.scrollWithinCell();
|
|
2150
|
+
}
|
|
2151
|
+
// If cell is not in the viewport and needs scrolling,
|
|
2152
|
+
// first scroll to the cell and then scroll within the cell.
|
|
2153
|
+
this.scrollToItem(this.activeCellIndex)
|
|
2154
|
+
.then(() => {
|
|
2155
|
+
void cell.ready.then(() => {
|
|
2156
|
+
scrollRequest.scrollWithinCell();
|
|
2157
|
+
});
|
|
2158
|
+
})
|
|
2159
|
+
.catch(reason => {
|
|
2160
|
+
// no-op
|
|
2161
|
+
});
|
|
2162
|
+
});
|
|
2135
2163
|
// If the insertion happened above, increment the active cell
|
|
2136
2164
|
// index, otherwise it stays the same.
|
|
2137
2165
|
this.activeCellIndex =
|
|
@@ -2212,7 +2240,7 @@ export class Notebook extends StaticNotebook {
|
|
|
2212
2240
|
const activeCell = this.activeCell;
|
|
2213
2241
|
if (this.mode === 'edit' && activeCell) {
|
|
2214
2242
|
// Test for !== true to cover hasFocus is false and editor is not yet rendered.
|
|
2215
|
-
if (activeCell.editor?.hasFocus() !== true
|
|
2243
|
+
if (activeCell.editor?.hasFocus() !== true) {
|
|
2216
2244
|
if (activeCell.inViewport) {
|
|
2217
2245
|
activeCell.editor?.focus();
|
|
2218
2246
|
} else {
|
package/src/windowing.ts
CHANGED
|
@@ -261,7 +261,7 @@ export class NotebookWindowedLayout extends WindowedLayout {
|
|
|
261
261
|
|
|
262
262
|
// Note: `index` is relative to the displayed cells, not all cells,
|
|
263
263
|
// hence we compare with the widget itself.
|
|
264
|
-
if (widget === this.activeCell) {
|
|
264
|
+
if (widget === this.activeCell && widget !== this._willBeRemoved) {
|
|
265
265
|
// Do not change display of the active cell to allow user to continue providing input
|
|
266
266
|
// into the code mirror editor when out of view. We still hide the cell so to prevent
|
|
267
267
|
// minor visual glitches when scrolling.
|
package/style/base.css
CHANGED
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
--jp-side-by-side-resized-cell: var(--jp-side-by-side-output-size);
|
|
22
22
|
--jp-private-notebook-dragImage-width: 304px;
|
|
23
23
|
--jp-private-notebook-dragImage-height: 36px;
|
|
24
|
-
--jp-private-notebook-selected-color: var(--md-blue-400);
|
|
25
|
-
--jp-private-notebook-active-color: var(--md-green-400);
|
|
24
|
+
--jp-private-notebook-selected-color: var(--md-blue-400, #42a5f5);
|
|
25
|
+
--jp-private-notebook-active-color: var(--md-green-400, #66bb6a);
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/*-----------------------------------------------------------------------------
|