0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-10 14:51:37 -05:00

🐛 Fix crash copy paste a Copy

This commit is contained in:
Pablo Alba 2024-03-12 14:36:09 +01:00
parent 9328974511
commit 76b75192e7
2 changed files with 18 additions and 2 deletions

View file

@ -215,6 +215,15 @@
(some find-ref-shape-in-head (ctn/get-parent-heads (:objects container) shape))))
(defn find-original-ref-shape
"Recursively call to find-ref-shape until find the original shape of the original component"
[file container libraries shape & options]
(let [ref-shape (find-ref-shape file container libraries shape options)]
(if (nil? (:shape-ref ref-shape))
ref-shape
(find-original-ref-shape file container libraries ref-shape options))))
(defn find-ref-component
"Locate the nearest component in the local file or libraries that is referenced by the
instance shape."
@ -303,7 +312,7 @@
(vals (:objects component)))))
;; Return true if the object is a component that exists on the file or its libraries (even a deleted one)
(defn is-known-component?
(defn is-main-of-known-component?
[shape libraries]
(let [main-instance? (ctk/main-instance? shape)
component-id (:component-id shape)

View file

@ -466,7 +466,7 @@
(nil? obj)
changes
(ctf/is-known-component? obj libraries)
(ctf/is-main-of-known-component? obj libraries)
(prepare-duplicate-component-change changes objects page obj parent-id frame-id delta libraries library-data it)
:else
@ -484,6 +484,9 @@
(ctk/instance-root? obj))
duplicating-component? (or duplicating-component? (ctk/instance-head? obj))
is-component-main? (ctk/main-instance? obj)
original-ref-shape (-> (ctf/find-original-ref-shape nil page libraries obj {:include-deleted? true})
:id)
into-component? (and duplicating-component?
(ctn/in-any-component? objects parent))
@ -514,6 +517,10 @@
(cond-> (or frame? group? bool?)
(assoc :shapes []))
(cond-> (and (some? original-ref-shape)
(not= original-ref-shape (:shape-ref obj)))
(assoc :shape-ref original-ref-shape))
(gsh/move delta)
(d/update-when :interactions #(ctsi/remap-interactions % ids-map objects))