mirror of
https://github.com/penpot/penpot.git
synced 2025-01-10 08:50:57 -05:00
🐛 Improved object deletion
This commit is contained in:
parent
8493e51070
commit
43198eb263
3 changed files with 67 additions and 53 deletions
|
@ -400,67 +400,74 @@
|
|||
(into (d/ordered-set) empty-parents-xform all-parents)
|
||||
|
||||
mk-del-obj-xf
|
||||
(map (fn [id]
|
||||
{:type :del-obj
|
||||
:page-id page-id
|
||||
:id id}))
|
||||
(comp (filter (partial contains? objects))
|
||||
(map (fn [id]
|
||||
{:type :del-obj
|
||||
:page-id page-id
|
||||
:id id})))
|
||||
|
||||
mk-add-obj-xf
|
||||
(map (fn [id]
|
||||
(let [item (get objects id)]
|
||||
{:type :add-obj
|
||||
:id (:id item)
|
||||
:page-id page-id
|
||||
:index (cp/position-on-parent id objects)
|
||||
:frame-id (:frame-id item)
|
||||
:parent-id (:parent-id item)
|
||||
:obj item})))
|
||||
(comp (filter (partial contains? objects))
|
||||
(map (fn [id]
|
||||
(let [item (get objects id)]
|
||||
{:type :add-obj
|
||||
:id (:id item)
|
||||
:page-id page-id
|
||||
:index (cp/position-on-parent id objects)
|
||||
:frame-id (:frame-id item)
|
||||
:parent-id (:parent-id item)
|
||||
:obj item}))))
|
||||
|
||||
mk-mod-touched-xf
|
||||
(map (fn [id]
|
||||
(let [parent (get objects id)]
|
||||
{:type :mod-obj
|
||||
:page-id page-id
|
||||
:id (:id parent)
|
||||
:operations [{:type :set-touched
|
||||
:touched (:touched parent)}]})))
|
||||
(comp (filter (partial contains? objects))
|
||||
(map (fn [id]
|
||||
(let [parent (get objects id)]
|
||||
{:type :mod-obj
|
||||
:page-id page-id
|
||||
:id (:id parent)
|
||||
:operations [{:type :set-touched
|
||||
:touched (:touched parent)}]}))))
|
||||
|
||||
mk-mod-int-del-xf
|
||||
(map (fn [obj]
|
||||
{:type :mod-obj
|
||||
:page-id page-id
|
||||
:id (:id obj)
|
||||
:operations [{:type :set
|
||||
:attr :interactions
|
||||
:val (vec (remove (fn [interaction]
|
||||
(contains? ids (:destination interaction)))
|
||||
(:interactions obj)))}]}))
|
||||
(comp (filter some?)
|
||||
(map (fn [obj]
|
||||
{:type :mod-obj
|
||||
:page-id page-id
|
||||
:id (:id obj)
|
||||
:operations [{:type :set
|
||||
:attr :interactions
|
||||
:val (vec (remove (fn [interaction]
|
||||
(contains? ids (:destination interaction)))
|
||||
(:interactions obj)))}]})))
|
||||
mk-mod-int-add-xf
|
||||
(map (fn [obj]
|
||||
{:type :mod-obj
|
||||
:page-id page-id
|
||||
:id (:id obj)
|
||||
:operations [{:type :set
|
||||
:attr :interactions
|
||||
:val (:interactions obj)}]}))
|
||||
(comp (filter some?)
|
||||
(map (fn [obj]
|
||||
{:type :mod-obj
|
||||
:page-id page-id
|
||||
:id (:id obj)
|
||||
:operations [{:type :set
|
||||
:attr :interactions
|
||||
:val (:interactions obj)}]})))
|
||||
|
||||
mk-mod-unmask-xf
|
||||
(map (fn [id]
|
||||
{:type :mod-obj
|
||||
:page-id page-id
|
||||
:id id
|
||||
:operations [{:type :set
|
||||
:attr :masked-group?
|
||||
:val false}]}))
|
||||
(comp (filter (partial contains? objects))
|
||||
(map (fn [id]
|
||||
{:type :mod-obj
|
||||
:page-id page-id
|
||||
:id id
|
||||
:operations [{:type :set
|
||||
:attr :masked-group?
|
||||
:val false}]})))
|
||||
|
||||
mk-mod-mask-xf
|
||||
(map (fn [id]
|
||||
{:type :mod-obj
|
||||
:page-id page-id
|
||||
:id id
|
||||
:operations [{:type :set
|
||||
:attr :masked-group?
|
||||
:val true}]}))
|
||||
(comp (filter (partial contains? objects))
|
||||
(map (fn [id]
|
||||
{:type :mod-obj
|
||||
:page-id page-id
|
||||
:id id
|
||||
:operations [{:type :set
|
||||
:attr :masked-group?
|
||||
:val true}]})))
|
||||
|
||||
rchanges
|
||||
(-> []
|
||||
|
|
|
@ -67,8 +67,10 @@
|
|||
(rx/of
|
||||
(dch/update-shapes [id] #(assoc % :content content))
|
||||
(dwu/commit-undo-transaction)))))
|
||||
(rx/of (dws/deselect-shape id)
|
||||
(dwc/delete-shapes #{id})))))))
|
||||
|
||||
(when (some? id)
|
||||
(rx/of (dws/deselect-shape id)
|
||||
(dwc/delete-shapes #{id}))))))))
|
||||
|
||||
(defn initialize-editor-state
|
||||
[{:keys [id content] :as shape} decorator]
|
||||
|
|
|
@ -6,8 +6,10 @@
|
|||
|
||||
(ns app.main.ui.workspace
|
||||
(:require
|
||||
[app.util.timers :as ts]
|
||||
[app.main.data.messages :as dm]
|
||||
[app.main.data.workspace :as dw]
|
||||
[app.main.data.workspace.persistence :as dwp]
|
||||
[app.main.refs :as refs]
|
||||
[app.main.store :as st]
|
||||
[app.main.ui.context :as ctx]
|
||||
|
@ -122,7 +124,10 @@
|
|||
(mf/deps project-id file-id)
|
||||
(fn []
|
||||
(st/emit! (dw/initialize-file project-id file-id))
|
||||
(st/emitf (dw/finalize-file project-id file-id))))
|
||||
(fn []
|
||||
;; Schedule to 100ms so we can do the update before the file is finalized
|
||||
(st/emit! ::dwp/force-persist)
|
||||
(ts/schedule 100 (st/emitf (dw/finalize-file project-id file-id))))))
|
||||
|
||||
(mf/use-effect
|
||||
(fn []
|
||||
|
|
Loading…
Reference in a new issue