Repository navigation
feat(core): group undo steps by browser task - #203
Draft
ilyamore88 wants to merge 2 commits into
Draft
ilyamore88 wants to merge 2 commits into
ilyamore88 wants to merge 2 commits into
Conversation
UndoRedoManager buffers the local model events of the current browser task and records them when the task ends (setTimeout 0). A single event keeps the consecutive-text batching, so typing is unchanged; several events from one task (Enter split, paste) close the open batch and start a new step together. undo()/redo() record buffered events first, destroy() drops them. Also wrap block-level event data in a list when re-applying it: block events carry one serialized block while the model inserts/removes blocks as lists, so undoing or redoing any block add/remove used to throw.
ilyamore88
added this pull request to stack #204
October 10, 2026 12:26
This was referenced Oct 10, 2026
Contributor
Unit Tests
Mutation Tests
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
This PR implements
undo-group-by-task, proposed in #201. It is the middle of the stack: #201 (proposal) ← this ← #191 (clipboard paste proposal).UndoRedoManager(core)setTimeout(0), which runs after the task and its microtasks.undo()andredo()record buffered events first.destroy()clears the task timer and drops the buffer.EditorDocument.insertData/removeDataexpect a list for aBlockIndex. Undoing or redoing any block add or remove threwdata.forEach is not a function.#applynow wraps the block in a one-item list.Tests
endTask()between events that model separate user actions.UndoRedoManager.integration.spec.ts(real model andBlocksManager): a mid-paragraph Enter undoes in one step, and a split that adds a block undoes and redoes withoutAlreadyExistingKeyError.Docs
docs/collaboration.mdanddocs/diagrams/undo-redo-flow.mmddescribe task grouping, and note thatcollaboration-managerdoesn't group by task yet.tasks.mdis fully checked in this PR.Verification
packages/core: 197 tests pass,lint:ciis clean, and the build succeeds.UndoRedoManager.tsscores 86%.yarn lintpasses. Rootyarn testpasses exceptcollaboration-manager/CollaborationManager.spec.ts, which fails to load locally on Node 20.9 (WebSocket is not defined). That package doesn't depend on core.Notes for reviewers
tasks.mdis complete. Archive it before merging, or label the PRopenspec:defer-archivewhile the stack is under review.