You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When text is wrapped in a block containing a CSS white-space rule with either pre, pre-wrap or break-spaces, repeated whitespace isn't collapsed but rendered instead. However, when text wrapped like this is inserted into CKEditor, the repeated spaces are lost.
Probably the most common scenario of this occurring is when copying content formatted with these white-space rules from other pages and pasting them into the editor.
As an example for the following HTML file:
<!DOCTYPE html><htmllang="en"><head><metacharset="UTF-8"><title>Document</title><style>
div {
white-space: pre-wrap;
}
</style></head><body><div> Foo Bar Baz </div></body></html>
When I select the text in the rendered document and copy it to the clipboard with Chrome 122, the clipboard content looks like this (retrieved by running xclip -selection clipboard -target text/html -out):
So the copied structure from Chrome has a different shape than the content on the original page, and it contains the required inline CSS to render it correctly on the pasted target.
However, when pasted into CKEditor, the spaces are collapsed to a single one, and the leading and trailing whitespace is stripped.
It's also really easy to reproduce in one of CKEditor's manual tests, by setting the editor data to something like
I expect repeated spaces contained within a block with white-space: pre, white-space: pre-wrap or white-space: break-spaces to be preserved when being set or pasted into the editor.
❌ Actual result
Repeated spaces are collapsed.
❓ Possible solution
I submitted a pull request with a possible fix: #16125
The text was updated successfully, but these errors were encountered:
I'm very hesitant about this change. Implementing a special check on the engine level is almost always not a proper way to go. If you want the editor to correctly store this style, a plugin should be created, ideally with some UI layer, so that users have a possibility to manage this as well. If I missed something, please let me know.
Ok, I understand, it's not even about the managing of this style, more on the preservation of spaces, that we eagerly merge right now. @niegowski . @scofalik, thoughts?
📝 Provide detailed reproduction steps (if any)
When text is wrapped in a block containing a CSS
white-space
rule with eitherpre
,pre-wrap
orbreak-spaces
, repeated whitespace isn't collapsed but rendered instead. However, when text wrapped like this is inserted into CKEditor, the repeated spaces are lost.Probably the most common scenario of this occurring is when copying content formatted with these
white-space
rules from other pages and pasting them into the editor.As an example for the following HTML file:
When I select the text in the rendered document and copy it to the clipboard with Chrome 122, the clipboard content looks like this (retrieved by running
xclip -selection clipboard -target text/html -out
):So the copied structure from Chrome has a different shape than the content on the original page, and it contains the required inline CSS to render it correctly on the pasted target.
However, when pasted into CKEditor, the spaces are collapsed to a single one, and the leading and trailing whitespace is stripped.
It's also really easy to reproduce in one of CKEditor's manual tests, by setting the editor data to something like
✔️ Expected result
I expect repeated spaces contained within a block with
white-space: pre
,white-space: pre-wrap
orwhite-space: break-spaces
to be preserved when being set or pasted into the editor.❌ Actual result
Repeated spaces are collapsed.
❓ Possible solution
I submitted a pull request with a possible fix: #16125
The text was updated successfully, but these errors were encountered: