Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remirror is broken after [email protected] #155

Closed
3 of 4 tasks
usman-web-dev opened this issue Jun 19, 2024 · 1 comment
Closed
3 of 4 tasks

remirror is broken after [email protected] #155

usman-web-dev opened this issue Jun 19, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@usman-web-dev
Copy link

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:

  1. Clone this repo
  2. Run npm i and then npm run dev to serve
  3. 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

Screenshots
image

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 [email protected]

  • I'm a sponsor 💖
  • This issue is a blocker for my project.
@usman-web-dev usman-web-dev added the bug Something isn't working label Jun 19, 2024
@dmonad
Copy link
Member

dmonad commented Jun 20, 2024

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 }))
  })
})

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants