Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use jsdelivr CDN for ipywidgets #491

Merged
merged 6 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions docs/render/interactive.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,22 @@ show(p)

## ipywidgets

:::{note}
IPyWidgets uses a special JS package `@jupyter-widgets/html-manager` for rendering Jupyter widgets outside notebooks. `myst-nb` loads a specific version of this package, which may be incompatible with your installation of IPyWidgets. If this is the case, you might need to specify the appropriate `nb_ipywidgets_js` config value, e.g. for `0.20.0`
```yaml

sphinx:
recursive_update: true
config:
nb_ipywidgets_js:
# Load IPywidgets bundle for embedding.
"https://cdn.jsdelivr.net/npm/@jupyter-widgets/[email protected]/dist/embed-amd.js":
"data-jupyter-widgets-cdn": "https://cdn.jsdelivr.net/npm/"
"crossorigin": "anonymous"
```
To determine which version of `@jupyter-widgets/html-manager` is required, find the `html-manager` JS package in the [`ipywidgets` repo](https://github.com/jupyter-widgets/ipywidgets), and identify its version.
:::

You may also run code for Jupyter Widgets in your document, and the interactive HTML
outputs will embed themselves in your side. See [the ipywidgets documentation](https://ipywidgets.readthedocs.io/en/latest/user_install.html)
for how to get set up in your own environment.
Expand Down
2 changes: 1 addition & 1 deletion myst_nb/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def ipywidgets_js_factory() -> Dict[str, Dict[str, str]]:
"crossorigin": "anonymous",
},
# Load IPywidgets bundle for embedding.
"https://unpkg.com/@jupyter-widgets/html-manager@^0.20.0/dist/embed-amd.js": {
"https://cdn.jsdelivr.net/npm/@jupyter-widgets/html-manager@1.0.6/dist/embed-amd.js": {
Copy link
Member

@choldgraf choldgraf Apr 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a comment here that provides a loose guidelines for when/how to update this import link? Or maybe just a block comment at the top of the #Load IPywidgets.. section? doesn't need to block if you don't have the time, but I feel like you brought some valuable domain-knowledge to this fix that could be useful for others

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hehe, we're on the same wavelength: 2deaa40

"data-jupyter-widgets-cdn": "https://cdn.jsdelivr.net/npm/",
"crossorigin": "anonymous",
},
Expand Down