From 93c7520ab801234b68fff2dd2f7d572312d0c990 Mon Sep 17 00:00:00 2001 From: mcrutch <51446717+mcrutch@users.noreply.github.com> Date: Tue, 4 Apr 2023 13:42:11 +0000 Subject: [PATCH] Support for JupyterLab 3.6/4+ and Notebook v7+ --- docs_src/changelog.md | 2 +- package.json | 14 +++++++------- pyproject.toml | 2 +- setup.py | 2 +- src/formatter.ts | 12 ++++++------ tsconfig.json | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/docs_src/changelog.md b/docs_src/changelog.md index e29b487..27d88cf 100644 --- a/docs_src/changelog.md +++ b/docs_src/changelog.md @@ -12,7 +12,7 @@ None **Jupyterlab extension** -None +Support for JupyterLab 3.6+/4+ and Notebook v7 ## 1.5.3 2022-08-10 diff --git a/package.json b/package.json index 1c4a1c6..6b6c337 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/pyproject.toml b/pyproject.toml index ba04c53..e561830 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/setup.py b/setup.py index 34cb17d..ba06df6 100644 --- a/setup.py +++ b/setup.py @@ -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, diff --git a/src/formatter.ts b/src/formatter.ts index 6635ea7..cf85cd8 100644 --- a/src/formatter.ts +++ b/src/formatter.ts @@ -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; @@ -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, @@ -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( @@ -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)) { @@ -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, @@ -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; }) diff --git a/tsconfig.json b/tsconfig.json index ba499a7..7c578f3 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,7 +16,7 @@ "rootDir": "src", "strict": true, "strictNullChecks": false, - "target": "es2017", + "target": "es2018", "types": [] }, "include": ["src/*"]