🐛 Fix problem when copy/pasting shapes

This commit is contained in:
alonso.torres 2023-03-24 15:09:40 +01:00
parent 26aec7d129
commit f11c782c0f
2 changed files with 12 additions and 6 deletions

View file

@ -1326,14 +1326,19 @@
res)))
(maybe-translate [shape objects selected+children]
(let [root-frame-id (cph/get-shape-id-root-frame objects (:id shape))]
(if (and (not (cph/root-frame? shape))
(not (contains? selected+children root-frame-id)))
;; When the parent frame is not selected we change to relative
;; coordinates
(let [frame-id (:frame-id shape)
root-frame-id (cph/get-shape-id-root-frame objects (:id shape))]
(cond
(cph/root-frame? shape) shape
(contains? selected+children root-frame-id) shape
(cph/frame-shape? shape)
(let [frame (get objects root-frame-id)]
(gsh/translate-to-frame shape frame))
shape)))
:else
(let [frame (get objects frame-id)]
(gsh/translate-to-frame shape frame)))))
(on-copy-error [error]
(js/console.error "Clipboard blocked:" error)