Hello,
I am a college undergrad using TipTap+y-websocket for a project. I was successful in setting up persistence using the bindState and writeState interfaces. Since I am persisting the Y.Doc in my database, I need to recover the TipTap’s JSON state from the Y.Doc for server-side processing.
I tried using yDocToProseMirrorJSON from y-prosemirror but it returns the following JSON:
{ type: 'doc', content: [] }
I narrowed it down to .toArray method within the function’s implementation returning an empty array.
I use the following to reinitialize my Y.Doc with the persisted state:
loadFromDatabase().then(data => {
const ydoc = new Y.Doc;
Y.applyUpdate(ydoc, data); // I persist data using Y.encodeStateAsUpdate(ydoc) in writeState()
console.log(yDocToProseMirrorJSON(ydoc)); // returns the empty json above
})
How may I access the JSON state from the Y.Doc? I need to recover it server-side in a NodeJS environment and not client-side.
I wasn’t able to find anything similar on the forum. I would appreciate any help regarding the same.
Thank you for your help.