I’m trying to make Lexical work when the document is already loaded (issue).
I know exactly what to do but not how to do it. The problem is here, the state gets read from the document as it comes in, but not from anything that was already loaded.
Is there a way to convert the current XmlText to an observe callback format?
In y-websocket there is a 'synced' event in WebsocketProvider that tells others it’s ready. You could try triggering something similar manually to see if it helps. It’s definitely a bug in lexical so probably someone there will handle it.
I agree that it should ideally be fixed within lexical. As a workaround, you might consider attaching an empty Doc doc to the editor first, then do Y.applyUpdate(doc, Y.encodeStateAsUpdate(docExisting)). That should trigger the observe event on doc.
But ideally I’d like to fix it in Lexical, I can make a PR but I’m just lost going from an update to the format that XmlText observe emits. The code that receives those updates is quite complex and I think it will be too error-prone to have separate code that loads state.