Consider the following markup:
<p>spaceflight</p>
<p> </p>
<p> </p>
<p>spaceflight</p>
When user selects the whole block of text (e.g. using [Ctrl+A]) and applies font formatting in CKEditor the resulting markup is something like this:
<p><span style="font-family:comic sans ms,cursive">spaceflight</span></p>
<p> </p>
<p> </p>
<p><span style="font-family:comic sans ms,cursive">spaceflight</span></p>
i.e. font is not applied to the empty paragraphs.
Steps to reproduce the problem:

Is there any known workaround allowing to make CKEditor to apply formatting to empty paragraphs inside the current selection?
The problem here is after user has explicitly applied font to the whole block they expect the whole block to be in that font, but when they use cursor and navigate to one of the empty paragraphs and start typing there it's a different font altogether
So the problem is actually different - it's not related to data, but to these empty blocks not preserving styling inside the editor. There's a ticket for this somewhere, but the solution is not trivial. The problem is that when you apply style to an empty block this structure is created (inspect the DOM of the editor):
<p><strong></strong><br /></p>
The <br> there is for making the paragraph visible - it's so called bogus br. Otherwise, the paragraph would have 0 height.
Now, when you try to place your caret there (using mouse or keyboard) the browser finds an empty strong element, which is 0x0 and a paragraph which has non-zero width and height. Where the browser puts your caret? In the paragraph.
The same situation happens if you apply style on an empty selection and move your caret - there's still an empty inline element out there, but you won't be able to move your caret back to it.
It is possible to workaround this and there's even more than one way. Unfortunately, none is trivial.
If you want to attempt to implement a hack which should solve the most common cases, then it should work like this:
editor#selectionChange).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With