samclarke / SCEditor

A lightweight HTML and BBCode WYSIWYG editor
http://www.sceditor.com/
Other
657 stars 187 forks source link

New lines in pasted text are not properly treated #624

Open abetis opened 6 years ago

abetis commented 6 years ago

When I copy few lines of text from the editor and paste them in the editor, there are extra new line after every pasted line.

Edit: Strange thing is that it's not always happens, probably the text is treated differently every time...

I think I found the way to reproduce it: Open the sceditor.com Switch to code view Select and delete everything from the editor (CTRL+A and DEL) Copy and paste the following BBCode to the editor:

[u]line 1[/u]
line 2

Switch to the styled view Select and copy the first 2 lines (CTRL+C) Delete everything from the editor with CTRL+A and DEL Paste the 2 lines you've copied before.

You should see the extra newline between the 2 lines...

abetis commented 6 years ago

By the way, if browser debugger is open when I switch to code view on sceditor.com with the initial string as it appears, there is an exception: Paused on exception TypeError: k.getSelection(...) is null

abetis commented 6 years ago

I think the problem appears when every line is represented as a separate DIV, while in the cases that do work properly the lines appear in the same DIV separated with BR.

I remember I saw some cases were every line of text was represented with P tag as well, strange to see the non-consistence.