From 8cf2448eee582c6c72df0247bae73c91337ef5fa Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Thu, 23 Oct 2025 15:42:44 +0200 Subject: [PATCH 1/2] Document executing commands from the dev tools console --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index 6dd9217..c9630dd 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,26 @@ app.commands.execute('jupyterlab-diff:unified-file-diff', { }); ``` +### Browser console via `window.jupyterapp` + + The commands can also be run from the browser console (for example during development) via the `app` object exposed as `window.jupyterapp`. The commands can be executed exactly the same way using `window.jupyterapp.commands.execute(...)`. + +First JupyterLab needs to be started with the `--expose-app-in-browser` flag to expose `window.jupyterapp`: + +``` +jupyter lab --expose-app-in-browser +``` + +Then, in the browser dev tools console: + +```javascript +window.jupyterapp.commands.execute('jupyterlab-diff:split-cell-diff', { + originalSource: `def add():\n return\n`, + newSource: `def add(a, b):\n return a + b\n`, + showActionButtons: true, +}); +``` + ### Command Arguments #### `jupyterlab-diff:split-cell-diff` (Split View) From 2e9e821946f6c4e399d9cc1f1a979e17ad36fb7e Mon Sep 17 00:00:00 2001 From: Jeremy Tuloup Date: Thu, 23 Oct 2025 15:43:45 +0200 Subject: [PATCH 2/2] lint --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c9630dd..975d931 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ app.commands.execute('jupyterlab-diff:unified-file-diff', { ### Browser console via `window.jupyterapp` - The commands can also be run from the browser console (for example during development) via the `app` object exposed as `window.jupyterapp`. The commands can be executed exactly the same way using `window.jupyterapp.commands.execute(...)`. +The commands can also be run from the browser console (for example during development) via the `app` object exposed as `window.jupyterapp`. The commands can be executed exactly the same way using `window.jupyterapp.commands.execute(...)`. First JupyterLab needs to be started with the `--expose-app-in-browser` flag to expose `window.jupyterapp`: @@ -92,7 +92,7 @@ Then, in the browser dev tools console: window.jupyterapp.commands.execute('jupyterlab-diff:split-cell-diff', { originalSource: `def add():\n return\n`, newSource: `def add(a, b):\n return a + b\n`, - showActionButtons: true, + showActionButtons: true }); ```