-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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 parameter to add_editor_style() to determine for which editor the styles are loaded #34380
Comments
@oandregal perhaps you might have some thoughts here? |
I kind of agree, loading styles for the block previews and for the rich text editor should not be coupled. It sounds like a conception error to me. |
The TinyMCE/Classic editors have a class |
@ellatrix This is what I did finally, I'm just not really happy with it. When I now decide to configure a classic theme, I have to edit three files instead of just comment out one single line of code, this was my point. But yeah let's leave it as it is I got used to it. |
Why do you need to edit three files? Can't you use the same file and use those classes when you need to tweak something for a specific editor? |
@ellatrix My previous setup was such that I could place all gutenberg relevant settings in a file "gutenberg_setup.php". The practical thing about this was that if I commented out the line that included the file in functions.php, I only had to install the classic editor plugin so that gutenberg and all its styles would disappear completely from the website. Today I would have to comment out the settings file, delete the theme.json and then comment out the gutenberg styles in 2 of my scss files. But as I mentioned, this is now completely irrelevant, as the introduction of the theme.json has completely thrown my concept out of kilter anyways. |
What problem does this address?
Currently I use the function
add_editor_style()
exclusively to load the styles for tinymce. Styles for Gutenberg are added viaenqueue_block_editor_assets()
so that I can use both editors and make individual adjustments. Due to the different structure of the content, this is unavoidable if you want to support both. If I addadd_theme_support('editor-styles')
, my tinymce.css is also loaded in Gutenberg, which I actually don't want.I came across the problem because with my themes the HTML previews don't work properly - they are only displayed in the browser default. Open issue here: #9129
» According to this thread, you should be able to fix the problem by using the
add_editor_style()
function to provide Gutenberg styles too. I tried to change my themes according to the instructions there, but it didn't help. Apart from now having my tinymce.css in Gutenberg too, nothing has changed. The HTML preview is still not displayed in my theme styles (but that is not the point here).What is your proposed solution?
My idea would be to add an additional parameter to the function
add_editor_style()
, where you can specify for which editor the corresponding files are loaded. Or maybe a new function likeadd_tinymce_style()
, which doesn't get influenced by Gutenberg? Something like this would make it easier for theme developers to upgrade old themes for gutenberg, but keep backwards compability. Because like this you can simply leave the old editor styles (which are likely to contain selectors likebody#tinymce
to overwrite font-sizes and stuff) and create/compile a new file for Gutenbergs backend.At the moment I have two files that control the editor functions. One is a
tinymce_setup.php
and the other isgutenberg_setup.php
. When I create a classic theme, I simply do without loadinggutenberg_setup.php
, so all settings jump back to standard/classic. If I could now call add_editor_style() in both files, but only one specific, it would be great. At the moment, I can only solve the whole thing by not callingadd_theme_support('editor_styles')
at all and usingadd_block_editor_assets()
for Gutenbergs backend instead.The text was updated successfully, but these errors were encountered: