From 2ece527f9b079dace00dff1d6bd9f8dd72440368 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 8 Jan 2021 11:45:55 +0100 Subject: [PATCH] :bug: Fixes problems with texts options --- common/app/common/attrs.cljc | 6 +++++- frontend/src/app/main/ui/workspace/shapes/text.cljs | 8 ++++---- .../app/main/ui/workspace/sidebar/options/multiple.cljs | 6 ++++-- .../src/app/main/ui/workspace/sidebar/options/text.cljs | 9 +++++++-- frontend/src/app/util/text.cljs | 3 ++- 5 files changed, 22 insertions(+), 10 deletions(-) diff --git a/common/app/common/attrs.cljc b/common/app/common/attrs.cljc index 905447175..31fab1a22 100644 --- a/common/app/common/attrs.cljc +++ b/common/app/common/attrs.cljc @@ -70,6 +70,10 @@ (if (= value :undefined) nil value)) cleanup (fn [result] - (zipmap attrs (map #(cleanup-value (get result %)) attrs)))] + (->> attrs + (map #(get result %)) + (zipmap attrs) + (filter #(not= (second %) :undefined)) + (into {})))] (cleanup combined)))) diff --git a/frontend/src/app/main/ui/workspace/shapes/text.cljs b/frontend/src/app/main/ui/workspace/shapes/text.cljs index 47ce0fc57..4c894e4d0 100644 --- a/frontend/src/app/main/ui/workspace/shapes/text.cljs +++ b/frontend/src/app/main/ui/workspace/shapes/text.cljs @@ -106,16 +106,16 @@ [:> shape-container {:shape shape} ;; We keep hidden the shape when we're editing so it keeps track of the size ;; and updates the selrect acordingly - [:g.text-shape {:opacity (when edition? 0)} + [:g.text-shape {:opacity (when edition? 0) + :pointer-events "none"} [:& text/text-shape {:key (str "text-shape" (:id shape)) :ref text-ref-cb :shape shape :selected? selected? :grow-type (:grow-type shape)}]] (when edition? - [:g {:pointer-events "none"} - [:& editor/text-shape-edit {:key (str "editor" (:id shape)) - :shape shape}]]) + [:& editor/text-shape-edit {:key (str "editor" (:id shape)) + :shape shape}]) (when-not edition? [:rect.text-actions diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/multiple.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/multiple.cljs index 3dd87282b..9ac5e9693 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/multiple.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/multiple.cljs @@ -93,7 +93,7 @@ :shadow shadow-attrs :blur blur-attrs :stroke stroke-attrs - :text ot/text-attrs}) + :text ot/attrs}) (def shadow-keys [:style :color :offset-x :offset-y :blur :spread]) @@ -145,7 +145,9 @@ :shape [(conj ids id) (merge-attrs values (select-keys shape attrs))] :text [(conj ids id) - (merge-attrs values (ut/get-text-attrs-multi content attrs))] + (-> values + (merge-attrs (select-keys shape attrs)) + (merge-attrs (ut/get-text-attrs-multi content attrs)))] :children (let [children (->> (:shapes shape []) (map #(get objects %)))] (get-attrs children objects attr-type)))] result))] diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/text.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/text.cljs index dab2ff829..e1167a3d6 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/text.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/text.cljs @@ -42,6 +42,7 @@ (def text-decoration-attrs [:text-decoration]) (def text-transform-attrs [:text-transform]) +(def shape-attrs [:grow-type]) (def root-attrs (d/concat text-valign-attrs text-align-attrs)) (def paragraph-attrs text-align-attrs) @@ -52,6 +53,8 @@ text-decoration-attrs text-transform-attrs)) +(def attrs (d/concat #{} shape-attrs root-attrs paragraph-attrs text-attrs)) + (mf/defc text-align-options [{:keys [editor ids values locale on-change] :as props}] (let [{:keys [text-align]} values @@ -112,9 +115,9 @@ i/align-bottom]])) (mf/defc grow-options - [{:keys [shapes editor ids values locale on-change] :as props}] + [{:keys [editor ids values locale on-change] :as props}] (let [to-single-value (fn [coll] (if (> (count coll) 1) nil (first coll))) - grow-type (->> shapes (map :grow-type) (remove nil?) (into #{}) to-single-value) + grow-type (->> values :grow-type) handle-change-grow (fn [event grow-type] (st/emit! (dwc/update-shapes ids #(assoc % :grow-type grow-type))))] @@ -299,7 +302,9 @@ (:fill fill-values) (assoc :fill-color (:fill fill-values)) (:opacity fill-values) (assoc :fill-opacity (:fill fill-values))) + text-values (merge + (select-keys shape [:grow-type]) (dwt/current-root-values {:editor editor :shape shape :attrs root-attrs}) diff --git a/frontend/src/app/util/text.cljs b/frontend/src/app/util/text.cljs index b9f8ff5f5..607e9251c 100644 --- a/frontend/src/app/util/text.cljs +++ b/frontend/src/app/util/text.cljs @@ -99,5 +99,6 @@ (fn rec-fn [current node] (let [current (reduce rec-fn current (:children node []))] (get-attrs-multi [current node] attrs)))] - (rec-fn {} node))) + (merge (select-keys default-text-attrs attrs) + (rec-fn {} node))))