🐛 Fix broken points on image shapes in comp-v2 migration

This commit is contained in:
Andrey Antukh 2024-01-31 11:10:44 +01:00
parent 43c13ed432
commit db5946d1ab

View file

@ -111,9 +111,14 @@
(def valid-color? (def valid-color?
(sm/lazy-validator ::ctc/color)) (sm/lazy-validator ::ctc/color))
(def valid-fill? (sm/lazy-validator ::cts/fill)) (def valid-fill?
(def valid-stroke? (sm/lazy-validator ::cts/stroke)) (sm/lazy-validator ::cts/fill))
(def valid-flow? (sm/lazy-validator ::ctp/flow))
(def valid-stroke?
(sm/lazy-validator ::cts/stroke))
(def valid-flow?
(sm/lazy-validator ::ctp/flow))
(def valid-text-content? (def valid-text-content?
(sm/lazy-validator ::ctsx/content)) (sm/lazy-validator ::ctsx/content))
@ -130,6 +135,9 @@
(def valid-shape-points? (def valid-shape-points?
(sm/lazy-validator ::cts/points)) (sm/lazy-validator ::cts/points))
(def valid-image-attrs?
(sm/lazy-validator ::cts/image-attrs))
(defn- prepare-file-data (defn- prepare-file-data
"Apply some specific migrations or fixes to things that are allowed in v1 but not in v2, "Apply some specific migrations or fixes to things that are allowed in v1 but not in v2,
or that are the result of old bugs." or that are the result of old bugs."
@ -330,6 +338,23 @@
(some? (:main-instance shape)) (some? (:main-instance shape))
(dissoc :main-instance) (dissoc :main-instance)
(and (cfh/image-shape? shape)
(valid-image-attrs? shape)
(grc/valid-rect? (:selrect shape))
(not (valid-shape-points? (:points shape))))
(as-> shape
(let [selrect (:selrect shape)
metadata (:metadata shape)
selrect (grc/make-rect
(:x selrect)
(:y selrect)
(:width metadata)
(:height metadata))
points (grc/rect->points selrect)]
(assoc shape
:selrect selrect
:points points)))
(and (cfh/text-shape? shape) (and (cfh/text-shape? shape)
(valid-text-content? (:content shape)) (valid-text-content? (:content shape))
(not (valid-shape-points? (:points shape))) (not (valid-shape-points? (:points shape)))