reedsy / quill-cursors

A multi cursor module for Quill text editor.
MIT License
249 stars 53 forks source link

IndexSizeError after inserting image and then selecting everything in the editor #57

Closed anna-kartynnik closed 4 years ago

anna-kartynnik commented 4 years ago

Hello, thank you for your module. I found a strange issue while working with it.

Steps to reproduce:

  1. Open https://jsfiddle.net/ganachka/w0udaost/5/ (I used the same code you have in your example folder).
  2. Additionally open Developer tools with browser console.
  3. Paste an image to one of the editors (it's important to copy image itself and paste it, not its URL).
  4. Select the content of the editor, for example by pressing Cmd+A

After that I get IndexSizeError: Index or size is negative or greater than the allowed amount from the quill-cursors script. I also get the same error when I resize browser window after that.

The screenshot from Firefox (but experienced the same in Chrome too):

Screen Shot 2020-05-20 at 12 11 34 AM

Do you have any ideas about how it can be fixed?

alecgibson commented 4 years ago

Interesting, if I follow your steps I get an error, but a different error:

quill-cursors.js:1 Uncaught DOMException: Failed to execute 'setEnd' on 'Range': There is no child at offset 1.
    at https://unpkg.com/quill-cursors@3.0.0/dist/quill-cursors.js:1:11573
    at Array.reduce (<anonymous>)
    at t._lineRanges (https://unpkg.com/quill-cursors@3.0.0/dist/quill-cursors.js:1:11299)
    at t._updateCursor (https://unpkg.com/quill-cursors@3.0.0/dist/quill-cursors.js:1:10035)
    at t.moveCursor (https://unpkg.com/quill-cursors@3.0.0/dist/quill-cursors.js:1:8510)
    at https://fiddle.jshell.net/ganachka/w0udaost/5/show/?editor_console=:190:30

I'll investigate

alecgibson commented 4 years ago

@anna-kartynnik released a fix in 3.0.1. Please let me know if this doesn't solve your issue.

anna-kartynnik commented 4 years ago

Works for me, thanks!