From ad2ecb2f08d1cbe0c06d4ea64f1a0d613578384e Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Thu, 13 Apr 2023 11:36:02 +0100 Subject: [PATCH 1/3] fix: use jsdelivr CDN --- myst_nb/core/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/myst_nb/core/config.py b/myst_nb/core/config.py index d90e85ab..33d39620 100644 --- a/myst_nb/core/config.py +++ b/myst_nb/core/config.py @@ -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@0.20.0/dist/embed-amd.js": { "data-jupyter-widgets-cdn": "https://cdn.jsdelivr.net/npm/", "crossorigin": "anonymous", }, From 85ac786244ffbc1f2667e60da7998180770c72cf Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Thu, 13 Apr 2023 11:54:11 +0100 Subject: [PATCH 2/3] chore: bump ipywidgets version to 8.0 --- myst_nb/core/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/myst_nb/core/config.py b/myst_nb/core/config.py index 33d39620..1d69465a 100644 --- a/myst_nb/core/config.py +++ b/myst_nb/core/config.py @@ -64,7 +64,7 @@ def ipywidgets_js_factory() -> Dict[str, Dict[str, str]]: "crossorigin": "anonymous", }, # Load IPywidgets bundle for embedding. - "https://cdn.jsdelivr.net/npm/@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": { "data-jupyter-widgets-cdn": "https://cdn.jsdelivr.net/npm/", "crossorigin": "anonymous", }, From 2deaa406b91f1f6f7e93db27ef9c9befc41fb053 Mon Sep 17 00:00:00 2001 From: Angus Hollands Date: Thu, 13 Apr 2023 12:04:01 +0100 Subject: [PATCH 3/3] docs: add note about ipywidgets --- docs/render/interactive.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/docs/render/interactive.md b/docs/render/interactive.md index f8648157..a8a87312 100644 --- a/docs/render/interactive.md +++ b/docs/render/interactive.md @@ -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/html-manager@0.20.0/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.