From accb03dda8d6b2faeac75178b4aad105c9c7c70f Mon Sep 17 00:00:00 2001 From: Josh Day Date: Sun, 8 Dec 2024 06:56:13 -0500 Subject: [PATCH] fix #51 --- Project.toml | 4 +++- src/PlotlyLight.jl | 15 +++++---------- test/runtests.jl | 7 +------ 3 files changed, 9 insertions(+), 17 deletions(-) diff --git a/Project.toml b/Project.toml index 4aa2bbe..5144999 100644 --- a/Project.toml +++ b/Project.toml @@ -1,7 +1,7 @@ name = "PlotlyLight" uuid = "ca7969ec-10b3-423e-8d99-40f33abb42bf" authors = ["joshday "] -version = "0.11.0" +version = "0.11.1" [deps] Artifacts = "56f22d72-fd6d-98f1-02f0-08ddc0907c33" @@ -10,6 +10,7 @@ Dates = "ade2ca70-3891-5945-98fb-dc099432e06a" Downloads = "f43a241f-c20a-4ad4-852c-f6b1247861c6" EasyConfig = "acab07b0-f158-46d4-8913-50acef6d41fe" JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1" +REPL = "3fa0cd96-eef1-5676-8a61-b3b8758bbffb" Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c" [compat] @@ -20,6 +21,7 @@ Dates = "1.11.0" Downloads = "1.6" EasyConfig = "0.1" JSON3 = "1.14" +REPL = "1.11.0" julia = "1.7" [extras] diff --git a/src/PlotlyLight.jl b/src/PlotlyLight.jl index 07e464f..95682fe 100644 --- a/src/PlotlyLight.jl +++ b/src/PlotlyLight.jl @@ -4,6 +4,7 @@ using Artifacts: @artifact_str using Downloads: download using Random: randstring using Dates +using REPL: REPLDisplay using JSON3: JSON3 using EasyConfig: Config @@ -13,15 +14,6 @@ using Cobweb: Cobweb, h, IFrame, Node export Config, preset, Plot, plot #-----------------------------------------------------------------------------# __init__ -function __init__() - # Hack since extensions with REPL are wonky - for M in Base.loaded_modules_order - if Symbol(M) == :REPL - @eval Base.display(::$M.REPLDisplay, o::Plot) = Cobweb.preview(html_page(o)) - end - end -end - include("json.jl") artifact(x...) = joinpath(artifact"plotly_artifacts", x...) @@ -133,7 +125,7 @@ end rand_id() = "plotlyx-" * join(rand('a':'z', 10)) function html_div(o::Plot, id=rand_id()) - h.div(class="plotlylight-parent", settings.src, settings.src_inject..., settings.div(; id), NewPlotScript(o, settings, id)) + h.div(class="plotlylight-parent", settings.src_inject..., settings.src, settings.div(; id), NewPlotScript(o, settings, id)) end function html_page(o::Plot, id=rand_id()) @@ -165,6 +157,9 @@ function Base.show(io::IO, ::MIME"text/html", o::Plot) end Base.show(io::IO, ::MIME"juliavscode/html", o) = show(io, MIME("text/html"), o) +Base.display(::REPLDisplay, o::Plot) = Cobweb.preview(html_page(o), reuse=settings.reuse_preview) + + #-----------------------------------------------------------------------------# preset # `preset_template_` overwrites `settings.layout.template` # `preset_src_` overwrites `settings.src` diff --git a/test/runtests.jl b/test/runtests.jl index 9b3a6b9..a919d98 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -1,10 +1,5 @@ -using PlotlyLight +using PlotlyLight, Cobweb, Test, Aqua, Dates, JSON3 using PlotlyLight: settings, Plot, json -using Cobweb -using Cobweb: h -using JSON3: JSON3 -using Test -using Aqua html(x) = repr("text/html", x)