diff --git a/CHANGES.md b/CHANGES.md index 4193b156db..8c1d5b8430 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -46,6 +46,7 @@ - Fix copying a shadow color from info tab [Taiga #11211](https://tree.taiga.io/project/penpot/issue/11211) - Fix remove color button in the gradient editor [Taiga #11623](https://tree.taiga.io/project/penpot/issue/11623) - Fix "Copy as SVG" generates different code from the Inspect panel [Taiga #11519](https://tree.taiga.io/project/penpot/issue/11519) +- Fix overriden tokens in text copies are not preserved [Taiga #11486](https://tree.taiga.io/project/penpot/issue/11486) ## 2.8.1 (Unreleased) diff --git a/common/src/app/common/types/container.cljc b/common/src/app/common/types/container.cljc index 6c7e468314..fa1e506906 100644 --- a/common/src/app/common/types/container.cljc +++ b/common/src/app/common/types/container.cljc @@ -522,9 +522,13 @@ (let [old-applied-tokens (d/nilv (:applied-tokens shape) #{}) changed-token-attrs (filter #(not= (get old-applied-tokens %) (get new-applied-tokens %)) ctt/all-keys) + text-shape? (= (:type shape) :text) changed-groups (into #{} - (comp (map ctt/token-attr->shape-attr) - (map #(get ctk/sync-attrs %)) + (comp (mapcat #(if (and text-shape? (ctt/attrs-in-text-content %)) + [:content-group :text-content-attribute] + [(->> % + (ctt/token-attr->shape-attr) + (get ctk/sync-attrs))])) (filter some?)) changed-token-attrs)] changed-groups)) diff --git a/common/src/app/common/types/token.cljc b/common/src/app/common/types/token.cljc index d3c1f27657..9ef1571e53 100644 --- a/common/src/app/common/types/token.cljc +++ b/common/src/app/common/types/token.cljc @@ -29,20 +29,20 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (def token-type->dtcg-token-type - {:boolean "boolean" - :border-radius "borderRadius" - :color "color" - :dimensions "dimension" - :font-size "fontSizes" + {:boolean "boolean" + :border-radius "borderRadius" + :color "color" + :dimensions "dimension" + :font-size "fontSizes" :letter-spacing "letterSpacing" - :number "number" - :opacity "opacity" - :other "other" - :rotation "rotation" - :sizing "sizing" - :spacing "spacing" - :string "string" - :stroke-width "strokeWidth"}) + :number "number" + :opacity "opacity" + :other "other" + :rotation "rotation" + :sizing "sizing" + :spacing "spacing" + :string "string" + :stroke-width "strokeWidth"}) (def dtcg-token-type->token-type (set/map-invert token-type->dtcg-token-type)) @@ -263,6 +263,13 @@ [attributes token-type] (seq (appliable-attrs attributes token-type))) +;; Token attrs that are set inside content blocks of text shapes, instead +;; at the shape level. +(def attrs-in-text-content + (set/union + typography-keys + #{:fill})) + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; TOKENS IN SHAPES ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;