mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 22:36:38 +02:00
🐛 Add migrations for fix shape geometry missing props
This commit is contained in:
parent
ec1bcada86
commit
c7fa7aa7bc
2 changed files with 61 additions and 5 deletions
|
@ -6,4 +6,4 @@
|
||||||
|
|
||||||
(ns app.common.files.defaults)
|
(ns app.common.files.defaults)
|
||||||
|
|
||||||
(def version 39)
|
(def version 41)
|
||||||
|
|
|
@ -318,7 +318,7 @@
|
||||||
(= "#7B7D85" fill-color)))
|
(= "#7B7D85" fill-color)))
|
||||||
(dissoc :fill-color :fill-opacity))))
|
(dissoc :fill-color :fill-opacity))))
|
||||||
|
|
||||||
(update-container [{:keys [objects] :as container}]
|
(update-container [container]
|
||||||
(if (contains? container :objects)
|
(if (contains? container :objects)
|
||||||
(loop [objects (:objects container)
|
(loop [objects (:objects container)
|
||||||
shapes (->> (vals objects)
|
shapes (->> (vals objects)
|
||||||
|
@ -627,8 +627,8 @@
|
||||||
;; Ensure all root objects are well formed shapes.
|
;; Ensure all root objects are well formed shapes.
|
||||||
(if (= (:id object) uuid/zero)
|
(if (= (:id object) uuid/zero)
|
||||||
(-> object
|
(-> object
|
||||||
(assoc :parent-id uuid/zero
|
(assoc :parent-id uuid/zero)
|
||||||
:frame-id uuid/zero)
|
(assoc :frame-id uuid/zero)
|
||||||
(cts/setup-shape))
|
(cts/setup-shape))
|
||||||
object))
|
object))
|
||||||
|
|
||||||
|
@ -703,7 +703,6 @@
|
||||||
(update :pages-index update-vals update-container)
|
(update :pages-index update-vals update-container)
|
||||||
(update :components update-vals update-container))))
|
(update :components update-vals update-container))))
|
||||||
|
|
||||||
|
|
||||||
(defmethod migrate 39
|
(defmethod migrate 39
|
||||||
[data]
|
[data]
|
||||||
(letfn [(update-shape [shape]
|
(letfn [(update-shape [shape]
|
||||||
|
@ -718,3 +717,60 @@
|
||||||
(-> data
|
(-> data
|
||||||
(update :pages-index update-vals update-container)
|
(update :pages-index update-vals update-container)
|
||||||
(update :components update-vals update-container))))
|
(update :components update-vals update-container))))
|
||||||
|
|
||||||
|
(defmethod migrate 40
|
||||||
|
[data]
|
||||||
|
(letfn [(update-shape [{:keys [content shapes] :as shape}]
|
||||||
|
;; Fix frame shape that in reallity is a path shape
|
||||||
|
(if (and (cfh/frame-shape? shape)
|
||||||
|
(contains? shape :selrect)
|
||||||
|
(seq content)
|
||||||
|
(not (seq shapes))
|
||||||
|
(contains? (first content) :command))
|
||||||
|
(-> shape
|
||||||
|
(assoc :type :path)
|
||||||
|
(assoc :x nil)
|
||||||
|
(assoc :y nil)
|
||||||
|
(assoc :width nil)
|
||||||
|
(assoc :height nil))
|
||||||
|
shape))
|
||||||
|
|
||||||
|
(update-container [container]
|
||||||
|
(d/update-when container :objects update-vals update-shape))]
|
||||||
|
|
||||||
|
(-> data
|
||||||
|
(update :pages-index update-vals update-container)
|
||||||
|
(update :components update-vals update-container))))
|
||||||
|
|
||||||
|
(defmethod migrate 41
|
||||||
|
[data]
|
||||||
|
(letfn [(update-shape [shape]
|
||||||
|
(cond
|
||||||
|
(or (cfh/bool-shape? shape)
|
||||||
|
(cfh/path-shape? shape))
|
||||||
|
shape
|
||||||
|
|
||||||
|
;; Fix all shapes that has geometry broken but still
|
||||||
|
;; preservers the selrect, so we recalculate the
|
||||||
|
;; geometry from selrect.
|
||||||
|
(and (contains? shape :selrect)
|
||||||
|
(or (nil? (:x shape))
|
||||||
|
(nil? (:y shape))
|
||||||
|
(nil? (:width shape))
|
||||||
|
(nil? (:height shape))))
|
||||||
|
(let [selrect (:selrect shape)]
|
||||||
|
(-> shape
|
||||||
|
(assoc :x (:x selrect))
|
||||||
|
(assoc :y (:y selrect))
|
||||||
|
(assoc :width (:width selrect))
|
||||||
|
(assoc :height (:height selrect))))
|
||||||
|
|
||||||
|
:else
|
||||||
|
shape))
|
||||||
|
|
||||||
|
(update-container [container]
|
||||||
|
(d/update-when container :objects update-vals update-shape))]
|
||||||
|
|
||||||
|
(-> data
|
||||||
|
(update :pages-index update-vals update-container)
|
||||||
|
(update :components update-vals update-container))))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue