suneditor icon indicating copy to clipboard operation
suneditor copied to clipboard

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

Open abvas opened this issue 2 years ago • 3 comments

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):

  • OS: Windows 10
  • Browser chrome
  • Version 123.0.6312.123

abvas avatar Apr 17 '24 10:04 abvas

Hello @abvas , I'm having the same issue. Did you find any workaround to this?

g-domingos avatar Dec 11 '24 10:12 g-domingos

Hello @g-domingos ! Unfortunately, no one answered me here, and I myself could not solve this problem.

abvas avatar Dec 12 '24 11:12 abvas

I see. For what I could see, maybe inserting the "< br >" tag between "< p >< / p >" might work. The issue for me have been how to manipulate the html on a custom onPaste function.

Im having troubles pasting from word, since the line breaks disappear when I paste on suneditor. The closest I got for the same results from the word document it is when I press Ctrl + Shift + V to paste on the Editor, but that causes de
tags and the unusual behaviour you stated.

g-domingos avatar Dec 12 '24 12:12 g-domingos