Repeated spaces are not preserved when text is contained in an element that renders whitespace using a CSS white-space
rule.
#16124
Labels
Milestone
white-space
rule.
#16124
📝 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: