mirror of
https://github.com/penpot/penpot.git
synced 2025-05-22 13:06:12 +02:00
🐛 Fixes problems with texts options
This commit is contained in:
parent
d12b78985e
commit
2ece527f9b
5 changed files with 22 additions and 10 deletions
|
@ -70,6 +70,10 @@
|
||||||
(if (= value :undefined) nil value))
|
(if (= value :undefined) nil value))
|
||||||
|
|
||||||
cleanup (fn [result]
|
cleanup (fn [result]
|
||||||
(zipmap attrs (map #(cleanup-value (get result %)) attrs)))]
|
(->> attrs
|
||||||
|
(map #(get result %))
|
||||||
|
(zipmap attrs)
|
||||||
|
(filter #(not= (second %) :undefined))
|
||||||
|
(into {})))]
|
||||||
|
|
||||||
(cleanup combined))))
|
(cleanup combined))))
|
||||||
|
|
|
@ -106,16 +106,16 @@
|
||||||
[:> shape-container {:shape shape}
|
[:> shape-container {:shape shape}
|
||||||
;; We keep hidden the shape when we're editing so it keeps track of the size
|
;; We keep hidden the shape when we're editing so it keeps track of the size
|
||||||
;; and updates the selrect acordingly
|
;; 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))
|
[:& text/text-shape {:key (str "text-shape" (:id shape))
|
||||||
:ref text-ref-cb
|
:ref text-ref-cb
|
||||||
:shape shape
|
:shape shape
|
||||||
:selected? selected?
|
:selected? selected?
|
||||||
:grow-type (:grow-type shape)}]]
|
:grow-type (:grow-type shape)}]]
|
||||||
(when edition?
|
(when edition?
|
||||||
[:g {:pointer-events "none"}
|
|
||||||
[:& editor/text-shape-edit {:key (str "editor" (:id shape))
|
[:& editor/text-shape-edit {:key (str "editor" (:id shape))
|
||||||
:shape shape}]])
|
:shape shape}])
|
||||||
|
|
||||||
(when-not edition?
|
(when-not edition?
|
||||||
[:rect.text-actions
|
[:rect.text-actions
|
||||||
|
|
|
@ -93,7 +93,7 @@
|
||||||
:shadow shadow-attrs
|
:shadow shadow-attrs
|
||||||
:blur blur-attrs
|
:blur blur-attrs
|
||||||
:stroke stroke-attrs
|
:stroke stroke-attrs
|
||||||
:text ot/text-attrs})
|
:text ot/attrs})
|
||||||
|
|
||||||
(def shadow-keys [:style :color :offset-x :offset-y :blur :spread])
|
(def shadow-keys [:style :color :offset-x :offset-y :blur :spread])
|
||||||
|
|
||||||
|
@ -145,7 +145,9 @@
|
||||||
:shape [(conj ids id)
|
:shape [(conj ids id)
|
||||||
(merge-attrs values (select-keys shape attrs))]
|
(merge-attrs values (select-keys shape attrs))]
|
||||||
:text [(conj ids id)
|
: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 %)))]
|
:children (let [children (->> (:shapes shape []) (map #(get objects %)))]
|
||||||
(get-attrs children objects attr-type)))]
|
(get-attrs children objects attr-type)))]
|
||||||
result))]
|
result))]
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
(def text-decoration-attrs [:text-decoration])
|
(def text-decoration-attrs [:text-decoration])
|
||||||
(def text-transform-attrs [:text-transform])
|
(def text-transform-attrs [:text-transform])
|
||||||
|
|
||||||
|
(def shape-attrs [:grow-type])
|
||||||
(def root-attrs (d/concat text-valign-attrs
|
(def root-attrs (d/concat text-valign-attrs
|
||||||
text-align-attrs))
|
text-align-attrs))
|
||||||
(def paragraph-attrs text-align-attrs)
|
(def paragraph-attrs text-align-attrs)
|
||||||
|
@ -52,6 +53,8 @@
|
||||||
text-decoration-attrs
|
text-decoration-attrs
|
||||||
text-transform-attrs))
|
text-transform-attrs))
|
||||||
|
|
||||||
|
(def attrs (d/concat #{} shape-attrs root-attrs paragraph-attrs text-attrs))
|
||||||
|
|
||||||
(mf/defc text-align-options
|
(mf/defc text-align-options
|
||||||
[{:keys [editor ids values locale on-change] :as props}]
|
[{:keys [editor ids values locale on-change] :as props}]
|
||||||
(let [{:keys [text-align]} values
|
(let [{:keys [text-align]} values
|
||||||
|
@ -112,9 +115,9 @@
|
||||||
i/align-bottom]]))
|
i/align-bottom]]))
|
||||||
|
|
||||||
(mf/defc grow-options
|
(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)))
|
(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
|
handle-change-grow
|
||||||
(fn [event grow-type]
|
(fn [event grow-type]
|
||||||
(st/emit! (dwc/update-shapes ids #(assoc % :grow-type 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))
|
(:fill fill-values) (assoc :fill-color (:fill fill-values))
|
||||||
(:opacity fill-values) (assoc :fill-opacity (:fill fill-values)))
|
(:opacity fill-values) (assoc :fill-opacity (:fill fill-values)))
|
||||||
|
|
||||||
|
|
||||||
text-values (merge
|
text-values (merge
|
||||||
|
(select-keys shape [:grow-type])
|
||||||
(dwt/current-root-values
|
(dwt/current-root-values
|
||||||
{:editor editor :shape shape
|
{:editor editor :shape shape
|
||||||
:attrs root-attrs})
|
:attrs root-attrs})
|
||||||
|
|
|
@ -99,5 +99,6 @@
|
||||||
(fn rec-fn [current node]
|
(fn rec-fn [current node]
|
||||||
(let [current (reduce rec-fn current (:children node []))]
|
(let [current (reduce rec-fn current (:children node []))]
|
||||||
(get-attrs-multi [current node] attrs)))]
|
(get-attrs-multi [current node] attrs)))]
|
||||||
(rec-fn {} node)))
|
(merge (select-keys default-text-attrs attrs)
|
||||||
|
(rec-fn {} node))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue