yjs / y-prosemirror

ProseMirror editor binding for Yjs
https://demos.yjs.dev/prosemirror/prosemirror.html
MIT License
328 stars 115 forks source link

Readme section for undo/redo, proposed addToHistory command #111

Closed thatsjonsense closed 2 years ago

thatsjonsense commented 2 years ago

The proposed API mirrors prosemirror-history, for more info see https://github.com/ProseMirror/prosemirror-history/blob/master/src/history.js#L380

dmonad commented 2 years ago

Thanks :+1: I implemented the API and will release it in a bit.

thatsjonsense commented 2 years ago

Hey @dmonad , thanks so much for pushing this change. I've been testing it locally though and I'm still not seeing the intended behavior. It looks like when ProseMirror sends multiple transactions in a row, y-prosemirror is batching them together and only checking this meta key for the last one. This means that the whole batch is still actually getting captured.

image

Is there any way to prevent this?

dmonad commented 2 years ago

I think this is fixed in v1.1.1, can you please verify?

thatsjonsense commented 2 years ago

Hey @dmonad unfortunately not. I think the issue remains that when multiple prosemirror transactions happen in short sequence, and Yjs batches them together into its own transaction, only the last prosemirror transaction's addToHistory value is used:

image

thatsjonsense commented 2 years ago

I haven't tested this code, but I suspect a solution would look something like:

image
dmonad commented 2 years ago

@thatsjonsense I think the next release should fix this issue.

dmonad commented 2 years ago

If not, please write a test case so I can reproduce it better.