Site logo

[Support request] Overriding default editor styles

Home Forums Support [Support request] Overriding default editor styles

Home Forums Support Overriding default editor styles

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #2558490
    mkjj

    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.

    #2558544
    David
    Staff
    Customer Support

    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.

    #2558593
    mkjj

    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.

    #2558747
    David
    Staff
    Customer Support

    We stopped loading styles back with WP 5.9.
    See here:

    https://docs.generatepress.com/article/classic-editor-styling/

    So what are you seeing ?

    #2558771
    mkjj

    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.

    #2559893
    David
    Staff
    Customer Support

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

    #2559926
    mkjj

    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

    #2560122
    David
    Staff
    Customer Support

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

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.