mirror of
https://github.com/penpot/penpot.git
synced 2025-08-07 14:38:33 +02:00
🐛 Detach a shape when moving it out of a component
This commit is contained in:
parent
bde62473a4
commit
f3d5515795
2 changed files with 25 additions and 6 deletions
|
@ -222,7 +222,24 @@
|
||||||
(d/dissoc-in [pid :remote-synced?])))))))))
|
(d/dissoc-in [pid :remote-synced?])))))))))
|
||||||
|
|
||||||
(update-parent-id [objects id]
|
(update-parent-id [objects id]
|
||||||
(update objects id assoc :parent-id parent-id))
|
(update objects id
|
||||||
|
(fn [object]
|
||||||
|
(let [prev-component-root (cph/get-root-shape object objects)
|
||||||
|
detach-component (fn [object]
|
||||||
|
(let [new-component-root
|
||||||
|
(cph/get-root-shape object objects)]
|
||||||
|
(cond-> object
|
||||||
|
(not= prev-component-root new-component-root)
|
||||||
|
(dissoc object
|
||||||
|
:component-id
|
||||||
|
:component-file
|
||||||
|
:component-root?
|
||||||
|
:remote-synced?
|
||||||
|
:shape-ref
|
||||||
|
:touched))))]
|
||||||
|
(-> object
|
||||||
|
(assoc :parent-id parent-id)
|
||||||
|
detach-component)))))
|
||||||
|
|
||||||
;; Updates the frame-id references that might be outdated
|
;; Updates the frame-id references that might be outdated
|
||||||
(assign-frame-id [frame-id objects id]
|
(assign-frame-id [frame-id objects id]
|
||||||
|
|
|
@ -36,11 +36,13 @@
|
||||||
(defn get-root-shape
|
(defn get-root-shape
|
||||||
"Get the root shape linked to a component for this shape, if any"
|
"Get the root shape linked to a component for this shape, if any"
|
||||||
[shape objects]
|
[shape objects]
|
||||||
|
(if-not (:shape-ref shape)
|
||||||
|
nil
|
||||||
(if (:component-id shape)
|
(if (:component-id shape)
|
||||||
shape
|
shape
|
||||||
(if-let [parent-id (:parent-id shape)]
|
(if-let [parent-id (:parent-id shape)]
|
||||||
(get-root-shape (get objects parent-id) objects)
|
(get-root-shape (get objects parent-id) objects)
|
||||||
nil)))
|
nil))))
|
||||||
|
|
||||||
(defn make-container
|
(defn make-container
|
||||||
[page-or-component type]
|
[page-or-component type]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue