From b262e6a46ff2199cf269b3ee8b9e3b119af15098 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 30 Jul 2025 11:44:07 +0200 Subject: [PATCH 1/3] :bug: Fix incorrect condition on checking text shape attrs --- common/src/app/common/logic/shapes.cljc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/common/src/app/common/logic/shapes.cljc b/common/src/app/common/logic/shapes.cljc index 1f41a71c54..69d0a456b2 100644 --- a/common/src/app/common/logic/shapes.cljc +++ b/common/src/app/common/logic/shapes.cljc @@ -36,11 +36,12 @@ text-changed-attrs (fn [shape] (let [new-shape (get new-objects (:id shape)) - attrs (ctt/get-diff-attrs (:content shape) (:content new-shape)) + attrs (ctt/get-diff-attrs (:content shape) (:content new-shape)) + ;; Unapply token when applying typography asset style - attrs (if (set/intersection text-typography-attrs attrs) - (into attrs cto/typography-keys) - attrs)] + attrs (if (seq (set/intersection text-typography-attrs attrs)) + (into attrs cto/typography-keys) + attrs)] (apply set/union (map cto/shape-attr->token-attrs attrs)))) check-attr (fn [shape changes attr] From e1c5a32fcb71ed2a2b95a42944661d9a4d1ece0d Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 30 Jul 2025 11:45:19 +0200 Subject: [PATCH 2/3] :lipstick: Fix indentation style on generate-unapply-tokens --- common/src/app/common/logic/shapes.cljc | 45 ++++++++++++++----------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/common/src/app/common/logic/shapes.cljc b/common/src/app/common/logic/shapes.cljc index 69d0a456b2..6a15a5fe9d 100644 --- a/common/src/app/common/logic/shapes.cljc +++ b/common/src/app/common/logic/shapes.cljc @@ -7,6 +7,7 @@ (ns app.common.logic.shapes (:require [app.common.data :as d] + [app.common.data.macros :as dm] [app.common.files.changes-builder :as pcb] [app.common.files.helpers :as cfh] [app.common.geom.shapes :as gsh] @@ -26,7 +27,7 @@ (defn- generate-unapply-tokens "When updating attributes that have a token applied, we must unapply it, because the value - of the attribute now has been given directly, and does not come from the token. + of the attribute now has been given directly, and does not come from the token. When applying a typography asset style we also unapply any typographic tokens." [changes objects changed-sub-attr] (let [new-objects (pcb/get-objects changes) @@ -44,26 +45,30 @@ attrs)] (apply set/union (map cto/shape-attr->token-attrs attrs)))) - check-attr (fn [shape changes attr] - (let [tokens (get shape :applied-tokens {}) - token-attrs (if (or (not= (:type shape) :text) (not= attr :content)) - (cto/shape-attr->token-attrs attr changed-sub-attr) - (text-changed-attrs shape))] - (if (some #(contains? tokens %) token-attrs) - (pcb/update-shapes changes [(:id shape)] #(cto/unapply-token-id % token-attrs)) - changes))) + check-attr + (fn [shape changes attr] + (let [shape-id (dm/get-prop shape :id) + tokens (get shape :applied-tokens {}) + token-attrs (if (and (cfh/text-shape? shape) (= attr :content)) + (text-changed-attrs shape) + (cto/shape-attr->token-attrs attr changed-sub-attr))] - check-shape (fn [changes mod-obj-change] - (let [shape (get objects (:id mod-obj-change)) - xf (comp (filter #(= (:type %) :set)) - (map :attr)) - attrs (into [] xf (:operations mod-obj-change))] - (reduce (partial check-attr shape) - changes - attrs)))] - (reduce check-shape - changes - mod-obj-changes))) + (if (some #(contains? tokens %) token-attrs) + (pcb/update-shapes changes [shape-id] #(cto/unapply-token-id % token-attrs)) + changes))) + + check-shape + (fn [changes mod-obj-change] + (let [shape (get objects (:id mod-obj-change)) + attrs (into [] + (comp (filter #(= (:type %) :set)) + (map :attr)) + (:operations mod-obj-change))] + (reduce (partial check-attr shape) + changes + attrs)))] + + (reduce check-shape changes mod-obj-changes))) (defn generate-update-shapes [changes ids update-fn objects {:keys [attrs changed-sub-attr ignore-tree ignore-touched with-objects?]}] From 7fde1436e1d5de3dc596cfbee8959807cba560c6 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Wed, 30 Jul 2025 11:45:39 +0200 Subject: [PATCH 3/3] :bug: Add missing styles to the empty node on editor-v1 --- common/src/app/common/text.cljc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/src/app/common/text.cljc b/common/src/app/common/text.cljc index 469fda6eb3..8493bd2c05 100644 --- a/common/src/app/common/text.cljc +++ b/common/src/app/common/text.cljc @@ -292,7 +292,7 @@ (fix-gradients) (assoc :text text)))) - (split-texts [text styles] + (split-texts [text styles data] (let [cpoints (text->code-points text) children (->> (parse-draft-styles styles) (build-style-index (count cpoints)) @@ -301,7 +301,7 @@ (mapv #(extract-text cpoints %)))] (cond-> children (empty? children) - (conj {:text ""})))) + (conj (assoc data :text ""))))) (build-paragraph [block] (let [key (get block :key) @@ -312,7 +312,7 @@ (-> data (assoc :key key) (assoc :type "paragraph") - (assoc :children (split-texts text styles)))))] + (assoc :children (split-texts text styles data)))))] {:type "root" :children