Read the value from the database as the initial value for the collaboration

I use slate-yjs and use y-websocket as provider.

I want to make a collaborative file system that allows file owners to turn on or off cooperative editing permissions for files at any time, after which the file contents are persisted to mysql.
Now that the file owner has enabled the collaboration permissions, the file content needs to be the initial value in the websocket server room. I tried to modify the getDoc function of y-websocket/bin/utils.cjs as follows.

const getYDoc = (docname, gc = true) => map.setIfUndefined(docs, docname, () => {
  const doc = new WSSharedDoc(docname)
  const initialDoc=new Y.Doc()
  initialDoc.get('slate',Y.XmlText).insert(0,"initialValue");
  Y.applyUpdate(doc,Y.encodeStateAsUpdate(initialDoc,Y.encodeStateVector(doc)),)
  // if I write like this,will throw error
  //C:\Users\86170\Desktop\y-websocket-2.0.4\y-websocket-2.0.4\node_modules\yjs\dist\yjs.cjs:636
  // throw new Error(`Type with the name ${name} has already been defined with a different constructor`
  // doc.getText("slate").insert(0,"initialValue");

  if (persistence !== null) {
    persistence.bindState(docname, doc)
  }
  docs.set(docname, doc)
  return doc
})

But after I do this, the initial value of each room is still empty.
Do you have any good solutions?