mirror of
https://github.com/penpot/penpot.git
synced 2025-02-03 21:09:00 -05:00
:tada Add undo-group for layout updates
This commit is contained in:
parent
c214d8b044
commit
bad0fb912b
13 changed files with 61 additions and 58 deletions
|
@ -777,7 +777,7 @@
|
||||||
|
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dch/commit-changes changes)
|
(dch/commit-changes changes)
|
||||||
(ptk/data-event :layout/update selected-ids)
|
(ptk/data-event :layout/update {:ids selected-ids})
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id))))))
|
||||||
|
|
||||||
;; --- Change Shape Order (D&D Ordering)
|
;; --- Change Shape Order (D&D Ordering)
|
||||||
|
@ -987,7 +987,7 @@
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dch/commit-changes changes)
|
(dch/commit-changes changes)
|
||||||
(dwco/expand-collapse parent-id)
|
(dwco/expand-collapse parent-id)
|
||||||
(ptk/data-event :layout/update (concat all-parents ids))
|
(ptk/data-event :layout/update {:ids (concat all-parents ids)})
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id))))))
|
||||||
|
|
||||||
(defn relocate-selected-shapes
|
(defn relocate-selected-shapes
|
||||||
|
@ -1105,7 +1105,7 @@
|
||||||
(when (can-align? selected objects)
|
(when (can-align? selected objects)
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dwt/position-shapes moved)
|
(dwt/position-shapes moved)
|
||||||
(ptk/data-event :layout/update selected)
|
(ptk/data-event :layout/update {:ids selected})
|
||||||
(dwu/commit-undo-transaction undo-id)))))))
|
(dwu/commit-undo-transaction undo-id)))))))
|
||||||
|
|
||||||
(defn can-distribute? [selected]
|
(defn can-distribute? [selected]
|
||||||
|
@ -1132,7 +1132,7 @@
|
||||||
(when (can-distribute? selected)
|
(when (can-distribute? selected)
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dwt/position-shapes moved)
|
(dwt/position-shapes moved)
|
||||||
(ptk/data-event :layout/update selected)
|
(ptk/data-event :layout/update {:ids selected})
|
||||||
(dwu/commit-undo-transaction undo-id)))))))
|
(dwu/commit-undo-transaction undo-id)))))))
|
||||||
|
|
||||||
;; --- Shape Proportions
|
;; --- Shape Proportions
|
||||||
|
@ -2016,7 +2016,7 @@
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dch/commit-changes changes)
|
(dch/commit-changes changes)
|
||||||
(dws/select-shapes selected)
|
(dws/select-shapes selected)
|
||||||
(ptk/data-event :layout/update [frame-id])
|
(ptk/data-event :layout/update {:ids [frame-id]})
|
||||||
(dwu/commit-undo-transaction undo-id)))))))
|
(dwu/commit-undo-transaction undo-id)))))))
|
||||||
|
|
||||||
(defn as-content [text]
|
(defn as-content [text]
|
||||||
|
|
|
@ -101,7 +101,7 @@
|
||||||
|
|
||||||
;; Update layouts for properties marked
|
;; Update layouts for properties marked
|
||||||
(if (d/not-empty? update-layout-ids)
|
(if (d/not-empty? update-layout-ids)
|
||||||
(rx/of (ptk/data-event :layout/update update-layout-ids))
|
(rx/of (ptk/data-event :layout/update {:ids update-layout-ids}))
|
||||||
(rx/empty))))))))
|
(rx/empty))))))))
|
||||||
|
|
||||||
(defn send-update-indices
|
(defn send-update-indices
|
||||||
|
|
|
@ -194,7 +194,7 @@
|
||||||
(prepare-create-group it objects page-id shapes "Group" false)]
|
(prepare-create-group it objects page-id shapes "Group" false)]
|
||||||
(rx/of (dch/commit-changes changes)
|
(rx/of (dch/commit-changes changes)
|
||||||
(dws/select-shapes (d/ordered-set (:id group)))
|
(dws/select-shapes (d/ordered-set (:id group)))
|
||||||
(ptk/data-event :layout/update parents))))))))
|
(ptk/data-event :layout/update {:ids parents}))))))))
|
||||||
|
|
||||||
(def ungroup-selected
|
(def ungroup-selected
|
||||||
(ptk/reify ::ungroup-selected
|
(ptk/reify ::ungroup-selected
|
||||||
|
@ -244,7 +244,7 @@
|
||||||
(when-not (empty? selected)
|
(when-not (empty? selected)
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dch/commit-changes changes)
|
(dch/commit-changes changes)
|
||||||
(ptk/data-event :layout/update parents)
|
(ptk/data-event :layout/update {:ids parents})
|
||||||
(dwu/commit-undo-transaction undo-id)
|
(dwu/commit-undo-transaction undo-id)
|
||||||
(dws/select-shapes child-ids)))))))
|
(dws/select-shapes child-ids)))))))
|
||||||
|
|
||||||
|
@ -289,7 +289,7 @@
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dch/commit-changes changes)
|
(dch/commit-changes changes)
|
||||||
(dws/select-shapes (d/ordered-set (:id group)))
|
(dws/select-shapes (d/ordered-set (:id group)))
|
||||||
(ptk/data-event :layout/update [(:id group)])
|
(ptk/data-event :layout/update {:ids [(:id group)]})
|
||||||
(dwu/commit-undo-transaction undo-id))))))))
|
(dwu/commit-undo-transaction undo-id))))))))
|
||||||
|
|
||||||
(def unmask-group
|
(def unmask-group
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
[potok.v2.core :as ptk]))
|
[potok.v2.core :as ptk]))
|
||||||
|
|
||||||
;; Change this to :info :debug or :trace to debug this module, or :warn to reset to default
|
;; Change this to :info :debug or :trace to debug this module, or :warn to reset to default
|
||||||
(log/set-level! :trace)
|
(log/set-level! :warn)
|
||||||
|
|
||||||
(defn- log-changes
|
(defn- log-changes
|
||||||
[changes file]
|
[changes file]
|
||||||
|
@ -334,7 +334,7 @@
|
||||||
(when-not (empty? (:redo-changes changes))
|
(when-not (empty? (:redo-changes changes))
|
||||||
(rx/of (dch/commit-changes changes)
|
(rx/of (dch/commit-changes changes)
|
||||||
(dws/select-shapes (d/ordered-set (:id root)))
|
(dws/select-shapes (d/ordered-set (:id root)))
|
||||||
(ptk/data-event :layout/update parents)))))))))
|
(ptk/data-event :layout/update {:ids parents})))))))))
|
||||||
|
|
||||||
(defn add-component
|
(defn add-component
|
||||||
"Add a new component to current file library, from the currently selected shapes.
|
"Add a new component to current file library, from the currently selected shapes.
|
||||||
|
@ -566,7 +566,7 @@
|
||||||
undo-id (js/Symbol)]
|
undo-id (js/Symbol)]
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dch/commit-changes changes)
|
(dch/commit-changes changes)
|
||||||
(ptk/data-event :layout/update [(:id new-shape)])
|
(ptk/data-event :layout/update {:ids [(:id new-shape)]})
|
||||||
(dws/select-shapes (d/ordered-set (:id new-shape)))
|
(dws/select-shapes (d/ordered-set (:id new-shape)))
|
||||||
(when start-move?
|
(when start-move?
|
||||||
(dwtr/start-move initial-point #{(:id new-shape)}))
|
(dwtr/start-move initial-point #{(:id new-shape)}))
|
||||||
|
@ -948,7 +948,6 @@
|
||||||
|
|
||||||
undo-id (js/Symbol)
|
undo-id (js/Symbol)
|
||||||
undo-group (uuid/next)]
|
undo-group (uuid/next)]
|
||||||
|
|
||||||
(rx/of
|
(rx/of
|
||||||
(dwu/start-undo-transaction undo-id)
|
(dwu/start-undo-transaction undo-id)
|
||||||
(dwsh/delete-shapes nil (d/ordered-set (:id shape)) {:component-swap true
|
(dwsh/delete-shapes nil (d/ordered-set (:id shape)) {:component-swap true
|
||||||
|
@ -956,7 +955,7 @@
|
||||||
:undo-group undo-group})
|
:undo-group undo-group})
|
||||||
(add-component-for-swap shape file page libraries id-new-component index target-cell keep-props-values
|
(add-component-for-swap shape file page libraries id-new-component index target-cell keep-props-values
|
||||||
{:undo-group undo-group})
|
{:undo-group undo-group})
|
||||||
(ptk/data-event :layout/update [(:parent-id shape)])
|
(ptk/data-event :layout/update {:ids [(:parent-id shape)] :undo-group undo-group})
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id))))))
|
||||||
|
|
||||||
(defn component-multi-swap
|
(defn component-multi-swap
|
||||||
|
@ -1082,7 +1081,7 @@
|
||||||
:file-id file-id))))
|
:file-id file-id))))
|
||||||
(when-not (empty? updated-frames)
|
(when-not (empty? updated-frames)
|
||||||
(rx/merge
|
(rx/merge
|
||||||
(rx/of (ptk/data-event :layout/update (map :id updated-frames)))
|
(rx/of (ptk/data-event :layout/update {:ids (map :id updated-frames) :undo-group undo-group}))
|
||||||
(->> (rx/from updated-frames)
|
(->> (rx/from updated-frames)
|
||||||
(rx/mapcat
|
(rx/mapcat
|
||||||
(fn [shape]
|
(fn [shape]
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
[clojure.set :as set]))
|
[clojure.set :as set]))
|
||||||
|
|
||||||
;; Change this to :info :debug or :trace to debug this module, or :warn to reset to default
|
;; Change this to :info :debug or :trace to debug this module, or :warn to reset to default
|
||||||
(log/set-level! :trace)
|
(log/set-level! :warn)
|
||||||
|
|
||||||
(declare generate-sync-container)
|
(declare generate-sync-container)
|
||||||
(declare generate-sync-shape)
|
(declare generate-sync-shape)
|
||||||
|
@ -320,16 +320,17 @@
|
||||||
(loop [containers (ctf/object-containers-seq file)
|
(loop [containers (ctf/object-containers-seq file)
|
||||||
changes (pcb/empty-changes it)]
|
changes (pcb/empty-changes it)]
|
||||||
(if-let [container (first containers)]
|
(if-let [container (first containers)]
|
||||||
(recur (next containers)
|
(do
|
||||||
(pcb/concat-changes
|
(recur (next containers)
|
||||||
changes
|
(pcb/concat-changes
|
||||||
(generate-sync-container it
|
changes
|
||||||
asset-type
|
(generate-sync-container it
|
||||||
asset-id
|
asset-type
|
||||||
library-id
|
asset-id
|
||||||
state
|
library-id
|
||||||
container
|
state
|
||||||
components-v2)))
|
container
|
||||||
|
components-v2))))
|
||||||
changes))))
|
changes))))
|
||||||
|
|
||||||
(defn generate-sync-library
|
(defn generate-sync-library
|
||||||
|
|
|
@ -454,7 +454,7 @@
|
||||||
([]
|
([]
|
||||||
(apply-modifiers nil))
|
(apply-modifiers nil))
|
||||||
|
|
||||||
([{:keys [modifiers undo-transation? stack-undo? ignore-constraints ignore-snap-pixel]
|
([{:keys [modifiers undo-transation? stack-undo? ignore-constraints ignore-snap-pixel undo-group]
|
||||||
:or {undo-transation? true stack-undo? false ignore-constraints false ignore-snap-pixel false}}]
|
:or {undo-transation? true stack-undo? false ignore-constraints false ignore-snap-pixel false}}]
|
||||||
(ptk/reify ::apply-modifiers
|
(ptk/reify ::apply-modifiers
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
|
@ -504,6 +504,7 @@
|
||||||
{:reg-objects? true
|
{:reg-objects? true
|
||||||
:stack-undo? stack-undo?
|
:stack-undo? stack-undo?
|
||||||
:ignore-tree ignore-tree
|
:ignore-tree ignore-tree
|
||||||
|
:undo-group undo-group
|
||||||
;; Attributes that can change in the transform. This way we don't have to check
|
;; Attributes that can change in the transform. This way we don't have to check
|
||||||
;; all the attributes
|
;; all the attributes
|
||||||
:attrs [:selrect
|
:attrs [:selrect
|
||||||
|
|
|
@ -332,7 +332,7 @@
|
||||||
|
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ _ _]
|
(watch [_ _ _]
|
||||||
(rx/of (ptk/data-event :layout/update [id])))))
|
(rx/of (ptk/data-event :layout/update {:ids [id]})))))
|
||||||
|
|
||||||
(defn split-segments
|
(defn split-segments
|
||||||
[{:keys [from-p to-p t]}]
|
[{:keys [from-p to-p t]}]
|
||||||
|
|
|
@ -751,7 +751,7 @@
|
||||||
(dwu/start-undo-transaction undo-id)
|
(dwu/start-undo-transaction undo-id)
|
||||||
(dch/commit-changes changes)
|
(dch/commit-changes changes)
|
||||||
(select-shapes new-selected)
|
(select-shapes new-selected)
|
||||||
(ptk/data-event :layout/update frames)
|
(ptk/data-event :layout/update {:ids frames})
|
||||||
(memorize-duplicated id-original id-duplicated)
|
(memorize-duplicated id-original id-duplicated)
|
||||||
(dwu/commit-undo-transaction undo-id))))))))))
|
(dwu/commit-undo-transaction undo-id))))))))))
|
||||||
|
|
||||||
|
|
|
@ -94,7 +94,7 @@
|
||||||
;; Never call this directly but through the data-event `:layout/update`
|
;; Never call this directly but through the data-event `:layout/update`
|
||||||
;; Otherwise a lot of cycle dependencies could be generated
|
;; Otherwise a lot of cycle dependencies could be generated
|
||||||
(defn- update-layout-positions
|
(defn- update-layout-positions
|
||||||
[ids]
|
[{:keys [ids undo-group]}]
|
||||||
(ptk/reify ::update-layout-positions
|
(ptk/reify ::update-layout-positions
|
||||||
ptk/WatchEvent
|
ptk/WatchEvent
|
||||||
(watch [_ state _]
|
(watch [_ state _]
|
||||||
|
@ -103,7 +103,8 @@
|
||||||
(if (d/not-empty? ids)
|
(if (d/not-empty? ids)
|
||||||
(let [modif-tree (dwm/create-modif-tree ids (ctm/reflow-modifiers))]
|
(let [modif-tree (dwm/create-modif-tree ids (ctm/reflow-modifiers))]
|
||||||
(rx/of (dwm/apply-modifiers {:modifiers modif-tree
|
(rx/of (dwm/apply-modifiers {:modifiers modif-tree
|
||||||
:stack-undo? true})))
|
:stack-undo? true
|
||||||
|
:undo-group undo-group})))
|
||||||
(rx/empty))))))
|
(rx/empty))))))
|
||||||
|
|
||||||
(defn initialize
|
(defn initialize
|
||||||
|
@ -139,7 +140,7 @@
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dch/update-shapes [id] layout-initializer {:with-objects? true})
|
(dch/update-shapes [id] layout-initializer {:with-objects? true})
|
||||||
(dch/update-shapes (dm/get-prop parent :shapes) #(dissoc % :constraints-h :constraints-v))
|
(dch/update-shapes (dm/get-prop parent :shapes) #(dissoc % :constraints-h :constraints-v))
|
||||||
(ptk/data-event :layout/update [id])
|
(ptk/data-event :layout/update {:ids [id]})
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id))))))
|
||||||
|
|
||||||
(defn create-layout-from-selection
|
(defn create-layout-from-selection
|
||||||
|
@ -180,7 +181,7 @@
|
||||||
(dch/update-shapes [new-shape-id] #(assoc % :layout-item-h-sizing :auto :layout-item-v-sizing :auto))
|
(dch/update-shapes [new-shape-id] #(assoc % :layout-item-h-sizing :auto :layout-item-v-sizing :auto))
|
||||||
(dch/update-shapes selected #(assoc % :layout-item-h-sizing :fix :layout-item-v-sizing :fix))
|
(dch/update-shapes selected #(assoc % :layout-item-h-sizing :fix :layout-item-v-sizing :fix))
|
||||||
(dwsh/delete-shapes page-id selected)
|
(dwsh/delete-shapes page-id selected)
|
||||||
(ptk/data-event :layout/update [new-shape-id])
|
(ptk/data-event :layout/update {:ids [new-shape-id]})
|
||||||
(dwu/commit-undo-transaction undo-id)))
|
(dwu/commit-undo-transaction undo-id)))
|
||||||
|
|
||||||
;; Create Layout from selection
|
;; Create Layout from selection
|
||||||
|
@ -191,7 +192,7 @@
|
||||||
(dch/update-shapes [new-shape-id] #(assoc % :layout-item-h-sizing :auto :layout-item-v-sizing :auto))
|
(dch/update-shapes [new-shape-id] #(assoc % :layout-item-h-sizing :auto :layout-item-v-sizing :auto))
|
||||||
(dch/update-shapes selected #(assoc % :layout-item-h-sizing :fix :layout-item-v-sizing :fix))))
|
(dch/update-shapes selected #(assoc % :layout-item-h-sizing :fix :layout-item-v-sizing :fix))))
|
||||||
|
|
||||||
(rx/of (ptk/data-event :layout/update [new-shape-id])
|
(rx/of (ptk/data-event :layout/update {:ids [new-shape-id]})
|
||||||
(dwu/commit-undo-transaction undo-id)))))))
|
(dwu/commit-undo-transaction undo-id)))))))
|
||||||
|
|
||||||
(defn remove-layout
|
(defn remove-layout
|
||||||
|
@ -203,7 +204,7 @@
|
||||||
(rx/of
|
(rx/of
|
||||||
(dwu/start-undo-transaction undo-id)
|
(dwu/start-undo-transaction undo-id)
|
||||||
(dch/update-shapes ids #(apply dissoc % layout-keys))
|
(dch/update-shapes ids #(apply dissoc % layout-keys))
|
||||||
(ptk/data-event :layout/update ids)
|
(ptk/data-event :layout/update {:ids ids})
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id))))))
|
||||||
|
|
||||||
(defn create-layout
|
(defn create-layout
|
||||||
|
@ -256,7 +257,7 @@
|
||||||
(let [undo-id (js/Symbol)]
|
(let [undo-id (js/Symbol)]
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dch/update-shapes ids (d/patch-object changes))
|
(dch/update-shapes ids (d/patch-object changes))
|
||||||
(ptk/data-event :layout/update ids)
|
(ptk/data-event :layout/update {:ids ids})
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id))))))
|
||||||
|
|
||||||
(defn add-layout-track
|
(defn add-layout-track
|
||||||
|
@ -275,7 +276,7 @@
|
||||||
(case type
|
(case type
|
||||||
:row (ctl/add-grid-row shape value index)
|
:row (ctl/add-grid-row shape value index)
|
||||||
:column (ctl/add-grid-column shape value index))))
|
:column (ctl/add-grid-column shape value index))))
|
||||||
(ptk/data-event :layout/update ids)
|
(ptk/data-event :layout/update {:ids ids})
|
||||||
(dwu/commit-undo-transaction undo-id)))))))
|
(dwu/commit-undo-transaction undo-id)))))))
|
||||||
|
|
||||||
(defn remove-layout-track
|
(defn remove-layout-track
|
||||||
|
@ -309,7 +310,7 @@
|
||||||
:row (ctl/remove-grid-row shape index objects)
|
:row (ctl/remove-grid-row shape index objects)
|
||||||
:column (ctl/remove-grid-column shape index objects)))
|
:column (ctl/remove-grid-column shape index objects)))
|
||||||
{:with-objects? true})
|
{:with-objects? true})
|
||||||
(ptk/data-event :layout/update ids)
|
(ptk/data-event :layout/update {:ids ids})
|
||||||
(dwu/commit-undo-transaction undo-id)))))))
|
(dwu/commit-undo-transaction undo-id)))))))
|
||||||
|
|
||||||
(defn duplicate-layout-track
|
(defn duplicate-layout-track
|
||||||
|
@ -363,7 +364,7 @@
|
||||||
undo-id (js/Symbol)]
|
undo-id (js/Symbol)]
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dch/commit-changes changes)
|
(dch/commit-changes changes)
|
||||||
(ptk/data-event :layout/update ids)
|
(ptk/data-event :layout/update {:ids ids})
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id))))))
|
||||||
|
|
||||||
(defn reorder-layout-track
|
(defn reorder-layout-track
|
||||||
|
@ -381,7 +382,7 @@
|
||||||
(case type
|
(case type
|
||||||
:row (ctl/reorder-grid-row shape from-index to-index move-content?)
|
:row (ctl/reorder-grid-row shape from-index to-index move-content?)
|
||||||
:column (ctl/reorder-grid-column shape from-index to-index move-content?))))
|
:column (ctl/reorder-grid-column shape from-index to-index move-content?))))
|
||||||
(ptk/data-event :layout/update ids)
|
(ptk/data-event :layout/update {:ids ids})
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id))))))
|
||||||
|
|
||||||
(defn hover-layout-track
|
(defn hover-layout-track
|
||||||
|
@ -426,7 +427,7 @@
|
||||||
(fn [shape]
|
(fn [shape]
|
||||||
(-> shape
|
(-> shape
|
||||||
(update-in [property index] merge props))))
|
(update-in [property index] merge props))))
|
||||||
(ptk/data-event :layout/update ids)
|
(ptk/data-event :layout/update {:ids ids})
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id))))))
|
||||||
|
|
||||||
(defn fix-child-sizing
|
(defn fix-child-sizing
|
||||||
|
@ -523,7 +524,7 @@
|
||||||
(cond-> (ctl/grid-layout? parent)
|
(cond-> (ctl/grid-layout? parent)
|
||||||
(ctl/assign-cells objects))))
|
(ctl/assign-cells objects))))
|
||||||
{:with-objects? true})
|
{:with-objects? true})
|
||||||
(ptk/data-event :layout/update ids)
|
(ptk/data-event :layout/update {:ids ids})
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id))))))
|
||||||
|
|
||||||
(defn update-grid-cells
|
(defn update-grid-cells
|
||||||
|
@ -546,7 +547,7 @@
|
||||||
[:layout-grid-cells cell-id]
|
[:layout-grid-cells cell-id]
|
||||||
d/patch-object props))
|
d/patch-object props))
|
||||||
shape))))
|
shape))))
|
||||||
(ptk/data-event :layout/update [layout-id])
|
(ptk/data-event :layout/update {:ids [layout-id]})
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id))))))
|
||||||
|
|
||||||
(defn change-cells-mode
|
(defn change-cells-mode
|
||||||
|
@ -612,7 +613,7 @@
|
||||||
(d/update-in-when [:layout-grid-cells (:id target-cell)] assoc :position :area)))))
|
(d/update-in-when [:layout-grid-cells (:id target-cell)] assoc :position :area)))))
|
||||||
{:with-objects? true})
|
{:with-objects? true})
|
||||||
(dwge/clean-selection layout-id)
|
(dwge/clean-selection layout-id)
|
||||||
(ptk/data-event :layout/update [layout-id])
|
(ptk/data-event :layout/update {:ids [layout-id]})
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id))))))
|
||||||
|
|
||||||
(defn merge-cells
|
(defn merge-cells
|
||||||
|
@ -644,7 +645,7 @@
|
||||||
(ctl/assign-cells objects))))
|
(ctl/assign-cells objects))))
|
||||||
{:with-objects? true})
|
{:with-objects? true})
|
||||||
(dwge/clean-selection layout-id)
|
(dwge/clean-selection layout-id)
|
||||||
(ptk/data-event :layout/update [layout-id])
|
(ptk/data-event :layout/update {:ids [layout-id]})
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id))))))
|
||||||
|
|
||||||
(defn update-grid-cell-position
|
(defn update-grid-cell-position
|
||||||
|
@ -669,7 +670,7 @@
|
||||||
(:row-span new-data) (:column-span new-data))
|
(:row-span new-data) (:column-span new-data))
|
||||||
(ctl/assign-cells objects))))
|
(ctl/assign-cells objects))))
|
||||||
{:with-objects? true})
|
{:with-objects? true})
|
||||||
(ptk/data-event :layout/update [layout-id])
|
(ptk/data-event :layout/update {:ids [layout-id]})
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id))))))
|
||||||
|
|
||||||
|
|
||||||
|
@ -724,5 +725,5 @@
|
||||||
(rx/of
|
(rx/of
|
||||||
(dwu/start-undo-transaction undo-id)
|
(dwu/start-undo-transaction undo-id)
|
||||||
(dch/commit-changes changes)
|
(dch/commit-changes changes)
|
||||||
(ptk/data-event :layout/update [layout-id])
|
(ptk/data-event :layout/update {:ids [layout-id]})
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id))))))
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dch/commit-changes changes)
|
(dch/commit-changes changes)
|
||||||
(when-not no-update-layout?
|
(when-not no-update-layout?
|
||||||
(ptk/data-event :layout/update [(:parent-id shape)]))
|
(ptk/data-event :layout/update {:ids [(:parent-id shape)]}))
|
||||||
(when-not no-select?
|
(when-not no-select?
|
||||||
(dws/select-shapes (d/ordered-set (:id shape))))
|
(dws/select-shapes (d/ordered-set (:id shape))))
|
||||||
(dwu/commit-undo-transaction undo-id))
|
(dwu/commit-undo-transaction undo-id))
|
||||||
|
@ -141,10 +141,11 @@
|
||||||
|
|
||||||
(rx/concat
|
(rx/concat
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(update-shape-flags ids-to-hide {:hidden true}))
|
(update-shape-flags ids-to-hide {:hidden true :undo-group (:undo-group options)}))
|
||||||
(real-delete-shapes file page objects ids-to-delete it {:components-v2 components-v2
|
(real-delete-shapes file page objects ids-to-delete it {:components-v2 components-v2
|
||||||
:ignore-touched (:component-swap options)
|
:ignore-touched (:component-swap options)
|
||||||
:undo-group (:undo-group options)})
|
:undo-group (:undo-group options)
|
||||||
|
:undo-id undo-id})
|
||||||
(rx/of (dwu/commit-undo-transaction undo-id))))))))
|
(rx/of (dwu/commit-undo-transaction undo-id))))))))
|
||||||
|
|
||||||
(defn- real-delete-shapes-changes
|
(defn- real-delete-shapes-changes
|
||||||
|
@ -291,11 +292,11 @@
|
||||||
(defn- real-delete-shapes
|
(defn- real-delete-shapes
|
||||||
[file page objects ids it options]
|
[file page objects ids it options]
|
||||||
(let [[changes all-parents] (real-delete-shapes-changes file page objects ids it options)
|
(let [[changes all-parents] (real-delete-shapes-changes file page objects ids it options)
|
||||||
undo-id (js/Symbol)]
|
undo-id (or (:undo-id options) (js/Symbol))]
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dc/detach-comment-thread ids)
|
(dc/detach-comment-thread ids)
|
||||||
(dch/commit-changes changes)
|
(dch/commit-changes changes)
|
||||||
(ptk/data-event :layout/update all-parents)
|
(ptk/data-event :layout/update {:ids all-parents :undo-group (:undo-group options)})
|
||||||
(dwu/commit-undo-transaction undo-id))))
|
(dwu/commit-undo-transaction undo-id))))
|
||||||
|
|
||||||
(defn create-and-add-shape
|
(defn create-and-add-shape
|
||||||
|
@ -377,7 +378,7 @@
|
||||||
(dwu/start-undo-transaction undo-id)
|
(dwu/start-undo-transaction undo-id)
|
||||||
(dch/commit-changes changes)
|
(dch/commit-changes changes)
|
||||||
(dws/select-shapes (d/ordered-set (:id frame-shape)))
|
(dws/select-shapes (d/ordered-set (:id frame-shape)))
|
||||||
(ptk/data-event :layout/update [(:id frame-shape)])
|
(ptk/data-event :layout/update {:ids [(:id frame-shape)]})
|
||||||
(dwu/commit-undo-transaction undo-id))))))))
|
(dwu/commit-undo-transaction undo-id))))))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
@ -385,7 +386,7 @@
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
(defn update-shape-flags
|
(defn update-shape-flags
|
||||||
[ids {:keys [blocked hidden transforming] :as flags}]
|
[ids {:keys [blocked hidden transforming undo-group] :as flags}]
|
||||||
(dm/assert!
|
(dm/assert!
|
||||||
"expected valid coll of uuids"
|
"expected valid coll of uuids"
|
||||||
(every? uuid? ids))
|
(every? uuid? ids))
|
||||||
|
@ -409,7 +410,7 @@
|
||||||
ids (if (boolean? blocked)
|
ids (if (boolean? blocked)
|
||||||
(into ids (->> ids (mapcat #(cfh/get-children-ids objects %))))
|
(into ids (->> ids (mapcat #(cfh/get-children-ids objects %))))
|
||||||
ids)]
|
ids)]
|
||||||
(rx/of (dch/update-shapes ids update-fn {:attrs #{:blocked :hidden :transforming}}))))))
|
(rx/of (dch/update-shapes ids update-fn {:attrs #{:blocked :hidden :transforming} :undo-group undo-group}))))))
|
||||||
|
|
||||||
(defn toggle-visibility-selected
|
(defn toggle-visibility-selected
|
||||||
[]
|
[]
|
||||||
|
|
|
@ -102,7 +102,7 @@
|
||||||
(rx/of (dwu/start-undo-transaction undo-id)
|
(rx/of (dwu/start-undo-transaction undo-id)
|
||||||
(dch/commit-changes changes)
|
(dch/commit-changes changes)
|
||||||
(dws/select-shapes (d/ordered-set (:id new-shape)))
|
(dws/select-shapes (d/ordered-set (:id new-shape)))
|
||||||
(ptk/data-event :layout/update [(:id new-shape)])
|
(ptk/data-event :layout/update {:ids [(:id new-shape)]})
|
||||||
(dwu/commit-undo-transaction undo-id)))
|
(dwu/commit-undo-transaction undo-id)))
|
||||||
|
|
||||||
(catch :default cause
|
(catch :default cause
|
||||||
|
|
|
@ -382,7 +382,7 @@
|
||||||
:stack-undo? true
|
:stack-undo? true
|
||||||
:ignore-remote? true
|
:ignore-remote? true
|
||||||
:ignore-touched true})
|
:ignore-touched true})
|
||||||
(ptk/data-event :layout/update ids)
|
(ptk/data-event :layout/update {:ids ids})
|
||||||
(dwu/commit-undo-transaction undo-id))))))))
|
(dwu/commit-undo-transaction undo-id))))))))
|
||||||
|
|
||||||
(defn resize-text
|
(defn resize-text
|
||||||
|
|
|
@ -719,7 +719,7 @@
|
||||||
(rx/of
|
(rx/of
|
||||||
(dwu/start-undo-transaction undo-id)
|
(dwu/start-undo-transaction undo-id)
|
||||||
(dch/commit-changes changes)
|
(dch/commit-changes changes)
|
||||||
(ptk/data-event :layout/update selected)
|
(ptk/data-event :layout/update {:ids selected})
|
||||||
(dwu/commit-undo-transaction undo-id))))))
|
(dwu/commit-undo-transaction undo-id))))))
|
||||||
|
|
||||||
(defn nudge-selected-shapes
|
(defn nudge-selected-shapes
|
||||||
|
|
Loading…
Add table
Reference in a new issue