From bec683d1efa18544d5429e04af7cfa785b078f60 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Tue, 7 Nov 2023 11:26:01 +0100 Subject: [PATCH] :bug: Fix problem resizing texts --- common/src/app/common/data.cljc | 29 ++++++++++--------- common/src/app/common/geom/modif_tree.cljc | 1 - .../app/common/geom/shapes/transforms.cljc | 2 +- .../src/app/common/geom/shapes/tree_seq.cljc | 1 - .../shapes/text/viewport_texts_html.cljs | 23 +++++++++------ 5 files changed, 31 insertions(+), 25 deletions(-) diff --git a/common/src/app/common/data.cljc b/common/src/app/common/data.cljc index adfa66189..6ac1c0013 100644 --- a/common/src/app/common/data.cljc +++ b/common/src/app/common/data.cljc @@ -250,22 +250,25 @@ #(patch-object % changes)) ([object changes] - (->> changes - (reduce-kv - (fn [object key value] - (cond - (map? value) - (update object key patch-object value) + (if object + (->> changes + (reduce-kv + (fn [object key value] + (cond + (map? value) + (let [current (get object key)] + (assoc object key (patch-object current value))) - (and (nil? value) (record? object)) - (assoc object key nil) + (and (nil? value) (record? object)) + (assoc object key nil) - (nil? value) - (dissoc object key value) + (nil? value) + (dissoc object key value) - :else - (assoc object key value))) - object)))) + :else + (assoc object key value))) + object)) + changes))) (defn remove-at-index "Takes a vector and returns a vector with an element in the diff --git a/common/src/app/common/geom/modif_tree.cljc b/common/src/app/common/geom/modif_tree.cljc index 709012d7d..e587d05c8 100644 --- a/common/src/app/common/geom/modif_tree.cljc +++ b/common/src/app/common/geom/modif_tree.cljc @@ -7,7 +7,6 @@ (ns app.common.geom.modif-tree (:require [app.common.data.macros :as dm] - [app.common.geom.shapes.min-size-layout] [app.common.pages.helpers :as cph] [app.common.types.modifiers :as ctm])) diff --git a/common/src/app/common/geom/shapes/transforms.cljc b/common/src/app/common/geom/shapes/transforms.cljc index 376cd41a7..f03d73daf 100644 --- a/common/src/app/common/geom/shapes/transforms.cljc +++ b/common/src/app/common/geom/shapes/transforms.cljc @@ -486,7 +486,7 @@ (transform-shape modifiers)))) ([shape modifiers] - (if (and (some? modifiers) (not (ctm/empty? modifiers))) + (if (and (some? shape) (some? modifiers) (not (ctm/empty? modifiers))) (let [transform (ctm/modifiers->transform modifiers)] (cond-> shape (and (some? transform) diff --git a/common/src/app/common/geom/shapes/tree_seq.cljc b/common/src/app/common/geom/shapes/tree_seq.cljc index 77932154b..bc0ee4a40 100644 --- a/common/src/app/common/geom/shapes/tree_seq.cljc +++ b/common/src/app/common/geom/shapes/tree_seq.cljc @@ -8,7 +8,6 @@ (:require [app.common.data :as d] [app.common.data.macros :as dm] - [app.common.geom.shapes.min-size-layout] [app.common.pages.helpers :as cph] [app.common.types.shape.layout :as ctl] [app.common.uuid :as uuid])) diff --git a/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts_html.cljs b/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts_html.cljs index 864ff8d15..7ff9f23ca 100644 --- a/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts_html.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/text/viewport_texts_html.cljs @@ -30,15 +30,20 @@ [rumext.v2 :as mf])) (defn fix-position [shape] - (let [modifiers (:modifiers shape) - shape' (gsh/transform-shape shape modifiers) - ;; We need to remove the movement because the dynamic modifiers will have move it - deltav (gpt/to-vec (gpt/point (:selrect shape')) - (gpt/point (:selrect shape)))] - (-> shape - (gsh/transform-shape (ctm/move modifiers deltav)) - (mdwm/update-grow-type shape) - (dissoc :modifiers)))) + (if-let [modifiers (:modifiers shape)] + (let [shape' (gsh/transform-shape shape modifiers) + + old-sr (dm/get-prop shape :selrect) + new-sr (dm/get-prop shape' :selrect) + + ;; We need to remove the movement because the dynamic modifiers will have move it + deltav (gpt/to-vec (gpt/point new-sr) + (gpt/point old-sr))] + (-> shape + (gsh/transform-shape (ctm/move modifiers deltav)) + (mdwm/update-grow-type shape) + (dissoc :modifiers))) + shape)) (defn- update-with-editor-state "Updates the shape with the current state in the editor"