From 87d917bc2efec936f56804107ca15a4e96a75306 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Fri, 30 May 2025 11:30:01 +0200 Subject: [PATCH 1/2] :recycle: Deprecate old image type --- common/src/app/common/files/migrations.cljc | 23 ++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/common/src/app/common/files/migrations.cljc b/common/src/app/common/files/migrations.cljc index 282bfa6c6a..bdb7e8852b 100644 --- a/common/src/app/common/files/migrations.cljc +++ b/common/src/app/common/files/migrations.cljc @@ -1354,6 +1354,26 @@ (update data :pages-index d/update-vals update-page))) +(defmethod migrate-data "0005-deprecate-image-type" + [data _] + (letfn [(update-object [object] + (if (cfh/image-shape? object) + (let [metadata (:metadata object) + fills (into [{:fill-image (assoc metadata :keep-aspect-ratio false) + :opacity 1}] + (:fills object))] + (-> object + (assoc :fills fills) + (dissoc :metadata) + (assoc :type :rect))) + object)) + + (update-container [container] + (d/update-when container :objects update-vals update-object))] + + (-> data + (update :pages-index d/update-vals update-container) + (d/update-when :components d/update-vals update-container)))) (def available-migrations (into (d/ordered-set) @@ -1414,4 +1434,5 @@ "0002-clean-shape-interactions" "0003-fix-root-shape" "0003-convert-path-content" - "0004-add-partial-text-touched-flags"])) + "0004-add-partial-text-touched-flags" + "0005-deprecate-image-type"])) From cd02905d1f7e89888f66abb51a5dd0659560a654 Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Fri, 30 May 2025 12:11:55 +0200 Subject: [PATCH 2/2] :recycle: Migrate old fill text attributes --- common/src/app/common/files/migrations.cljc | 35 ++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/common/src/app/common/files/migrations.cljc b/common/src/app/common/files/migrations.cljc index bdb7e8852b..a912b46c0a 100644 --- a/common/src/app/common/files/migrations.cljc +++ b/common/src/app/common/files/migrations.cljc @@ -1375,6 +1375,38 @@ (update :pages-index d/update-vals update-container) (d/update-when :components d/update-vals update-container)))) +(defmethod migrate-data "0006-fix-old-texts-fills" + [data _] + (letfn [(fix-fills [node] + (let [fills (cond + (or (some? (:fill-color node)) + (some? (:fill-opacity node)) + (some? (:fill-color-gradient node))) + [(d/without-nils (select-keys node [:fill-color :fill-opacity :fill-color-gradient + :fill-color-ref-id :fill-color-ref-file]))] + + (nil? (:fills node)) + [{:fill-color "#000000" :fill-opacity 1}] + + :else + (:fills node))] + (-> node + (assoc :fills fills) + (dissoc :fill-color :fill-opacity :fill-color-gradient + :fill-color-ref-id :fill-color-ref-file)))) + + (update-object [object] + (if (cfh/text-shape? object) + (update object :content (partial txt/transform-nodes identity fix-fills)) + object)) + + (update-container [container] + (d/update-when container :objects d/update-vals update-object))] + + (-> data + (update :pages-index d/update-vals update-container) + (d/update-when :components d/update-vals update-container)))) + (def available-migrations (into (d/ordered-set) ["legacy-2" @@ -1435,4 +1467,5 @@ "0003-fix-root-shape" "0003-convert-path-content" "0004-add-partial-text-touched-flags" - "0005-deprecate-image-type"])) + "0005-deprecate-image-type" + "0006-fix-old-texts-fills"]))