🐛 Fix problem with missplaced texts

This commit is contained in:
alonso.torres 2022-05-30 12:08:38 +02:00
parent 4764674374
commit 321c3fb34b
6 changed files with 50 additions and 29 deletions

View file

@ -28,3 +28,11 @@
[shape]
(gpr/points->selrect (position-data-points shape)))
(defn overlaps-position-data?
"Checks if the given position data is inside the shape"
[{:keys [points]} position-data]
(let [bounding-box (gpr/points->selrect points)
fix-rect #(assoc % :y (- (:y %) (:height %)))]
(->> position-data
(some #(gpr/overlaps-rects? bounding-box (fix-rect %)))
(boolean))))

View file

@ -9,7 +9,7 @@
[app.common.colors :as clr]
[app.common.uuid :as uuid]))
(def file-version 18)
(def file-version 19)
(def default-color clr/gray-20)
(def root uuid/zero)

View file

@ -10,6 +10,7 @@
[app.common.geom.matrix :as gmt]
[app.common.geom.shapes :as gsh]
[app.common.geom.shapes.path :as gsp]
[app.common.geom.shapes.text :as gsht]
[app.common.logging :as l]
[app.common.math :as mth]
[app.common.pages :as cp]
@ -415,5 +416,21 @@
(update :pages-index d/update-vals update-container)
(update :components d/update-vals update-container))))
(defmethod migrate 19
[data]
(letfn [(update-object [object]
(cond-> object
(and (cph/text-shape? object)
(d/not-empty? (:position-data object))
(not (gsht/overlaps-position-data? object (:position-data object))))
(dissoc :position-data)))
(update-container [container]
(update container :objects d/update-vals update-object))]
(-> data
(update :pages-index d/update-vals update-container)
(update :components d/update-vals update-container))))
;; TODO: pending to do a migration for delete already not used fill
;; and stroke props. This should be done for >1.14.x version.