Skip to content

Commit

Permalink
Jupyterlab>4.1 (#13)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
brichet authored Jan 8, 2025
1 parent b4e6af9 commit 402f215
Show file tree
Hide file tree
Showing 6 changed files with 953 additions and 696 deletions.
16 changes: 8 additions & 8 deletions js/jupyterlab-slideshow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@
},
"types": "lib/index.d.ts",
"dependencies": {
"@jupyterlab/application": "3 || 4",
"@jupyterlab/apputils": "3 || 4",
"@jupyterlab/fileeditor": "3 || 4",
"@jupyterlab/markdownviewer": "3 || 4",
"@jupyterlab/notebook": "3 || 4",
"@jupyterlab/statusbar": "3 || 4",
"@jupyterlab/ui-components": "3 || 4",
"@jupyterlab/application": "^4.1.0",
"@jupyterlab/apputils": "^4.2.0",
"@jupyterlab/fileeditor": "^4.1.0",
"@jupyterlab/markdownviewer": "^4.1.0",
"@jupyterlab/notebook": "^4.1.0",
"@jupyterlab/statusbar": "^4.1.0",
"@jupyterlab/ui-components": "^4.1.0",
"d3-drag": "3"
},
"devDependencies": {
"@deathbeds/jupyterlab-fonts": "^3.0.0",
"@jupyter-notebook/application": "^7.0.5",
"@jupyter-notebook/application": "^7.1.0",
"@jupyterlab/builder": "^4.0.7",
"@types/d3-drag": "3"
},
Expand Down
24 changes: 22 additions & 2 deletions js/jupyterlab-slideshow/src/notebook/presenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ export class NotebookPresenter implements IPresenter<NotebookPanel> {
protected _extents = new Map<INotebookModel, NotebookPresenter.TExtentMap>();
protected _layers = new Map<INotebookModel, NotebookPresenter.TLayerMap>();

private _windowingModeBackup: 'defer' | 'full' | 'none' = 'full';

constructor(options: NotebookPresenter.IOptions) {
this._manager = options.manager;
this._commands = options.commands;
Expand Down Expand Up @@ -95,6 +97,13 @@ export class NotebookPresenter implements IPresenter<NotebookPanel> {
}
this._removeStyle(panel);
panel.content.activeCellChanged.disconnect(this._onActiveCellChanged, this);

// restore the windowing mode of the notebook.
panel.content.notebookConfig = {
...panel.content.notebookConfig,
windowingMode: this._windowingModeBackup
};

panel.update();

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

public async start(panel: NotebookPanel): Promise<void> {
const { model, content: notebook } = panel;

// Switch to not windowing mode
this._windowingModeBackup = notebook.notebookConfig.windowingMode;
notebook.notebookConfig = {...panel.content.notebookConfig, windowingMode: 'none'};
// Force viewport properties that may not be properly set, depending on lab version.
notebook.viewportNode.style.minHeight = '';
(notebook.viewportNode.parentNode as HTMLDivElement).style.height = '';

if (model) {
const _watchPanel = async (change: any) => {
/* istanbul ignore if */
Expand Down Expand Up @@ -312,7 +329,7 @@ export class NotebookPresenter implements IPresenter<NotebookPanel> {
this._commands.addKeyBinding({
command: CommandIds[direction],
keys: DIRECTION_KEYS[direction],
selector: `.${CSS.deck} .jp-Notebook.jp-mod-commandMode:focus`,
selector: `.${CSS.deck} .jp-Notebook.jp-mod-commandMode:not(.jp-mod-readWrite) :focus`,
});
}
for (const [directions, keys] of COMPOUND_KEYS.entries()) {
Expand All @@ -321,7 +338,7 @@ export class NotebookPresenter implements IPresenter<NotebookPanel> {
command: CommandIds.go,
args: { direction, alternate },
keys,
selector: `.${CSS.deck} .jp-Notebook.jp-mod-commandMode:focus`,
selector: `.${CSS.deck} .jp-Notebook.jp-mod-commandMode:not(.jp-mod-readWrite) :focus`,
});
}
}
Expand Down Expand Up @@ -518,6 +535,9 @@ export class NotebookPresenter implements IPresenter<NotebookPanel> {
if (this._manager.layover) {
this._manager.layover.model.parts = onScreen;
}

// Force the focus on the new active cell.
notebook.activeCell?.node.focus();
}

protected _forceStyle() {
Expand Down
5 changes: 5 additions & 0 deletions js/jupyterlab-slideshow/style/notebook.css
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ body[data-notebook='notebooks']
position: fixed;
}

/** cell focus not visible **/
.jp-Deck .jp-Notebook.jp-mod-commandMode .jp-Cell.jp-mod-active:focus-visible {
box-shadow: none;
}

/** markdown tweaks **/
.jp-Deck .jp-MarkdownOutput {
border: 0;
Expand Down
4 changes: 3 additions & 1 deletion js/jupyterlab-slideshow/style/shell.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
body[data-jp-deck-mode='presenting'] {
body[data-jp-deck-mode='presenting'],
body[data-jp-deck-mode='presenting'] .jp-ThemedContainer:has(.jp-Deck),
body[data-jp-deck-mode='presenting'][data-notebook='notebooks'] .jp-WindowedPanel-outer {
background: var(--jp-layout-color0);
}

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ classifiers = [
requires-python = ">=3.8"
dynamic = ["description"]
dependencies = [
"jupyterlab >=3.5,<5.0.0a0",
"jupyterlab >=4.1,<5.0.0a0",
"jupyterlab-fonts >=3.0.0"
]

Expand Down
Loading

0 comments on commit 402f215

Please sign in to comment.