mirror of
https://github.com/penpot/penpot.git
synced 2025-05-10 15:56:37 +02:00
Add page metadata changes to the undo stack.
This commit is contained in:
parent
bb28ab78d6
commit
438f8f5f82
1 changed files with 20 additions and 17 deletions
|
@ -27,7 +27,8 @@
|
||||||
(rx/take 1))]
|
(rx/take 1))]
|
||||||
(->> stream
|
(->> stream
|
||||||
(rx/take-until stopper)
|
(rx/take-until stopper)
|
||||||
(rx/filter #(satisfies? udp/IPageUpdate %))
|
(rx/filter #(or (satisfies? udp/IPageUpdate %)
|
||||||
|
(satisfies? udp/IMetadataUpdate %)))
|
||||||
(rx/filter #(not (undo? %)))
|
(rx/filter #(not (undo? %)))
|
||||||
(rx/filter #(not (redo? %)))
|
(rx/filter #(not (redo? %)))
|
||||||
(rx/debounce 500)
|
(rx/debounce 500)
|
||||||
|
@ -42,15 +43,13 @@
|
||||||
(defrecord SaveUndoEntry [id]
|
(defrecord SaveUndoEntry [id]
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [page (udp/pack-page state id)]
|
(let [page (udp/pack-page state id)
|
||||||
|
undo {:data (:data page)
|
||||||
|
:metadata (:metadata page)}]
|
||||||
(-> state
|
(-> state
|
||||||
(update-in [:undo id :stack] #(cons (:data page) %))
|
(update-in [:undo id :stack] #(cons undo %))
|
||||||
(assoc-in [:undo id :selected] 0)))))
|
(assoc-in [:undo id :selected] 0)))))
|
||||||
|
|
||||||
;; ptk/EffectEvent
|
|
||||||
;; (effect [_ state]
|
|
||||||
;; (let [undo (get-in state [:undo id])]
|
|
||||||
;; (println (pr-str undo)))))
|
|
||||||
|
|
||||||
(defn save-undo-entry
|
(defn save-undo-entry
|
||||||
[id]
|
[id]
|
||||||
|
@ -91,15 +90,17 @@
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [page-id (get-in state [:workspace :page])
|
(let [page-id (get-in state [:workspace :page])
|
||||||
undo (get-in state [:undo page-id])
|
undo-state (get-in state [:undo page-id])
|
||||||
stack (:stack undo)
|
stack (:stack undo-state)
|
||||||
selected (:selected undo 0)]
|
selected (:selected undo-state 0)]
|
||||||
(if (>= selected (dec (count stack)))
|
(if (>= selected (dec (count stack)))
|
||||||
state
|
state
|
||||||
(let [pointer (inc selected)
|
(let [pointer (inc selected)
|
||||||
page (get-in state [:pages page-id])
|
page (get-in state [:pages page-id])
|
||||||
data (nth stack pointer)
|
undo (nth stack pointer)
|
||||||
packed (assoc page :data data)]
|
data (:data undo)
|
||||||
|
metadata (:metadata undo)
|
||||||
|
packed (assoc page :data data :metadata metadata)]
|
||||||
|
|
||||||
;; (println "Undo: pointer=" pointer)
|
;; (println "Undo: pointer=" pointer)
|
||||||
;; (println "Undo: packed=")
|
;; (println "Undo: packed=")
|
||||||
|
@ -124,15 +125,17 @@
|
||||||
ptk/UpdateEvent
|
ptk/UpdateEvent
|
||||||
(update [_ state]
|
(update [_ state]
|
||||||
(let [page-id (get-in state [:workspace :page])
|
(let [page-id (get-in state [:workspace :page])
|
||||||
undo (get-in state [:undo page-id])
|
undo-state (get-in state [:undo page-id])
|
||||||
stack (:stack undo)
|
stack (:stack undo-state)
|
||||||
selected (:selected undo)]
|
selected (:selected undo-state)]
|
||||||
(if (or (nil? selected) (zero? selected))
|
(if (or (nil? selected) (zero? selected))
|
||||||
state
|
state
|
||||||
(let [pointer (dec selected)
|
(let [pointer (dec selected)
|
||||||
data (nth stack pointer)
|
undo (nth stack pointer)
|
||||||
|
data (:data undo)
|
||||||
|
metadata (:metadata undo)
|
||||||
page (get-in state [:pages page-id])
|
page (get-in state [:pages page-id])
|
||||||
packed (assoc page :data data)]
|
packed (assoc page :data data :metadata metadata)]
|
||||||
|
|
||||||
;; (println "Redo: pointer=" pointer)
|
;; (println "Redo: pointer=" pointer)
|
||||||
;; (println "Redo: packed=")
|
;; (println "Redo: packed=")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue