mirror of
https://github.com/penpot/penpot.git
synced 2025-01-10 17:00:36 -05:00
Merge pull request #3138 from penpot/fix-bad-undo-group-association-in-alt-copy
🐛 Fix bad undo group associations
This commit is contained in:
commit
52763ceaf7
4 changed files with 17 additions and 10 deletions
|
@ -87,7 +87,8 @@
|
|||
{:redo-changes (d/concat-vec (:redo-changes changes1) (:redo-changes changes2))
|
||||
:undo-changes (d/concat-vec (:undo-changes changes1) (:undo-changes changes2))
|
||||
:origin (:origin changes1)
|
||||
:undo-group (:undo-group changes1)})
|
||||
:undo-group (:undo-group changes1)
|
||||
:tags (:tags changes1)})
|
||||
|
||||
; TODO: remove this when not needed
|
||||
(defn- assert-page-id
|
||||
|
|
|
@ -45,7 +45,8 @@
|
|||
add-undo-group? (and
|
||||
(not (nil? undo-group))
|
||||
(= (get-in changes [:redo-changes 0 :type]) :mod-obj)
|
||||
(= (get-in prev-item [:redo-changes 0 :type]) :add-obj))] ;; This is a copy-and-move with mouse+alt
|
||||
(= (get-in prev-item [:redo-changes 0 :type]) :add-obj)
|
||||
(contains? (:tags prev-item) :alt-duplication))] ;; This is a copy-and-move with mouse+alt
|
||||
|
||||
(cond-> changes add-undo-group? (assoc :undo-group undo-group))))
|
||||
|
||||
|
@ -172,8 +173,8 @@
|
|||
undo-group, they will be undone or redone in a single step
|
||||
"
|
||||
[{:keys [redo-changes undo-changes
|
||||
origin save-undo? file-id undo-group stack-undo?]
|
||||
:or {save-undo? true stack-undo? false undo-group (uuid/next)}}]
|
||||
origin save-undo? file-id undo-group tags stack-undo?]
|
||||
:or {save-undo? true stack-undo? false tags #{} undo-group (uuid/next)}}]
|
||||
(log/debug :msg "commit-changes"
|
||||
:js/undo-group (str undo-group)
|
||||
:js/redo-changes redo-changes
|
||||
|
@ -192,6 +193,7 @@
|
|||
:frames frames
|
||||
:save-undo? save-undo?
|
||||
:undo-group undo-group
|
||||
:tags tags
|
||||
:stack-undo? stack-undo?})
|
||||
|
||||
ptk/UpdateEvent
|
||||
|
@ -241,5 +243,6 @@
|
|||
(when (and save-undo? (seq undo-changes))
|
||||
(let [entry {:undo-changes undo-changes
|
||||
:redo-changes redo-changes
|
||||
:undo-group undo-group}]
|
||||
:undo-group undo-group
|
||||
:tags tags}]
|
||||
(rx/of (dwu/append-undo entry stack-undo?)))))))))))
|
||||
|
|
|
@ -575,7 +575,7 @@
|
|||
(defn duplicate-selected
|
||||
([move-delta?]
|
||||
(duplicate-selected move-delta? false))
|
||||
([move-delta? add-undo-group?]
|
||||
([move-delta? alt-duplication?]
|
||||
(ptk/reify ::duplicate-selected
|
||||
ptk/WatchEvent
|
||||
(watch [it state _]
|
||||
|
@ -596,7 +596,9 @@
|
|||
changes (->> (prepare-duplicate-changes objects page selected delta it libraries library-data)
|
||||
(duplicate-changes-update-indices objects selected))
|
||||
|
||||
changes (cond-> changes add-undo-group? (assoc :undo-group (uuid/random)))
|
||||
tags (or (:tags changes) #{})
|
||||
|
||||
changes (cond-> changes alt-duplication? (assoc :tags (conj tags :alt-duplication)))
|
||||
|
||||
id-original (first selected)
|
||||
|
||||
|
|
|
@ -67,11 +67,12 @@
|
|||
(add-undo-entry state entry))))
|
||||
|
||||
(defn- accumulate-undo-entry
|
||||
[state {:keys [undo-changes redo-changes undo-group]}]
|
||||
[state {:keys [undo-changes redo-changes undo-group tags]}]
|
||||
(-> state
|
||||
(update-in [:workspace-undo :transaction :undo-changes] #(into undo-changes %))
|
||||
(update-in [:workspace-undo :transaction :redo-changes] #(into % redo-changes))
|
||||
(assoc-in [:workspace-undo :transaction :undo-group] undo-group)))
|
||||
(assoc-in [:workspace-undo :transaction :undo-group] undo-group)
|
||||
(assoc-in [:workspace-undo :transaction :tags] tags)))
|
||||
|
||||
(defn append-undo
|
||||
[entry stack?]
|
||||
|
|
Loading…
Reference in a new issue