The content is doubled when it is synced

I’m going to make article editing collaboration platform.
I placed Quill editor in the edit page and integrated Y.js library.
As you know, the article has its initial content.
My idea is that when the author is editing the content, the other connected peers can see editing in real-time.
I set initial content to both author and watcher’s quill editor and the problem is that after syncing, both editor’s content is doubled.
Who have ever met this situation? Kindly help me. Thanks.

I have encountered the same issue. The root cause of this problem is that Y.js cannot distinguish between the initial value and the actual content when setting the initial value. I have a solution, though I’m not sure if it aligns with Y.js’s design, but I’ve been using it for six months without any issues. The method is to set the client ID to 1 when setting the initial value (I set it on the server and sync it to the clients). This way, even if the initial value is set twice, since the client ID + sv are the same, it won’t be synced again.

@ununian This is a terrible idea! You will encounter sync issues - if that is not already the case. Please do not make suggestions like these, without highlighting the consequences.

@johny_giang Content should only be initialized once. Either the user who creates the document initializes the content, or the server (any central source) populates the document with initial content. Two clients should not populate the content at the same time! This will lead to sync issues once a client joins and the content is initialized in a different way.

Thank you for your kindful answer. I’ll try and then let you know back. :grinning: