ckeditor / ckeditor5

Powerful rich text editor framework with a modular architecture, modern integrations, and features like collaborative editing.
https://ckeditor.com/ckeditor-5
Other
9.51k stars 3.7k forks source link

[Safari] Crash after removing all content when table is the last element in the editor #10580

Closed FilipTokarski closed 9 months ago

FilipTokarski commented 3 years ago

📝 Provide detailed reproduction steps (if any)

  1. Open editor in Safari
  2. Add some content and a table, so that the table is the last element inside the editor
  3. Select all
  4. Press backspace

✔️ Expected result

Content is removed, no errors.

❌ Actual result

Content is removed, console throws errors, making editor mostly unusable:

[Error] CKEditorError: The index is not in the allowed range.
Read more: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html#error-The index is not in the allowed range.
    rethrowUnexpectedError (snippet.js:4:1599)
    fire (snippet.js:4:56027)
    n (snippet.js:4:176924)

[Error] CKEditorError: cannot-change-view-tree
Read more: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html#error-cannot-change-view-tree
    rethrowUnexpectedError (snippet.js:4:1599)
    fire (snippet.js:4:56027)
    set (snippet.js:4:71308)
    (anonymous function) (snippet.js:4:138121)

📃 Other details


If you'd like to see this fixed sooner, add a 👍 reaction to this post.

mateuszzagorski commented 2 years ago

It does not crash for me when:

1. The table is the only element in the editor:
https://ckeditor.com/docs/ckeditor5/latest/features/table.html#table-caption
2. There is one line of text (before and/or after the table), and a table.
https://ckeditor.com/docs/ckeditor5/latest/features/table.html#nesting-tables
3. There are multiple tables but only 1 line of text (before/after/between them).

Additionally, it seems that when the text between the tables is a link it does not cause the editor to crash as well.

olga-kulish commented 2 years ago

I have a similar issue with the images.
Enter text --> on the next line upload block image --> Ctrl+A, Delete --> error. (Won't reproduce for inline image on the same line. Won't reproduce if there is other text below image.) After this error is thrown, you can't upload images anymore.

Can be reproduced on the demo page:

https://user-images.githubusercontent.com/38751932/177203208-baac59a2-6c45-4e02-a4d2-e189d688dd87.mp4

This leads to isDomSelectionBackward:range.setEnd https://github.com/ckeditor/ckeditor5/blob/v34.1.0/packages/ckeditor5-engine/src/view/domconverter.js#L1097 In Safari, focusOffset is 2 when focusNode.childNodes.length is 1 (focusNode is <p><br></p>). So when converter tries to create a range from this offset, it fails because offset is bigger then the number of child nodes. In Chrome, focusOffset is 1 and everything is ok.

CKEditorBot commented 10 months ago

There has been no activity on this issue for the past year. We've marked it as stale and will close it in 30 days. We understand it may still be relevant, so if you're interested in the solution, leave a comment or reaction under this issue.

CKEditorBot commented 9 months ago

We've closed your issue due to inactivity over the last year. We understand that the issue may still be relevant. If so, feel free to open a new one (and link this issue to it).