mirror of
https://github.com/penpot/penpot.git
synced 2025-02-13 10:38:13 -05:00
✨ Create frames in reverse order of other shapes.
This commit is contained in:
parent
f314efdfdc
commit
81e909b961
1 changed files with 30 additions and 20 deletions
|
@ -735,28 +735,38 @@
|
|||
(defmethod process-change :add-obj
|
||||
[data {:keys [id obj page-id component-id frame-id parent-id
|
||||
index ignore-touched] :as change}]
|
||||
(let [update-fn (fn [data]
|
||||
(let [parent-id (or parent-id frame-id)
|
||||
objects (:objects data)]
|
||||
(let [obj (assoc obj
|
||||
:frame-id frame-id
|
||||
:parent-id parent-id
|
||||
:id id)]
|
||||
(-> data
|
||||
(update :objects assoc id obj)
|
||||
(update-in [:objects parent-id :shapes]
|
||||
(fn [shapes]
|
||||
(let [shapes (or shapes [])]
|
||||
(cond
|
||||
(some #{id} shapes) shapes
|
||||
(nil? index) (conj shapes id)
|
||||
:else (cph/insert-at-index shapes index [id])))))
|
||||
(cond->
|
||||
(and (:shape-ref (get-in data [:objects parent-id]))
|
||||
(letfn [(update-fn [data]
|
||||
(let [parent-id (or parent-id frame-id)
|
||||
objects (:objects data)]
|
||||
(let [obj (assoc obj
|
||||
:frame-id frame-id
|
||||
:parent-id parent-id
|
||||
:id id)]
|
||||
(if (and (contains? objects parent-id)
|
||||
(contains? objects frame-id))
|
||||
(-> data
|
||||
(update :objects assoc id obj)
|
||||
(update-in [:objects parent-id :shapes]
|
||||
(fn [shapes]
|
||||
(let [shapes (or shapes [])]
|
||||
(cond
|
||||
(some #{id} shapes)
|
||||
shapes
|
||||
|
||||
(nil? index)
|
||||
(if (= :frame (:type obj))
|
||||
(d/concat [id] shapes)
|
||||
(conj shapes id))
|
||||
|
||||
:else
|
||||
(cph/insert-at-index shapes index [id])))))
|
||||
|
||||
(cond-> (and (:shape-ref (get-in data [:objects parent-id]))
|
||||
(not= parent-id frame-id)
|
||||
(not ignore-touched))
|
||||
(update-in [:objects parent-id :touched]
|
||||
cph/set-touched-group :shapes-group))))))]
|
||||
(update-in [:objects parent-id :touched]
|
||||
cph/set-touched-group :shapes-group)))
|
||||
data))))]
|
||||
(if page-id
|
||||
(d/update-in-when data [:pages-index page-id] update-fn)
|
||||
(d/update-in-when data [:components component-id] update-fn))))
|
||||
|
|
Loading…
Add table
Reference in a new issue