0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-10 08:50:57 -05:00

Merge pull request #446 from penpot/fix/problems_with_text

:Fixes problems with texts options
This commit is contained in:
Andrey Antukh 2021-01-08 14:17:01 +01:00 committed by GitHub
commit d188ac2df4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 22 additions and 10 deletions

View file

@ -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))))

View file

@ -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

View file

@ -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))]

View file

@ -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})

View file

@ -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))))