0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-12 15:51:37 -05:00

Upload media with data in plugins

This commit is contained in:
alonso.torres 2024-06-21 12:44:58 +02:00
parent fb1429956a
commit 4b67c0593d
2 changed files with 17 additions and 1 deletions

View file

@ -131,7 +131,7 @@
(rx/merge-map svg->clj)
(rx/tap on-svg)))))
(defn- process-blobs
(defn process-blobs
[{:keys [file-id local? name blobs force-media on-image on-svg]}]
(letfn [(svg-blob? [blob]
(and (not force-media)

View file

@ -124,6 +124,22 @@
(rx/take 1)
(rx/subs! resolve reject)))))))
(uploadMediaData
[_ name data mime-type]
(let [file-id (:current-file-id @st/state)]
(p/create
(fn [resolve reject]
(->> (dwm/process-blobs
{:file-id file-id
:local? false
:name name
:blobs [(js/Blob. #js [data] #js {:type mime-type})]
:on-image identity
:on-svg identity})
(rx/take 1)
(rx/map u/to-js)
(rx/subs! resolve reject))))))
(group
[_ shapes]
(cond