From 92403f2afed6ca5b83d8d698e661600077fdc37f Mon Sep 17 00:00:00 2001 From: Alejandro Alonso Date: Thu, 1 Dec 2022 14:25:35 +0100 Subject: [PATCH] :bug: Fix paste svg leads to internal server error --- frontend/src/app/main/data/workspace/shapes.cljs | 11 ++++++++--- frontend/src/app/main/data/workspace/svg_upload.cljs | 10 +++++++--- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/frontend/src/app/main/data/workspace/shapes.cljs b/frontend/src/app/main/data/workspace/shapes.cljs index eddf9155e..e3bfa7272 100644 --- a/frontend/src/app/main/data/workspace/shapes.cljs +++ b/frontend/src/app/main/data/workspace/shapes.cljs @@ -283,12 +283,17 @@ x (:x data (- vbc-x (/ width 2))) y (:y data (- vbc-y (/ height 2))) page-id (:current-page-id state) + objects (wsh/lookup-page-objects state page-id) frame-id (-> (wsh/lookup-page-objects state page-id) (ctst/top-nested-frame {:x frame-x :y frame-y})) + selected (wsh/lookup-selected state) page-objects (wsh/lookup-page-objects state) - page-selected (wsh/lookup-selected state) - base (cph/get-base-shape page-objects page-selected) - parent-id (:parent-id base) + base (cph/get-base-shape page-objects selected) + selected-frame? (and (= 1 (count selected)) + (= :frame (get-in objects [(first selected) :type]))) + parent-id (if + (or selected-frame? (empty? selected)) frame-id + (:parent-id base)) shape (-> (cts/make-minimal-shape type) (merge data) diff --git a/frontend/src/app/main/data/workspace/svg_upload.cljs b/frontend/src/app/main/data/workspace/svg_upload.cljs index d2004bf86..869f39416 100644 --- a/frontend/src/app/main/data/workspace/svg_upload.cljs +++ b/frontend/src/app/main/data/workspace/svg_upload.cljs @@ -442,9 +442,13 @@ selected (wsh/lookup-selected state) page-objects (wsh/lookup-page-objects state) - page-selected (wsh/lookup-selected state) - base (cph/get-base-shape page-objects page-selected) - parent-id (:parent-id base) + base (cph/get-base-shape page-objects selected) + selected-frame? (and (= 1 (count selected)) + (= :frame (get-in objects [(first selected) :type]))) + + parent-id (if + (or selected-frame? (empty? selected)) frame-id + (:parent-id base)) [vb-x vb-y vb-width vb-height] (svg-dimensions svg-data) x (- x vb-x (/ vb-width 2))