0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-01-24 15:39:50 -05:00

Merge pull request #2626 from penpot/superalex-fix-paste-svg-leads-to-internal-server-error

🐛 Fix paste svg leads to internal server error
This commit is contained in:
Andrey Antukh 2022-12-01 14:29:33 +01:00 committed by GitHub
commit ca7ebdcc8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

View file

@ -283,12 +283,17 @@
x (:x data (- vbc-x (/ width 2))) x (:x data (- vbc-x (/ width 2)))
y (:y data (- vbc-y (/ height 2))) y (:y data (- vbc-y (/ height 2)))
page-id (:current-page-id state) page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)
frame-id (-> (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})) (ctst/top-nested-frame {:x frame-x :y frame-y}))
selected (wsh/lookup-selected state)
page-objects (wsh/lookup-page-objects state) page-objects (wsh/lookup-page-objects state)
page-selected (wsh/lookup-selected state) base (cph/get-base-shape page-objects selected)
base (cph/get-base-shape page-objects page-selected) selected-frame? (and (= 1 (count selected))
parent-id (:parent-id base) (= :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) shape (-> (cts/make-minimal-shape type)
(merge data) (merge data)

View file

@ -442,9 +442,13 @@
selected (wsh/lookup-selected state) selected (wsh/lookup-selected state)
page-objects (wsh/lookup-page-objects state) page-objects (wsh/lookup-page-objects state)
page-selected (wsh/lookup-selected state) base (cph/get-base-shape page-objects selected)
base (cph/get-base-shape page-objects page-selected) selected-frame? (and (= 1 (count selected))
parent-id (:parent-id base) (= :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) [vb-x vb-y vb-width vb-height] (svg-dimensions svg-data)
x (- x vb-x (/ vb-width 2)) x (- x vb-x (/ vb-width 2))