From bd0ab0cddfdea08b8a0a1763dcfa5c8892c1308a Mon Sep 17 00:00:00 2001 From: Tonya Mork Date: Wed, 1 Feb 2023 20:15:38 +0000 Subject: [PATCH] Editor: Separate content styles for iframe in __wp_get_iframed_editor_assets() and wp_default_styles(). This changeset: * Removes the `'wp-block-editor'` and `'wp-block-library'` from the iframe's stylesheet collection (i.e. `_wp_get_iframed_editor_assets()`). * Adds the new `'wp-block-editor-content'` for the separate stylesheet to the list of editor (`'wp-edit-blocks'`) dependencies. Why? These PHP changes are part of the initiative to: * Separate the content styles contained in the block editor package into a separate stylesheet. * Avoid loading all block editor styles into the iframe. References: * [https://github.com/WordPress/gutenberg/pull/44298 Gutenberg PR 44298]. Follow-up to [53160], [50761]. Props ellatrix, youknowriad. Fixes #57550. git-svn-id: https://develop.svn.wordpress.org/trunk@55179 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/block-editor.php | 2 -- src/wp-includes/script-loader.php | 7 +++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/wp-includes/block-editor.php b/src/wp-includes/block-editor.php index 62ad62049c..4a62837f49 100644 --- a/src/wp-includes/block-editor.php +++ b/src/wp-includes/block-editor.php @@ -300,8 +300,6 @@ function _wp_get_iframed_editor_assets() { $script_handles = array(); $style_handles = array( - 'wp-block-editor', - 'wp-block-library', 'wp-edit-blocks', ); diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index de52578936..63f5c4fe28 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -1609,6 +1609,12 @@ function wp_default_styles( $styles ) { array() ); + $styles->add( + 'wp-block-editor-content', + "/wp-includes/css/dist/block-editor/content$suffix.css", + array() + ); + $wp_edit_blocks_dependencies = array( 'wp-components', 'wp-editor', @@ -1617,6 +1623,7 @@ function wp_default_styles( $styles ) { 'wp-reset-editor-styles', 'wp-block-library', 'wp-reusable-blocks', + 'wp-block-editor-content', ); // Only load the default layout and margin styles for themes without theme.json file.