From 08a9371322f1f64a63de26830b456dc05b5c3256 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 28 Oct 2024 15:37:30 +0100 Subject: [PATCH 1/3] :bug: Use proper ::sm/int schema type on color and shape schemas --- common/src/app/common/types/color.cljc | 4 ++-- common/src/app/common/types/shape.cljc | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/common/src/app/common/types/color.cljc b/common/src/app/common/types/color.cljc index fd20b0330..ab50f4be0 100644 --- a/common/src/app/common/types/color.cljc +++ b/common/src/app/common/types/color.cljc @@ -56,8 +56,8 @@ (def schema:image-color [:map {:title "ImageColor"} [:name {:optional true} :string] - [:width :int] - [:height :int] + [:width ::sm/int] + [:height ::sm/int] [:mtype {:optional true} [:maybe :string]] [:id ::sm/uuid] [:keep-aspect-ratio {:optional true} :boolean]]) diff --git a/common/src/app/common/types/shape.cljc b/common/src/app/common/types/shape.cljc index 4ede3a641..5dfa9a016 100644 --- a/common/src/app/common/types/shape.cljc +++ b/common/src/app/common/types/shape.cljc @@ -224,8 +224,8 @@ [:map {:title "ImageAttrs"} [:metadata [:map - [:width {:gen/gen (sg/small-int :min 1)} :int] - [:height {:gen/gen (sg/small-int :min 1)} :int] + [:width {:gen/gen (sg/small-int :min 1)} ::sm/int] + [:height {:gen/gen (sg/small-int :min 1)} ::sm/int] [:mtype {:optional true :gen/gen (sg/elements ["image/jpeg" "image/png"])} From 6b817d102b4c2454b0af7d2f9b56f9652bb00a18 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 28 Oct 2024 15:38:17 +0100 Subject: [PATCH 2/3] :bug: Add migration for a fix of invalid fills --- common/src/app/common/files/defaults.cljc | 2 +- common/src/app/common/files/migrations.cljc | 30 ++++++++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/common/src/app/common/files/defaults.cljc b/common/src/app/common/files/defaults.cljc index fb70a81ee..7628d9469 100644 --- a/common/src/app/common/files/defaults.cljc +++ b/common/src/app/common/files/defaults.cljc @@ -6,4 +6,4 @@ (ns app.common.files.defaults) -(def version 55) +(def version 56) diff --git a/common/src/app/common/files/migrations.cljc b/common/src/app/common/files/migrations.cljc index 2b6c4b450..a2e2b5f55 100644 --- a/common/src/app/common/files/migrations.cljc +++ b/common/src/app/common/files/migrations.cljc @@ -1075,6 +1075,33 @@ (update data :pages-index d/update-vals update-page))) +(defn migrate-up-56 + [data] + (letfn [(fix-fills [object] + (d/update-when object :fills (partial filterv valid-fill?))) + + (update-object [object] + (-> object + (fix-fills) + + ;; If shape contains shape-ref but has a nil value, we + ;; should remove it from shape object + (cond-> (and (contains? object :shape-ref) + (nil? (get object :shape-ref))) + (dissoc :shape-ref)) + + ;; The text shape also can has fills on the text + ;; fragments so we need to fix fills there + (cond-> (cfh/text-shape? object) + (update :content (partial txt/transform-nodes identity fix-fills))))) + + (update-container [container] + (d/update-when container :objects update-vals update-object))] + + (-> data + (update :pages-index update-vals update-container) + (update :components update-vals update-container)))) + (def migrations "A vector of all applicable migrations" [{:id 2 :migrate-up migrate-up-2} @@ -1121,4 +1148,5 @@ {:id 52 :migrate-up migrate-up-52} {:id 53 :migrate-up migrate-up-26} {:id 54 :migrate-up migrate-up-54} - {:id 55 :migrate-up migrate-up-55}]) + {:id 55 :migrate-up migrate-up-55} + {:id 56 :migrate-up migrate-up-56}]) From d9310d651ab5bb2766b15ec7fbefee837dab49b7 Mon Sep 17 00:00:00 2001 From: Andrey Antukh Date: Mon, 28 Oct 2024 18:21:02 +0100 Subject: [PATCH 3/3] :bug: Fix exception on adding animation to an interraction Happens when an animation is added to a just created interaction and then changed to other animation type. Bug is caused by missing dependency on react handlers. --- .../sidebar/options/menus/interactions.cljs | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/frontend/src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs b/frontend/src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs index 4949433e2..bf215b4a0 100644 --- a/frontend/src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs +++ b/frontend/src/app/main/ui/workspace/sidebar/options/menus/interactions.cljs @@ -226,27 +226,27 @@ change-event-type (mf/use-fn - (mf/deps index) + (mf/deps index update-interaction) (fn [event] (let [value (keyword event)] (update-interaction index #(ctsi/set-event-type % value shape))))) change-action-type (mf/use-fn - (mf/deps index) + (mf/deps index update-interaction) (fn [event] (let [value (keyword event)] (update-interaction index #(ctsi/set-action-type % value))))) change-delay (mf/use-fn - (mf/deps index) + (mf/deps index update-interaction) (fn [value] (update-interaction index #(ctsi/set-delay % value)))) change-destination (mf/use-fn - (mf/deps index) + (mf/deps index update-interaction) (fn [event] (let [value event value (when (not= value "") (uuid/uuid value))] @@ -254,21 +254,21 @@ change-position-relative-to (mf/use-fn - (mf/deps index) + (mf/deps index update-interaction) (fn [event] (let [value (uuid/uuid event)] (update-interaction index #(ctsi/set-position-relative-to % value))))) change-preserve-scroll (mf/use-fn - (mf/deps index) + (mf/deps index update-interaction) (fn [event] (let [value (-> event dom/get-target dom/checked?)] (update-interaction index #(ctsi/set-preserve-scroll % value))))) change-url (mf/use-fn - (mf/deps index) + (mf/deps index update-interaction) (fn [event] (let [target (dom/get-target event) value (dom/get-value target) @@ -287,7 +287,7 @@ change-overlay-pos-type (mf/use-fn - (mf/deps shape) + (mf/deps shape update-interaction) (fn [value] (let [shape-id (:id shape)] (update-interaction index #(ctsi/set-overlay-pos-type % value shape objects)) @@ -296,7 +296,7 @@ toggle-overlay-pos-type (mf/use-fn - (mf/deps index) + (mf/deps index update-interaction) (fn [event] (let [pos-type (-> (dom/get-current-target event) (dom/get-data "value") @@ -305,21 +305,21 @@ change-close-click-outside (mf/use-fn - (mf/deps index) + (mf/deps index update-interaction) (fn [event] (let [value (-> event dom/get-target dom/checked?)] (update-interaction index #(ctsi/set-close-click-outside % value))))) change-background-overlay (mf/use-fn - (mf/deps index) + (mf/deps index update-interaction) (fn [event] (let [value (-> event dom/get-target dom/checked?)] (update-interaction index #(ctsi/set-background-overlay % value))))) change-animation-type (mf/use-fn - (mf/deps index) + (mf/deps index update-interaction) (fn [event] (let [value (if (= "" event) nil @@ -327,33 +327,35 @@ (update-interaction index #(ctsi/set-animation-type % value))))) change-duration - (mf/use-fn (fn [value] - (update-interaction index #(ctsi/set-duration % value)))) + (mf/use-fn + (mf/deps index update-interaction) + (fn [value] + (update-interaction index #(ctsi/set-duration % value)))) change-easing (mf/use-fn - (mf/deps index) + (mf/deps index update-interaction) (fn [event] (let [value (keyword event)] (update-interaction index #(ctsi/set-easing % value))))) change-way (mf/use-fn - (mf/deps index) + (mf/deps index update-interaction) (fn [event] (let [value (keyword event)] (update-interaction index #(ctsi/set-way % value))))) change-direction (mf/use-fn - (mf/deps index) + (mf/deps index update-interaction) (fn [event] (let [value (keyword event)] (update-interaction index #(ctsi/set-direction % value))))) change-offset-effect (mf/use-fn - (mf/deps index) + (mf/deps index update-interaction) (fn [event] (let [value (-> event dom/get-target dom/checked?)] (update-interaction index #(ctsi/set-offset-effect % value)))))