From 11eedd0368f85cb93fe6fdf641ecce22f79ae025 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Thu, 12 Feb 2026 16:01:55 +0100 Subject: [PATCH 1/3] :bug: Patch alternative ways of applying tokens to shapes --- frontend/src/app/plugins/tokens.cljs | 8 ++++++-- plugins/apps/poc-tokens-plugin/src/plugin.ts | 9 ++++++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/plugins/tokens.cljs b/frontend/src/app/plugins/tokens.cljs index 6328a5bafd..2c45878ca3 100644 --- a/frontend/src/app/plugins/tokens.cljs +++ b/frontend/src/app/plugins/tokens.cljs @@ -16,7 +16,7 @@ [app.main.data.workspace.tokens.application :as dwta] [app.main.data.workspace.tokens.library-edit :as dwtl] [app.main.store :as st] - [app.plugins.shape :as shape] + ;; [app.plugins.shape :as shape] [app.plugins.utils :as u] [app.util.object :as obj] [beicon.v2.core :as rx] @@ -113,7 +113,11 @@ :applyToShapes {:schema [:tuple - [:vector [:fn shape/shape-proxy?]] + ;; FIXME: the schema decoder is interpreting the array of shape-proxys and converting + ;; them to plain maps. For now we adapt the schema to accept it, but the decoder + ;; should be fixed to keep the original proxy objects coming from the plugin. + ;; [:vector [:fn shape/shape-proxy?]] + [:vector [:map [:id ::sm/uuid]]] [:maybe [:set ::sm/keyword]]] :fn (fn [shapes attrs] (apply-token-to-shapes file-id set-id id (map :id shapes) attrs))} diff --git a/plugins/apps/poc-tokens-plugin/src/plugin.ts b/plugins/apps/poc-tokens-plugin/src/plugin.ts index 28fe7e8d14..303dccbde5 100644 --- a/plugins/apps/poc-tokens-plugin/src/plugin.ts +++ b/plugins/apps/poc-tokens-plugin/src/plugin.ts @@ -251,7 +251,14 @@ function applyToken( token.applyToSelected(properties); } - // Alternatve way + // Alternative way + // + // const selection = penpot.selection; + // if (token && selection) { + // token.applyToShapes(selection, properties); + // } + + // Other alternative way // // const selection = penpot.selection; // if (token && selection) { From c6266346105b802604d080c28103992caa53a20d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Thu, 12 Feb 2026 16:04:23 +0100 Subject: [PATCH 2/3] :bug: Detect empty font-family --- common/src/app/common/files/tokens.cljc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/src/app/common/files/tokens.cljc b/common/src/app/common/files/tokens.cljc index 67b6217ee6..2da869cccf 100644 --- a/common/src/app/common/files/tokens.cljc +++ b/common/src/app/common/files/tokens.cljc @@ -35,7 +35,7 @@ [::sm/text {:error/fn token-value-empty-fn}]) (def schema:token-value-font-family - [:vector :string]) + [:vector ::sm/text]) (def schema:token-value-typography-map [:map From a23ca6a1cbff06cba477f01822bd5087c3944686 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Thu, 12 Feb 2026 16:38:16 +0100 Subject: [PATCH 3/3] :bug: Fix applied tokens reading in shape proxy --- frontend/src/app/plugins/shape.cljs | 3 ++- frontend/src/app/plugins/tokens.cljs | 6 +++--- plugins/libs/plugin-types/index.d.ts | 4 ++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/plugins/shape.cljs b/frontend/src/app/plugins/shape.cljs index e85efe6115..3f8d655a5b 100644 --- a/frontend/src/app/plugins/shape.cljs +++ b/frontend/src/app/plugins/shape.cljs @@ -11,6 +11,7 @@ [app.common.files.helpers :as cfh] [app.common.geom.rect :as grc] [app.common.geom.shapes :as gsh] + [app.common.json :as json] [app.common.path-names :as cpn] [app.common.record :as crc] [app.common.schema :as sm] @@ -1295,7 +1296,7 @@ (get :applied-tokens))] (reduce (fn [acc [prop name]] - (obj/set! acc (d/name prop) name)) + (obj/set! acc (json/write-camel-key prop) name)) #js {} tokens)))} diff --git a/frontend/src/app/plugins/tokens.cljs b/frontend/src/app/plugins/tokens.cljs index 2c45878ca3..f46722884a 100644 --- a/frontend/src/app/plugins/tokens.cljs +++ b/frontend/src/app/plugins/tokens.cljs @@ -16,7 +16,7 @@ [app.main.data.workspace.tokens.application :as dwta] [app.main.data.workspace.tokens.library-edit :as dwtl] [app.main.store :as st] - ;; [app.plugins.shape :as shape] + ;; [app.plugins.shape :as shape] [app.plugins.utils :as u] [app.util.object :as obj] [beicon.v2.core :as rx] @@ -118,12 +118,12 @@ ;; should be fixed to keep the original proxy objects coming from the plugin. ;; [:vector [:fn shape/shape-proxy?]] [:vector [:map [:id ::sm/uuid]]] - [:maybe [:set ::sm/keyword]]] + [:maybe [:set [:set [:and ::sm/keyword [:fn cto/token-attr?]]]]]] :fn (fn [shapes attrs] (apply-token-to-shapes file-id set-id id (map :id shapes) attrs))} :applyToSelected - {:schema [:tuple [:maybe [:set ::sm/keyword]]] + {:schema [:tuple [:maybe [:set [:and ::sm/keyword [:fn cto/token-attr?]]]]] :fn (fn [attrs] (let [selected (get-in @st/state [:workspace-local :selected])] (apply-token-to-shapes file-id set-id id selected attrs)))})) diff --git a/plugins/libs/plugin-types/index.d.ts b/plugins/libs/plugin-types/index.d.ts index 4b2fbe1c96..d302adabf6 100644 --- a/plugins/libs/plugin-types/index.d.ts +++ b/plugins/libs/plugin-types/index.d.ts @@ -3744,7 +3744,7 @@ export interface ShapeBase extends PluginData { * and the value set to the attributes will depend on which sets are active * (and will change if different sets or themes are activated later). */ - readonly tokens: { [property: string]: string }; + readonly tokens: { [property in TokenProperty]: string }; /** * @return Returns true if the current shape is inside a component instance @@ -5221,7 +5221,7 @@ type TokenDimensionProps = | 'y' // Stroke width - | 'stroke-width'; + | 'strokeWidth'; /** * The properties that a FontFamilies token can be applied to.