diff --git a/common/src/app/common/geom/shapes/min_size_layout.cljc b/common/src/app/common/geom/shapes/min_size_layout.cljc index 9b2d5bcdf..8f1d6b6f7 100644 --- a/common/src/app/common/geom/shapes/min_size_layout.cljc +++ b/common/src/app/common/geom/shapes/min_size_layout.cljc @@ -6,7 +6,7 @@ (ns app.common.geom.shapes.min-size-layout (:require - [app.common.data :as d] + [app.common.data.macros :as dm] [app.common.geom.shapes.flex-layout.bounds :as fb] [app.common.geom.shapes.flex-layout.layout-data :as fd] [app.common.geom.shapes.grid-layout.bounds :as gb] @@ -19,10 +19,10 @@ [child child-bounds bounds objects] (let [min-width (cond - (and (ctl/fill-width? child) - (ctl/flex-layout? child)) - (let [children (->> child :shapes (map (d/getf objects)))] - (gpo/width-points (fb/layout-content-bounds bounds child children objects))) + (and (ctl/fill-width? child) (ctl/flex-layout? child)) + (let [children (cph/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})] + (max (ctl/child-min-width child) + (gpo/width-points (fb/layout-content-bounds bounds child children objects)))) (and (ctl/fill-width? child) (ctl/grid-layout? child)) @@ -30,7 +30,8 @@ (->> (cph/get-immediate-children objects (:id child) {:remove-hidden true}) (map #(vector @(get bounds (:id %)) %))) layout-data (gd/calc-layout-data child @(get bounds (:id child)) children bounds objects true)] - (gpo/width-points (gb/layout-content-bounds bounds child layout-data))) + (max (ctl/child-min-width child) + (gpo/width-points (gb/layout-content-bounds bounds child layout-data)))) (ctl/fill-width? child) (ctl/child-min-width child) @@ -44,15 +45,18 @@ (let [min-height (cond (and (ctl/fill-height? child) (ctl/flex-layout? child)) - (gpo/height-points (fb/layout-content-bounds bounds child (->> child :shapes (map (d/getf objects))) objects)) + (let [children (cph/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true})] + (max (ctl/child-min-height child) + (gpo/height-points (fb/layout-content-bounds bounds child children objects)))) (and (ctl/fill-height? child) (ctl/grid-layout? child)) - (let [children (->> child :shapes - (map (d/getf objects)) - (map (fn [child] [@(get bounds (:id child)) child]))) + (let [children + (->> (cph/get-immediate-children objects (dm/get-prop child :id) {:remove-hidden true}) + (map (fn [child] [@(get bounds (:id child)) child]))) layout-data (gd/calc-layout-data child (:points child) children bounds objects true) auto-bounds (gb/layout-content-bounds bounds child layout-data)] - (gpo/height-points auto-bounds)) + (max (ctl/child-min-height child) + (gpo/height-points auto-bounds))) (ctl/fill-height? child) (ctl/child-min-height child) 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 d1a8b3b4d..94fd08b94 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 @@ -26,7 +26,6 @@ [app.util.object :as obj] [app.util.text-editor :as ted] [app.util.text-svg-position :as tsp] - [app.util.timers :as ts] [promesa.core :as p] [rumext.v2 :as mf])) @@ -96,13 +95,7 @@ (assoc :height height)) props)) props)))) - (p/fmap (fn [props] - ;; We need to wait for the text modifier to be updated before - ;; we can update the position data. Otherwise the position data - ;; will be wrong. - ;; TODO: This is a hack. We need to find a better way to do this. - (st/emit! (dwt/update-text-modifier id props)) - (ts/schedule 30 #(update-text-shape shape node)))))) + (p/fmap #(st/emit! (dwt/update-text-modifier id %))))) (mf/defc text-container {::mf/wrap-props false @@ -125,15 +118,15 @@ (defn text-properties-equal? [shape other] - ;; FIXME: use dm/get-prop (or (identical? shape other) - (and (= (:content shape) (:content other)) + (and (= (dm/get-prop shape :grow-type) (dm/get-prop other :grow-type)) + (= (dm/get-prop shape :content) (dm/get-prop other :content)) ;; Check if the position and size is close. If any of these changes the shape has changed ;; and if not there is no geometry relevant change - (mth/close? (:x shape) (:x other)) - (mth/close? (:y shape) (:y other)) - (mth/close? (:width shape) (:width other)) - (mth/close? (:height shape) (:height other))))) + (mth/close? (dm/get-prop shape :x) (dm/get-prop other :x)) + (mth/close? (dm/get-prop shape :y) (dm/get-prop other :y)) + (mth/close? (dm/get-prop shape :width) (dm/get-prop other :width)) + (mth/close? (dm/get-prop shape :height) (dm/get-prop other :height))))) (mf/defc text-changes-renderer {::mf/wrap-props false} diff --git a/frontend/src/app/util/text_svg_position.cljs b/frontend/src/app/util/text_svg_position.cljs index 7047413ff..649873284 100644 --- a/frontend/src/app/util/text_svg_position.cljs +++ b/frontend/src/app/util/text_svg_position.cljs @@ -53,6 +53,7 @@ font-id (dom/get-property-value styles "--font-id")] (->> (fonts/ensure-loaded! font-id) + (p/delay 125) (p/fmap (fn [] (when-not ^boolean (dom/check-font? font) (load-font font))))