Paste <p>a</p><p><br></p><p>b</p> into the editor.
The editor will have:
a
b
This is the CKEditor 4 behavior and the behavior of most other editors.
The editor will have (note the two blank lines instead of one):
a
b
If you'd like to see this fixed sooner, add ๐ to this post.
Issue is being caused by the fact that extra filler is added to the paragraph, and this is in fact different from CKE4. Here's how the view is rendered:
<p>a</p>
<p><br><br data-cke-filler="true"></p>
<p>b</p>
Jupp, pretty annoying.... Need this fixed 2
https://github.com/ckeditor/ckeditor5/issues/5589
Is this a regression, guys? Did it work well in previous versions of CKEditor 5? It seems suspicious that there are two bug reports about this in a short period of time.
Pretty annoying indeed. Does anyone know if this can be fixed?
@mlewand & @Reinmar is this a bug or expected conversion an empty paragraph with s soft break inside?
<p>foo<br>bar</p>
will be rendered as:
foo
bar
and for me the <p><br></p> is just a special case of the above (two empty lines in a paragraph)
More importantly the editor.getData() will return "" for empty two-line paragraph and <p>foo<br>bar</p> for the latter case.
ps.: The same will happen if you press shift+enter in empty editor - you will get <p><br></p> in the data. But to display those two lines we must but a block filler in the editing area do only in editing area you will have <p><br><br data-cke-filler="true"></p> so user can put selection in the second line (after a soft-break).
Lacking a formal specification for rich text content editing on the web, I think the correct approach is to by default follow the behavior of a vanilla contenteditable field.
In Chrome, if you paste the sample html into a vanilla contenteditable you will get a single blank line between the A and B.
If CKEditor 5 (and other editors), doesn't align with the vanilla contenteditable behavior where there isn't a compelling reason to do something different, it creates unnecessary divergence between itself and other Rich Text Editor's on the web [1]. This creates costs for web developers as if every RTE is doing its own thing, it makes it hard for developers to correctly format their text to be pasted across editors.
[1] Most editors will put a single space including CKEditor 4, TinyMCE, Google Docs, Gmail. The only one I've tested which diverges other than CKEditor 5 is Facebook's DraftJS which strips all blank lines on pasting.
Did someone solve this already?
I gave it a quick check and this behavior was changed in 10.1.0, was good in 10.0.1 - so it can be considered a regression.
I agree that it's a tricky case.
Let's make a clear list of pros and cons of both solutions:
<p><br></p> as _two_ paragraphs)<br>,<p><br></p> as a _single_ paragraph)<br> at the end of the lineFrom my point of view better interoperability is more desired, so proposed solution seems to add some value here.
- currently user would not be able to remove or tell that there's an extra tailing
<br>at the end of the line
What will happen on shift+enter in empty paragraph? Displaying single line is not an option I think. So if pasting this causes problems I'd remove <br> from <p> if we want to fix this.
does anyone know what the guestimate in getting this issue fixed is?
To prevent the editor for adding extra
tags i actually removed the
manually by data.replace(/<br data-cke-filler="true">/g, " "); before setting the data.
This has solved the annoying adding of extra breaks bug for me.
<br>s were completely ignored.<p><br></p>. However, it's annoying because it affects pasting and, potentially, content ported from other editors (especially those which use plain contentEditable). s. <br> is used as a block filler but only in the editing pipeline. We assumed that one DOMConverter needs to handle just one type of block filler. It turns out that one of them will have to handle two types. It will be an "ugly" change.<br> filler that we use is detected by the data-cke-filler attribute. The <br> we're dealing with in this case will not have it. So, actually, it's also not that filler.DOMConverter#isBlockFiller() to handle a special case there that if the domNode passed is a single child of a block element, it's considered a filler (despite DOMConverter#blockFillerMode being set to nbsp. The confusing logic will be enclosed in this method and easy to document.<p> <br> </p>. From what I can see Chrome and Firefox output exactly <p>x</p><p><br></p><p>x</p> when you type x<ENTER><ENTER>x. So, my goal is to handle pasting that to CKEditor 5.
Most helpful comment
Did someone solve this already?