Closed usman-web-dev closed 2 months ago
I think removing the timeout was the right choice. The initial content shouldn't be populated in a timeout - it should happen synchronously. This also fixes other issues, that we can't fix any other way. I'm sorry that this breaks remirror. @ifiokjr let me know if you need help on this.
If you populate the initial ProseMirror state with the Yjs content, no state change is triggered. This avoids an unnecessary update and is generally the recommended way to instantiate ProseMirror state. Please check the demo in this repository to see how to do that. But I think remirror could also support the synchronous state change.
const { doc, mapping } = initProseMirrorDoc(type, schema)
const prosemirrorView = new EditorView(editor, {
state: EditorState.create({
doc,
schema,
plugins: [
ySyncPlugin(type, { mapping }),
yCursorPlugin(provider.awareness),
yUndoPlugin(),
keymap({
'Mod-z': undo,
'Mod-y': redo,
'Mod-Shift-z': redo
})
].concat(exampleSetup({ schema }))
})
})
Checklist
Describe the bug Before 1.2.4, remirror was working fine, but as soon as I updated to 1.2.4 it's breaking. It says
Cannot read properties of undefined (reading 'state')
To Reproduce Steps to reproduce the behavior:
npm i
and thennpm run dev
to serveCannot read properties of undefined (reading 'state')
Expected behavior The app should run as it runs on
1.2.3
Screenshots
Environment Information
y-prosemirror
are on latest versionsAdditional context From what I have figured out that the error is occurring due to this change, if we put back the timeout, it will start working again.
Possible workaround Hardcode
y-prosemirror
to1.2.3
usingnpm i y-prosemirror@1.2.3