Ckeditor5: CKEditor 5 stops working and even the events when copied the entire html page data from site

Created on 1 Dec 2020  ·  6Comments  ·  Source: ckeditor/ckeditor5

📝 Provide detailed reproduction steps (if any)

  1. …I tried pasting the content by selecting select all and pasting to CKEditor 5.. The site is https://www.lipsum.com/ . Editor is inline editor and using with only create() function. The version is pulled from ckeditor5 stable, adding the TableProperties and TableCellProperties
  2. …CKEditor stops working and even doesn't allow existing toolbar functions like bold etc. Basically the keypress mouse events stop working.
  3. …The tableproperties tries to set properties (attribute) but the item itself is not existing and then it just gives dump and breaks all the CKEditor

✔️ Expected result

_What is the expected result of the above steps?_ Copied the items or wherever there is error, the formatting is skipped or the specific item is not copied, but entire CKEditor 5 shouldn't stop working

❌ Actual result

_What is the actual result of the above steps?_ Items not copied and CKEditor 5 stops working entirely.

📃 Other details

  | r | @ | ckeditorerror.js:64
-- | -- | -- | --
  | rethrowUnexpectedError | @ | ckeditorerror.js:117
  | fire | @ | emittermixin.js:244
  | _convertItem | @ | upcastdispatcher.js:249
  | _convertChildren | @ | upcastdispatcher.js:282
  | (anonymous) | @ | upcasthelpers.js:896
  | fire | @ | emittermixin.js:209
  | _convertItem | @ | upcastdispatcher.js:249
  | _convertChildren | @ | upcastdispatcher.js:282
  | (anonymous) | @ | upcasthelpers.js:896
  | fire | @ | emittermixin.js:209
  | _convertItem | @ | upcastdispatcher.js:249
  | _convertChildren | @ | upcastdispatcher.js:282
  | (anonymous) | @ | tableproperties.js:66
  | fire | @ | emittermixin.js:209
  | _convertItem | @ | upcastdispatcher.js:249
  | _convertChildren | @ | upcastdispatcher.js:282
  | (anonymous) | @ | upcasthelpers.js:779
  | fire | @ | emittermixin.js:209
  | _convertItem | @ | upcastdispatcher.js:249
  | _convertChildren | @ | upcastdispatcher.js:282
  | (anonymous) | @ | upcasthelpers.js:779
  | fire | @ | emittermixin.js:209
  | _convertItem | @ | upcastdispatcher.js:249
  | (anonymous) | @ | upcasttable.js:51
  | (anonymous) | @ | upcasttable.js:51
  | fire | @ | emittermixin.js:209
  | _convertItem | @ | upcastdispatcher.js:249
  | _convertChildren | @ | upcastdispatcher.js:282
  | (anonymous) | @ | upcasthelpers.js:896
  | fire | @ | emittermixin.js:209
  | _convertItem | @ | upcastdispatcher.js:249
  | _convertChildren | @ | upcastdispatcher.js:282
  | (anonymous) | @ | upcasthelpers.js:779
  | fire | @ | emittermixin.js:209
  | _convertItem | @ | upcastdispatcher.js:249
  | _convertChildren | @ | upcastdispatcher.js:282
  | (anonymous) | @ | upcasthelpers.js:779
  | fire | @ | emittermixin.js:209
  | _convertItem | @ | upcastdispatcher.js:249
  | _convertChildren | @ | upcastdispatcher.js:282
  | (anonymous) | @ | upcasthelpers.js:779
  | fire | @ | emittermixin.js:209
  | _convertItem | @ | upcastdispatcher.js:249
  | _convertChildren | @ | upcastdispatcher.js:282
  | (anonymous) | @ | upcasthelpers.js:896
  | fire | @ | emittermixin.js:209
  | _convertItem | @ | upcastdispatcher.js:249
  | _convertChildren | @ | upcastdispatcher.js:282
  | Ia.upcastDispatcher.on.priority | @ | upcasthelpers.js:446
  | fire | @ | emittermixin.js:209
  | _convertItem | @ | upcastdispatcher.js:253
  | convert | @ | upcastdispatcher.js:207
  | (anonymous) | @ | datacontroller.js:414
  | change | @ | model.js:178
  | toModel | @ | datacontroller.js:413
  | listenTo.priority | @ | clipboard.js:112
  | fire | @ | emittermixin.js:209
  | listenTo.priority | @ | clipboard.js:88
  | fire | @ | emittermixin.js:209
  | i | @ | clipboardobserver.js:51
  | fire | @ | emittermixin.js:209
  | fire | @ | domeventobserver.js:96
  | onDomEvent | @ | clipboardobserver.js:74
  | listenTo.useCapture | @ | domeventobserver.js:79
  | fire | @ | emittermixin.js:209
  | i | @ | emittermixin.js:247

  • Browser: …
  • OS: …
  • CKEditor version:
  • Installed CKEditor plugins: …

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

