Repository navigation
Conversation
The multi-column drop handler removed the dragged blocks and then created or updated the column list with separate editor calls, so each dispatched its own transaction. When the two edits weren't adjacent, prosemirror-history put them in separate undo groups: the first undo only reverted the column change, leaving the dragged blocks deleted, and a second undo was needed to bring them back. Run the removal and the column list change in one `editor.transact` call so the whole drop is one transaction and one undo step. Closes TypeCellOS#3197
|
@adarshsm is attempting to deploy a commit to the TypeCell Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
Important Draft PR not reviewedDraft PRs are not automatically reviewed by default.
To automatically review draft PRs, update your CodeRabbit configuration: reviews:
auto_review:
drafts: true
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
@blocknote/ariakit
@blocknote/code-block
@blocknote/core
@blocknote/diagram-block
@blocknote/mantine
@blocknote/math-block
@blocknote/react
@blocknote/server-util
@blocknote/shadcn
@blocknote/xl-ai
@blocknote/xl-docx-exporter
@blocknote/xl-email-exporter
@blocknote/xl-multi-column
@blocknote/xl-odt-exporter
@blocknote/xl-pdf-exporter
@blocknote/xl-typst-exporter
commit: |
This branch has not been deployed
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.
Summary
Closes #3197.
Dropping a block on the left or right edge of another block (which creates a column list or adds a column) took two undos to revert. The first undo removed the column change but left the dragged block deleted, so the block disappeared until a second undo brought it back. With this change, one undo reverts the whole drop.
Rationale
createMultiColumnHandleDropPlugin'shandleDropfirst callseditor.removeBlocks(...)to take the dragged blocks out of their old position. It then callseditor.replaceBlocks(...)oreditor.updateBlock(...)to build the column list. Each of those calls runs its owneditor.transact, so the drop dispatches two transactions.prosemirror-history merges consecutive transactions into one undo event only when their changed ranges are adjacent. A block dragged from elsewhere in the document usually isn't adjacent to the drop target, so the drop becomes two undo events. Undoing the newer one restores the target and leaves the removal in place.
The reporter's suggestion in the issue (wrapping both steps in
editor.transact()) is what this PR does.Changes
multiColumnHandleDropPlugin.ts: both branches (adding a column to an existing column list, and creating a new column list) now run the removal and the column-list change inside oneeditor.transact(() => ...). The nestedtransactcalls inremoveBlocks/replaceBlocks/updateBlockreuse the outer transaction, so the drop dispatches once. The logic inside is unchanged apart from indentation.Impact
onChangelisteners see a single change instead of two.Testing
New
undoing an edge dropcases insrc/test/extensions/columnDrop.test.ts, using the existingdropOnEdgehelper:paragraph-2onparagraph-1's edge (creates a column list;column-list-0sits between them)paragraph-0oncolumn-1's edge (adds a column;paragraph-1sits between them)Each test checks that the drop changed the document and that one
editor.undo()restores it. The test movesDate.nowforward for the drop so it starts its own undo group and isn't merged with thebeforeEachdocument setup.On
mainboth cases fail the same way as the issue: after one undo, the dragged block (paragraph-2/paragraph-0) is missing from the document. With this change both pass.Full
@blocknote/xl-multi-columnsuite: 123 passed, 5 skipped.vp lintandvp fmt --checkare clean on the touched files.Screenshots/Video
n/a
Checklist
Additional Notes
I only ran the jsdom suite locally, not the browser drag-and-drop tests (
columnDrop.browser.test.ts).🤖 Generated with Claude Code