ckeditor / ckeditor4

The best enterprise-grade WYSIWYG editor. Fully customizable with countless features and plugins.
https://ckeditor.com/ckeditor-4
Other
5.8k stars 2.48k forks source link

Editor Pasting Crashes after Certain Sequence of Actions #3858

Closed scottfr closed 3 years ago

scottfr commented 4 years ago

Type of report

Bug

Provide detailed reproduction steps (if any)

  1. Create a CKeditor 4 editor with { enterMode: CKEDITOR.ENTER_BR, shiftEnterMode: CKEDITOR.ENTER_BR } (standard p mode does not have this issue)
  2. Paste this HTML into the editor: <p>a</p><p>b</p> (if you copy this from an editor, make sure you copy it with p-tags and not a br as the br will work fine)
  3. Hit enter twice
  4. Type a (or any other letter), then a backspace to delete the letter you just typed (this is important to do otherwise the issue does not manifest itself)
  5. Paste the same text from step 2 into the editor again (note you shouldn't be moving your cursor around during these steps, just follow them from top to bottom)

So again: paste, enter twice, any letter, delete letter, paste again.

Here's a code pen with CKEditor 4 and text ready to copy:

https://codepen.io/scottfr/pen/WNvQgwp

Expected result

The editor's content is:

a
b

a
b

Actual result

The editor's content is:

a
b

The javascript console has the error:

ckeditor.js:155 Uncaught TypeError: Cannot read property 'getParents' of null at d (ckeditor.js:155)

Other details

Comandeer commented 4 years ago

I can reproduce the issue. It seems to be connected with editor.inserHtml function.

The whole error stack:

Uncaught TypeError: Cannot read property 'getParents' of null
    at d (ckeditor.js:149)
    at CKEDITOR.dom.range.extractContents (ckeditor.js:154)
    at CKEDITOR.dom.range.splitElement (ckeditor.js:180)
    at ckeditor.js:410
    at $.insertHtml (ckeditor.js:374)
    at $.<anonymous> (ckeditor.js:384)
    at a.n (ckeditor.js:10)
    at a.<anonymous> (ckeditor.js:12)
    at a.CKEDITOR.editor.CKEDITOR.editor.fire (ckeditor.js:13)
    at a.insertHtml (ckeditor.js:286)
carestad commented 4 years ago

I've seen a lot of TypeError: Cannot read property 'getParents' of null in our Sentry logs recently as well. It does not appear to be triggered in the same manner as here though, but I would not be surprised if it is related to the "paste from Word" functionality or the like, which probably uses insertHtml?

scottfr commented 4 years ago

We have another user who is affected by this bug. It would be great if it could be looked into.

Sugao1995 commented 3 years ago

Have there been any updates to this issue? I'm seeing a lot of these errors in our Sentry logs but I've only managed to reproduce this issue following steps posted here. I can't seem to reproduce the issue on an older CKEditor 4 version, such as 4.2. The one we're currently using is on 4.16.

CKEditorBot commented 3 years ago

Closed in https://github.com/ckeditor/ckeditor4/pull/4895