mirror of
https://github.com/penpot/penpot.git
synced 2025-03-12 15:51:37 -05:00
🐛 Fix component-root when createing new component
This commit is contained in:
parent
a19f5fd305
commit
19379fdd2c
3 changed files with 10 additions and 15 deletions
|
@ -20,14 +20,7 @@
|
||||||
[root-shape new-shapes updated-shapes]
|
[root-shape new-shapes updated-shapes]
|
||||||
(if-not components-v2
|
(if-not components-v2
|
||||||
(ctn/make-component-shape root objects file-id components-v2)
|
(ctn/make-component-shape root objects file-id components-v2)
|
||||||
(let [new-id (uuid/next)]
|
(ctn/convert-shape-in-component root objects file-id))
|
||||||
[(assoc root :id new-id)
|
|
||||||
nil
|
|
||||||
[(assoc root
|
|
||||||
:component-id new-id
|
|
||||||
:component-file file-id
|
|
||||||
:component-root true
|
|
||||||
:main-instance true)]]))
|
|
||||||
|
|
||||||
changes (-> changes
|
changes (-> changes
|
||||||
(pcb/add-component (:id root-shape)
|
(pcb/add-component (:id root-shape)
|
||||||
|
@ -39,12 +32,10 @@
|
||||||
page-id))]
|
page-id))]
|
||||||
[root-shape changes]))
|
[root-shape changes]))
|
||||||
|
|
||||||
|
|
||||||
(defn generate-add-component
|
(defn generate-add-component
|
||||||
"If there is exactly one id, and it's a frame (or a group in v1), and not already a
|
"If there is exactly one id, and it's a frame (or a group in v1), and not already a component,
|
||||||
component, use it as root. Otherwise, create a frame (v2) or group (v1) that contains
|
use it as root. Otherwise, create a frame (v2) or group (v1) that contains all ids. Then, make a
|
||||||
all ids. Then, make a component with it, and link all shapes to their corresponding one
|
component with it, and link all shapes to their corresponding one in the component."
|
||||||
in the component."
|
|
||||||
[it shapes objects page-id file-id components-v2 prepare-create-group prepare-create-board]
|
[it shapes objects page-id file-id components-v2 prepare-create-group prepare-create-board]
|
||||||
(let [changes (pcb/empty-changes it page-id)
|
(let [changes (pcb/empty-changes it page-id)
|
||||||
|
|
||||||
|
@ -81,7 +72,9 @@
|
||||||
|
|
||||||
[root changes (map :id shapes)]))
|
[root changes (map :id shapes)]))
|
||||||
|
|
||||||
[root-shape changes] (generate-add-component-changes changes root objects file-id page-id components-v2)
|
objects' (assoc objects (:id root) root)
|
||||||
|
|
||||||
|
[root-shape changes] (generate-add-component-changes changes root objects' file-id page-id components-v2)
|
||||||
|
|
||||||
changes (pcb/update-shapes changes
|
changes (pcb/update-shapes changes
|
||||||
old-root-ids
|
old-root-ids
|
||||||
|
|
|
@ -86,7 +86,8 @@
|
||||||
|
|
||||||
:always
|
:always
|
||||||
(assoc :frame-id frame-id
|
(assoc :frame-id frame-id
|
||||||
:parent-id parent-id)
|
:parent-id parent-id
|
||||||
|
:shapes (into [] selected))
|
||||||
|
|
||||||
:always
|
:always
|
||||||
(with-meta {:index new-index})
|
(with-meta {:index new-index})
|
||||||
|
|
|
@ -1604,6 +1604,7 @@
|
||||||
(watch [_ _ _]
|
(watch [_ _ _]
|
||||||
(try
|
(try
|
||||||
(let [clipboard-str (wapi/read-from-clipboard)
|
(let [clipboard-str (wapi/read-from-clipboard)
|
||||||
|
|
||||||
paste-transit-str
|
paste-transit-str
|
||||||
(->> clipboard-str
|
(->> clipboard-str
|
||||||
(rx/filter t/transit?)
|
(rx/filter t/transit?)
|
||||||
|
|
Loading…
Add table
Reference in a new issue