ckeditor / ckeditor4

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

Deleting Content surrounded by Div's in gui leaves Div's behind #5221

Open kwfinken opened 2 years ago

kwfinken commented 2 years ago

Type of report

Bug

Provide detailed reproduction steps (if any)

  1. On a "full package" installation of CKEditor 4 (e.g. https://ckeditor.com/docs/ckeditor4/latest/examples/fullpreset.html), go to source mode and enter the following:
    <div class="test2">
    <div class="test">ad fsadfd asf dsafd</div>
    </div>
  2. Return to GUI mode
  3. select all text (ctrl-a)
  4. press delete
  5. go to source mode and see the result

Expected result

Because it was select all (ctrl-a) delete should remove every bit of code. Meaning source code should be empty.

Actual result

<div class="test2">
<div class="test">&nbsp;</div>
</div>

Other details

This only seems to happen when it is a div inside a div and both div's have assigned classes.

This causes unexpected outcomes for users as when they enter additional text into the editor, they are (unbeknownst to them) now working inside a div instead of on a blank canvas.

Comandeer commented 2 years ago

I can confirm the issue. It's probably connected with the upstream behavior of the browser and can be reproduced on native [contenteditable]. To actually delete the `div`, Backspace/Delete needs to be pressed twice.

However, the editor seems to have some custom handling of divs as it correctly removes the following content:

<div>
<div>Test</div>
</div>

The issue appears when some divs have classes. In that case, they are not removed.