0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-02-12 18:18:24 -05:00

Merge pull request #3814 from penpot/azazeln28-fix-color-picker

🐛 Fix color picker
This commit is contained in:
Alejandro 2023-11-23 07:35:50 +01:00 committed by GitHub
commit dce2eb03c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -32,16 +32,18 @@
[svg-node]
(let [image-nodes (dom/query-all svg-node "image:not([href^=data])")
noop-fn (constantly nil)]
(->> (rx/from image-nodes)
(rx/mapcat
(fn [image]
(let [href (dom/get-attribute image "href")]
(->> (http/fetch {:method :get :uri href})
(rx/mapcat (fn [response] (.blob ^js response)))
(rx/mapcat wapi/read-file-as-data-url)
(rx/tap (fn [data]
(dom/set-attribute! image "href" data)))
(rx/reduce noop-fn))))))))
(if (empty? image-nodes)
(rx/of nil)
(->> (rx/from image-nodes)
(rx/mapcat
(fn [image]
(let [href (dom/get-attribute image "href")]
(->> (http/fetch {:method :get :uri href})
(rx/mapcat (fn [response] (.blob ^js response)))
(rx/mapcat wapi/read-file-as-data-url)
(rx/tap (fn [data]
(dom/set-attribute! image "href" data)))
(rx/reduce noop-fn)))))))))
(defn- svg-as-data-url
"Transforms SVG as data-url resolving any blob, http or https url to
@ -95,7 +97,7 @@
canvas-ref (mf/use-ref nil)
img-ref (mf/use-ref nil)
update-str (rx/subject)
update-str (rx/subject)
handle-keydown
(mf/use-callback