-
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
Add CSS class to paragraph block #47282
base: trunk
Are you sure you want to change the base?
Conversation
I'll be working on fixing tests and all. |
# Conflicts: # lib/compat/wordpress-6.2/block-patterns/centered-footer-with-social-links.php # lib/compat/wordpress-6.2/block-patterns/centered-footer.php # lib/compat/wordpress-6.2/block-patterns/footer-with-large-font-size.php # lib/compat/wordpress-6.2/block-patterns/simple-header-with-image.php
…k and affect test results.
# Conflicts: # packages/block-editor/src/hooks/test/__snapshots__/align.native.js.snap # packages/block-library/src/cover/test/__snapshots__/edit.native.js.snap # packages/block-library/src/embed/test/__snapshots__/index.native.js.snap # packages/e2e-tests/specs/editor/blocks/__snapshots__/heading.test.js.snap # packages/e2e-tests/specs/editor/blocks/pullquote.test.js # packages/e2e-tests/specs/editor/plugins/__snapshots__/container-blocks.test.js.snap # packages/e2e-tests/specs/editor/plugins/__snapshots__/cpt-locking.test.js.snap # packages/e2e-tests/specs/editor/plugins/__snapshots__/inner-blocks-render-appender.test.js.snap # packages/e2e-tests/specs/editor/various/__snapshots__/block-deletion.test.js.snap # packages/e2e-tests/specs/editor/various/__snapshots__/block-grouping.test.js.snap # packages/e2e-tests/specs/editor/various/__snapshots__/block-hierarchy-navigation.test.js.snap # packages/e2e-tests/specs/editor/various/__snapshots__/embedding.test.js.snap # packages/e2e-tests/specs/editor/various/__snapshots__/inserting-blocks.test.js.snap # packages/e2e-tests/specs/editor/various/__snapshots__/keep-styles-on-block-transforms.test.js.snap # packages/e2e-tests/specs/editor/various/__snapshots__/links.test.js.snap # packages/e2e-tests/specs/editor/various/__snapshots__/list-view.test.js.snap # packages/e2e-tests/specs/editor/various/__snapshots__/multi-block-selection.test.js.snap # packages/e2e-tests/specs/editor/various/__snapshots__/rich-text.test.js.snap # packages/e2e-tests/specs/editor/various/block-grouping.test.js # packages/e2e-tests/specs/editor/various/format-library/__snapshots__/text-color.test.js.snap # packages/e2e-tests/specs/editor/various/multi-block-selection.test.js # packages/e2e-tests/specs/widgets/editing-widgets.test.js # packages/format-library/src/text-color/test/__snapshots__/index.native.js.snap # packages/react-native-editor/__device-tests__/helpers/test-data.js # packages/react-native-editor/src/initial-html.js # packages/rich-text/src/test/__snapshots__/index.native.js.snap # test/e2e/specs/editor/blocks/__snapshots__/List-can-be-exited-to-selected-paragraph-1-chromium.txt # test/e2e/specs/editor/blocks/__snapshots__/List-selects-all-transformed-output-1-chromium.txt # test/e2e/specs/editor/various/font-size-picker.spec.js # test/integration/__snapshots__/blocks-raw-handling.test.js.snap
# Conflicts: # packages/e2e-tests/specs/editor/various/__snapshots__/multi-block-selection.test.js.snap # packages/e2e-tests/specs/editor/various/multi-block-selection.test.js
We're coming up on 6.4 beta 1 and I'm curious where we stand. I can see some recent commits and requests for more feedback but I'm not seeing additional reviews come in. Where do we stand? |
Unfortunately, as we're now also past Beta 1 for 6.4, and based on the conversation above about this being a pretty major change, I think this should now be punted to 6.5. However, it would be great to aim to include it in the next Gutenberg release. |
This is an important change, but it's also a tough one to test because it touches so much. I think we need to start looking at it early if it's going to make 6.5, otherwise it will keep getting punted. |
Agree. Since it touches native files too it might be good to get a sign off list of reviewers. I've smoked tested this PR with existing P blocks and creating new ones and it works great, but the breadth of the changes makes me want a security blanket of concurring reviews 😄 |
Just thinking out loud: since the approach in this PR involves changing a lot of files, and alters how the block is serialized to post content, would it be worth investigating a subtle alternative that uses the That way the saved markup is never changed, and we wouldn't need to worry about backwards compat / support in the mobile apps as older versions would still see the earlier markup? I might very well be missing some context, and there could be a good reason to save the classname in post content, so apologies if I've missed something obvious there! |
Thanks for your comments 😄 I was out of the office. The number of files involved in this PR is related to updating the tests that involve the paragraph block, to include the CSS class. There were no changes to the logic of native, only updating tests and snapshots. The main changes are only these. I believe that, in favor of consistency with the behavior of other blocks, I would save the data with the class. But that may be subjective. But I'm thinking that maybe it is better to play safe and cover all scenarios where the data is retrieved (in case the post data is retrieved in some way other than being rendered). |
Hey all 👋 We are 1 week out from Beta 1 of WordPress 6.5. Is anyone working on getting this is before then? / What are the current blockers? |
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @juanfra@theeventscalendar.com, @apeatling. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Hi @fabiankaegy, Thanks for coming back to this one. I could rebase and fix the merge conflicts, but I believe that it'd be interesting to define if we're ok with the approach of having the class name in the markup, as I've seen some concerns about it. |
I wonder if we might be able to reference how Heading block or List block rollout classing additions looked like and try to mirror the rollout to the most recent one: Heading or List. I do not have enough historical recall to guess, nor would I want to 😄 I feel like this functionality is important, but would like to have a bit more clarity as to what is being affected (at a glance). Perhaps a written summary of potential considerations for testing or what is impacted (without a contributor glancing at all the code) may go a long way for folks to assert their opinions. It is more work, but potentially could keep this moving forward. Just an idea. Thanks for working on this @juanfra 🫶 |
From my understanding with this PR, Paragraph block styling will now only be applied to the Paragraph block itself rather than any
Maybe before landing this change, we talk about adding global styling for the |
Sorry, @colorful-tones, I missed the notification. Thank you for your comment, @justintadlock. To add a bit more context on the purpose of the PR. What's happening right now, is that if you're setting up styles for the paragraph block (let's say a background color) via the site editor, those styles are applied to any This means that the styles that you're selecting, as a site administrator, will not only affect the paragraph block but any other In the following screencast, you can see that I'm setting a red background color for the paragraph block. This is affecting other elements, like the site title and tagline. Screen.Recording.2024-09-05.at.18.14.05.movThis is just a quick example, but it also happens in comments, pullquotes, quotes and other elements that are relevant to a site. The goal of this PR is to add className support for the paragraph block. That way, the styles the site admin selects for the paragraph block only affect the paragraphs that are "produced" by the paragraph block and not other The code is doing the following:
After this PR, the styles added via the editor styles for the paragraph block will exclusively affect the content generated by the paragraph block. If I set a red background color for the paragraph block, it'll be limited to that and won't affect others like: the site title, tagline, pullquote, quote, etc.
While this is true, it is for non-block themes only (I believe). We should be covered for block themes because any I believe the problem that you're surfacing is valid, and relevant to non-block themes that had styles for People having custom CSS with rules for We should consider this edge case, in order to bring the best experience for users without block themes. Users who rely on the powerful styling options of the site editor and want to keep the styles of the paragraphs that are not generated via the block. But it's going to be a tough one. Personally, I can't think of a way (right now) to add these settings without adding confusion. I see this is an isolated case and the only block that's applying styles to a generic HTML element. Thinking out loud, for these edge cases we're talking about, part of the styling should be covered with other settings: The |
@juanfra - I understand the issue that this is trying to fix. I'm saying that it's introducing an entirely new issue.
No, I'm specifically talking about block themes here (though I suspect the same would apply to classic themes with a Personally, I don't think it was a good idea to do this, but that's the system that existed if those authors wanted to avoid writing custom CSS and use With this change, those styles on the Paragraph block that were previously applied to all Because of this, there should be an element that can be styled via
There are so many missing cases where this is not even remotely correct. But that's a different topic entirely (though the addition of a
This issue I brought up is unrelated to custom CSS.
The pathway out of this with the least breakage is to, yes, make this change. But also create the addition of a Edit: FWIW, it was a nightmare dealing with this when the same change was made for the List block with no element support for general |
Thanks for your response @justintadlock The recap intended to add a bit to what Damon mentioned and more context so that anyone coming to the PR could understand what was happening with the changes and its implications. Sorry if it was redundant, but it wasn't directed to your comment at all 🙂
I see what you mean now; I didn't understand that you were talking about the I agree with your suggestion about implementing the option to have the
Is there any other lesson we can learn from that experience to keep in mind as we proceed with this? Edit: I removed a comment about a test I made with a wrong build. |
I don't have any strong opinions. There is some precedent for spelling it out, seeing that there is a
The lessons:
Even if we can't land a |
What?
Adding the
wp-block-paragraph
to the paragraph block elements.Fixes #46863
Why?
It was reported in #46863 that the style changes for the paragraph block were affecting all the paragraphs, and this was affecting other pieces of the site such as the site tagline (and others).
How?
Adding the
wp-block-paragraph
class to the paragraph block for new content, and parsing the block output to add it for previously generated content.Testing Instructions
For new content
wp-block-paragraph
class.For previously generated content
wp-block-paragraph
class was added to the previously generated content.For the problem reported in #46863
<p>
that doesn't have thewp-block-paragraph
class)Screenshots or screencast
Screen.Recording.2023-02-03.at.17.18.43.mov