From bebdc78ce6d34b38058f2badfd6f0523115185e3 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Thu, 25 Apr 2024 15:35:53 +0200 Subject: [PATCH 1/2] :bug: Fix problem with exporter texts --- frontend/src/app/main/ui/shapes/export.cljs | 6 +++++- frontend/src/app/main/ui/shapes/shape.cljs | 7 +++++++ frontend/src/app/worker/import/parser.cljs | 20 ++++++++++++++++---- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/main/ui/shapes/export.cljs b/frontend/src/app/main/ui/shapes/export.cljs index d10378e19..8ac2387e8 100644 --- a/frontend/src/app/main/ui/shapes/export.cljs +++ b/frontend/src/app/main/ui/shapes/export.cljs @@ -122,7 +122,11 @@ (add! :stroke-cap-end))) (cond-> text? - (-> (add! :grow-type) + (-> (add! :x) + (add! :y) + (add! :width) + (add! :height) + (add! :grow-type) (add! :content (comp json/encode uuid->string)) (add! :position-data (comp json/encode uuid->string)))) diff --git a/frontend/src/app/main/ui/shapes/shape.cljs b/frontend/src/app/main/ui/shapes/shape.cljs index cbda63671..e0ab37c45 100644 --- a/frontend/src/app/main/ui/shapes/shape.cljs +++ b/frontend/src/app/main/ui/shapes/shape.cljs @@ -94,6 +94,13 @@ (obj/unset! "disable-shadows?") (obj/set! "ref" ref) (obj/set! "id" (dm/fmt "shape-%" shape-id)) + + ;; TODO: This is added for backward compatibility. + (cond-> (and (cfh/text-shape? shape) (empty? (:position-data shape))) + (-> (obj/set! "x" (:x shape)) + (obj/set! "y" (:y shape)) + (obj/set! "width" (:width shape)) + (obj/set! "height" (:height shape)))) (obj/set! "style" styles)) wrapper-props diff --git a/frontend/src/app/worker/import/parser.cljs b/frontend/src/app/worker/import/parser.cljs index a0da1e60d..fab4075ca 100644 --- a/frontend/src/app/worker/import/parser.cljs +++ b/frontend/src/app/worker/import/parser.cljs @@ -272,9 +272,21 @@ (def has-position? #{:frame :rect :image :text}) (defn parse-position - [props svg-data] - (let [values (->> (select-keys svg-data [:x :y :width :height]) - (d/mapm (fn [_ val] (d/parse-double val))))] + [props node svg-data] + (let [x (get-meta node :x d/parse-double) + y (get-meta node :y d/parse-double) + width (get-meta node :width d/parse-double) + height (get-meta node :height d/parse-double) + + values (->> (select-keys svg-data [:x :y :width :height]) + (d/mapm (fn [_ val] (d/parse-double val)))) + + values + (cond-> values + (some? x) (assoc :x x) + (some? y) (assoc :y y) + (some? width) (assoc :width width) + (some? height) (assoc :height height))] (d/merge props values))) (defn parse-circle @@ -392,7 +404,7 @@ center (gpt/point center-x center-y)] (cond-> props (has-position? type) - (parse-position svg-data) + (parse-position node svg-data) (= type :svg-raw) (add-svg-position node) From 3a71068a4868d4a76132fb7501dab1a7b93c0e56 Mon Sep 17 00:00:00 2001 From: "alonso.torres" Date: Fri, 26 Apr 2024 12:16:05 +0200 Subject: [PATCH 2/2] :bug: Add warning when font cannot be found --- frontend/src/app/main/fonts.cljs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/frontend/src/app/main/fonts.cljs b/frontend/src/app/main/fonts.cljs index a17201124..31949e7fe 100644 --- a/frontend/src/app/main/fonts.cljs +++ b/frontend/src/app/main/fonts.cljs @@ -133,7 +133,10 @@ (defn- fetch-gfont-css [url] (->> (http/send! {:method :get :uri url :mode :cors :response-type :text}) - (rx/map :body))) + (rx/map :body) + (rx/catch (fn [err] + (.warn js/console "Cannot find the font" (obj/get err "message")) + (rx/empty))))) (defmethod load-font :google [{:keys [id ::on-loaded] :as font}]