diff --git a/common/src/app/common/files/comp_processors.cljc b/common/src/app/common/files/comp_processors.cljc index 5900fd6e03..fb46ff1c66 100644 --- a/common/src/app/common/files/comp_processors.cljc +++ b/common/src/app/common/files/comp_processors.cljc @@ -409,7 +409,7 @@ (vary-meta assoc ::deferred-swaps true)))) (def ^:private legacy-text-groups - #{:text-content-attribute :text-content-structure}) + #{:text-content-attribute :text-content-structure :text-content-structure-same-attrs}) (defn legacy-text-touched? "Whether `shape` holds the text override groups of files older than the @@ -452,7 +452,8 @@ "Store the text overrides of the file's copies per letters and per style. Files older than the feature components/text-overrides mark a copy text with `:text-content-attribute` (any style) and `:text-content-structure` - (the number of paragraphs or runs); now it holds `:text-content-text` and + (the number of paragraphs or runs, with `:text-content-structure-same-attrs` + when the styles were uniform); now it holds `:text-content-text` and one group per style unit (`cttx/style-units`). Older files still mark it with `:content-group` alone, which allows every group. Each copy text with the old groups is compared with its near main, and takes the groups the diff --git a/common/test/common_tests/files/convert_text_overrides_test.cljc b/common/test/common_tests/files/convert_text_overrides_test.cljc index f26935202a..3c9cb72de5 100644 --- a/common/test/common_tests/files/convert_text_overrides_test.cljc +++ b/common/test/common_tests/files/convert_text_overrides_test.cljc @@ -63,6 +63,21 @@ (convert) (touched :copy-child))))) +(t/deftest the-uniform-structure-flag-goes-with-the-others + ;; older files mark a structure change of a uniform text with + ;; `:text-content-structure-same-attrs` too + (t/is (= #{:content-group :text-content-text} + (-> (old-copy [[["Price:"] ["$10" {:weight 700}]]] + #{:content-group :text-content-structure :text-content-structure-same-attrs}) + (convert) + (touched :copy-child)))) + (t/testing "it goes without the structure flag as well" + (t/is (= #{:content-group :text-content-text} + (-> (old-copy [[["Price:"] ["$10" {:weight 700}]]] + #{:content-group :text-content-text :text-content-structure-same-attrs}) + (convert) + (touched :copy-child)))))) + (t/deftest an-old-flag-where-nothing-differs-sets-nothing (t/is (= #{:fill-group} (-> (old-copy main #{:content-group :text-content-attribute :fill-group}) diff --git a/common/test/common_tests/files/repair_components_test.cljc b/common/test/common_tests/files/repair_components_test.cljc index 677ef27558..f00ca3eb03 100644 --- a/common/test/common_tests/files/repair_components_test.cljc +++ b/common/test/common_tests/files/repair_components_test.cljc @@ -369,7 +369,13 @@ #{:content-group :text-content-attribute}))] (t/is (= #{:legacy-text-touched} found)) (t/is (nil? errors)) - (t/is (empty? (:touched (ths/get-shape file' :copy-child)))))) + (t/is (empty? (:touched (ths/get-shape file' :copy-child))))) + (t/testing "the uniform structure flag is an old flag too" + (let [[found file' errors] (repair (ths/update-shape (simple) :copy-child :touched + #{:content-group :text-content-structure-same-attrs}))] + (t/is (= #{:legacy-text-touched} found)) + (t/is (nil? errors)) + (t/is (empty? (:touched (ths/get-shape file' :copy-child))))))) ;; ---- Nesting