remirror is broken after y-prosemirror@1.2.4
usman-web-dev opened this issue · comments
Checklist
- Are you reporting a bug? Use github issues for bug reports and feature requests. For general questions, please use https://discuss.yjs.dev/
- Try to report your issue in the correct repository. Yjs consists of many modules. When in doubt, report it to https://github.com/yjs/yjs/issues/
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:
- Clone this repo
- Run
npm i
and thennpm run dev
to serve - There will be a blank page and if you open the console, there will be an error saying
Cannot read properties of undefined (reading 'state')
Expected behavior
The app should run as it runs on 1.2.3
Environment Information
- Browser: Chrome
- YJS and
y-prosemirror
are on latest versions
Additional 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
to 1.2.3
using npm i y-prosemirror@1.2.3
- I'm a sponsor 💖
- This issue is a blocker for my project.
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 }))
})
})