Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#10294 closed Bug (invalid)

Incorrect line breaks using paste as plain text and div as enter mode

Reported by: Perttu Myry Owned by:
Priority: Normal Milestone:
Component: Core : Pasting Version: 4.1
Keywords: Cc:

Description

Some line breaks can be lost when pasting data as plain text to editor which is using div as enter mode.

Steps to reproduce

  1. Copy some text with multiple line breaks, I used the following piece of text
#1 first

#2 second
#3 third
  1. Paste that data into editor which is using div as enter mode
  2. The line break between first and second will be lost and output will look like this
#1 first
#2 second
#3 third

When using either p or br as enter mode the line break between first and second will be there so this issue is specific to using div enter mode.

The HTML source for the pasted data looks like this.

<div>
<div>1. foo</div>

<div>3. bar<br />
4. foz</div>
</div>

Change History (3)

comment:1 Changed 11 years ago by Jakub Ś

Keywords: linebreak line break paste removed
Resolution: invalid
Status: newclosed

Hi,

This is unified behaviour in CKEditor.
One enter from notepad gets changed to br. Two enters from notepad get changed to two BR’s or one p or one div.
3 new lines in Notepad -> 3 brs or <p><br />&nbsp;</p> or <div><br />&nbsp;</div>,
4 new lines -> <p>&nbsp;</p><p>&nbsp;</p> or <div>&nbsp;</div><div>&nbsp;</div>

In order to see new line in modes like div or p you have to make two enters in Notepad.

NOTE: P shows the same result as div. You see it as new line because p has margin. If you remove margin from p you will see the same thing in both div and p.

comment:2 Changed 11 years ago by Perttu Myry

Okay, thanks for clarifying this.

I studied this bit further though and noticed that pasting works bit differently when using ctrl + v and forcePasteAsPlainText option in comparison to using paste as plain text plugin. Via paste as plain text plugin I got correct looking HTML with divs and br elements, but when pasting via ctrl + v I got just br elements as line breaks. Here's how the source looked after pasting.

<div>
<br />
#1 first<br />
#2 second<br />
#3 third<br />
</div>

I also checked out the event in editor.on('paste') handler and event.data.dataValue looked like this when pasting using ctrl + v.

<br>#1 first<br>#2 second<br>#3 third<br>

Whereas the event.data.dataValue looked like this when using paste as plain text plugin.

<div>#1 first</div><div>#2 second<br>#3 third</div>

Is this a bug or do these two different "paste as plain text" methods work differently by definition?

comment:3 Changed 11 years ago by Perttu Myry

Version: 4.0.24.1
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy