From f55e7d81652fb7d6624d9ffc99212c548bd39552 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Moya?= Date: Wed, 23 Jul 2025 10:54:30 +0200 Subject: [PATCH] :bug: Keep shape level groups for token sync later --- common/src/app/common/types/container.cljc | 36 ++++++++++++++-------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/common/src/app/common/types/container.cljc b/common/src/app/common/types/container.cljc index fa1e506906..c231ba222c 100644 --- a/common/src/app/common/types/container.cljc +++ b/common/src/app/common/types/container.cljc @@ -518,19 +518,31 @@ ;; --- SHAPE UPDATE (defn- get-token-groups + "Get the sync attrs groups that are affected by changes in applied tokens. + + If any token has been applied or unapplied in the shape, calculate the corresponding + attributes and get the groups. If some of the attributes are to be applied in the + content nodes of a text shape, also return the content groups (only for attributes, + so the text is not touched)." [shape new-applied-tokens] - (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 (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)] + (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) + attrs-in-text-content? (some #(ctt/attrs-in-text-content %) + changed-token-attrs) + + changed-groups (into #{} + (comp (map ctt/token-attr->shape-attr) + (map #(get ctk/sync-attrs %)) + (filter some?)) + changed-token-attrs) + + changed-groups (if (and text-shape? + (d/not-empty? changed-groups) + attrs-in-text-content?) + (conj changed-groups :content-group :text-content-attribute) + changed-groups)] changed-groups)) (defn set-shape-attr