🐛 Exclude nil decoded values when reading text styles from v2 editor

The v2 editor style-reading functions (get-styles-from-style-declaration
and get-attrs-from-styles) decoded empty CSS variable values to nil for
typography-ref-file and typography-ref-id, then unconditionally included
them in the result map. These nils propagated into shape content and
sidebar values, ultimately leaking into new text shapes created after
detaching a typography.

Skip entries whose decoded/resolved value is nil so the keys are simply
absent instead of present-with-nil.
This commit is contained in:
Andrey Antukh 2026-04-13 17:50:45 +00:00 committed by Eva Marco
parent 241a4ec2fa
commit b802859a53
2 changed files with 14 additions and 7 deletions

View File

@ -50,8 +50,11 @@
[_ style-decode] (get styles/mapping key)]
(style-decode (.getPropertyValue style style-name)))
(let [style-name (styles/get-style-name key)]
(styles/normalize-attr-value key (.getPropertyValue style style-name))))]
(assoc acc key (if (value-empty? value) (get defaults key) value))))
(styles/normalize-attr-value key (.getPropertyValue style style-name))))
resolved (if (value-empty? value) (get defaults key) value)]
(if (some? resolved)
(assoc acc key resolved)
acc)))
{} attrs)))
(defn get-text-span-styles

View File

@ -200,13 +200,17 @@
(if (contains? mapping k)
(let [style-name (get-style-name-as-css-variable k)
[_ style-decode] (get mapping k)
style-value (.getPropertyValue style-declaration style-name)]
(when (or (not removed-mixed) (not (contains? mixed-values style-value)))
(assoc acc k (style-decode style-value))))
style-value (.getPropertyValue style-declaration style-name)
decoded (style-decode style-value)]
(if (and (some? decoded)
(or (not removed-mixed) (not (contains? mixed-values style-value))))
(assoc acc k decoded)
acc))
(let [style-name (get-style-name k)
style-value (normalize-attr-value k (.getPropertyValue style-declaration style-name))]
(when (or (not removed-mixed) (not (contains? mixed-values style-value)))
(assoc acc k style-value))))) {} txt/text-style-attrs))
(if (or (not removed-mixed) (not (contains? mixed-values style-value)))
(assoc acc k style-value)
acc)))) {} txt/text-style-attrs))
(defn get-styles-from-event
"Returns a ClojureScript object compatible with text nodes"