mirror of
https://github.com/penpot/penpot.git
synced 2025-06-10 07:11:39 +02:00
🐛 Improved object deletion
This commit is contained in:
parent
8493e51070
commit
43198eb263
3 changed files with 67 additions and 53 deletions
|
@ -400,12 +400,14 @@
|
||||||
(into (d/ordered-set) empty-parents-xform all-parents)
|
(into (d/ordered-set) empty-parents-xform all-parents)
|
||||||
|
|
||||||
mk-del-obj-xf
|
mk-del-obj-xf
|
||||||
|
(comp (filter (partial contains? objects))
|
||||||
(map (fn [id]
|
(map (fn [id]
|
||||||
{:type :del-obj
|
{:type :del-obj
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
:id id}))
|
:id id})))
|
||||||
|
|
||||||
mk-add-obj-xf
|
mk-add-obj-xf
|
||||||
|
(comp (filter (partial contains? objects))
|
||||||
(map (fn [id]
|
(map (fn [id]
|
||||||
(let [item (get objects id)]
|
(let [item (get objects id)]
|
||||||
{:type :add-obj
|
{:type :add-obj
|
||||||
|
@ -414,18 +416,20 @@
|
||||||
:index (cp/position-on-parent id objects)
|
:index (cp/position-on-parent id objects)
|
||||||
:frame-id (:frame-id item)
|
:frame-id (:frame-id item)
|
||||||
:parent-id (:parent-id item)
|
:parent-id (:parent-id item)
|
||||||
:obj item})))
|
:obj item}))))
|
||||||
|
|
||||||
mk-mod-touched-xf
|
mk-mod-touched-xf
|
||||||
|
(comp (filter (partial contains? objects))
|
||||||
(map (fn [id]
|
(map (fn [id]
|
||||||
(let [parent (get objects id)]
|
(let [parent (get objects id)]
|
||||||
{:type :mod-obj
|
{:type :mod-obj
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
:id (:id parent)
|
:id (:id parent)
|
||||||
:operations [{:type :set-touched
|
:operations [{:type :set-touched
|
||||||
:touched (:touched parent)}]})))
|
:touched (:touched parent)}]}))))
|
||||||
|
|
||||||
mk-mod-int-del-xf
|
mk-mod-int-del-xf
|
||||||
|
(comp (filter some?)
|
||||||
(map (fn [obj]
|
(map (fn [obj]
|
||||||
{:type :mod-obj
|
{:type :mod-obj
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
|
@ -434,33 +438,36 @@
|
||||||
:attr :interactions
|
:attr :interactions
|
||||||
:val (vec (remove (fn [interaction]
|
:val (vec (remove (fn [interaction]
|
||||||
(contains? ids (:destination interaction)))
|
(contains? ids (:destination interaction)))
|
||||||
(:interactions obj)))}]}))
|
(:interactions obj)))}]})))
|
||||||
mk-mod-int-add-xf
|
mk-mod-int-add-xf
|
||||||
|
(comp (filter some?)
|
||||||
(map (fn [obj]
|
(map (fn [obj]
|
||||||
{:type :mod-obj
|
{:type :mod-obj
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
:id (:id obj)
|
:id (:id obj)
|
||||||
:operations [{:type :set
|
:operations [{:type :set
|
||||||
:attr :interactions
|
:attr :interactions
|
||||||
:val (:interactions obj)}]}))
|
:val (:interactions obj)}]})))
|
||||||
|
|
||||||
mk-mod-unmask-xf
|
mk-mod-unmask-xf
|
||||||
|
(comp (filter (partial contains? objects))
|
||||||
(map (fn [id]
|
(map (fn [id]
|
||||||
{:type :mod-obj
|
{:type :mod-obj
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
:id id
|
:id id
|
||||||
:operations [{:type :set
|
:operations [{:type :set
|
||||||
:attr :masked-group?
|
:attr :masked-group?
|
||||||
:val false}]}))
|
:val false}]})))
|
||||||
|
|
||||||
mk-mod-mask-xf
|
mk-mod-mask-xf
|
||||||
|
(comp (filter (partial contains? objects))
|
||||||
(map (fn [id]
|
(map (fn [id]
|
||||||
{:type :mod-obj
|
{:type :mod-obj
|
||||||
:page-id page-id
|
:page-id page-id
|
||||||
:id id
|
:id id
|
||||||
:operations [{:type :set
|
:operations [{:type :set
|
||||||
:attr :masked-group?
|
:attr :masked-group?
|
||||||
:val true}]}))
|
:val true}]})))
|
||||||
|
|
||||||
rchanges
|
rchanges
|
||||||
(-> []
|
(-> []
|
||||||
|
|
|
@ -67,8 +67,10 @@
|
||||||
(rx/of
|
(rx/of
|
||||||
(dch/update-shapes [id] #(assoc % :content content))
|
(dch/update-shapes [id] #(assoc % :content content))
|
||||||
(dwu/commit-undo-transaction)))))
|
(dwu/commit-undo-transaction)))))
|
||||||
|
|
||||||
|
(when (some? id)
|
||||||
(rx/of (dws/deselect-shape id)
|
(rx/of (dws/deselect-shape id)
|
||||||
(dwc/delete-shapes #{id})))))))
|
(dwc/delete-shapes #{id}))))))))
|
||||||
|
|
||||||
(defn initialize-editor-state
|
(defn initialize-editor-state
|
||||||
[{:keys [id content] :as shape} decorator]
|
[{:keys [id content] :as shape} decorator]
|
||||||
|
|
|
@ -6,8 +6,10 @@
|
||||||
|
|
||||||
(ns app.main.ui.workspace
|
(ns app.main.ui.workspace
|
||||||
(:require
|
(:require
|
||||||
|
[app.util.timers :as ts]
|
||||||
[app.main.data.messages :as dm]
|
[app.main.data.messages :as dm]
|
||||||
[app.main.data.workspace :as dw]
|
[app.main.data.workspace :as dw]
|
||||||
|
[app.main.data.workspace.persistence :as dwp]
|
||||||
[app.main.refs :as refs]
|
[app.main.refs :as refs]
|
||||||
[app.main.store :as st]
|
[app.main.store :as st]
|
||||||
[app.main.ui.context :as ctx]
|
[app.main.ui.context :as ctx]
|
||||||
|
@ -122,7 +124,10 @@
|
||||||
(mf/deps project-id file-id)
|
(mf/deps project-id file-id)
|
||||||
(fn []
|
(fn []
|
||||||
(st/emit! (dw/initialize-file project-id file-id))
|
(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
|
(mf/use-effect
|
||||||
(fn []
|
(fn []
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue