mirror of
https://github.com/penpot/penpot.git
synced 2026-09-13 07:30:24 +00:00
🐛 Fix automatic frame assignment in clone-object
This commit is contained in:
parent
2e27a5b4b6
commit
e568ad0370
@ -296,7 +296,7 @@
|
|||||||
(gpt/add orig-pos delta)
|
(gpt/add orig-pos delta)
|
||||||
{:skip-components? true
|
{:skip-components? true
|
||||||
:bottom-frames? true}))
|
:bottom-frames? true}))
|
||||||
ids-map (volatile! {})
|
ids-map (volatile! {})
|
||||||
|
|
||||||
update-new-shape
|
update-new-shape
|
||||||
(fn [new-shape original-shape]
|
(fn [new-shape original-shape]
|
||||||
@ -339,7 +339,7 @@
|
|||||||
|
|
||||||
[new-shape new-shapes _]
|
[new-shape new-shapes _]
|
||||||
(ctst/clone-object component-shape
|
(ctst/clone-object component-shape
|
||||||
nil
|
uuid/zero
|
||||||
(if components-v2 (:objects component-page) (:objects component))
|
(if components-v2 (:objects component-page) (:objects component))
|
||||||
update-new-shape
|
update-new-shape
|
||||||
(fn [object _] object)
|
(fn [object _] object)
|
||||||
|
|||||||
@ -354,29 +354,38 @@
|
|||||||
the order of the children of each parent."
|
the order of the children of each parent."
|
||||||
|
|
||||||
([object parent-id objects]
|
([object parent-id objects]
|
||||||
(clone-object object parent-id objects (fn [object _] object) (fn [object _] object) nil false))
|
(clone-object object parent-id objects (fn [object _] object) (fn [object _] object) nil false true))
|
||||||
|
|
||||||
([object parent-id objects update-new-object]
|
([object parent-id objects update-new-object]
|
||||||
(clone-object object parent-id objects update-new-object (fn [object _] object) nil false))
|
(clone-object object parent-id objects update-new-object (fn [object _] object) nil false true))
|
||||||
|
|
||||||
([object parent-id objects update-new-object update-original-object]
|
([object parent-id objects update-new-object update-original-object]
|
||||||
(clone-object object parent-id objects update-new-object update-original-object nil false))
|
(clone-object object parent-id objects update-new-object update-original-object nil false true))
|
||||||
|
|
||||||
([object parent-id objects update-new-object update-original-object force-id]
|
([object parent-id objects update-new-object update-original-object force-id]
|
||||||
(clone-object object parent-id objects update-new-object update-original-object force-id false))
|
(clone-object object parent-id objects update-new-object update-original-object force-id false true))
|
||||||
|
|
||||||
([object parent-id objects update-new-object update-original-object force-id keep-ids?]
|
([object parent-id objects update-new-object update-original-object force-id keep-ids?]
|
||||||
|
(clone-object object parent-id objects update-new-object update-original-object force-id keep-ids? true))
|
||||||
|
|
||||||
|
([object parent-id objects update-new-object update-original-object force-id keep-ids? calc-frame?]
|
||||||
(let [new-id (cond
|
(let [new-id (cond
|
||||||
(some? force-id) force-id
|
(some? force-id) force-id
|
||||||
keep-ids? (:id object)
|
keep-ids? (:id object)
|
||||||
:else (uuid/next))
|
:else (uuid/next))
|
||||||
|
|
||||||
;; Assign the correct frame-id for the given parent.
|
;; Assign the correct frame-id for the given parent. It's the parent-id (if parent is frame)
|
||||||
;; It's the parent-id (if frame) or the parent's frame-id otherwise.
|
;; or the parent's frame-id otherwise. Only for the first cloned shapes. In recursive calls
|
||||||
frame-id
|
;; this is not needed.
|
||||||
(if (cph/frame-shape? objects parent-id)
|
frame-id (cond
|
||||||
parent-id
|
(and calc-frame? (cph/frame-shape? objects parent-id))
|
||||||
(dm/get-in objects [parent-id :frame-id]))]
|
parent-id
|
||||||
|
|
||||||
|
calc-frame?
|
||||||
|
(dm/get-in objects [parent-id :frame-id])
|
||||||
|
|
||||||
|
:else
|
||||||
|
(:frame-id object))]
|
||||||
|
|
||||||
(loop [child-ids (seq (:shapes object))
|
(loop [child-ids (seq (:shapes object))
|
||||||
new-direct-children []
|
new-direct-children []
|
||||||
@ -408,7 +417,7 @@
|
|||||||
_ (dm/assert! (some? child))
|
_ (dm/assert! (some? child))
|
||||||
|
|
||||||
[new-child new-child-objects updated-child-objects]
|
[new-child new-child-objects updated-child-objects]
|
||||||
(clone-object child new-id objects update-new-object update-original-object nil keep-ids?)]
|
(clone-object child new-id objects update-new-object update-original-object nil keep-ids? false)]
|
||||||
|
|
||||||
(recur
|
(recur
|
||||||
(next child-ids)
|
(next child-ids)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user