Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor crashes when trying to apply browsers spellcheck suggestion in table cell in chrome/safari #6062

Closed
cutteroid opened this issue Jan 10, 2020 · 8 comments · Fixed by ckeditor/ckeditor5-table#231
Assignees
Labels
type:bug This issue reports a buggy (incorrect) behavior. type:regression This issue reports a bug that was not present in the previous releases.

Comments

@cutteroid
Copy link

Editor crashes when trying to apply browsers spellcheck suggestion inside table cell in chrome/safari

Screen Recording 2020-01-10 at 16 41 08

Stacktrace:

Uncaught CKEditorError: model-nodelist-offset-out-of-bounds: Given offset cannot be found in the node list. Read more: https://ckeditor.com/docs/ckeditor5/latest/framework/guides/support/error-codes.html#error-model-nodelist-offset-out-of-bounds
 {"offset":9,"nodeList":[{"name":"paragraph","children":[{"data":"this "}]},{"name":"paragraph","children":[{"data":"computer"}]}]}
    at Ws.offsetToIndex (https://ckeditor.com/assets/libs/ckeditor5/16.0.0/ckeditor.js:5:226045)
    at Ys.offsetToIndex (https://ckeditor.com/assets/libs/ckeditor5/16.0.0/ckeditor.js:5:227117)
    at Ks.get index [as index] (https://ckeditor.com/assets/libs/ckeditor5/16.0.0/ckeditor.js:5:231967)
    at Ks.get textNode [as textNode] (https://ckeditor.com/assets/libs/ckeditor5/16.0.0/ckeditor.js:5:232043)
    at zc (https://ckeditor.com/assets/libs/ckeditor5/16.0.0/ckeditor.js:5:342883)
    at jc._validateSelectionRange (https://ckeditor.com/assets/libs/ckeditor5/16.0.0/ckeditor.js:5:342719)
    at fa.<anonymous> (https://ckeditor.com/assets/libs/ckeditor5/16.0.0/ckeditor.js:5:262468)
    at fa.fire (https://ckeditor.com/assets/libs/ckeditor5/16.0.0/ckeditor.js:5:128711)
    at fa._setRanges (https://ckeditor.com/assets/libs/ckeditor5/16.0.0/ckeditor.js:5:255934)
    at fa.setTo (https://ckeditor.com/assets/libs/ckeditor5/16.0.0/ckeditor.js:5:255010)

📃 Other details

  • Browser: Chrome/Safari
  • OS: OS X 10.15.2
  • CKEditor version: 16.0.0

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

@cutteroid cutteroid added the type:bug This issue reports a buggy (incorrect) behavior. label Jan 10, 2020
@FilipTokarski
Copy link
Member

Hi!
Thank you for reporting this. I checked it and unfortunately can confirm - this bug happens on Chrome, Safari and new chromium-based Edge, both Win10 and macOS.
Seems like regression, I was not able to reproduce this on older versions of CKEditor ( v12.0.0 ).
Firefox seems to be working fine.

@Mgsy Mgsy added status:confirmed type:regression This issue reports a bug that was not present in the previous releases. labels Jan 10, 2020
@Reinmar Reinmar added this to the next milestone Jan 14, 2020
@Mgsy
Copy link
Member

Mgsy commented Jan 14, 2020

It occurs also in v15.0.0. I'll bisect it.

@Reinmar Reinmar modified the milestones: next, iteration 29 Jan 14, 2020
@Mgsy
Copy link
Member

Mgsy commented Jan 14, 2020

I've investigated this issue and it looks like this change has introduced the bug - ckeditor/ckeditor5-typing@0aeb384.

@Reinmar
Copy link
Member

Reinmar commented Jan 29, 2020

OK, first finding:

image

There are two mutations that are being handled. Unfortunately, something incorrect happens between them so when the 2nd one is being handled, the selection is in an incorrect place (after a paragraph).

@Reinmar
Copy link
Member

Reinmar commented Jan 29, 2020

The first mutation:

{type: "text", oldText: "see comter", newText: "see ", node: Text}

So, it easily deletes the old text.

The 2nd mutation:

{
    type: "children"
    oldChildren: Array(1)
         0: ContainerElement {parent: EditableElement, name: "span", _attrs: Map(0), _children: Array(1), _classes: Set(0), …}
    newChildren: Array(2)
         0: ContainerElement {parent: EditableElement, name: "span", _attrs: Map(0), _children: Array(1), _classes: Set(0), …}
         1: Text {parent: null, _textData: "commuter"}
    node: EditableElement {parent: ContainerElement, name: "td", _attrs: Map(1), _children: Array(1), _classes: Set(2), …}
}

So, the "commuter" text is being inserted by the browser outside of the <span> which wraps a lonely text node (it maps to a <paragraph> in the model). Unfortunately, since we map the view <span> to model <paragraph> in this case, it gives us an insertion position outside of that paragraph and this happily breaks.

I wonder how did it work before the changes that @Mgsy found.

@Reinmar
Copy link
Member

Reinmar commented Jan 29, 2020

OK, previously it didn't work either:

image

It didn't crash because of some nice postfixers that we have, but the input command tried to do something incorrect.

@Reinmar
Copy link
Member

Reinmar commented Jan 29, 2020

The solution to this is forcing Chrome/Safari to insert this text inside that span. It turned out that changing the display to inline-block or block is enough. I think that none of them should affect how tables are rendered so I'll go with inline-block as it should be the safest option.

@Reinmar Reinmar self-assigned this Jan 30, 2020
@Reinmar
Copy link
Member

Reinmar commented Jan 30, 2020

From what I can see the above hack fixes #3243 too. It may probably fix some other bugs as well but I couldn't find any matching tickets.

jodator added a commit to ckeditor/ckeditor5-table that referenced this issue Feb 4, 2020
Fix: Fixed a bug with spellchecking or pasting via the context menu into a table cell crashing the editor. Closes ckeditor/ckeditor5#6062
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:bug This issue reports a buggy (incorrect) behavior. type:regression This issue reports a bug that was not present in the previous releases.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants