| @@ -13,11 +13,18 @@ | ||
| 13 | 13 | /** |
| 14 | 14 | * Registers hooks to WordPress. |
| 15 | 15 | * |
| 16 | 16 | * @codeCoverageIgnore |
| 17 | + * | |
| 18 | + * @return void | |
| 17 | 19 | */ |
| 18 | 20 | public function register_hooks() { |
| 21 | + // For the Classic editor. | |
| 19 | 22 | add_filter( 'mce_css', [ $this, 'add_css_inside_editor' ] ); |
| 23 | + // For the Block/Gutenberg editor. | |
| 24 | + // See https://github.com/danielbachhuber/gutenberg-migration-guide/blob/master/filter-mce-css.md. | |
| 25 | + add_action( 'enqueue_block_editor_assets', [ $this, 'add_editor_styles' ] ); | |
| 26 | + | |
| 20 | 27 | add_filter( 'tiny_mce_before_init', [ $this, 'add_custom_element' ] ); |
| 21 | 28 | } |
| 22 | 29 | |
| 23 | 30 | /** |
| @@ -41,8 +48,18 @@ | ||
| 41 | 48 | $css_files .= ',' . $url; |
| 42 | 49 | } |
| 43 | 50 | |
| 44 | 51 | return $css_files; |
| 52 | + } | |
| 53 | + | |
| 54 | + /** | |
| 55 | + * Enqueues the CSS to use in the TinyMCE editor. | |
| 56 | + * | |
| 57 | + * @return void | |
| 58 | + */ | |
| 59 | + public function add_editor_styles() { | |
| 60 | + $asset_manager = new WPSEO_Admin_Asset_Manager(); | |
| 61 | + $asset_manager->enqueue_style( 'inside-editor' ); | |
| 45 | 62 | } |
| 46 | 63 | |
| 47 | 64 | /** |
| 48 | 65 | * Adds a custom element to the tinyMCE editor that we need for marking the content. |