-
Notifications
You must be signed in to change notification settings - Fork 7
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
example-block-style-js doesn't display proper style in the block editor #9
Comments
The change from In a normal WordPress install, we're now getting the same CSS ( The problem from Playground stems from this code in add_action( 'after_setup_theme', 'themeslug_editor_styles' );
/**
* Adds the `style.css` file as an editor stylesheet.
*
* @since 1.0.0
*/
function themeslug_editor_styles() {
add_editor_style( get_stylesheet_uri() );
} Why is Playground not loading the CSS for |
You can see the block style being loaded twice with the change in #10 (once in |
Isn't
|
To be clear, we can use I'd rather make sure this is corrected in Playground if there's a bug. If Playground is not loading styles via |
Yup, this is the recommended approach for themes. I wonder if playground is having trouble with |
As far as I can tell, I've tried the standard add_action( 'after_setup_theme', 'themeslug_editor_styles' );
function themeslug_editor_styles() {
add_editor_style( get_stylesheet_uri() );
} I've tried add_action( 'after_setup_theme', 'themeslug_editor_styles' );
function themeslug_editor_styles() {
add_editor_style( get_theme_file_uri( 'style.css' ) );
} And a relative URL (usually not recommended unless specifically overwriting a parent theme doing this): add_action( 'after_setup_theme', 'themeslug_editor_styles' );
function themeslug_editor_styles() {
add_editor_style( 'style.css' );
} All three of these methods are acceptable in standard WP themes, but none of them seem to work with Playground. |
Pinging @adamziel for visibility of this conversation |
I can't reproduce the issue, unfortunately. This URL loads an editor with the "handdrawn" style applied for me: In a wp-env WordPress installation, the following plugin does not load add_action( 'after_setup_theme', 'themeslug_editor_styles' );
function themeslug_editor_styles() {
file_put_contents('/var/www/html/wp-content/themes/twentytwentythree/mystyle.css', 'body { background: red; }');
add_editor_style(get_theme_file_uri('mystyle.css'));
} |
@adamziel sorry about the confusion, let me clarify it. I have updated the code to use The issue in Playground seems to be with |
@juanmaguitar is that specific to Playground, though? I just installed that theme on my local WordPress installation and ran into the exact same problem there: ![]() |
@adamziel you're right, I've tested this locally with
and it also doesn't work... @justintadlock can you provide more context about this issue? |
The issue is that when using this code to load an editor stylesheet (as the theme is doing now):
It looks like this in Playground (because the stylesheet is not being loaded and inlined in the iframe It looks like this on a normal WordPress site (the stylesheet is being correctly loaded and inlined in That last one is from my local install, but this is also the method for loading editor styles for thousands of WordPress themes. |
Or, if you want to test another theme, try Powder: https://playground.wordpress.net/?theme=powder It uses Create a new page and insert a Group block. Add the "Shadow Solid" style to it. You should see that the box-shadow is missing: The block should look like this (but the stylesheet is not loaded and inlined in the This only happens in Playground as far as I know. It works fine for me on a local test install. |
This is super weird @justintadlock! I just installed the powder theme in wp-env and I'm not getting that CSS loaded in my editor: ![]() |
It does seem to work on my WordPress.com site, though. How weird. |
|
On wp.com these styles are added via... wp.domReady( function() {
resolve(wp.editPost.initializeEditor('editor', "post", 1394, {
"alignWide": false,
"allowedBlockTypes": true,
"styles": [
{ "css": "<!-- HERE -->" } |
I don't use Maybe this is a Gutenberg ticket since it seems to not be working in at least two environments? I'm not sure. At this point, it's a bit beyond me. |
Should we consider this fixed for Playground now? Will that setting continue to be enabled? @juanmaguitar We might still need to address this with |
@justintadlock oh I just checked the checkbox in my browser tab. To enable it in a Blueprint you'll need to add the following entry: {
"features": {
"networking": true
}
} See also https://wordpress.github.io/wordpress-playground/blueprints-api/data-format#features |
@adamziel @justintadlock I have updated the blueprint of
and regenerated the zip, and it works fine now ✅ |
There's an issue with the playground created for example-block-style-js that is a bit strange:
wp-env
- launchwp-env start
from inside theexample-block-style-js
folderIn the block editor, the image component with the "HaIn Drawn" block style look like this
![Screenshot 2023-12-07 at 17 01 14](https://private-user-images.githubusercontent.com/422576/288904033-4e4cf3bd-b462-4f09-8a28-c754ec1aaa61.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNzk2MTAsIm5iZiI6MTczOTA3OTMxMCwicGF0aCI6Ii80MjI1NzYvMjg4OTA0MDMzLTRlNGNmM2JkLWI0NjItNGYwOS04YTI4LWM3NTRlYzFhYWE2MS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwOVQwNTM1MTBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT02Yjg4NmJmZmU0MzNmYjkwNTdjYWQ2N2ZiZGNlNDgxNDYzZGVjMmMxZDJlNzg1ZGNlZGNiYjU5OWRjNTA0NTQ5JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.41NnPxKL2THkF8BxpAysrYQI4m4i8s6dSjqTysAQD38)
And it should have the same look in the editor than the example-block-style-php
![Screenshot 2023-12-07 at 17 20 50](https://private-user-images.githubusercontent.com/422576/288908053-c5548bbb-674c-42ea-98c6-ee68454e3bfa.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkwNzk2MTAsIm5iZiI6MTczOTA3OTMxMCwicGF0aCI6Ii80MjI1NzYvMjg4OTA4MDUzLWM1NTQ4YmJiLTY3NGMtNDJlYS05OGM2LWVlNjg0NTRlM2JmYS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwMjA5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDIwOVQwNTM1MTBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1jMjlmMmIzNTExYWZlZDU1N2E2ZjZkYzE4ZDM2NDBjMmQwNjJkZTNhZTI3YWVjZmY5OGNkOWY4YTA2YzFiYTMzJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.6VoCBvrbtn1zKtYvOCMJB5Oei-L_6F_NRWvp9gd0euw)
The issue with example-block-style-js is that is not loading
style.css
and it should according the the code atfunctions.php
of that exampleThe text was updated successfully, but these errors were encountered: