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

Changes are being accepted when shouldn't #3

Open
seleckis opened this issue Jan 5, 2024 · 3 comments
Open

Changes are being accepted when shouldn't #3

seleckis opened this issue Jan 5, 2024 · 3 comments

Comments

@seleckis
Copy link

seleckis commented Jan 5, 2024

I have added buttons to accept or reject changes in a toolbar:

<button
  onClick={() => editor.chain().focus().acceptChange()}
  disabled={!editor.can().chain().focus().acceptChange()}
  >
  accept
</button>

this is a main approach to construct toolbar with commands.

The issue: when this button is there, inserted content goes accepted right after typing, but the deleted content — on putting caret in the deleted area.

I have also tried to do like this

<button
  onClick={() => editor.commands.acceptChange()}
  disabled={!editor.commands.acceptChange()}
  >
  accept
</button>

Same result, also throws an error:

Uncaught RangeError: Applying a mismatched transaction

The Demo doesn't have an example of usage of these functions.

@seleckis
Copy link
Author

seleckis commented Jan 5, 2024

btw there is a typo in documentation, should be acceptAllChanges and rejectAllChanges, "-s" is missing.

@chenyuncaiwork
Copy link
Contributor

AcceptChange is a method call, not a state. Maybe you put it in your disable status cause it was caculated(invoked) sometime?

It seems we need expose a computed status to outside. I'll try it latter.

Thanks

@seleckis
Copy link
Author

I'm working on my own track changes plugin, so I cannot check the issue again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants