mirror of
https://github.com/penpot/penpot.git
synced 2026-09-18 18:06:14 +00:00
Merge pull request #7994 from penpot/alotor-fix-font-style
🐛 Fix problem when changing colors with multiple fonts
This commit is contained in:
commit
cb325282ec
@ -554,7 +554,7 @@
|
|||||||
(when (features/active-feature? state "text-editor/v2")
|
(when (features/active-feature? state "text-editor/v2")
|
||||||
(let [instance (:workspace-editor state)
|
(let [instance (:workspace-editor state)
|
||||||
styles (some-> (editor.v2/getCurrentStyle instance)
|
styles (some-> (editor.v2/getCurrentStyle instance)
|
||||||
(styles/get-styles-from-style-declaration)
|
(styles/get-styles-from-style-declaration :removed-mixed true)
|
||||||
((comp update-node-fn migrate-node))
|
((comp update-node-fn migrate-node))
|
||||||
(styles/attrs->styles))]
|
(styles/attrs->styles))]
|
||||||
(editor.v2/applyStylesToSelection instance styles)))))))
|
(editor.v2/applyStylesToSelection instance styles)))))))
|
||||||
|
|||||||
@ -307,7 +307,7 @@
|
|||||||
:title (tr "inspect.attributes.typography.font-family")
|
:title (tr "inspect.attributes.typography.font-family")
|
||||||
:on-click #(reset! open-selector? true)}
|
:on-click #(reset! open-selector? true)}
|
||||||
(cond
|
(cond
|
||||||
(= :multiple font-id)
|
(or (= :multiple font-id) (= "mixed" font-id))
|
||||||
"--"
|
"--"
|
||||||
|
|
||||||
(some? font)
|
(some? font)
|
||||||
|
|||||||
@ -187,19 +187,23 @@
|
|||||||
style-value (normalize-style-value style-name v)]
|
style-value (normalize-style-value style-name v)]
|
||||||
(assoc acc style-name style-value)))) {} style-defaults)))
|
(assoc acc style-name style-value)))) {} style-defaults)))
|
||||||
|
|
||||||
|
(def mixed-values #{:mixed :multiple "mixed" "multiple"})
|
||||||
|
|
||||||
(defn get-styles-from-style-declaration
|
(defn get-styles-from-style-declaration
|
||||||
"Returns a ClojureScript object compatible with text nodes"
|
"Returns a ClojureScript object compatible with text nodes"
|
||||||
[style-declaration]
|
[style-declaration & {:keys [removed-mixed] :or {removed-mixed false}}]
|
||||||
(reduce
|
(reduce
|
||||||
(fn [acc k]
|
(fn [acc k]
|
||||||
(if (contains? mapping k)
|
(if (contains? mapping k)
|
||||||
(let [style-name (get-style-name-as-css-variable k)
|
(let [style-name (get-style-name-as-css-variable k)
|
||||||
[_ style-decode] (get mapping k)
|
[_ style-decode] (get mapping k)
|
||||||
style-value (.getPropertyValue style-declaration style-name)]
|
style-value (.getPropertyValue style-declaration style-name)]
|
||||||
(assoc acc k (style-decode style-value)))
|
(when (or (not removed-mixed) (not (contains? mixed-values style-value)))
|
||||||
|
(assoc acc k (style-decode style-value))))
|
||||||
(let [style-name (get-style-name k)
|
(let [style-name (get-style-name k)
|
||||||
style-value (normalize-attr-value k (.getPropertyValue style-declaration style-name))]
|
style-value (normalize-attr-value k (.getPropertyValue style-declaration style-name))]
|
||||||
(assoc acc k style-value)))) {} txt/text-style-attrs))
|
(when (or (not removed-mixed) (not (contains? mixed-values style-value)))
|
||||||
|
(assoc acc k style-value))))) {} txt/text-style-attrs))
|
||||||
|
|
||||||
(defn get-styles-from-event
|
(defn get-styles-from-event
|
||||||
"Returns a ClojureScript object compatible with text nodes"
|
"Returns a ClojureScript object compatible with text nodes"
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user