chenyuncai / tiptap-track-change-extension

MIT License
78 stars 11 forks source link

Changes are being accepted when shouldn't #3

Open seleckis opened 7 months ago

seleckis commented 7 months ago

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 commented 7 months ago

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

chenyuncaiwork commented 7 months ago

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 commented 7 months ago

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