I have y-quill with collaborate editing with y-websocket updates synchronization.

I need to make snapshots to mysql database to show document text on the website.

My guess is that I need to use CALLBACK_URL and CALLBACK_OBJECTS to send data to server via API. But I don’t know if I’m right and if I am then how to pass quill content to api.

Anyone can help me to do it in true yjs way?

Hi @NickMitin,

the CALLBACK_* feature was proposed as a neat little helper to the y-websocket project. I think everybody is currently doing the same thing differently. I accepted the CALLBACK_* PR because I thought it might be generally useful. But it might not cover all cases, so you are absolutely encouraged to try out something different.

Here is how it works:

Since y-quill uses th Y.Text type, you need to specify CALLBACK_OBJECTS as a Y.Text. Assuming you do the following on the client-side:

const ydoc = new Y.Doc()
const ytext = ydoc.getText('editor') // "editor" is just an arbitrary string - you could also name it "content"
const binding = new QuillBinding(ytext, editor)

Then you start the server with …

CALLBACK_URL=http://localhost:3000/ CALLBACK_OBJECTS='{"editor":"Text"}' npm start
#                                                       ↳ the name of the Y.Text type on ydoc
#                                                                ↳ The used type class

Now the y-websocket server will send PUT or POST requests to localhost:3000 whenever the document changes.