mirror of
https://github.com/penpot/penpot.git
synced 2025-05-30 14:56:11 +02:00
🎉 Add .penpot (binfile-v3) support for library
This commit is contained in:
parent
1fea1e8f5b
commit
29d23577d2
20 changed files with 926 additions and 751 deletions
|
@ -34,41 +34,35 @@
|
|||
|
||||
(defn export-files
|
||||
[files format]
|
||||
(dm/assert!
|
||||
"expected valid files param"
|
||||
(check-export-files files))
|
||||
(assert (contains? valid-formats format)
|
||||
"expected valid export format")
|
||||
|
||||
(dm/assert!
|
||||
"expected valid format"
|
||||
(contains? valid-formats format))
|
||||
(let [files (check-export-files files)]
|
||||
|
||||
(ptk/reify ::export-files
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [features (get state :features)
|
||||
team-id (:current-team-id state)
|
||||
evname (if (= format :legacy-zip)
|
||||
"export-standard-files"
|
||||
"export-binary-files")]
|
||||
|
||||
(rx/merge
|
||||
(rx/of (ptk/event ::ev/event {::ev/name evname
|
||||
::ev/origin "dashboard"
|
||||
:format format
|
||||
:num-files (count files)}))
|
||||
(->> (rx/from files)
|
||||
(rx/mapcat
|
||||
(fn [file]
|
||||
(->> (rp/cmd! :has-file-libraries {:file-id (:id file)})
|
||||
(rx/map #(assoc file :has-libraries %)))))
|
||||
(rx/reduce conj [])
|
||||
(rx/map (fn [files]
|
||||
(modal/show
|
||||
{:type ::export-files
|
||||
:features features
|
||||
:team-id team-id
|
||||
:files files
|
||||
:format format})))))))))
|
||||
(ptk/reify ::export-files
|
||||
ptk/WatchEvent
|
||||
(watch [_ state _]
|
||||
(let [team-id (get state :current-team-id)
|
||||
evname (if (= format :legacy-zip)
|
||||
"export-standard-files"
|
||||
"export-binary-files")]
|
||||
(rx/merge
|
||||
(rx/of (ptk/event ::ev/event {::ev/name evname
|
||||
::ev/origin "dashboard"
|
||||
:format format
|
||||
:num-files (count files)}))
|
||||
(->> (rx/from files)
|
||||
(rx/mapcat
|
||||
(fn [file]
|
||||
(->> (rp/cmd! :has-file-libraries {:file-id (:id file)})
|
||||
(rx/map #(assoc file :has-libraries %)))))
|
||||
(rx/reduce conj [])
|
||||
(rx/map (fn [files]
|
||||
(modal/show
|
||||
{:type ::export-files
|
||||
:team-id team-id
|
||||
:files files
|
||||
:format format}))))))))))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;
|
||||
;; Team Request
|
||||
|
|
|
@ -254,7 +254,7 @@
|
|||
|
||||
(defn add-media
|
||||
[media]
|
||||
(let [media (ctf/check-media-object media)]
|
||||
(let [media (ctf/check-file-media media)]
|
||||
(ptk/reify ::add-media
|
||||
ev/Event
|
||||
(-data [_] media)
|
||||
|
|
|
@ -10,11 +10,11 @@
|
|||
[app.common.data :as d]
|
||||
[app.common.data.macros :as dm]
|
||||
[app.common.exceptions :as ex]
|
||||
[app.common.files.builder :as fb]
|
||||
[app.common.files.changes-builder :as pcb]
|
||||
[app.common.files.shapes-builder :as sb]
|
||||
[app.common.logging :as log]
|
||||
[app.common.math :as mth]
|
||||
[app.common.media :as media]
|
||||
[app.common.schema :as sm]
|
||||
[app.common.types.container :as ctn]
|
||||
[app.common.types.shape :as cts]
|
||||
|
@ -137,7 +137,7 @@
|
|||
(= (.-type blob) "image/svg+xml")))
|
||||
|
||||
(prepare-blob [blob]
|
||||
(let [name (or name (if (dmm/file? blob) (fb/strip-image-extension (.-name blob)) "blob"))]
|
||||
(let [name (or name (if (dmm/file? blob) (media/strip-image-extension (.-name blob)) "blob"))]
|
||||
{:file-id file-id
|
||||
:name name
|
||||
:is-local local?
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue