yjs / y-prosemirror

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

TypeError: nextytext.toDelta is not a function or its return value is not iterable #163

Closed danny-hunt closed 3 months ago

danny-hunt commented 3 months ago

Crash caused by upgrading to 1.2.11

Checklist

Describe the bug TypeError: nextytext.toDelta is not a function or its return value is not iterable shows on performing a specific action in the editor. This caught error escalates to a crash on other actions (eg changing page)

I added some console logging in sync-plugin.js on my machine (logging out the type & nextytext):

image

And get these logs - showing an instance where nextytext does not have a toDelta function.

image

The command function here is the one that triggers the error for me. There must be more than one user collaborating at the same time for the bug to occur

image

I've patched the error locally via

image

To Reproduce Apologies that I don't have a simple example case for this Steps to reproduce the behavior:

  1. Two users in collaboration
  2. Open console
  3. Perform action that results in a nextytext that does not have a toDelta function (eg a YXmlElement)
  4. See error

Expected behavior Would not expect a strict requirement for nextytext to have a toDelta function

Screenshots Added above

Environment Information

Additional context

manstie commented 3 months ago

I am also getting this issue when trying to copy an editor's contents to another using this:

xml2.insert(
    0,
    xml1
    .toArray()
    .filter((item) => !(item instanceof XmlHook))
    .map((item) => item.clone()),
);
dmonad commented 3 months ago

Thank you for the bug report. The issue should be fixed in the latest release (1.2.12). Thanks to @manstie we have a bugfix. Please let me know if there is still an issue.