Compare commits

...

2 Commits

Author SHA1 Message Date
alonso.torres
fc4ab7ecb9 🐛 Fix problem with createText in plugins 2026-02-19 15:57:14 +01:00
alonso.torres
cee974a906 🐛 Fix problem with tokens in plugins 2026-02-18 17:20:46 +01:00
4 changed files with 28 additions and 13 deletions

View File

@@ -50,6 +50,7 @@ services:
- 4400:4400 - 4400:4400
- 4401:4401 - 4401:4401
- 4402:4402 - 4402:4402
- 4403:4403
# Plugins # Plugins
- 4200:4200 - 4200:4200

View File

@@ -27,6 +27,7 @@
[app.main.data.workspace.media :as dwm] [app.main.data.workspace.media :as dwm]
[app.main.data.workspace.selection :as dws] [app.main.data.workspace.selection :as dws]
[app.main.data.workspace.wasm-text :as dwwt] [app.main.data.workspace.wasm-text :as dwwt]
[app.main.features :as features]
[app.main.fonts :refer [fetch-font-css]] [app.main.fonts :refer [fetch-font-css]]
[app.main.router :as rt] [app.main.router :as rt]
[app.main.store :as st] [app.main.store :as st]
@@ -365,8 +366,10 @@
(cb/add-object shape))] (cb/add-object shape))]
(st/emit! (ch/commit-changes changes) (st/emit! (ch/commit-changes changes)
(se/event plugin-id "create-shape" :type :text) (se/event plugin-id "create-shape" :type :text))
(dwwt/resize-wasm-text-debounce (:id shape)))
(when (features/active-feature? @st/state "render-wasm/v1")
(st/emit! (dwwt/resize-wasm-text-debounce (:id shape))))
(shape/shape-proxy plugin-id (:id shape))))) (shape/shape-proxy plugin-id (:id shape)))))

View File

@@ -1305,7 +1305,8 @@
tokens)))} tokens)))}
:applyToken :applyToken
{:schema [:tuple {:enumerable false
:schema [:tuple
[:fn token-proxy?] [:fn token-proxy?]
[:maybe [:set [:and ::sm/keyword [:fn cto/token-attr?]]]]] [:maybe [:set [:and ::sm/keyword [:fn cto/token-attr?]]]]]
:fn (fn [token attrs] :fn (fn [token attrs]

View File

@@ -144,14 +144,16 @@
(st/emit! (dwtl/delete-token set-id id))) (st/emit! (dwtl/delete-token set-id id)))
:applyToShapes :applyToShapes
{:schema [:tuple {:enumerable false
:schema [:tuple
[:vector [:fn shape-proxy?]] [:vector [:fn shape-proxy?]]
[:maybe [:set [:and ::sm/keyword [:fn cto/token-attr?]]]]] [:maybe [:set [:and ::sm/keyword [:fn cto/token-attr?]]]]]
:fn (fn [shapes attrs] :fn (fn [shapes attrs]
(apply-token-to-shapes file-id set-id id (map #(obj/get % "$id") shapes) attrs))} (apply-token-to-shapes file-id set-id id (map #(obj/get % "$id") shapes) attrs))}
:applyToSelected :applyToSelected
{:schema [:tuple [:maybe [:set [:and ::sm/keyword [:fn cto/token-attr?]]]]] {:enumerable false
:schema [:tuple [:maybe [:set [:and ::sm/keyword [:fn cto/token-attr?]]]]]
:fn (fn [attrs] :fn (fn [attrs]
(let [selected (get-in @st/state [:workspace-local :selected])] (let [selected (get-in @st/state [:workspace-local :selected])]
(apply-token-to-shapes file-id set-id id selected attrs)))})) (apply-token-to-shapes file-id set-id id selected attrs)))}))
@@ -236,14 +238,16 @@
(apply array))))} (apply array))))}
:getTokenById :getTokenById
{:schema [:tuple ::sm/uuid] {:enumerable false
:schema [:tuple ::sm/uuid]
:fn (fn [token-id] :fn (fn [token-id]
(let [token (u/locate-token file-id id token-id)] (let [token (u/locate-token file-id id token-id)]
(when (some? token) (when (some? token)
(token-proxy plugin-id file-id id token-id))))} (token-proxy plugin-id file-id id token-id))))}
:addToken :addToken
{:schema (fn [args] {:enumerable false
:schema (fn [args]
[:tuple (-> (cfo/make-token-schema [:tuple (-> (cfo/make-token-schema
(-> (u/locate-tokens-lib file-id) (ctob/get-tokens id)) (-> (u/locate-tokens-lib file-id) (ctob/get-tokens id))
(cto/dtcg-token-type->token-type (-> args (first) (get "type")))) (cto/dtcg-token-type->token-type (-> args (first) (get "type"))))
@@ -353,13 +357,15 @@
{:this true :get (fn [_])} {:this true :get (fn [_])}
:addSet :addSet
{:schema [:tuple [:fn token-set-proxy?]] {:enumerable false
:schema [:tuple [:fn token-set-proxy?]]
:fn (fn [token-set] :fn (fn [token-set]
(let [theme (u/locate-token-theme file-id id)] (let [theme (u/locate-token-theme file-id id)]
(st/emit! (dwtl/update-token-theme id (ctob/enable-set theme (obj/get token-set :name))))))} (st/emit! (dwtl/update-token-theme id (ctob/enable-set theme (obj/get token-set :name))))))}
:removeSet :removeSet
{:schema [:tuple [:fn token-set-proxy?]] {:enumerable false
:schema [:tuple [:fn token-set-proxy?]]
:fn (fn [token-set] :fn (fn [token-set]
(let [theme (u/locate-token-theme file-id id)] (let [theme (u/locate-token-theme file-id id)]
(st/emit! (dwtl/update-token-theme id (ctob/disable-set theme (obj/get token-set :name))))))} (st/emit! (dwtl/update-token-theme id (ctob/disable-set theme (obj/get token-set :name))))))}
@@ -406,7 +412,8 @@
(apply array (map #(token-set-proxy plugin-id file-id (ctob/get-id %)) sets))))} (apply array (map #(token-set-proxy plugin-id file-id (ctob/get-id %)) sets))))}
:addTheme :addTheme
{:schema (fn [attrs] {:enumerable false
:schema (fn [attrs]
[:tuple (-> (sm/schema (cfo/make-token-theme-schema [:tuple (-> (sm/schema (cfo/make-token-theme-schema
(u/locate-tokens-lib file-id) (u/locate-tokens-lib file-id)
(or (obj/get attrs "group") "") (or (obj/get attrs "group") "")
@@ -419,7 +426,8 @@
(token-theme-proxy plugin-id file-id (:id theme))))} (token-theme-proxy plugin-id file-id (:id theme))))}
:addSet :addSet
{:schema [:tuple (-> (sm/schema (cfo/make-token-set-schema {:enumerable false
:schema [:tuple (-> (sm/schema (cfo/make-token-set-schema
(u/locate-tokens-lib file-id) (u/locate-tokens-lib file-id)
nil)) nil))
(sm/dissoc-key :id))] ;; We don't allow plugins to set the id (sm/dissoc-key :id))] ;; We don't allow plugins to set the id
@@ -431,14 +439,16 @@
(token-set-proxy plugin-id file-id (ctob/get-id set))))} (token-set-proxy plugin-id file-id (ctob/get-id set))))}
:getThemeById :getThemeById
{:schema [:tuple ::sm/uuid] {:enumerable false
:schema [:tuple ::sm/uuid]
:fn (fn [theme-id] :fn (fn [theme-id]
(let [theme (u/locate-token-theme file-id theme-id)] (let [theme (u/locate-token-theme file-id theme-id)]
(when (some? theme) (when (some? theme)
(token-theme-proxy plugin-id file-id theme-id))))} (token-theme-proxy plugin-id file-id theme-id))))}
:getSetById :getSetById
{:schema [:tuple ::sm/uuid] {:enumerable false
:schema [:tuple ::sm/uuid]
:fn (fn [set-id] :fn (fn [set-id]
(let [set (u/locate-token-set file-id set-id)] (let [set (u/locate-token-set file-id set-id)]
(when (some? set) (when (some? set)