Skip to content

Commit f8596a0

Browse files
authored
Update usage section in the README (#33)
* Update usage section in the README * add listCommands * add sample overrides.json * disable the interface switcher * Add more info about config files * fixes * Apply suggestions from code review
1 parent 501560e commit f8596a0

File tree

3 files changed

+111
-18
lines changed

3 files changed

+111
-18
lines changed

README.md

Lines changed: 104 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,99 @@
11
# jupyter-iframe-commands
22

33
[![Github Actions Status](https://github.com/TileDB-Inc/jupyter-iframe-commands/workflows/Build/badge.svg)](https://github.com/TileDB-Inc/jupyter-iframe-commands/actions/workflows/build.yml)
4+
[![lite-badge](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://tiledb-inc.github.io/jupyter-iframe-commands/)
45

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
67

78
> [!WARNING]
89
> This project is still in an early development stage.
910
1011
## Requirements
1112

12-
- JupyterLab >= 4.0.0
13+
- JupyterLab >= 4.0.0 or Jupyter Notebook >= 7.0.0
1314

14-
## Install
15+
### Try it in your browser
1516

16-
To install the extension
17+
Try out the extension in your browser:
1718

18-
- Clone the repo to your local environment
19-
- Change directory to the `jupyter-iframe-commands` directory
20-
- execute: `pip install .`
19+
[![lite-badge](https://jupyterlite.rtfd.io/en/latest/_static/badge.svg)](https://tiledb-inc.github.io/jupyter-iframe-commands/)
2120

2221
## Usage
2322

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+
![a screenshot showing Jupyter Notebook running in an iframe](https://github.com/user-attachments/assets/cf4a64c0-9a2c-4614-93da-e1a2467711d9)
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
2597

2698
### Available Commands
2799

@@ -55,22 +127,37 @@ Examples of commands with arguments:
55127

56128
To run the demo on a local Jupyter Lab instance:
57129

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+
```
63143

64144
Open http://localhost:8080 in your browser.
65145

66146
### Lite Demo
67147

68148
To run the demo on a Jupyter Lite instance:
69149

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+
```
74161

75162
## Uninstall
76163

jupyter-lite.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"disabledExtensions": [
55
"@jupyterlab/mainmenu-extension",
66
"@jupyterlite/application-extension:logo",
7-
"@jupyterlab/help-extension:resources"
7+
"@jupyterlab/help-extension:resources",
8+
"@jupyter-notebook/lab-extension"
89
]
910
}
1011
}

overrides.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"@jupyter-notebook/application-extension:top": {
3+
"visible": "no"
4+
}
5+
}

0 commit comments

Comments
 (0)