Site logo

Archived topic

Overriding default editor styles

7 replies · Started by mkjj on March 7, 2023

Viewing posts 1–8 of 8

Hi there,
I usually use the editor-style.css to make the classic editor as much WYSIWYG as possible. I've just found out that some default GP styles are not overwritten. I could use !important, but I would prefer a more elegant solution. Can I programmatically load the editor-style.css after the default CSS editor stylesheet (generatepress/assets/css/admin/editor-typography.css)?

I use the standard code for loading the custom stylesheet:

add_editor_style(get_stylesheet_directory_uri() . '/editor-style.css?v=' . filemtime(get_stylesheet_directory() . '/editor-style.css'));

(Versioning is added to prevent issues with caching.)

Thank you.

Hi there,

hmmm... no priority on the add_editor_style function.
You could try calling it later like so:

add_theme_support( 'editor-styles' );
add_action('after_setup_theme', 'db_add_my_editor_styles');

function db_add_my_editor_styles() {
    add_editor_style(get_stylesheet_directory_uri() . '/editor-style.css?v=' . filemtime(get_stylesheet_directory() . '/editor-style.css'));
}

To cover, the add_editor_style includes the add_theme_support( 'editor-styles' ); but i believe that needs to be called earlier then after_theme_setup so we call it first. Then make the add_editor_style callback after the theme has loaded...

Let me know.

No, it doesn't work either. It seems that all editor-related stylesheets are loaded via javascript and cannot modified so easily. Could I completely deactivate the default editor stylesheet that comes with GP. I don't really need it.

I use the classic editor. Is the GP editor stylesheet loaded when the classic editor is activated? But it seems to be a different stylesheet. The loaded stylesheet is:

/generatepress/assets/css/admin/editor-typography.css

It contains only 66 lines of CSS.

Aah my bad, forgot about that.
Simple fix - is to add an empty style sheet: editor-typography.css to your child theme.

Hm, still not working. I tried it with the stylesheet in /gp-child/ and in /gp-child/assets/css/admin/editor-typography.css. But it works, if I change the stylesheet in /gp-child/assets/css/admin/editor-typography.css It's not super ideal, since I have to edit two files. But that's not too bad.

That's ok?

Thanks, Mike

That is ok... ill have a look round to see if there is a better way, ill report back if i find one :)

This archived topic is closed to new replies.