JiHong88 / suneditor

Pure javascript based WYSIWYG html editor, with no dependencies.
http://suneditor.com
MIT License
1.66k stars 307 forks source link

Strange handling of several consecutive line breaks (<br><br>) #1379

Open abvas opened 2 months ago

abvas commented 2 months ago

Describe the bug The editor formats the inserted HTML very strangely if it uses more than one <br> character in a row For some reason, the editor leaves only one <br> character out of several in a row.

To Reproduce

  1. Go to http://suneditor.com/sample/index.html
  2. Using "Code View" insert UTML:
<div>
Header <br><br>
Line 1<br><br>
Line 2<br><br>
Line 3 <br><br><br>
Footer</div>
  1. Return to editor mode.
  2. Insert the cursor, for example, between Line 1 and Line 2
  3. Press "Enter" key
  4. Press the "Enter" key again

After point 5. the cursor will jump to the very beginning of the text to the line "Header" After point 6. spaces between lines will be removed, but an empty line will be added at the very top of the text.

In "Code View" we will see this HTML:

<div><br>
</div>

<div>Header <br>
Line 1<br>
Line 2<br>
Line 3 <br>
Footer</div>

Expected behavior After pressing the "Enter" key twice in a row, two empty lines should be added.

Screenshots It should be like this: 2

But it turns out like this: 1

Desktop (please complete the following information):