mirror of
https://github.com/penpot/penpot.git
synced 2025-07-19 00:17:20 +02:00
🐛 Fix color picker not rendering Latin1 svgs
This commit is contained in:
parent
dce2eb03c0
commit
9474700d09
1 changed files with 9 additions and 3 deletions
|
@ -7,6 +7,7 @@
|
||||||
(ns app.main.ui.workspace.viewport.pixel-overlay
|
(ns app.main.ui.workspace.viewport.pixel-overlay
|
||||||
(:require
|
(:require
|
||||||
[app.common.data :as d]
|
[app.common.data :as d]
|
||||||
|
[app.common.data.macros :as dm]
|
||||||
[app.common.pages.helpers :as cph]
|
[app.common.pages.helpers :as cph]
|
||||||
[app.common.uuid :as uuid]
|
[app.common.uuid :as uuid]
|
||||||
[app.main.data.modal :as modal]
|
[app.main.data.modal :as modal]
|
||||||
|
@ -33,7 +34,7 @@
|
||||||
(let [image-nodes (dom/query-all svg-node "image:not([href^=data])")
|
(let [image-nodes (dom/query-all svg-node "image:not([href^=data])")
|
||||||
noop-fn (constantly nil)]
|
noop-fn (constantly nil)]
|
||||||
(if (empty? image-nodes)
|
(if (empty? image-nodes)
|
||||||
(rx/of nil)
|
(rx/of svg-node)
|
||||||
(->> (rx/from image-nodes)
|
(->> (rx/from image-nodes)
|
||||||
(rx/mapcat
|
(rx/mapcat
|
||||||
(fn [image]
|
(fn [image]
|
||||||
|
@ -43,7 +44,8 @@
|
||||||
(rx/mapcat wapi/read-file-as-data-url)
|
(rx/mapcat wapi/read-file-as-data-url)
|
||||||
(rx/tap (fn [data]
|
(rx/tap (fn [data]
|
||||||
(dom/set-attribute! image "href" data)))
|
(dom/set-attribute! image "href" data)))
|
||||||
(rx/reduce noop-fn)))))))))
|
(rx/reduce noop-fn)))))
|
||||||
|
(rx/map (fn [_] svg-node))))))
|
||||||
|
|
||||||
(defn- svg-as-data-url
|
(defn- svg-as-data-url
|
||||||
"Transforms SVG as data-url resolving any blob, http or https url to
|
"Transforms SVG as data-url resolving any blob, http or https url to
|
||||||
|
@ -51,7 +53,11 @@
|
||||||
[svg]
|
[svg]
|
||||||
(let [svg-clone (.cloneNode svg true)]
|
(let [svg-clone (.cloneNode svg true)]
|
||||||
(->> (resolve-svg-images! svg-clone)
|
(->> (resolve-svg-images! svg-clone)
|
||||||
(rx/map (fn [_] (dom/svg-node->data-uri svg-clone))))))
|
(rx/mapcat (fn [svg-node]
|
||||||
|
(let [xml (js/XMLSerializer.)
|
||||||
|
xmlstr (.serializeToString xml svg-node)]
|
||||||
|
(->> (rx/of xmlstr)
|
||||||
|
(rx/map #(dm/str "data:image/svg+xml;charset=utf-8," (js/encodeURIComponent %))))))))))
|
||||||
|
|
||||||
(defn format-viewbox [vbox]
|
(defn format-viewbox [vbox]
|
||||||
(str/join " " [(:x vbox 0)
|
(str/join " " [(:x vbox 0)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue