mirror of
https://github.com/penpot/penpot.git
synced 2025-06-10 22:31:39 +02: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)})
|
:typography (assoc typography :id id)})
|
||||||
(assoc :last-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
|
(defn add-library-media
|
||||||
[file media]
|
[file media]
|
||||||
(let [id (or (:id media) (uuid/next))]
|
(let [id (or (:id media) (uuid/next))]
|
||||||
|
|
|
@ -91,6 +91,13 @@
|
||||||
(rx/filter #(d/not-empty? (second %)))
|
(rx/filter #(d/not-empty? (second %)))
|
||||||
(rx/map e/parse-library-color))
|
(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
|
media-stream
|
||||||
(->> files-stream
|
(->> files-stream
|
||||||
(rx/flat-map vals)
|
(rx/flat-map vals)
|
||||||
|
@ -120,7 +127,8 @@
|
||||||
pages-stream
|
pages-stream
|
||||||
components-stream
|
components-stream
|
||||||
media-stream
|
media-stream
|
||||||
colors-stream)
|
colors-stream
|
||||||
|
typographies-stream)
|
||||||
(rx/reduce conj [])
|
(rx/reduce conj [])
|
||||||
(rx/with-latest-from files-stream)
|
(rx/with-latest-from files-stream)
|
||||||
(rx/flat-map (fn [[data _]]
|
(rx/flat-map (fn [[data _]]
|
||||||
|
@ -209,6 +217,14 @@
|
||||||
(set! file (fb/delete-library-media file (parse-data data)))
|
(set! file (fb/delete-library-media file (parse-data data)))
|
||||||
(str (:last-id file)))
|
(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]
|
(startComponent [_ data]
|
||||||
(set! file (fb/start-component file (parse-data data)))
|
(set! file (fb/start-component file (parse-data data)))
|
||||||
(str (:current-component-id file)))
|
(str (:current-component-id file)))
|
||||||
|
|
|
@ -155,14 +155,15 @@
|
||||||
(->> (r/render-components (:data file) :deleted-components)
|
(->> (r/render-components (:data file) :deleted-components)
|
||||||
(rx/map #(vector (str (:id file) "/deleted-components.svg") %))))
|
(rx/map #(vector (str (:id file) "/deleted-components.svg") %))))
|
||||||
|
|
||||||
(defn fetch-file-with-libraries [file-id components-v2]
|
(defn fetch-file-with-libraries
|
||||||
(->> (rx/zip (rp/query :file {:id file-id :components-v2 components-v2})
|
[file-id components-v2]
|
||||||
(rp/query :file-libraries {:file-id file-id}))
|
(let [features (cond-> #{} components-v2 (conj "components/v2"))]
|
||||||
(rx/map
|
(->> (rx/zip (rp/cmd! :get-file {:id file-id :features features})
|
||||||
(fn [[file file-libraries]]
|
(rp/cmd! :get-file-libraries {:file-id file-id}))
|
||||||
(let [libraries-ids (->> file-libraries (map :id) (filterv #(not= (:id file) %)))]
|
(rx/map
|
||||||
(-> file
|
(fn [[file file-libraries]]
|
||||||
(assoc :libraries libraries-ids)))))))
|
(let [libraries-ids (->> file-libraries (map :id) (filterv #(not= (:id file) %)))]
|
||||||
|
(assoc file :libraries libraries-ids)))))))
|
||||||
|
|
||||||
(defn get-component-ref-file
|
(defn get-component-ref-file
|
||||||
[objects shape]
|
[objects shape]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue