mirror of
https://github.com/penpot/penpot.git
synced 2025-03-15 09:11:21 -05:00
🎉 Add support typography management via library
This commit is contained in:
parent
fffacf3552
commit
3252088494
3 changed files with 34 additions and 9 deletions
|
@ -532,6 +532,14 @@
|
|||
:typography (assoc typography :id id)})
|
||||
(assoc :last-id id))))
|
||||
|
||||
(defn delete-library-typography
|
||||
[file typography-id]
|
||||
(let [id (uuid/uuid typography-id)]
|
||||
(-> file
|
||||
(commit-change
|
||||
{:type :del-typography
|
||||
:id id}))))
|
||||
|
||||
(defn add-library-media
|
||||
[file media]
|
||||
(let [id (or (:id media) (uuid/next))]
|
||||
|
|
|
@ -91,6 +91,13 @@
|
|||
(rx/filter #(d/not-empty? (second %)))
|
||||
(rx/map e/parse-library-color))
|
||||
|
||||
typographies-stream
|
||||
(->> files-stream
|
||||
(rx/flat-map vals)
|
||||
(rx/map #(vector (:id %) (get-in % [:data :typographies])))
|
||||
(rx/filter #(d/not-empty? (second %)))
|
||||
(rx/map e/parse-library-typographies))
|
||||
|
||||
media-stream
|
||||
(->> files-stream
|
||||
(rx/flat-map vals)
|
||||
|
@ -120,7 +127,8 @@
|
|||
pages-stream
|
||||
components-stream
|
||||
media-stream
|
||||
colors-stream)
|
||||
colors-stream
|
||||
typographies-stream)
|
||||
(rx/reduce conj [])
|
||||
(rx/with-latest-from files-stream)
|
||||
(rx/flat-map (fn [[data _]]
|
||||
|
@ -209,6 +217,14 @@
|
|||
(set! file (fb/delete-library-media file (parse-data data)))
|
||||
(str (:last-id file)))
|
||||
|
||||
(addLibraryTypography [_ data]
|
||||
(set! file (fb/add-library-typography file (parse-data data)))
|
||||
(str (:last-id file)))
|
||||
|
||||
(deleteLibraryTypography [_ data]
|
||||
(set! file (fb/delete-library-typography file (parse-data data)))
|
||||
(str (:last-id file)))
|
||||
|
||||
(startComponent [_ data]
|
||||
(set! file (fb/start-component file (parse-data data)))
|
||||
(str (:current-component-id file)))
|
||||
|
|
|
@ -155,14 +155,15 @@
|
|||
(->> (r/render-components (:data file) :deleted-components)
|
||||
(rx/map #(vector (str (:id file) "/deleted-components.svg") %))))
|
||||
|
||||
(defn fetch-file-with-libraries [file-id components-v2]
|
||||
(->> (rx/zip (rp/query :file {:id file-id :components-v2 components-v2})
|
||||
(rp/query :file-libraries {:file-id file-id}))
|
||||
(rx/map
|
||||
(fn [[file file-libraries]]
|
||||
(let [libraries-ids (->> file-libraries (map :id) (filterv #(not= (:id file) %)))]
|
||||
(-> file
|
||||
(assoc :libraries libraries-ids)))))))
|
||||
(defn fetch-file-with-libraries
|
||||
[file-id components-v2]
|
||||
(let [features (cond-> #{} components-v2 (conj "components/v2"))]
|
||||
(->> (rx/zip (rp/cmd! :get-file {:id file-id :features features})
|
||||
(rp/cmd! :get-file-libraries {:file-id file-id}))
|
||||
(rx/map
|
||||
(fn [[file file-libraries]]
|
||||
(let [libraries-ids (->> file-libraries (map :id) (filterv #(not= (:id file) %)))]
|
||||
(assoc file :libraries libraries-ids)))))))
|
||||
|
||||
(defn get-component-ref-file
|
||||
[objects shape]
|
||||
|
|
Loading…
Add table
Reference in a new issue