Skip to content

Commit 5ee726c

Browse files
committed
Add support for JupyterLab 3.6/4+ and Notebook v7+
1 parent d578906 commit 5ee726c

File tree

5 files changed

+25
-19
lines changed

5 files changed

+25
-19
lines changed

docs/changelog.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## Dev
4+
5+
**Jupyterlab extension**
6+
7+
- Support for JupyterLab 3.6+/4+ and Notebook v7, courtesy of mcrutch;
8+
39
## 2.0.0 2023-05-08
410

511
**General**

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,18 +56,18 @@
5656
"watch:labextension": "jupyter labextension watch ."
5757
},
5858
"dependencies": {
59-
"@jupyterlab/application": "^3.1.0",
60-
"@jupyterlab/settingregistry": "^3.1.0",
59+
"@jupyterlab/application": "^3.6.0 || ~4.0.0",
60+
"@jupyterlab/settingregistry": "^3.6.0 || ~4.0.0",
6161
"@jupyterlab/coreutils": "^5.1.0",
6262
"@jupyterlab/services": "^6.1.0",
63-
"@jupyterlab/fileeditor": "^3.0.0",
64-
"@jupyterlab/mainmenu": "^3.0.0"
63+
"@jupyterlab/fileeditor": "^3.6.0 || ~4.0.0",
64+
"@jupyterlab/mainmenu": "^3.6.0 || ~4.0.0"
6565
},
6666
"devDependencies": {
6767
"@babel/core": "^7.0.0",
6868
"@babel/preset-env": "^7.0.0",
69-
"@jupyterlab/builder": "^3.1.0",
70-
"@jupyterlab/testutils": "^3.0.0",
69+
"@jupyterlab/builder": "^3.6.0 || ~4.0.0",
70+
"@jupyterlab/testutils": "^3.6.0 || ~4.0.0",
7171
"@types/jest": "^26.0.0",
7272
"@typescript-eslint/eslint-plugin": "^4.8.1",
7373
"@typescript-eslint/parser": "^4.8.1",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build-system]
2-
requires = ["hatchling>=1.4.0", "jupyterlab>=3.4.7,<4.0.0", "hatch-nodejs-version"]
2+
requires = ["hatchling>=1.4.0", "jupyterlab>=3.6,<5", "hatch-nodejs-version"]
33
build-backend = "hatchling.build"
44

55
[project]

src/formatter.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class JupyterlabNotebookCodeFormatter extends JupyterlabCodeFormatter {
8787
}
8888

8989
const metadata =
90-
this.notebookTracker.currentWidget.content.model!.metadata.toJSON();
90+
this.notebookTracker.currentWidget.content.model!.sharedModel.metadata;;
9191

9292
if (!metadata) {
9393
return null;
@@ -148,7 +148,7 @@ export class JupyterlabNotebookCodeFormatter extends JupyterlabCodeFormatter {
148148
if (formatterToUse === 'noop' || formatterToUse === 'skip') {
149149
continue;
150150
}
151-
const currentTexts = selectedCells.map(cell => cell.model.value.text);
151+
const currentTexts = selectedCells.map(cell => cell.model.sharedModel.source);
152152
const formattedTexts = await this.formatCode(
153153
currentTexts,
154154
formatterToUse,
@@ -162,7 +162,7 @@ export class JupyterlabNotebookCodeFormatter extends JupyterlabCodeFormatter {
162162
const cell = selectedCells[i];
163163
const currentText = currentTexts[i];
164164
const formattedText = formattedTexts.code[i];
165-
const cellValueHasNotChanged = cell.model.value.text === currentText;
165+
const cellValueHasNotChanged = cell.model.sharedModel.source === currentText;
166166
if (cellValueHasNotChanged) {
167167
if (formattedText.error) {
168168
if (showErrors) {
@@ -172,7 +172,7 @@ export class JupyterlabNotebookCodeFormatter extends JupyterlabCodeFormatter {
172172
);
173173
}
174174
} else {
175-
cell.model.value.text = formattedText.code;
175+
cell.model.sharedModel.source = formattedText.code;
176176
}
177177
} else {
178178
if (showErrors) {
@@ -236,7 +236,7 @@ export class JupyterlabFileEditorCodeFormatter extends JupyterlabCodeFormatter {
236236
const editorWidget = this.editorTracker.currentWidget;
237237
this.working = true;
238238
const editor = editorWidget!.content.editor;
239-
const code = editor.model.value.text;
239+
const code = editor.model.sharedModel.source;
240240
this.formatCode(
241241
[code],
242242
formatter,
@@ -253,7 +253,7 @@ export class JupyterlabFileEditorCodeFormatter extends JupyterlabCodeFormatter {
253253
this.working = false;
254254
return;
255255
}
256-
this.editorTracker.currentWidget!.content.editor.model.value.text =
256+
this.editorTracker.currentWidget!.content.editor.model.sharedModel.source =
257257
data.code[0].code;
258258
this.working = false;
259259
})

yarn.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,7 +1285,7 @@
12851285
y-protocols "^1.0.5"
12861286
yjs "^13.5.40"
12871287

1288-
"@jupyterlab/application@^3.1.0":
1288+
"@jupyterlab/application@^3.6.0 || ~4.0.0":
12891289
version "3.6.3"
12901290
resolved "https://registry.yarnpkg.com/@jupyterlab/application/-/application-3.6.3.tgz#7e199f77a4536bc7429fbecf9ba1850f51d9de52"
12911291
integrity sha512-G0tR6sUSCuHB8vGQnaB5lfihKNJVHtqYNoMlsZYF9rYpZEhW1TRD4uE5rg4RfDDR+GghjckQlP3rRNB2Vn4tMA==
@@ -1352,7 +1352,7 @@
13521352
"@lumino/disposable" "^1.10.0"
13531353
"@lumino/signaling" "^1.10.0"
13541354

1355-
"@jupyterlab/builder@^3.1.0":
1355+
"@jupyterlab/builder@^3.6.0 || ~4.0.0":
13561356
version "3.6.3"
13571357
resolved "https://registry.yarnpkg.com/@jupyterlab/builder/-/builder-3.6.3.tgz#a4b22efe34e9598b84122ff10509d3d890017b6a"
13581358
integrity sha512-oY1a/r75RMoPzhSmuVu+DfjL0cKk1ceHTniZsM2wPuhjjyoF875u6CDzArJatpOOuTgLm7CY5OcU3LCIK1OAgg==
@@ -1565,7 +1565,7 @@
15651565
"@lumino/widgets" "^1.37.2"
15661566
react "^17.0.1"
15671567

1568-
"@jupyterlab/fileeditor@^3.0.0":
1568+
"@jupyterlab/fileeditor@^3.6.0 || ~4.0.0":
15691569
version "3.6.3"
15701570
resolved "https://registry.yarnpkg.com/@jupyterlab/fileeditor/-/fileeditor-3.6.3.tgz#3eff401fe35e3c3f0b960d0252e1c7068aeb1d96"
15711571
integrity sha512-O3VM2Dd5tsMNC/mvwGGTBdrQuQYVqqQ7SUAlF8eFnDLnmMranq05s5fNRADQLJez6FtR8lDZR8vmxRcOhUN5iw==
@@ -1581,7 +1581,7 @@
15811581
"@lumino/widgets" "^1.37.2"
15821582
react "^17.0.1"
15831583

1584-
"@jupyterlab/mainmenu@^3.0.0":
1584+
"@jupyterlab/mainmenu@^3.6.0 || ~4.0.0":
15851585
version "3.6.3"
15861586
resolved "https://registry.yarnpkg.com/@jupyterlab/mainmenu/-/mainmenu-3.6.3.tgz#5d322db9b8d742b7042109ab7e8c733696ae38fc"
15871587
integrity sha512-ohZzHDeReKX3zbLz2bUsYRSdkX6bVhNoCer3Rat8gjfb8vr/bqK9ReAvvoA4rRqm0mrfqwotpZSzbE4+y5KqZA==
@@ -1711,7 +1711,7 @@
17111711
node-fetch "^2.6.0"
17121712
ws "^7.4.6"
17131713

1714-
"@jupyterlab/settingregistry@^3.1.0", "@jupyterlab/settingregistry@^3.6.3":
1714+
"@jupyterlab/settingregistry@^3.6.0 || ~4.0.0", "@jupyterlab/settingregistry@^3.6.3":
17151715
version "3.6.3"
17161716
resolved "https://registry.yarnpkg.com/@jupyterlab/settingregistry/-/settingregistry-3.6.3.tgz#642f8b6449d626821ef13a7e778ae716fa8331c9"
17171717
integrity sha512-pnzIge0ZC8V63R97HiNroJ0eaPM0DN6x65SStyLuv/K8Qez4XqpOdc0Wfell5ri5mxMvm1qKekuFeTikqSXQKQ==
@@ -1755,7 +1755,7 @@
17551755
react "^17.0.1"
17561756
typestyle "^2.0.4"
17571757

1758-
"@jupyterlab/testutils@^3.0.0":
1758+
"@jupyterlab/testutils@^3.6.0 || ~4.0.0":
17591759
version "3.6.3"
17601760
resolved "https://registry.yarnpkg.com/@jupyterlab/testutils/-/testutils-3.6.3.tgz#f6785f616ad23c37a07f6c7350def440a9a0cffa"
17611761
integrity sha512-ryydfRiTWCWebLWevKyY/ZqEV5MIdH4VV4Cdn3KsBhZ/jD/wN9BGpX4w/PlXkz211KfC6izbuhC8NwOV33SH4g==

0 commit comments

Comments
 (0)