Skip to content

Commit

Permalink
Merge pull request #300 from mcrutch/jupyterlab4
Browse files Browse the repository at this point in the history
Support for JupyterLab 3.6/4+ and Notebook v7+
  • Loading branch information
ryantam626 committed May 5, 2023
2 parents 3d29dd9 + 93c7520 commit 5e935fc
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion docs_src/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ None

**Jupyterlab extension**

None
Support for JupyterLab 3.6+/4+ and Notebook v7

## 1.6.1 2023-04-16

Expand Down
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@
"prepare": "jlpm run clean && jlpm run build:prod"
},
"dependencies": {
"@jupyterlab/application": "^3.0.0",
"@jupyterlab/apputils": "^3.0.0",
"@jupyterlab/builder": "^3.0.0",
"@jupyterlab/fileeditor": "^3.0.0",
"@jupyterlab/mainmenu": "^3.0.0",
"@jupyterlab/notebook": "^3.0.0",
"@jupyterlab/application": "^3.6.0 || ~4.0.0",
"@jupyterlab/apputils": "^3.6.0 || ~4.0.0",
"@jupyterlab/builder": "^3.6.0 || ~4.0.0",
"@jupyterlab/fileeditor": "^3.6.0 || ~4.0.0",
"@jupyterlab/mainmenu": "^3.6.0 || ~4.0.0",
"@jupyterlab/notebook": "^3.6.0 || ~4.0.0",
"npm-run-all": "^4.1.5"
},
"devDependencies": {
"@jupyterlab/builder": "^3.0.0",
"@jupyterlab/builder": "^3.6.0 || ~4.0.0",
"prettier": "^1.19.1",
"rimraf": "^3.0.2",
"tslint": "^5.15.0",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
requires = ["jupyter_packaging~=0.7.9", "jupyterlab~=3.0", "setuptools>=40.8.0", "wheel"]
requires = ["jupyter_packaging~=0.7.9", "jupyterlab>=3.6,<5", "setuptools>=40.8.0", "wheel"]
build-backend = "setuptools.build_meta"
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
cmdclass=cmdclass,
packages=setuptools.find_packages(),
install_requires=[
"jupyterlab~=3.0",
"jupyterlab>=3.6,<5",
],
zip_safe=False,
include_package_data=True,
Expand Down
12 changes: 6 additions & 6 deletions src/formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export class JupyterlabNotebookCodeFormatter extends JupyterlabCodeFormatter {
return null;
}

const metadata = this.notebookTracker.currentWidget.content.model.metadata.toJSON();
const metadata = this.notebookTracker.currentWidget.content.model.sharedModel.metadata;

if (!metadata) {
return null;
Expand Down Expand Up @@ -154,7 +154,7 @@ export class JupyterlabNotebookCodeFormatter extends JupyterlabCodeFormatter {
if (formatterToUse === 'noop' || formatterToUse === 'skip') {
continue;
}
const currentTexts = selectedCells.map(cell => cell.model.value.text);
const currentTexts = selectedCells.map(cell => cell.model.sharedModel.source);
const formattedTexts = await this.formatCode(
currentTexts,
formatterToUse,
Expand All @@ -166,7 +166,7 @@ export class JupyterlabNotebookCodeFormatter extends JupyterlabCodeFormatter {
const cell = selectedCells[i];
const currentText = currentTexts[i];
const formattedText = formattedTexts.code[i];
if (cell.model.value.text === currentText) {
if (cell.model.sharedModel.source === currentText) {
if (formattedText.error) {
if (!(config.suppressFormatterErrors ?? false)) {
await showErrorMessage(
Expand All @@ -175,7 +175,7 @@ export class JupyterlabNotebookCodeFormatter extends JupyterlabCodeFormatter {
);
}
} else {
cell.model.value.text = formattedText.code;
cell.model.sharedModel.source = formattedText.code;
}
} else {
if (!(config.suppressFormatterErrors ?? false)) {
Expand Down Expand Up @@ -218,7 +218,7 @@ export class JupyterlabFileEditorCodeFormatter extends JupyterlabCodeFormatter {
const editorWidget = this.editorTracker.currentWidget;
this.working = true;
const editor = editorWidget.content.editor;
const code = editor.model.value.text;
const code = editor.model.sharedModel.source;
this.formatCode(
[code],
formatter,
Expand All @@ -235,7 +235,7 @@ export class JupyterlabFileEditorCodeFormatter extends JupyterlabCodeFormatter {
this.working = false;
return;
}
this.editorTracker.currentWidget.content.editor.model.value.text =
this.editorTracker.currentWidget.content.editor.model.sharedModel.source =
data.code[0].code;
this.working = false;
})
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"rootDir": "src",
"strict": true,
"strictNullChecks": false,
"target": "es2017",
"target": "es2018",
"types": []
},
"include": ["src/*"]
Expand Down

0 comments on commit 5e935fc

Please sign in to comment.