mirror of
https://github.com/penpot/penpot.git
synced 2025-05-23 16:36:15 +02:00
🐛 Implement undo in layer move operation
This commit is contained in:
parent
a050a45424
commit
25518a4ac0
3 changed files with 21 additions and 10 deletions
|
@ -916,13 +916,11 @@
|
|||
|
||||
;; --- Change Shape Order (D&D Ordering)
|
||||
|
||||
;; TODO: pending UNDO
|
||||
|
||||
(defn relocate-shape
|
||||
[id parent-id index]
|
||||
[id parent-id to-index]
|
||||
(us/verify ::us/uuid id)
|
||||
(us/verify ::us/uuid parent-id)
|
||||
(us/verify number? index)
|
||||
(us/verify number? to-index)
|
||||
|
||||
(ptk/reify ::relocate-shape
|
||||
dwc/IUpdateGroup
|
||||
|
@ -931,12 +929,18 @@
|
|||
ptk/WatchEvent
|
||||
(watch [_ state stream]
|
||||
(let [page-id (:current-page-id state)
|
||||
objects (get-in state [:workspace-data page-id :objects])
|
||||
parent (get objects (cp/get-parent id objects))
|
||||
current-index (d/index-of (:shapes parent) id)
|
||||
selected (get-in state [:workspace-local :selected])]
|
||||
(rx/of (dwc/commit-changes [{:type :mov-objects
|
||||
:parent-id parent-id
|
||||
:index index
|
||||
:index to-index
|
||||
:shapes (vec selected)}]
|
||||
[{:type :mov-objects
|
||||
:parent-id (:id parent)
|
||||
:index current-index
|
||||
:shapes (vec selected)}]
|
||||
[]
|
||||
{:commit-local? true}))))))
|
||||
|
||||
;; --- Change Page Order (D&D Ordering)
|
||||
|
|
|
@ -153,9 +153,9 @@
|
|||
(fn [side {:keys [id] :as data}]
|
||||
(if (= side :center)
|
||||
(st/emit! (dw/relocate-shape id (:id item) 0))
|
||||
(let [index (if (= side :top) (inc index) index)
|
||||
(let [to-index (if (= side :top) (inc index) index)
|
||||
parent-id (cp/get-parent (:id item) objects)]
|
||||
(st/emit! (dw/relocate-shape id parent-id index)))))
|
||||
(st/emit! (dw/relocate-shape id parent-id to-index)))))
|
||||
|
||||
[dprops dref] (hooks/use-sortable
|
||||
:type (str (:frame-id item))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue