-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Preserve repeated spaces when text is wrapped with a CSS white-space
rule
#16125
Conversation
85ef3a6
to
e24783b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thank you for contributing to our repository.
- To accept your code, we need you to sign the Contributor License Agreement (CLA) - see https://ckeditor.com/docs/ckeditor5/latest/framework/contributing/contributing.html#contributor-license-agreement-cla.
- Since the problem you're fixing isn't reproducible in the editor itself, please provide a sample environment showing that the fix works.
- What if the
white-space
property is set in the style sheet instead of directly in data? - There are already two custom matchers in the
DomConverter
: https://github.com/jessevanassen/ckeditor5/blob/54ebaddc4f3a077e479fa636fd3675a51eb5400b/packages/ckeditor5-engine/src/view/domconverter.ts#L143-L148. Maybe it would be possible to implement your check in a similar manner? It could make checking the ancestors more difficult probably though, so it's not a must.
Hi @Dumluregn, thanks for coming back to me!
|
I've looked at the Matchers, but to me it feels like they wouldn't be the right approach for this check. If I understand them correctly, a However, for the check, I want to see if a specific element is preformatted, and take specific actions if it is (or isn't). I could try to implement it with a Like it is now, a pure function that returns a boolean, feels better suited for the task. Would you agree, or do you have other insights? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see it is indeed simple to reproduce the problem in any manual test, so I'll just repost it here:
It's also really easy to reproduce in one of CKEditor's manual tests, by setting the editor data to something like
<span style="white-space: pre-wrap">Hello, World!</span>
Thank you for investigating the Matcher approach. I think it brings too little benefits to pursue it.
Could you please merge the latest master
branch and ensure it still works fine? I left just one comment and we'll be good to merge this PR.
I've made it up to date with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thank you for the contribution!
Suggested merge commit message (convention)
Fix (engine): Preserve repeated spaces in text that is contained within an element that renders (repeated) white space. Closes #16124
Additional information
This pull request offers a possible solution for #16124.
It will preserve (repeated) whitespace when the text is contained within a block that preserves whitespace during rendering, which is done through the
white-space
CSS property. This is similar to what the code for the<pre>
element is already doing.Existing code within CKEditor is already taking care of swapping out the repeated spaces by
-patterns, so they are also preserved when the data is extracted again.