|
1 | 1 | # jupyter-iframe-commands
|
2 | 2 |
|
3 | 3 | [](https://github.com/TileDB-Inc/jupyter-iframe-commands/actions/workflows/build.yml)
|
| 4 | +[](https://tiledb-inc.github.io/jupyter-iframe-commands/) |
4 | 5 |
|
5 |
| -A JupyterLab extension to facilitate integration with a host page via an IFrame |
| 6 | +A JupyterLab extension to facilitate integration with a host page via an iframe |
6 | 7 |
|
7 | 8 | > [!WARNING]
|
8 | 9 | > This project is still in an early development stage.
|
9 | 10 |
|
10 | 11 | ## Requirements
|
11 | 12 |
|
12 |
| -- JupyterLab >= 4.0.0 |
| 13 | +- JupyterLab >= 4.0.0 or Jupyter Notebook >= 7.0.0 |
13 | 14 |
|
14 |
| -## Install |
| 15 | +### Try it in your browser |
15 | 16 |
|
16 |
| -To install the extension |
| 17 | +Try out the extension in your browser: |
17 | 18 |
|
18 |
| -- Clone the repo to your local environment |
19 |
| -- Change directory to the `jupyter-iframe-commands` directory |
20 |
| -- execute: `pip install .` |
| 19 | +[](https://tiledb-inc.github.io/jupyter-iframe-commands/) |
21 | 20 |
|
22 | 21 | ## Usage
|
23 | 22 |
|
24 |
| -Try out a preview [here](https://tiledb-inc.github.io/jupyter-iframe-commands/) |
| 23 | +This repository provides two packages: |
| 24 | + |
| 25 | +- The extension package: `jupyter-iframe-commands`. This is the JupyterLab extension that provides the API to execute JupyterLab commands from a host page. |
| 26 | +- The host package: `jupyter-iframe-commands-host`. This is a package that provides a bridge to communicate with JupyterLab running in an iframe. |
| 27 | + |
| 28 | +### Host Package |
| 29 | + |
| 30 | +The host package provides a bridge to communicate with JupyterLab running in an iframe. To use it in your application: |
| 31 | + |
| 32 | +1. Install the package: |
| 33 | + |
| 34 | +```bash |
| 35 | +npm install jupyter-iframe-commands-host |
| 36 | +``` |
| 37 | + |
| 38 | +2. Import and use the `CommandBridge`: |
| 39 | + |
| 40 | +```typescript |
| 41 | +import { CommandBridge } from 'jupyter-iframe-commands-host'; |
| 42 | + |
| 43 | +// Initialize the bridge with your iframe ID |
| 44 | +const bridge = new CommandBridge({ |
| 45 | + iframeId: 'your-jupyter-iframe-id' |
| 46 | +}); |
| 47 | + |
| 48 | +// Execute JupyterLab commands |
| 49 | +// Example: Toggle the left sidebar |
| 50 | +await bridge.commandBridge.execute('application:toggle-left-area'); |
| 51 | + |
| 52 | +// Example: Change the theme |
| 53 | +await bridge.commandBridge.execute('apputils:change-theme', { |
| 54 | + theme: 'JupyterLab Dark' |
| 55 | +}); |
| 56 | + |
| 57 | +// List available JupyterLab commands |
| 58 | +const commands = await bridge.commandBridge.listCommands(); |
| 59 | +console.log(commands); |
| 60 | +``` |
| 61 | + |
| 62 | +### Extension Package |
| 63 | + |
| 64 | +The JupyterLab extension should be installed in the JupyterLab environment running in the iframe. |
| 65 | + |
| 66 | +To install the extension: |
| 67 | + |
| 68 | +```bash |
| 69 | +pip install jupyter-iframe-commands |
| 70 | +``` |
| 71 | + |
| 72 | +### Customizing the user interface |
| 73 | + |
| 74 | +The Jupyter UI can be customized in different ways. |
| 75 | + |
| 76 | +#### Example |
| 77 | + |
| 78 | +On the following screenshot: |
| 79 | + |
| 80 | +- `@jupyterlab/mainmenu-extension` is disabled to remove the menu entries |
| 81 | +- `@jupyter-notebook/lab-extension` is disabled to remove the interface switcher from the notebook toolbar |
| 82 | +- The `visible` property of the `@jupyter-notebook/application-extension:top` plugin is set to `no`, to hide the top bar |
| 83 | + |
| 84 | + |
| 85 | + |
| 86 | +For the demo in this repo, this configuration is provided via two files: |
| 87 | + |
| 88 | +- `overrides.json`: This file is used to override the default settings of the JupyterLab and Jupyter Notebook applications |
| 89 | +- `jupyter-lite.json`: This file is used to set a list of `disabledExtensions`, which can be used to disabled invidual plugins |
| 90 | + |
| 91 | +#### Configuring JupyterLab |
| 92 | + |
| 93 | +JupyterLab can be configured in a smilar way, using well-known files at specific locations: |
| 94 | + |
| 95 | +- `page_config.json`: https://jupyterlab.readthedocs.io/en/latest/user/directories.html#labconfig-directories |
| 96 | +- `overrides.json`: https://jupyterlab.readthedocs.io/en/latest/user/directories.html#overridesjson |
25 | 97 |
|
26 | 98 | ### Available Commands
|
27 | 99 |
|
@@ -55,22 +127,37 @@ Examples of commands with arguments:
|
55 | 127 |
|
56 | 128 | To run the demo on a local Jupyter Lab instance:
|
57 | 129 |
|
58 |
| -- Follow the [development install instructions](#development-install) |
59 |
| -- `cd demo` |
60 |
| -- Run: `jlpm start:lab` |
61 |
| -- In another terminal |
62 |
| -- Run: `jlpm start:local` |
| 130 | +1. Follow the [development install instructions](#development-install) |
| 131 | +2. `cd demo` |
| 132 | +3. Start JupyterLab: |
| 133 | + |
| 134 | +```bash |
| 135 | +jlpm start:lab |
| 136 | +``` |
| 137 | + |
| 138 | +4. In another terminal, start the demo app: |
| 139 | + |
| 140 | +```bash |
| 141 | +jlpm start:local |
| 142 | +``` |
63 | 143 |
|
64 | 144 | Open http://localhost:8080 in your browser.
|
65 | 145 |
|
66 | 146 | ### Lite Demo
|
67 | 147 |
|
68 | 148 | To run the demo on a Jupyter Lite instance:
|
69 | 149 |
|
70 |
| -- Follow the [development install instructions](#development-install) |
71 |
| -- Run: `jlpm build:lite` |
72 |
| -- `cd demo` |
73 |
| -- Run: `jlpm start:lite` |
| 150 | +1. Follow the [development install instructions](#development-install) |
| 151 | +2. `cd demo` |
| 152 | +3. Build and start the demo app: |
| 153 | + |
| 154 | +```bash |
| 155 | +# Build the demo |
| 156 | +jlpm build:ghpages |
| 157 | + |
| 158 | +# Start the development server |
| 159 | +jlpm start:lite |
| 160 | +``` |
74 | 161 |
|
75 | 162 | ## Uninstall
|
76 | 163 |
|
|
0 commit comments