Yjs overside the previous schema doc

When you use Yjs for shared editing, Yjs will control the content of the editor. The initial content shouldn’t be set in the initial state in ProseMirror, because the initial state must be empty when you have a collaborative document that is opened by several users at once. One approach would be to set the initial content in the server. Another approach would be to set the initial document content after the editor instance is created and the websocket server is opened. Here is an example:

const prosemirrorView = new EditorView({ .. })
let setInitialContent = false
provider.on('sync', () => {
  // The "sync" event is fired every time the "provider.synced" state changes.
  // I.e. when y-websocket created a connection and synced with the server

  // Only set the initial state once. Only set it when the initial content if the document is empty.
  if (!setInitialContent && provider.synced && prosemirrorView.state.content.size < 3) {
    setInitialContent = true
    prosemirrorView.setState($yourInitialContent)
  }
})

But please not that this approach is not ideal if you also want to handle clients that are temporarily offline. It would be better to set the initial content in the server. Better yet, store e Yjs document updates instead of the ProseMirror state. This will allow you to always sync clients and you can still set the initial content on the client side.