Skip to content

Commit

Permalink
Invoke command after shell change, support local dev
Browse files Browse the repository at this point in the history
  • Loading branch information
krassowski committed Aug 16, 2024
1 parent 3bb8174 commit b1e860b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,11 @@ JupyterLite is being tested against modern web browsers:

- Firefox 90+
- Chromium 89+

## Developing locally:

```
pip install -r requirements.txt
jupyter lite build --contents content && jupyter lite serve
open http://127.0.0.1:8000/files/demo-dev.html
```
5 changes: 4 additions & 1 deletion content/demo-dev.html
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ <h2>AI Assurance Portal</h2>
cleanCode += line.substring(indent) + '\n';
}
codeEl.textContent = cleanCode;
iframe.src = `https://quansight.github.io/jupyterlite-demo/repl/index.html?kernel=python&toolbar=1`;
const baseURL = location.href.split('/').slice(0, -2).join('/');
iframe.src = baseURL + `/repl/index.html?kernel=python&toolbar=1`;
iframe.style.width = '100%';
const wrapper = document.createElement('div');
wrapper.classList.add('code-wrapper');
Expand All @@ -164,6 +165,8 @@ <h2>AI Assurance Portal</h2>
jupyter.restored.then(() => {
codeEl.style.display = 'none';
iframe.style.display = 'block';
});
jupyter.shell.currentChanged.connect((shell, change) => {
jupyter.commands.execute('console:replace-selection', {text: cleanCode});
});
} else {
Expand Down

0 comments on commit b1e860b

Please sign in to comment.