-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
RichText: add preserveWhiteSpace prop #18656
Conversation
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.
Tested it on RN-mobile on iOS and on the playground and all is working correctly now.
Thanks for the fix @ellatrix
@@ -6,7 +6,8 @@ | |||
"type": "string", | |||
"source": "html", | |||
"selector": "pre", | |||
"default": "" | |||
"default": "", | |||
"__unstablePreserveWhiteSpace": true |
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.
Why is this in the block.json. Isn't this a RichText prop?
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.
It is needed for merging the values, which uses create
and toHTMLString
under the hood. It is similar to __unstableMultilineWrapperTags
: https://github.com/WordPress/gutenberg/search?q=__unstableMultilineWrapperTags&unscoped_q=__unstableMultilineWrapperTags. I marked it unstable as maybe there's other ways we want to do this in future.
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.
mmm didn't know about that one. not great to be honest. Maybe the root issue is with the "merge" itself. maybe it should move to RichText somehow.
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.
Yes, we should have a look at it. The problem is that selection is stored based on the rich text value and not based on the HTML.
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.
Does it mean we should add information about these flags in the selection reducer?
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'm not sure... Normally they are set with RichText
props. We should document the selection reducers to say that the offsets are based on the rich text values, yes.
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've added a bit more documentation for WPBlockSelection
. I agree that the merge function could be improved, but this should be looked at separately while this PR fixes an issue. The attribute property has been marked unstable so it could be adjusted in the future.
def524f
to
0a6f065
Compare
Thanks for the review @SergioEstevao and @youknowriad! Let me know if there's anything I can review for you. |
Description
Fixes #18476. White space should be preserved with preformatted <=> paragraph transformations.
Also ensures that any white space in preformatted is preserved. Currently white space is collapsed.
I've done this by adding a
preserveWhiteSpace
and building it intoRichText
.How has this been tested?
Merge a paragraph with a preformatted block.
Screenshots
Types of changes
Checklist: