mirror of
https://github.com/penpot/penpot.git
synced 2025-06-03 00:31:40 +02:00
🐛 Fix inconsistencies on drop datauri images (mainly for firefox browser)
This commit is contained in:
parent
5cec969ee3
commit
7ef07385c6
2 changed files with 32 additions and 9 deletions
|
@ -60,6 +60,23 @@
|
|||
(assert (blob? b) "invalid arguments")
|
||||
(js/URL.createObjectURL b))
|
||||
|
||||
(defn data-uri?
|
||||
[s]
|
||||
(str/starts-with? s "data:"))
|
||||
|
||||
(defn data-uri->blob
|
||||
[data-uri]
|
||||
(let [[mtype b64-data] (str/split data-uri ";base64,")
|
||||
mtype (subs mtype (inc (str/index-of mtype ":")))
|
||||
decoded (.atob js/window b64-data)
|
||||
size (.-length ^js decoded)
|
||||
content (js/Uint8Array. size)]
|
||||
|
||||
(doseq [i (range 0 size)]
|
||||
(aset content i (.charCodeAt ^js decoded i)))
|
||||
|
||||
(create-blob content mtype)))
|
||||
|
||||
(defn write-to-clipboard
|
||||
[data]
|
||||
(assert (string? data) "`data` should be string")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue