mirror of
https://github.com/penpot/penpot.git
synced 2025-06-12 16:51:40 +02:00
🐛 Fix group undo/redo.
This commit is contained in:
parent
527acac92e
commit
5fb0c5c312
3 changed files with 33 additions and 22 deletions
|
@ -1318,17 +1318,28 @@
|
|||
(let [page-id (::page-id state)
|
||||
session-id (:session-id state)
|
||||
objects (get-in state [:workspace-data page-id :objects])
|
||||
rchanges (mapv #(array-map :type :del-obj :id %) ids)
|
||||
uchanges (mapv (fn [id]
|
||||
(let [obj (get objects id)
|
||||
frm (get objects (:frame-id obj))
|
||||
idx (d/index-of (:shapes frm) id)]
|
||||
{:type :add-obj
|
||||
:id id
|
||||
:frame-id (:id frm)
|
||||
:index idx
|
||||
:obj obj}))
|
||||
(reverse ids))]
|
||||
cpindex (helpers/calculate-child-parent-map objects)
|
||||
|
||||
del-change #(array-map :type :del-obj :id %)
|
||||
|
||||
rchanges
|
||||
(reduce (fn [res id]
|
||||
(let [chd (helpers/get-children id objects)]
|
||||
(into res (d/concat
|
||||
(mapv del-change (reverse chd))
|
||||
[(del-change id)]))))
|
||||
[]
|
||||
ids)
|
||||
|
||||
uchanges
|
||||
(mapv (fn [id]
|
||||
(let [obj (get objects id)]
|
||||
{:type :add-obj
|
||||
:id id
|
||||
:frame-id (:frame-id obj)
|
||||
:parent-id (get cpindex id)
|
||||
:obj obj}))
|
||||
(reverse (map :id rchanges)))]
|
||||
(rx/of (commit-changes rchanges uchanges {:commit-local? true}))))))
|
||||
|
||||
(defn- delete-frame
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue