inokawa / rich-textarea

A small customizable textarea for React to colorize, highlight, decorate texts, offer autocomplete and much more.
https://inokawa.github.io/rich-textarea/
MIT License
312 stars 8 forks source link

The `rangeAtIndex` throws an `IndexSizeError` error #160

Closed uonr closed 1 month ago

uonr commented 1 month ago

Describe the bug Sometimes the library will throw IndexSizeError.

IndexSizeError
Failed to execute 'setStart' on 'Range': The offset 4294967295 is larger than the node's length (3).

Here's where the error occurred https://github.com/inokawa/rich-textarea/blob/main/src/vendor/range-at-index.js#L47

Called by https://github.com/inokawa/rich-textarea/blob/main/src/input.tsx#L270 and https://github.com/inokawa/rich-textarea/blob/main/src/textarea.tsx#L247

I haven't set selection in my code, I don't know why it's causing this error, it could also be a browser bug, but it looks like you can avoid a component crash by simply checking the selectionStart.

To Reproduce I only have the bug report, not the actual reproduction.

Expected behavior Check the parameters, or catch an error so that the component does not crash.

图片

Platform:

Additional context Add any other context about the problem here.

inokawa commented 1 month ago

https://github.com/slab/quill/issues/3080#issuecomment-652000347 https://github.com/ueberdosis/tiptap/issues/954#issuecomment-788133825

inokawa commented 1 month ago

I patched it in 0.26.3. Please reopen this issue If it happens again.