diff --git a/Project.toml b/Project.toml
index a6eb61c..6567331 100644
--- a/Project.toml
+++ b/Project.toml
@@ -1,7 +1,7 @@
name = "JolinPluto"
uuid = "5b0b4ef8-f4e6-4363-b674-3f031f7b9530"
authors = ["Stephan Sahm and contributors"]
-version = "0.1.84"
+version = "0.1.85"
[deps]
AbstractPlutoDingetjes = "6e696c72-6542-2067-7265-42206c756150"
diff --git a/ext/PythonCallExt.jl b/ext/PythonCallExt.jl
index 2359146..409dbb8 100644
--- a/ext/PythonCallExt.jl
+++ b/ext/PythonCallExt.jl
@@ -110,12 +110,6 @@ JolinPluto.IPyWidget_init() = @htl """
"""
-# Defined in JolinPluto
-# """ Wrap an ipywidget to be used in Pluto """
-# struct IPyWidget
-# wi
-# end
-
function Base.show(io::IO, m::MIME"text/html", w::JolinPluto.IPyWidget)
e = PythonCall.pyimport("ipywidgets.embed")
data = e.embed_data(views=[w.wi], state=e.dependency_state([w.wi]))
@@ -129,15 +123,22 @@ function Base.show(io::IO, m::MIME"text/html", w::JolinPluto.IPyWidget)
// this value property will be read out for the client-site initial value
div.value = $(pyconvert(Any, w.wi.value))
+ if((window.require == null) || window.specified){
+ div.innerHTML = '⚠️ Activate ipywidgets by running the following once inside Pluto ⚠️
from juliacall import Main as jl
jl.seval("using Jolin")
jl.IPyWidget_init() # <-- this is important
'
+ }
+
// TODO renderWidgets(div) has the advantage that no duplicates appear
// however if the same ui is used multiple times on the website, they also won't be combined any longer into one synced state (which actually happens automatically without the div restriction)
// still for now having no duplicates (why ever they appear without the div restriction) is better than no sync
- window.require(["@jupyter-widgets/html-manager/dist/libembed-amd"], (function(e) {
- // without this the second execution wouldn't show anything
- "complete" === document.readyState ? e.renderWidgets(div) : window.addEventListener("load", (function() {
- e.renderWidgets(div)
- }))
- }))
+ window.require?.(["@jupyter-widgets/html-manager/dist/libembed-amd"],
+ (function(e) {
+ // without this the second execution wouldn't show anything
+ "complete" === document.readyState ? e.renderWidgets(div) : window.addEventListener("load", (function() {
+ e.renderWidgets(div)
+ }))
+ })
+ )
+
})();
@@ -199,4 +200,75 @@ function __init__()
end
end
+# Here an alternative implementation which unfortunately does not really work because if the same is used multiple times, on the first load it will actually
+# interfere with one another so that all widgets are duplicated 3 to 10 times, depending on how many widgets load the common dependency in parallel.
+# function Base.show(io::IO, m::MIME"text/html", w::JolinPluto.IPyWidget)
+# e = PythonCall.pyimport("ipywidgets.embed")
+# data = e.embed_data(views=[w.wi], state=e.dependency_state([w.wi]))
+# show(io, m, @htl """
+#
+#
+#
+
+#
+#
+#
+#
+
+#
+#
+# """)
+# end
+
+
end
\ No newline at end of file