add_editor_style to the blog editor view (Gutenberg?)

How do I include a css from a custom plugin that would take effect when editing the post? (I assume now the WP blog editing page are all using Gutenberg)

I got this code during my research my it is not working for me at all:

function ghub_child_setup() {
    // Add support for editor styles.
    add_theme_support( 'editor-styles' );
  
    // Enqueue editor styles.
    add_editor_style( 'style.css' );
}
add_action( 'after_setup_theme', 'ghub_child_setup' );

I have replace the css path with the following, not working...

add_editor_style( plugins_url( 'css/editor.css', __FILE__) . '?ver=' . rand(0,100) );

I also found this code, still not working for me

//

add_filter( 'mce_css', 'plugin_mce_css' );
 
function plugin_mce_css( $mce_css ) {
    if ( ! empty( $mce_css ) )
        $mce_css .= ',';
 
    $mce_css .= plugins_url( 'css/editor.css', __FILE__ );
 
    return $mce_css;
}

Topic add-editor-style plugin-development Wordpress

Category Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.