Site logo

Archived topic

Disable inline heading styles in block editor

5 replies · Started by James on March 1, 2023

Viewing posts 1–6 of 6

Hi there,

I am using GeneratePress for a new site, where I am using the block editor but with essentially custom ACF blocks exclusively to offer editing flexibility while maintaining a high level of control.

So, for example, I have my own heading block where I can take text and other custom settings related to that heading. This works fine on the front end, but I am noticing on the backend that the default generatepress typography styles, specifically the .editor-styles-wrapper h1, that gets injected inline before the block editor override my intended styling. If I go into the inspector and disable these styles, my heading look as I want it in the block editor.

I don't want to disable all of GeneratePress' block editor styles, but so far I would like to disable the typography styling.

Is that possible?

Hi there,

we write all theme styles to the editor and excluding one style is not an option.
I assume that your ACF has specific styles on the front end ?
If so how are those styles added ?

Thanks, David

I made some progress since posting the question. Switched from using enqueue_block_editor_assets to add my css file to the backend, to instead using add_editor_style with a high numeric priority so they come last. While I'll still need to overrides to get things right, it's already much better.

Is using add_editor_style() the best option in your opinion?

Yep thats what we use in the theme:

https://github.com/tomusborne/generatepress/blob/e83706a6a641200de7ff6b20d40daabf84884742/functions.php#L75

and we provide our own filter generate_editor_styles if you want to piggy back on that.

To cover all based there is also block_editor_settings_all which has a lot of options:

https://developer.wordpress.org/reference/hooks/block_editor_settings_all/

an example of it can be found in this forum eg. adding Customizer > Additional CSS to the editor:


add_filter( 'block_editor_settings_all', function( $editor_settings ) {
    $css = wp_get_custom_css_post()->post_content;
    $editor_settings['styles'][] = array( 'css' => $css );

    return $editor_settings;
} );

Choices :)

Thanks, yeah I came across that example in other posts as well

You're welcome

This archived topic is closed to new replies.