🐛 Keep shape level groups for token sync later

This commit is contained in:
Andrés Moya 2025-07-23 10:54:30 +02:00 committed by Andrés Moya
parent 9fdc6be465
commit f55e7d8165

View File

@ -518,19 +518,31 @@
;; --- SHAPE UPDATE ;; --- SHAPE UPDATE
(defn- get-token-groups (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] [shape new-applied-tokens]
(let [old-applied-tokens (d/nilv (:applied-tokens shape) #{}) (let [old-applied-tokens (d/nilv (:applied-tokens shape) #{})
changed-token-attrs (filter #(not= (get old-applied-tokens %) (get new-applied-tokens %)) changed-token-attrs (filter #(not= (get old-applied-tokens %) (get new-applied-tokens %))
ctt/all-keys) ctt/all-keys)
text-shape? (= (:type shape) :text) text-shape? (= (:type shape) :text)
changed-groups (into #{} attrs-in-text-content? (some #(ctt/attrs-in-text-content %)
(comp (mapcat #(if (and text-shape? (ctt/attrs-in-text-content %)) changed-token-attrs)
[:content-group :text-content-attribute]
[(->> % changed-groups (into #{}
(ctt/token-attr->shape-attr) (comp (map ctt/token-attr->shape-attr)
(get ctk/sync-attrs))])) (map #(get ctk/sync-attrs %))
(filter some?)) (filter some?))
changed-token-attrs)] 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)) changed-groups))
(defn set-shape-attr (defn set-shape-attr