diff --git a/frontend/src/app/main/rasterizer.cljs b/frontend/src/app/main/rasterizer.cljs index 7c3cedeb46..3fb1f2ca1b 100644 --- a/frontend/src/app/main/rasterizer.cljs +++ b/frontend/src/app/main/rasterizer.cljs @@ -61,10 +61,19 @@ [message] (.push ^js queue message)) +(defn- replace-uris + "Replaces URIs for rasterizer ones in styles" + [styles] + (let [public-uri (str cf/public-uri) + rasterizer-uri (str cf/rasterizer-uri)] + (if-not (= public-uri rasterizer-uri) + (str/replace styles public-uri rasterizer-uri) + styles))) + (defn render "Renders an SVG" [{:keys [data styles width result] :as params}] - (let [styles (d/nilv styles "") + (let [styles (replace-uris (d/nilv styles "")) result (d/nilv result "blob") id (dm/str (uuid/next)) payload #js {:data data :styles styles :width width :result result} diff --git a/frontend/src/app/main/render.cljs b/frontend/src/app/main/render.cljs index 5345b895a9..89f1e32889 100644 --- a/frontend/src/app/main/render.cljs +++ b/frontend/src/app/main/render.cljs @@ -553,13 +553,15 @@ [fixed-width fixed-height] (th/get-relative-size width height) - data (rds/renderToStaticMarkup - (mf/element frame-imposter - #js {:objects objects - :frame shape - :vbox viewbox - :width width - :height height}))] + + data (with-redefs [cfg/public-uri cfg/rasterizer-uri] + (rds/renderToStaticMarkup + (mf/element frame-imposter + #js {:objects objects + :frame shape + :vbox viewbox + :width width + :height height})))] (->> (fonts/render-font-styles-cached fonts) (rx/catch (fn [cause] @@ -567,11 +569,11 @@ :cause cause) (rx/empty))) (rx/map (fn [styles] - {:id object-id - :data data - :viewbox viewbox - :width fixed-width - :height fixed-height - :styles styles})))) + {:id object-id + :data data + :viewbox viewbox + :width fixed-width + :height fixed-height + :styles styles})))) (do (l/warn :msg "imposter shape is nil") (rx/empty)))) diff --git a/frontend/src/app/rasterizer.cljs b/frontend/src/app/rasterizer.cljs index 36fab6ded6..0426787115 100644 --- a/frontend/src/app/rasterizer.cljs +++ b/frontend/src/app/rasterizer.cljs @@ -221,6 +221,10 @@ scope (unchecked-get evdata "scope")] (when (and (some? payload) (= scope "penpot/rasterizer")) + (log/dbg :hint "received message" + :id id + :payload payload + :scope scope) (->> (render payload) (rx/subs (partial send-success! id) (partial send-failure! id))))))))