yjs / y-prosemirror

ProseMirror editor binding for Yjs
https://demos.yjs.dev/prosemirror/prosemirror.html
MIT License
344 stars 119 forks source link

How to restore a snapshot #72

Open joacub opened 3 years ago

joacub commented 3 years ago

I already have the doc update but I don't know how to apply this to prose mirror editor, when apply im losing all the history Im using the next code to apply the snapshot

const newProsemirrorDoc = yDocToProsemirror(editor.schema, yDoc);

 editorView.state.doc = newProsemirrorDoc;
 editorView.dispatch(
    editorView.state.tr.setMeta(ySyncPluginKey, {
      restore: true,
      snapshot: yState.snapshot,
    })
 );

any suggestion for how to apply the update