Does a huge text (with tiny changes) overriding lead an entire document sync?

I know if I type something in Yjs Editor directly, it will be a small patch sync. But~~~
If I copy the current huge text from the Yjs Editor, then give it a tiny change, paste it back to replace the original one, will this action cause a entire document sync? I mean, whether the Yjs can detect the tiny change and sync only a patch? The network bandwidth is expensive, patch sync will be nice.

That will depend on the editor and how it interacts with the underlying YText. If it diffs on paste, then the patch will be small. If it does ytext.delete followed by ytext.insert it will be big.

I recommend performing a test and comparing the update size for pasting over vs doing the same edit manually.

Thanks for reply. So, the YText dosen’t have a diff detection. Hope some day, there would be a diff integration in or with Yjs.

A YText just has insert, delete, format, and applyDelta for making modifications. It really is up to the editor, not YJS, to choose how to modify the YText.

Luckily it’s pretty easy to convert a diff to a delta and use ytext.applyDelta. Check out this discussion and the included demo: