0
Fork 0
mirror of https://github.com/penpot/penpot.git synced 2025-03-12 07:41:43 -05:00

💄 Add cosmetic changes on ungroup event.

This commit is contained in:
Andrey Antukh 2021-12-09 16:51:14 +01:00 committed by Andrés Moya
parent 06d41c552b
commit 9ee5a3159c

View file

@ -219,18 +219,24 @@
(ptk/reify ::ungroup-selected
ptk/WatchEvent
(watch [it state _]
(let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)
changes-in-bulk (->> (wsh/lookup-selected state)
(map #(get objects %))
(filter #(or (= :bool (:type %)) (= :group (:type %))))
(map #(prepare-remove-group page-id % objects)))
rchanges-in-bulk (into [] (mapcat first) changes-in-bulk)
uchanges-in-bulk (into [] (mapcat second) changes-in-bulk)]
(rx/of (dch/commit-changes {:redo-changes rchanges-in-bulk
:undo-changes uchanges-in-bulk
:origin it}))))))
(let [page-id (:current-page-id state)
objects (wsh/lookup-page-objects state page-id)
is-group? #(or (= :bool (:type %)) (= :group (:type %)))
lookup #(get objects %)
prepare #(prepare-remove-group page-id % objects)
changes (sequence
(comp (map lookup)
(filter is-group?)
(map prepare))
(wsh/lookup-selected state))
rchanges (into [] (mapcat first) changes)
uchanges (into [] (mapcat second) changes)]
(rx/of (dch/commit-changes {:redo-changes rchanges
:undo-changes uchanges
:origin it}))))))
(def mask-group
(ptk/reify ::mask-group
ptk/WatchEvent