Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling editor.updateBlock() in quick succession breaks the editor's undo/redo functionality #829

Open
balu-deciphr opened this issue Jun 10, 2024 · 1 comment
Labels
bug Something isn't working prio:low Low priority

Comments

@balu-deciphr
Copy link

balu-deciphr commented Jun 10, 2024

Describe the bug
I'm using an (old) example from the docs to highlight blocks spanned by the current selection. The highlighting works just fine, but this seems to break the editor's undo/redo functionality.

To Reproduce
The demo is here.

To reproduce the issue, please do the following:

  1. Type something in the initialized content
  2. Press ctrl + z or cmd + z to undo what you typed. It will take multiple attempts to undo just one character.
  3. Remove the onSelectionChange prop from <BlockNoteView />
  4. Type something again in the editor
  5. Now the undo should work just fine.

It looks like the editor.updateBlock() calls within the editor.forEachBlock() causes the editor's history to break. Is there an alternate way to update the style of blocks?

Misc

  • Node version: 20.11.1
  • Package manager: npm
  • Browser: Firefox 126.0.1, Google Chrome 125.0.6422.142
@balu-deciphr balu-deciphr added the bug Something isn't working label Jun 10, 2024
@matthewlipski matthewlipski changed the title Updating a block's style with editor.updateBlock() breaks the editor's undo/redo functionality Calling editor.updateBlock() in quick succession breaks the editor's undo/redo functionality Jun 11, 2024
@matthewlipski
Copy link
Collaborator

Good catch! You're right, it does seem like calling updateBlock many times in a short time causes history to break. Seems like we should make it possible to update multiple blocks at once to prevent this.

@matthewlipski matthewlipski added the prio:low Low priority label Jun 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working prio:low Low priority
Projects
None yet
Development

No branches or pull requests

2 participants