mdx-editor / editor

A rich text editor React component for markdown
https://mdxeditor.dev
MIT License
1.75k stars 139 forks source link

[BUG] Undo/Redo Stack shared between multiple editor instances #554

Open Sin-Yone opened 1 month ago

Sin-Yone commented 1 month ago

If you want to ask for support or request features, sponsor the project and contact me over email.

Describe the bug If two or more instances of the editor are used and content has been created in them, when undo/redo is called in one editor, undo/redo is also performed in the other editors when all changes have been completed in the current editor.

Reproduction https://codesandbox.io/p/sandbox/mdx-editor-base-forked-r7vynx

To Reproduce Steps to reproduce the behavior:

  1. Create two or more editor instances
  2. Create content in each of them
  3. Undo/redo all changes in one of them and keep doing undo/redo (either with shortcut or with the button in the toolbar)
  4. See undo/redo applied to the other editor as well

Expected behavior Undo/redo only applies to the content of the editor, where it was called.

Video

https://github.com/user-attachments/assets/c775203b-466c-4d3f-a760-63a4e5b09adf

Desktop

Additional context I went back to version 2.0 and the error still occurred. Only when I switched to version 1.* did undo/redo only apply to the content of the editor to which it belongs.