table bug

All 6 comments

Hi, thanks for the report. I checked it and didn't have any problems with pasting content into inline editor. Please make sure you follow the docs and make sure your implementation is ok.
If it still does not help, we'll need more information to reproduce this - exact steps, editor configuration, plugin list, the content you paste, etc.

Hi, thanks for the report. I checked it and didn't have any problems with pasting content into inline editor. Please make sure you follow the docs and make sure your implementation is ok.
If it still does not help, we'll need more information to reproduce this - exact steps, editor configuration, plugin list, the content you paste, etc.

_Response:_

Sorry, I realized that I could post the error from the standard CKEditor site instead of posting my long issue details in earlier post.

Hi, thanks for the report. I checked it and didn't have any problems with pasting content into inline editor. Please make sure you follow the docs and make sure your implementation is ok.
If it still does not help, we'll need more information to reproduce this - exact steps, editor configuration, plugin list, the content you paste, etc.

_Response:_

Sorry, I realized that I could post the error from the standard CKEditor site instead of posting my long issue details in earlier post.

Hi, thanks for the report. I checked it and didn't have any problems with pasting content into inline editor. Please make sure you follow the docs and make sure your implementation is ok.
If it still does not help, we'll need more information to reproduce this - exact steps, editor configuration, plugin list, the content you paste, etc.

_Response:_

Sorry, I realized that I could post the error from the standard CKEditor site instead of posting my long issue details in earlier post.

Hi,
trust this information is sufficient with an example at ckeditor.com site itself.

_Trust this information provided is sufficient_

_Response:_

You can simulate it at https://ckeditor.com/ckeditor-5/demo/#document (or any editor like online, pagination or any editor which has tableproperties and tablecellproperties)
then go to site https://www.lipsum.com/ and then ctrl+a and ctrl+c to copy all content
then go back to this editor and paste it. It will give dump

Now I can reproduce this. Indeed there is a crash when pasting a part of the content from the lipsum.com site. It's enough to copy the fragment with form:

0_paste1

ckeditorerror.js:64 Uncaught TypeError: Cannot read property 'getAttribute' of undefined
    at Bn (writer.js:1487)
    at Dn.setAttribute (writer.js:380)
    at un.<anonymous> (tableproperties.js:73)
    at un.fire (emittermixin.js:209)
    at un._convertItem (upcastdispatcher.js:249)
    at un._convertChildren (upcastdispatcher.js:282)
    at un.<anonymous> (upcasthelpers.js:896)
    at un.fire (emittermixin.js:209)
    at un._convertItem (upcastdispatcher.js:249)
    at un._convertChildren (upcastdispatcher.js:282)

It seems that this happens only in editors that have tableCellProperties enabled.

Now I can reproduce this. Indeed there is a crash when pasting a part of the content from the lipsum.com site. It's enough to copy the fragment with form:

0_paste1

ckeditorerror.js:64 Uncaught TypeError: Cannot read property 'getAttribute' of undefined
    at Bn (writer.js:1487)
    at Dn.setAttribute (writer.js:380)
    at un.<anonymous> (tableproperties.js:73)
    at un.fire (emittermixin.js:209)
    at un._convertItem (upcastdispatcher.js:249)
    at un._convertChildren (upcastdispatcher.js:282)
    at un.<anonymous> (upcasthelpers.js:896)
    at un.fire (emittermixin.js:209)
    at un._convertItem (upcastdispatcher.js:249)
    at un._convertChildren (upcastdispatcher.js:282)

It seems that this happens only in editors that have tableCellProperties enabled.

Thanks for the feedback. Yes, I reported the same. Thanks for your time and efforts.

_Solutions:_

I think in the problem can be fixed in converters->tableproperties-> function n upcastBorderStyles after statement
_const modelElement = [ ...data.modelRange.getItems( { shallow: true } ) ].pop();_
_check if the modelElement is an object and not null or not undefined_
Since the object is not existing, it is giving the error. Also, probably the try catch to catch the errors

or alternatively the error is handled in common module of _conversionapi->write->setAttribute_. ### _Best solution_ would be to make changes in the ckeditor5-engine/src/model/writer.js and in the setAttribute function
setAttribute( key, value, itemOrRange ) {

Here check if the _itemOrRange is not null and not undefined and is an object_.
this fix will permanently fix all issues in setting the attributes called from anywhere.

I think one more important thing is that, CKEditor shouldn't crash in any case. There should be handling of the try catch at appropriate places and in case it crashes, there should be way to reinitialize the same. Just a suggestion.

Thanks for all your help.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

metalelf0 picture metalelf0  ·  3Comments

benjismith picture benjismith  ·  3Comments

pjasiun picture pjasiun  ·  3Comments

MCMicS picture MCMicS  ·  3Comments

hybridpicker picture hybridpicker  ·  3Comments