RichText: add preserveWhiteSpace prop#18656
Conversation
SergioEstevao
left a comment
There was a problem hiding this comment.
Tested it on RN-mobile on iOS and on the playground and all is working correctly now.
Thanks for the fix @ellatrix
There was a problem hiding this comment.
Why is this in the block.json. Isn't this a RichText prop?
There was a problem hiding this comment.
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.
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.
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.
Does it mean we should add information about these flags in the selection reducer?
There was a problem hiding this comment.
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.
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
preserveWhiteSpaceand building it intoRichText.How has this been tested?
Merge a paragraph with a preformatted block.
Screenshots
Types of changes
Checklist: