mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 15:39:50 -05:00
🐛 Fix duplicate a component copy missing shape-ref
This commit is contained in:
parent
1106ebc377
commit
9b9f2c39b9
1 changed files with 12 additions and 7 deletions
|
@ -397,9 +397,9 @@
|
||||||
|
|
||||||
(defn- prepare-duplicate-shape-change
|
(defn- prepare-duplicate-shape-change
|
||||||
([changes objects page unames update-unames! ids-map obj delta libraries library-data it file-id]
|
([changes objects page unames update-unames! ids-map obj delta libraries library-data it file-id]
|
||||||
(prepare-duplicate-shape-change changes objects page unames update-unames! ids-map obj delta libraries library-data it file-id (:frame-id obj) (:parent-id obj)))
|
(prepare-duplicate-shape-change changes objects page unames update-unames! ids-map obj delta libraries library-data it file-id (:frame-id obj) (:parent-id obj) false))
|
||||||
|
|
||||||
([changes objects page unames update-unames! ids-map obj delta libraries library-data it file-id frame-id parent-id]
|
([changes objects page unames update-unames! ids-map obj delta libraries library-data it file-id frame-id parent-id duplicating-component?]
|
||||||
(cond
|
(cond
|
||||||
(nil? obj)
|
(nil? obj)
|
||||||
changes
|
changes
|
||||||
|
@ -413,8 +413,9 @@
|
||||||
parent-id (or parent-id frame-id)
|
parent-id (or parent-id frame-id)
|
||||||
name (:name obj)
|
name (:name obj)
|
||||||
|
|
||||||
is-component-root? (:saved-component-root? obj)
|
is-component-root? (or (:saved-component-root? obj) (ctk/instance-root? obj))
|
||||||
is-component-main? (:main-instance? obj)
|
duplicating-component? (or duplicating-component? is-component-root?)
|
||||||
|
is-component-main? (ctk/main-instance? obj)
|
||||||
regenerate-component
|
regenerate-component
|
||||||
(fn [changes shape]
|
(fn [changes shape]
|
||||||
(let [components-v2 (dm/get-in library-data [:options :components-v2])
|
(let [components-v2 (dm/get-in library-data [:options :components-v2])
|
||||||
|
@ -428,12 +429,15 @@
|
||||||
:frame-id frame-id)
|
:frame-id frame-id)
|
||||||
(dissoc :shapes
|
(dissoc :shapes
|
||||||
:main-instance?
|
:main-instance?
|
||||||
:shape-ref
|
|
||||||
:use-for-thumbnail?)
|
:use-for-thumbnail?)
|
||||||
(gsh/move delta)
|
(gsh/move delta)
|
||||||
(d/update-when :interactions #(ctsi/remap-interactions % ids-map objects)))
|
(d/update-when :interactions #(ctsi/remap-interactions % ids-map objects)))
|
||||||
|
|
||||||
changes (-> (pcb/add-object changes new-obj)
|
new-obj (cond-> new-obj
|
||||||
|
(not duplicating-component?)
|
||||||
|
(dissoc :shape-ref))
|
||||||
|
|
||||||
|
changes (-> (pcb/add-object changes new-obj {:ignore-touched duplicating-component?})
|
||||||
(pcb/amend-last-change #(assoc % :old-id (:id obj))))
|
(pcb/amend-last-change #(assoc % :old-id (:id obj))))
|
||||||
|
|
||||||
changes (cond-> changes
|
changes (cond-> changes
|
||||||
|
@ -454,7 +458,8 @@
|
||||||
it
|
it
|
||||||
file-id
|
file-id
|
||||||
(if frame? new-id frame-id)
|
(if frame? new-id frame-id)
|
||||||
new-id))
|
new-id
|
||||||
|
duplicating-component?))
|
||||||
changes
|
changes
|
||||||
(map (d/getf objects) (:shapes obj)))))))
|
(map (d/getf objects) (:shapes obj)))))))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue