Skip to content

Commit 402f215

Browse files
authored
Jupyterlab>4.1 (#13)
* Switch from full windowing mode to no windowing before starting presenter * Fix white background * Fix background in notebook application * update dependency and fix keyboard shortcuts * Revert useless changes to handle notebook shell
1 parent b4e6af9 commit 402f215

File tree

6 files changed

+953
-696
lines changed

6 files changed

+953
-696
lines changed

js/jupyterlab-slideshow/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,18 @@
2424
},
2525
"types": "lib/index.d.ts",
2626
"dependencies": {
27-
"@jupyterlab/application": "3 || 4",
28-
"@jupyterlab/apputils": "3 || 4",
29-
"@jupyterlab/fileeditor": "3 || 4",
30-
"@jupyterlab/markdownviewer": "3 || 4",
31-
"@jupyterlab/notebook": "3 || 4",
32-
"@jupyterlab/statusbar": "3 || 4",
33-
"@jupyterlab/ui-components": "3 || 4",
27+
"@jupyterlab/application": "^4.1.0",
28+
"@jupyterlab/apputils": "^4.2.0",
29+
"@jupyterlab/fileeditor": "^4.1.0",
30+
"@jupyterlab/markdownviewer": "^4.1.0",
31+
"@jupyterlab/notebook": "^4.1.0",
32+
"@jupyterlab/statusbar": "^4.1.0",
33+
"@jupyterlab/ui-components": "^4.1.0",
3434
"d3-drag": "3"
3535
},
3636
"devDependencies": {
3737
"@deathbeds/jupyterlab-fonts": "^3.0.0",
38-
"@jupyter-notebook/application": "^7.0.5",
38+
"@jupyter-notebook/application": "^7.1.0",
3939
"@jupyterlab/builder": "^4.0.7",
4040
"@types/d3-drag": "3"
4141
},

js/jupyterlab-slideshow/src/notebook/presenter.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ export class NotebookPresenter implements IPresenter<NotebookPanel> {
6262
protected _extents = new Map<INotebookModel, NotebookPresenter.TExtentMap>();
6363
protected _layers = new Map<INotebookModel, NotebookPresenter.TLayerMap>();
6464

65+
private _windowingModeBackup: 'defer' | 'full' | 'none' = 'full';
66+
6567
constructor(options: NotebookPresenter.IOptions) {
6668
this._manager = options.manager;
6769
this._commands = options.commands;
@@ -95,6 +97,13 @@ export class NotebookPresenter implements IPresenter<NotebookPanel> {
9597
}
9698
this._removeStyle(panel);
9799
panel.content.activeCellChanged.disconnect(this._onActiveCellChanged, this);
100+
101+
// restore the windowing mode of the notebook.
102+
panel.content.notebookConfig = {
103+
...panel.content.notebookConfig,
104+
windowingMode: this._windowingModeBackup
105+
};
106+
98107
panel.update();
99108

100109
const { activeCell } = panel.content;
@@ -111,6 +120,14 @@ export class NotebookPresenter implements IPresenter<NotebookPanel> {
111120

112121
public async start(panel: NotebookPanel): Promise<void> {
113122
const { model, content: notebook } = panel;
123+
124+
// Switch to not windowing mode
125+
this._windowingModeBackup = notebook.notebookConfig.windowingMode;
126+
notebook.notebookConfig = {...panel.content.notebookConfig, windowingMode: 'none'};
127+
// Force viewport properties that may not be properly set, depending on lab version.
128+
notebook.viewportNode.style.minHeight = '';
129+
(notebook.viewportNode.parentNode as HTMLDivElement).style.height = '';
130+
114131
if (model) {
115132
const _watchPanel = async (change: any) => {
116133
/* istanbul ignore if */
@@ -312,7 +329,7 @@ export class NotebookPresenter implements IPresenter<NotebookPanel> {
312329
this._commands.addKeyBinding({
313330
command: CommandIds[direction],
314331
keys: DIRECTION_KEYS[direction],
315-
selector: `.${CSS.deck} .jp-Notebook.jp-mod-commandMode:focus`,
332+
selector: `.${CSS.deck} .jp-Notebook.jp-mod-commandMode:not(.jp-mod-readWrite) :focus`,
316333
});
317334
}
318335
for (const [directions, keys] of COMPOUND_KEYS.entries()) {
@@ -321,7 +338,7 @@ export class NotebookPresenter implements IPresenter<NotebookPanel> {
321338
command: CommandIds.go,
322339
args: { direction, alternate },
323340
keys,
324-
selector: `.${CSS.deck} .jp-Notebook.jp-mod-commandMode:focus`,
341+
selector: `.${CSS.deck} .jp-Notebook.jp-mod-commandMode:not(.jp-mod-readWrite) :focus`,
325342
});
326343
}
327344
}
@@ -518,6 +535,9 @@ export class NotebookPresenter implements IPresenter<NotebookPanel> {
518535
if (this._manager.layover) {
519536
this._manager.layover.model.parts = onScreen;
520537
}
538+
539+
// Force the focus on the new active cell.
540+
notebook.activeCell?.node.focus();
521541
}
522542

523543
protected _forceStyle() {

js/jupyterlab-slideshow/style/notebook.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ body[data-notebook='notebooks']
107107
position: fixed;
108108
}
109109

110+
/** cell focus not visible **/
111+
.jp-Deck .jp-Notebook.jp-mod-commandMode .jp-Cell.jp-mod-active:focus-visible {
112+
box-shadow: none;
113+
}
114+
110115
/** markdown tweaks **/
111116
.jp-Deck .jp-MarkdownOutput {
112117
border: 0;

js/jupyterlab-slideshow/style/shell.css

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
body[data-jp-deck-mode='presenting'] {
1+
body[data-jp-deck-mode='presenting'],
2+
body[data-jp-deck-mode='presenting'] .jp-ThemedContainer:has(.jp-Deck),
3+
body[data-jp-deck-mode='presenting'][data-notebook='notebooks'] .jp-WindowedPanel-outer {
24
background: var(--jp-layout-color0);
35
}
46

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ classifiers = [
2020
requires-python = ">=3.8"
2121
dynamic = ["description"]
2222
dependencies = [
23-
"jupyterlab >=3.5,<5.0.0a0",
23+
"jupyterlab >=4.1,<5.0.0a0",
2424
"jupyterlab-fonts >=3.0.0"
2525
]
2626

0 commit comments

Comments
 (0)