mirror of
https://github.com/logseq/logseq.git
synced 2026-05-05 19:36:35 +00:00
refactor: new undo/redo implementation
Previous undo/redo requires to handle every editor operation including any new ops. The new implemenation focus on db attributes instead of ops, it assumes that most attributes can be safely overwritten except :block/parent, block/order and other ref-type attributes. It works likes: 1. If a block has been moved by another client (:block/parent or :block/order has been changed), the whole tx will be skipped 2. If a refed entity has been deleted, the datom will be skipped
This commit is contained in:
@@ -553,13 +553,14 @@ when undo this op, this original entity-map will be transacted back into db")
|
||||
(:gen-undo-boundary-op? tx-meta true)
|
||||
tx-meta)))
|
||||
|
||||
(defn record-editor-info!
|
||||
[repo page-block-uuid editor-info]
|
||||
(swap! (:undo/repo->page-block-uuid->undo-ops @worker-state/*state)
|
||||
update-in [repo page-block-uuid]
|
||||
(fn [stack]
|
||||
(when (seq stack)
|
||||
(conj (vec stack) [::record-editor-info editor-info])))))
|
||||
(comment
|
||||
(defn record-editor-info!
|
||||
[repo page-block-uuid editor-info]
|
||||
(swap! (:undo/repo->page-block-uuid->undo-ops @worker-state/*state)
|
||||
update-in [repo page-block-uuid]
|
||||
(fn [stack]
|
||||
(when (seq stack)
|
||||
(conj (vec stack) [::record-editor-info editor-info]))))))
|
||||
|
||||
;;; listen db changes and push undo-ops (ends)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user