-
Notifications
You must be signed in to change notification settings - Fork 800
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
Gutenberg: Add editor styles to WordPress.com Simple sites' site editor #22640
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.
Here are some suggested test cases for this PR.
Gutenberg extensions
- Use Core's block editor
- Use latest stable Gutenberg plugin
Blocks
- Tiled Gallery
- Business Hours
- Calendly
- Form
- Contact Info
- Eventbrite
- Google calendar
- Mailchimp
- Map
- OpenTable
- Podcast player
- Star rating
- Recurring Payments
- Repeat Visitor
- Revue
- Simple Payments
- Slideshow
Extensions
- Publicize
- Likes
If you think that suggestions should be improved please edit the configuration file here. You can also modify/add test-suites to be used in the configuration file.
Caution: This PR has changes that must be merged to WordPress.com |
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖 The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available. Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped. Jetpack plugin:
|
I'm finding myself a bit confused here. add_editor_style is documented as being for themes to add styles to the TinyMCE editor, not the block editor? As far as I can tell from looking at WordPress Core's block editor API documentation, it seems they want the style handle to be declared as being for the block editor via
Overall this smells like a hack rather than an actual fix. A hack is ok, but maybe we should put the hack directly in the A non-hack Assets function seems like it would be building the args for |
@anomiex You are also correct when you say this is a hack, and it should be temporary until we find a more appropriate solution! 😄 The Metadata API (and many, many other block improvements) has been added in 5.8, which means it has only just recently become available to JP, while JP blocks have been typically developed in 2020 with some updates in 2021. This kind of change is outside of my knowledge area and is definitely outside of the scope of a high priority Dotcom bug fix. 🙂 Does Jetpack have a naming convention for functions that are not recommended for general use (something like |
620866f
to
1c19fe8
Compare
Actually, I don't think this is a hack. It seems that Gutenberg is reviving the Here you can see the Site editor getting the editor styles (via the And there are comments on Gutenberg issues recommending using I believe the plan is to eventually iframe the Post editor as well, so it seems that loading block styles this way will only become more necessary. |
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 wouldn't tie the naming to the Site editor. I think any of the editors may end up using an iframe (post, site, navigation, widgets), so I would keep this flexible.
For instance, the post editor loads these styles as well (https://github.com/WordPress/wordpress-develop/blob/1712bfcf79097df6766f093f3695c84f058e2666/src/wp-admin/edit-form-blocks.php#L194) and may lean on theme for inlining styles in an iframe. Anywhere blocks are used in a block editor, we may need to load these.
@creativecoder Apologies, I could have detailed more. IMHO the appropriate solution would be to build and enqueue block assets on a per-block basis through the block's metadata, as suggested above. I mean, we could call this hack or workaround, but either way, I wouldn't consider this a permanent solution, instead just a stopgap to take time to address the whole picture without fires. 🙂 |
What is Gutenberg intending to do about things like this code disabling some other styles when
I can help with figuring out the build logic in Jetpack. I don't know much about the actual blocks though. |
@anomiex I don't know Core plans, but at least in regards to this:
|
Ah, good to know. But then does that have any side effects elsewhere? I don't see any at a quick grep, but it is apparently output in the REST API. |
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.
✅ for this fixing the WP.com issue with Jetpack block styles in the Site editor (when combined with D74363-code). I left comments on both with a couple of tweaks, then let's get this fix out there as soon as we can!
Great news! One last step: head over to your WordPress.com diff, D74357-code, and commit it. Thank you! |
r239822-wpcom |
Fixes Automattic/wp-calypso#59501
Changes proposed in this Pull Request:
add_editor_style
function.The Issue
The site editor is currently rendered inside an
editor-canvas
iframe, which natively supports stylesheets added withadd_editor_style
.To apply those enqueued with
wp_enqueue_style
to the iframed canvas, Gutenberg copies the relevant stylesheets from the document's head and inlines them inside the iframe.If the CSS is served from a different origin, this compatibility solution fails.
This is what is happening on Simple sites in production.
We have an aggressive optimization process that minifies, concatenates, and serves from a CDN all Jetpack assets.
The JP editor styles are enqueued in "the old way", and served from
s0.wp.com
, which breaks the Gutenberg compatibility approach.The result is that JP blocks and editor extensions are missing all styles when rendered in the site editor.
The Fix (Kudos to @creativecoder)
add_editor_style
single-handedly fixes the issue, and it also works with stylesheets provisioned by the CDN.The function is not supposed to run with the enqueue hooks but works fine in
admin_init
.It also automatically provides an RTL version of the stylesheet whenever needed.
We call
add_editor_style
throughJetpack_Gutenberg::add_site_editor_style
, which handles most of the logic.We'll need to keep the situation monitored, though, and come up with another solution before Core Gutenberg iframes the post editor too.
To get the full picture, please read this: paYJgx-1Kl-p2
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
There are no functional changes to Jetpack, so please follow the testing instructions in D74363-code.