🐛 Replace conflicting fill inputs in text test edits

Make named colors and explicit fills replace each other in the text
notation. Raw nil, empty or nonstandard fills previously masked a new
named color, making generated source color edits no-ops (F225).

The notation regressions fail seven of eight assertions before the fix.
Validation: notation/text suites, transitive source and frontend controls,
full common JVM/JS, frontend and consumers, plus lint and formatting.
Golden data and production behavior are unchanged.

AI-assisted-by: GPT-6
This commit is contained in:
alonso.torres 2026-10-28 00:06:51 +01:00
parent ca97bae421
commit e4239e02b7
2 changed files with 20 additions and 2 deletions

View File

@ -331,11 +331,15 @@
runs))
(defn restyle
"Set the run style `k` to `v` on every run of `text`."
"Set the run style `k` to `v` on every run of `text`.
Named colors and explicit fills replace each other."
[text k v]
(update-paragraphs text
(fn [[style runs]]
[style (map (fn [[letters run-style]] [letters (assoc run-style k v)])
[style (map (fn [[letters run-style]]
[letters (cond-> (assoc run-style k v)
(= k :color) (dissoc :fills)
(= k :fills) (dissoc :color))])
(detach-typography runs k))])))
(defn restyle-paragraphs

View File

@ -16,6 +16,20 @@
(t/use-fixtures :each thi/test-fixture)
(t/deftest setting-a-named-color-replaces-explicit-fills
(doseq [fills [nil [] [{:fill-color "#123456" :fill-opacity 0.5}]]]
(let [text [[["Library text" {:fills fills :size 18}]]]
styled (thtx/restyle text :color :red)]
(t/is (= [[["Library text" {:color :red :size 18}]]]
(thtx/normalize styled)))
(t/is (= [{:fill-color "#FF0000" :fill-opacity 1}]
(get-in (thtx/content styled) [:children 0 :children 0 :children 0 :fills]))))))
(t/deftest setting-explicit-fills-replaces-a-named-color
(let [styled (thtx/restyle [[["Library text" {:color :red :size 18}]]] :fills nil)]
(t/is (= [[["Library text" {:fills nil :size 18}]]] styled))
(t/is (nil? (get-in (thtx/content styled) [:children 0 :children 0 :children 0 :fills])))))
(t/deftest content-is-written-as-the-editors-write-it
(let [content (thtx/content [[["Price: "] ["$10" {:weight 700 :color :red}]]])
paragraph (first (txt/node-seq txt/is-paragraph-node? content))