yjs / y-quill

Quill Editor binding for Yjs
https://demos.yjs.dev/quill/quill.html
MIT License
80 stars 18 forks source link

Nonconvergence when selecting Header on demo site #7

Closed burke closed 3 years ago

burke commented 3 years ago

Checklist

Describe the bug

Selecting "Heading 1" causes divergent states across peers

To Reproduce Steps to reproduce the behavior:

  1. Open https://demos.yjs.dev/quill/quill.html in two windows
  2. Clear document contents
  3. Refresh both windows
  4. Click "Normal" and select "Heading 1" in one window
  5. Type "heading 1" (newline) (newline) "normal"
  6. Observe different states across windows
  7. Refresh both windows
  8. Observe that both documents are now in a third state, different from either state from step 6.

Expected behavior

No divergence

Screenshots

Screen Shot 2020-10-22 at 15 09 08 Screen Shot 2020-10-22 at 15 09 16

Environment Information

dmonad commented 3 years ago

Hi @burke , Quill sometimes inserts additional formatting changes without firing the appropriate events. It is hard to detect that this is happening.

Quill has some really weird behavior if the last paragraph receives formatting attributes (e.g. the last paragraph is transformed to a heading, then to a centered text). One solution would be to prevent the user from creating empty documents. Before the user modifies the last paragraph, we could automatically append an additional paragraph. However, this is far from optimal..

The best solution for this would be to always double-check the quill document before applying formatting changes.

To be honest, it could be a while before I have time to look into this.

dmonad commented 3 years ago

This was an issue with the text-formatting implementation in Yjs. It should be fixed now.

I followed the steps to reproduce the issue and now end up in the same state on all sites.

You will notice that one window might have a newline more than another window. But that is the expected behavior for now. The text-attributes and block-formats don't diverge anymore.

Please let me know if you can still reproduce the issue.