mirror of
https://github.com/penpot/penpot.git
synced 2025-01-24 23:49:45 -05:00
🐛 Fix internal error when duplicating board which contains components
This commit is contained in:
parent
016ead108d
commit
c10b8c81fd
3 changed files with 12 additions and 7 deletions
|
@ -819,7 +819,9 @@
|
||||||
page
|
page
|
||||||
libraries
|
libraries
|
||||||
nil
|
nil
|
||||||
(:parent-id shape))
|
(:parent-id shape)
|
||||||
|
(:frame-id shape))
|
||||||
|
|
||||||
;; We need to set the same index as the original shape
|
;; We need to set the same index as the original shape
|
||||||
changes (pcb/change-parent changes (:parent-id shape) [new-shape] index {:component-swap true})]
|
changes (pcb/change-parent changes (:parent-id shape) [new-shape] index {:component-swap true})]
|
||||||
(rx/of (dch/commit-changes changes)
|
(rx/of (dch/commit-changes changes)
|
||||||
|
|
|
@ -144,9 +144,9 @@
|
||||||
(defn generate-instantiate-component
|
(defn generate-instantiate-component
|
||||||
"Generate changes to create a new instance from a component."
|
"Generate changes to create a new instance from a component."
|
||||||
([changes objects file-id component-id position page libraries]
|
([changes objects file-id component-id position page libraries]
|
||||||
(generate-instantiate-component changes objects file-id component-id position page libraries nil nil))
|
(generate-instantiate-component changes objects file-id component-id position page libraries nil nil nil))
|
||||||
|
|
||||||
([changes objects file-id component-id position page libraries old-id parent-id]
|
([changes objects file-id component-id position page libraries old-id parent-id frame-id]
|
||||||
(let [component (ctf/get-component libraries file-id component-id)
|
(let [component (ctf/get-component libraries file-id component-id)
|
||||||
parent (when parent-id (get objects parent-id))
|
parent (when parent-id (get objects parent-id))
|
||||||
library (get libraries file-id)
|
library (get libraries file-id)
|
||||||
|
@ -168,7 +168,9 @@
|
||||||
(and (not (nil? parent)) (not= :frame (:type parent)))
|
(and (not (nil? parent)) (not= :frame (:type parent)))
|
||||||
(assoc :frame-id (:frame-id parent))
|
(assoc :frame-id (:frame-id parent))
|
||||||
(and (not (nil? parent)) (ctn/in-any-component? objects parent))
|
(and (not (nil? parent)) (ctn/in-any-component? objects parent))
|
||||||
(dissoc :component-root))
|
(dissoc :component-root)
|
||||||
|
(and (nil? parent) (not (nil? frame-id)))
|
||||||
|
(assoc :frame-id frame-id))
|
||||||
|
|
||||||
;; on copy/paste old id is used later to reorder the paster layers
|
;; on copy/paste old id is used later to reorder the paster layers
|
||||||
changes (cond-> (pcb/add-object changes first-shape {:ignore-touched true})
|
changes (cond-> (pcb/add-object changes first-shape {:ignore-touched true})
|
||||||
|
|
|
@ -380,7 +380,7 @@
|
||||||
(prepare-duplicate-guides shapes page ids-map delta)))))
|
(prepare-duplicate-guides shapes page ids-map delta)))))
|
||||||
|
|
||||||
(defn- prepare-duplicate-component-change
|
(defn- prepare-duplicate-component-change
|
||||||
[changes objects page component-root parent-id delta libraries library-data it]
|
[changes objects page component-root parent-id frame-id delta libraries library-data it]
|
||||||
(let [component-id (:component-id component-root)
|
(let [component-id (:component-id component-root)
|
||||||
file-id (:component-file component-root)
|
file-id (:component-file component-root)
|
||||||
main-component (ctf/get-component libraries file-id component-id)
|
main-component (ctf/get-component libraries file-id component-id)
|
||||||
|
@ -396,7 +396,8 @@
|
||||||
page
|
page
|
||||||
libraries
|
libraries
|
||||||
(:id component-root)
|
(:id component-root)
|
||||||
parent-id)
|
parent-id
|
||||||
|
frame-id)
|
||||||
|
|
||||||
restore-component
|
restore-component
|
||||||
#(let [restore (dwlh/prepare-restore-component changes library-data (:component-id component-root) it page delta (:id component-root) parent-id)]
|
#(let [restore (dwlh/prepare-restore-component changes library-data (:component-id component-root) it page delta (:id component-root) parent-id)]
|
||||||
|
@ -419,7 +420,7 @@
|
||||||
changes
|
changes
|
||||||
|
|
||||||
(ctf/is-known-component? obj libraries)
|
(ctf/is-known-component? obj libraries)
|
||||||
(prepare-duplicate-component-change changes objects page obj parent-id delta libraries library-data it)
|
(prepare-duplicate-component-change changes objects page obj parent-id frame-id delta libraries library-data it)
|
||||||
|
|
||||||
:else
|
:else
|
||||||
(let [frame? (cfh/frame-shape? obj)
|
(let [frame? (cfh/frame-shape? obj)
|
||||||
|
|
Loading…
Add table
Reference in a new issue