Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Preformatted block: Add support for font sizes #27584
Preformatted block: Add support for font sizes #27584
Changes from 2 commits
86b553b
33e6b85
4dafabe
93d7527
c072553
486ec4a
5b789c3
a331c3e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
The
style.scss
file always gets loaded into the editor, so if a rule exists in that file, it does not need to be replicated ineditor.scss
.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.
Oh, yes, true that. I'll fix accordingly.
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.
Since this rule also exists in
style.scss
, we are so close to not needing any editor style at all for this block. And we should be avoiding !important anyway, if at all possible. I dug in to see why the !important was necessary, and it appears thatwhite-space: pre-wrap;
is applied as an inline style on the preformatted block:Why does that exist? I'm not sure, but from digging at the code, it looks to be related to this PR: #18656. Or possibly #17779. Specifically there's some commentary in https://github.com/WordPress/gutenberg/pull/17779/files#diff-7df6f5253ccec2f2e6d1bb22e81f87a4b6bccd2604463eeecded163aa27fd333R70 which seems relevant.
It seems we need to figure out why that output
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.
The
pre-wrap
inline style is coming from the<RichText>
component, and its value is defined here: https://github.com/WordPress/gutenberg/blob/master/packages/rich-text/src/component/index.js#L82The value is set on the
whiteSpace
variable, which is then added todefaultStyle
, which subsequently makes it to the component's inline styles via thestyle
prop here: https://github.com/WordPress/gutenberg/blob/master/packages/rich-text/src/component/index.js#L1075According to the inspector, I can see that besides the
pre-wrap
inline style, there's thepre-wrap
style attribute coming from the Block'sstyle.scss
stylesheet. If neither the inline style nor the block style are present, then, the<pre>
element will get its default style from the browser defaults.This makes me think we can live with the inline style, since the
<RichText>
component is using the style attribute to guarantee its proper display (my assumption). Assuming a future scenario where the<RichText>
component removes thepre-wrap
inline style, then we'll still be covered by thepre-wrap
style available in the preformatted block'sstyle.scss
.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 not just remove the inline style?
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.
That's a quite considerable change. The
<RichText>
component uses it by default, and it (the component) is used in many places. Changing this may change the overall behavior of the<RichText>
component.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.
👋 We should remove the CSS Custom Property from here. I've seen that the code block recently got it added as well in https://github.com/WordPress/gutenberg/pull/27294/files#r540890153 and I've prepared a PR that fixes and explain why we shouldn't do that #27672