-
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_theme_support( 'editor-styles' ); doesn’t work with styles added via enqueue_block_editor_assets #9873
Comments
I also tested it today and it was a bit confusing at first. But I think it is the wanted behaviour. A theme developer might still want to add CSS code to the editor without auto-injecting namespaces, for example some styling for metaboxes or sidebar plugins which are outside of the content area. I ended up with two stylesheets for now, one loaded with |
Ah, good point, that could be right. |
That's how I set it up too. All the CSS that gets passed in via So I don't think it makes sense to auto-transform all CSS. It's two different use cases. |
So that we're clear and I'm not misunderstanding, it requires two separate add_theme_support( 'editor-styles' );
add_editor_style( 'path/to/editor.css' );
Plus, any theme author utilizing this method would now have their block assets set up in two different places: once on the This implementation seems overly complex for something that was supposed to make things easier on theme authors. One call to |
Also, I'm not sure, how to address things like editor width in CSS today as styles added via Reported but closed: #9894 |
I have the same issue @florianbrinkmann, but what I discovered is it is "working" technically but styles are being overwritten now, whereas they didn't use to be. So you have to add |
I'm working on this. I also believe (not 100% tested yet...) that it is possible to prefix block-editor specific rules with .block-editor and tinymce specific rules with .mce-content-body (which will then be also used for Classic blocks in Gutenberg to maintain "classic" styling). So, in theory, it should be possible to maintain a single editor style file. And you can add several editor style files at a time with something like (taken from new twenty-thirteen): And I also think it is probably time to add all the theme specific block styles into the standard style.css file. Really minimize number of style files. |
Good news on this to @justintadlock and others... Gutenberg 4.2 will include, I believe, this pull requests which means we can simplify theme dev and maintain a single file and one function call to just Also, @weavertheme I think this is what Twenty Nineteen is now doing, so ya you're on the right track I think to follow what it's doing. |
@onetrev even with that PR you will still need to call |
Yes, the two function calls are needed. With 4.2, you should be able to style everything using this technique and avoid enqueuing your own styles into the editor. I'm closing this issue for now as nothing actionable. |
Describe the bug
I tried to use the new editor styles feature and followed the steps in the Handbook (https://wordpress.org/gutenberg/handbook/extensibility/theme-support/#editor-styles). I thought that using
and calling the
add_theme_support( 'editor-styles' );
would enable it for the file added in themytheme_block_editor_styles
function, but I get it only working viaadd_editor_style( 'assets/dist/css/editor.css' );
. Is this the wanted behavior? If not, am I doing something wrong?To Reproduce
Steps to reproduce the behavior:
wp_enqueue_style()
in a function hooked to theenqueue_block_editor_assets
.add_theme_support( 'editor-styles' );
..wp-block { width: 1250px; }
into the stylesheet.Expected behavior
The new behavior from #9008 should be applied to styles added via
enqueue_block_editor_assets
ifadd_theme_support( 'editor-styles' );
is set.Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
Additional context
The text was updated successfully, but these errors were encountered: