0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-04-01 01:21:21 -05:00

🐛 Fix remap colors on binary import

This commit is contained in:
Alejandro Alonso 2024-01-04 11:48:53 +01:00 committed by Andrey Antukh
parent 73b8f3fb17
commit 9cfc00ce97

View file

@ -593,6 +593,7 @@
(declare lookup-index) (declare lookup-index)
(declare update-index) (declare update-index)
(declare relink-media) (declare relink-media)
(declare relink-colors)
(declare relink-shapes) (declare relink-shapes)
(defmulti read-import ::version) (defmulti read-import ::version)
@ -723,6 +724,7 @@
(update :pages-index relink-shapes) (update :pages-index relink-shapes)
(update :components relink-shapes) (update :components relink-shapes)
(update :media relink-media) (update :media relink-media)
(update :colors relink-colors)
(d/without-nils)))))) (d/without-nils))))))
@ -997,6 +999,17 @@
media media
media)) media))
(defn- relink-colors
"A function responsible of process the :colors attr of file data and
remap the old ids with the new ones."
[colors]
(reduce-kv (fn [res k v]
(if (:image v)
(update-in res [k :image :id] lookup-index)
res))
colors
colors))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; HIGH LEVEL API ;; HIGH LEVEL API
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;