Skip to content

Commit 5e935fc

Browse files
authored
Merge pull request #300 from mcrutch/jupyterlab4
Support for JupyterLab 3.6/4+ and Notebook v7+
2 parents 3d29dd9 + 93c7520 commit 5e935fc

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

docs_src/changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ None
1313

1414
**Jupyterlab extension**
1515

16-
None
16+
Support for JupyterLab 3.6+/4+ and Notebook v7
1717

1818
## 1.6.1 2023-04-16
1919

package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@
4343
"prepare": "jlpm run clean && jlpm run build:prod"
4444
},
4545
"dependencies": {
46-
"@jupyterlab/application": "^3.0.0",
47-
"@jupyterlab/apputils": "^3.0.0",
48-
"@jupyterlab/builder": "^3.0.0",
49-
"@jupyterlab/fileeditor": "^3.0.0",
50-
"@jupyterlab/mainmenu": "^3.0.0",
51-
"@jupyterlab/notebook": "^3.0.0",
46+
"@jupyterlab/application": "^3.6.0 || ~4.0.0",
47+
"@jupyterlab/apputils": "^3.6.0 || ~4.0.0",
48+
"@jupyterlab/builder": "^3.6.0 || ~4.0.0",
49+
"@jupyterlab/fileeditor": "^3.6.0 || ~4.0.0",
50+
"@jupyterlab/mainmenu": "^3.6.0 || ~4.0.0",
51+
"@jupyterlab/notebook": "^3.6.0 || ~4.0.0",
5252
"npm-run-all": "^4.1.5"
5353
},
5454
"devDependencies": {
55-
"@jupyterlab/builder": "^3.0.0",
55+
"@jupyterlab/builder": "^3.6.0 || ~4.0.0",
5656
"prettier": "^1.19.1",
5757
"rimraf": "^3.0.2",
5858
"tslint": "^5.15.0",

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[build-system]
2-
requires = ["jupyter_packaging~=0.7.9", "jupyterlab~=3.0", "setuptools>=40.8.0", "wheel"]
2+
requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.6,<5", "setuptools>=40.8.0", "wheel"]
33
build-backend = "setuptools.build_meta"

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
cmdclass=cmdclass,
7878
packages=setuptools.find_packages(),
7979
install_requires=[
80-
"jupyterlab~=3.0",
80+
"jupyterlab>=3.6,<5",
8181
],
8282
zip_safe=False,
8383
include_package_data=True,

src/formatter.ts

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

89-
const metadata = this.notebookTracker.currentWidget.content.model.metadata.toJSON();
89+
const metadata = this.notebookTracker.currentWidget.content.model.sharedModel.metadata;
9090

9191
if (!metadata) {
9292
return null;
@@ -154,7 +154,7 @@ export class JupyterlabNotebookCodeFormatter extends JupyterlabCodeFormatter {
154154
if (formatterToUse === 'noop' || formatterToUse === 'skip') {
155155
continue;
156156
}
157-
const currentTexts = selectedCells.map(cell => cell.model.value.text);
157+
const currentTexts = selectedCells.map(cell => cell.model.sharedModel.source);
158158
const formattedTexts = await this.formatCode(
159159
currentTexts,
160160
formatterToUse,
@@ -166,7 +166,7 @@ export class JupyterlabNotebookCodeFormatter extends JupyterlabCodeFormatter {
166166
const cell = selectedCells[i];
167167
const currentText = currentTexts[i];
168168
const formattedText = formattedTexts.code[i];
169-
if (cell.model.value.text === currentText) {
169+
if (cell.model.sharedModel.source === currentText) {
170170
if (formattedText.error) {
171171
if (!(config.suppressFormatterErrors ?? false)) {
172172
await showErrorMessage(
@@ -175,7 +175,7 @@ export class JupyterlabNotebookCodeFormatter extends JupyterlabCodeFormatter {
175175
);
176176
}
177177
} else {
178-
cell.model.value.text = formattedText.code;
178+
cell.model.sharedModel.source = formattedText.code;
179179
}
180180
} else {
181181
if (!(config.suppressFormatterErrors ?? false)) {
@@ -218,7 +218,7 @@ export class JupyterlabFileEditorCodeFormatter extends JupyterlabCodeFormatter {
218218
const editorWidget = this.editorTracker.currentWidget;
219219
this.working = true;
220220
const editor = editorWidget.content.editor;
221-
const code = editor.model.value.text;
221+
const code = editor.model.sharedModel.source;
222222
this.formatCode(
223223
[code],
224224
formatter,
@@ -235,7 +235,7 @@ export class JupyterlabFileEditorCodeFormatter extends JupyterlabCodeFormatter {
235235
this.working = false;
236236
return;
237237
}
238-
this.editorTracker.currentWidget.content.editor.model.value.text =
238+
this.editorTracker.currentWidget.content.editor.model.sharedModel.source =
239239
data.code[0].code;
240240
this.working = false;
241241
})

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"rootDir": "src",
1717
"strict": true,
1818
"strictNullChecks": false,
19-
"target": "es2017",
19+
"target": "es2018",
2020
"types": []
2121
},
2222
"include": ["src/*"]

0 commit comments

Comments
 (0)