mirror of
https://github.com/penpot/penpot.git
synced 2025-02-12 18:18:24 -05:00
Merge pull request #4254 from penpot/palba-fix-crash-copy
🐛 Fix crash copy paste a Copy from a library
This commit is contained in:
commit
ecb8ed8b8b
2 changed files with 18 additions and 2 deletions
|
@ -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)
|
||||
|
|
|
@ -468,7 +468,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
|
||||
|
@ -486,6 +486,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))
|
||||
|
||||
|
@ -516,6 +519,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))
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue