Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#12282 closed Bug (invalid)

pressing enter appends a extra line in CKeditor.

Reported by: Holger Herbert Owned by:
Priority: Normal Milestone:
Component: General Version: 3.6.3
Keywords: Cc:

Description

Repro steps for undesirable behavior

1.) go to the end of the last line of text ckeditor.com/demo 2.) press enter

  1. notice the cursor moves down two lines (should only be one line)

What it should look like: the desired behavior can be seen when pressing shift enter instead of enter

1.) go to the end of the last line of text ckeditor.com/demo 2.) press SHIFT enter

  1. notice the cursor moves down ONE line

Change History (5)

comment:1 Changed 5 years ago by Jakub Ś

Keywords: carriage return enter removed
Resolution: invalid
Status: newclosed
Version: 4.5.0 (GitHub - major)

Please read more about enter mode http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-enterMode.

When you press enter P is inserted. When you press Shift+Enter BR is inserted. You got impression of two lines being inserted because P gets default margins from browser. You can change this in CSS file (contents.css for classic editor, page CSS file for inline editor).

Please remember that CKEditor css should be the same as target page css.

comment:2 in reply to:  1 Changed 5 years ago by Kunal

Version: 3.6.3

With the CSS, problem gets resolved in Chrome for CKEditor v3.6.3, however the problem persists for IF/Firefox where the root cause is probably different.

When we hit enter in IE, it creates the hierarchy as

<p>  
  content
  <br/>
</p>

when you copy the above content and paste it on to notepad, you would notice extra line due to this "BR" tag.

Any workaround or suggestion?

P.S - I noticed that this particular BR tag was introduced as part of http://dev.ckeditor.com/ticket/10907 fix. Replying to j.swiderski:

Please read more about enter mode http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-enterMode.

When you press enter P is inserted. When you press Shift+Enter BR is inserted. You got impression of two lines being inserted because P gets default margins from browser. You can change this in CSS file (contents.css for classic editor, page CSS file for inline editor).

Please remember that CKEditor css should be the same as target page css.

comment:3 Changed 5 years ago by Jakub Ś

With the CSS, problem gets resolved in Chrome for CKEditor v3.6.3

CKEditor 3.x is no longer supported. Only security fixes are provided. you should upgrade to the latest version.


About your problem in IE and FF: There is BR in Paragraph but this is still one line. You can put cursor only in one place. what is more when you switch to source mode or get editor data with getData method (which is correct way of getting data from editor) you will see this extra BR is removed.

I see no problem here.

comment:4 Changed 5 years ago by Kunal

Thanks for your response. Let me walk through with a use case and then probably you can understand what I am exactly referring to.

1) Open MS Word and type following sentence (<NEW_LINE_USE_ENTER just means press ENTER key to get to new line)

   ABC <NEW_LINE_USE_ENTER>
   DEF <NEW_LINE_USE_ENTER>
   GHI <NEW_LINE_USE_ENTER>

2) Copy the complete content and paste it into notepad. You would notice that it does nicely fit into notepad as

    ABC
    DEF
    GHI

and if you try to capture the paste event using javascript, it gives you the exact same data 'e.data.getData( "text/plain" )'

3) Now if you repeat the above steps with CKEditor (instead of MS WORD) and paste it into notepad, you would see

    ABC

    DEF

    GHI

If you also inspect the content of e.data.getData( "text/plain" ), you do see the same exact content.

I understand that I am comparing web application with desktop application which may not be entirely true and same as always. But in this case if you look at user steps, they are exactly same however the end results are different. How can we achieve the MS WORD behavior ?

I also understand that the above can be negated by using SHIFT+ENTER however that would mean extra key press for our user base.

Last edited 5 years ago by Kunal (previous) (diff)

comment:5 Changed 5 years ago by Jakub Ś

But in this case if you look at user steps, they are exactly same however the end results are different. How can we achieve the MS WORD behavior? I also understand that the above can be negated by using SHIFT+ENTER however that would mean extra key press for our user base.

When you press enter, paragraph is inserted by default. When you press Shift+Enter you insert BR. You can either leave it the way it is now (recommended) or switch enter mode to use BR's

Please see: http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-enterMode
http://docs.ckeditor.com/#!/api/CKEDITOR.config-cfg-shiftEnterMode

Note: See TracTickets for help on using tickets.
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy