Skip to content

Commit 9f134f6

Browse files
committed
Editor: Restore the default block editor styles.
Moves the default block editor styles into `get_default_block_editor_settings()` rather than attempting to read them from `wp-includes/css/dist/block-editor/default-editor-styles.css`. The file's source was removed from the block editor package in WordPress/gutenberg@aee1d48, so the `defaultEditorStyles` setting was empty and the styles were missing in these places: * The block editor, when a user turns off the theme styles preference. * The Customizer's widgets editor. The file's post title rule is not restored. The `.editor-post-title__block` class it targets was removed in WordPress 5.9. The tests are updated to ensure the default editor styles are populated. Developed in: #16118 Follow-up to r63535. Reviewed by wildworks. Props mukesh27, wildworks. Fixes #66762. git-svn-id: https://develop.svn.wordpress.org/trunk@65749 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 5ae0af9 commit 9f134f6

2 files changed

Lines changed: 15 additions & 15 deletions

File tree

‎src/wp-includes/block-editor.php‎

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -194,21 +194,18 @@ function get_default_block_editor_settings() {
194194
}
195195
}
196196

197-
// These styles are used if the "no theme styles" options is triggered or on
198-
// themes without their own editor styles.
199-
$default_editor_styles_file = ABSPATH . WPINC . '/css/dist/block-editor/default-editor-styles.css';
200-
201-
static $default_editor_styles_file_contents = false;
202-
if ( ! $default_editor_styles_file_contents && file_exists( $default_editor_styles_file ) ) {
203-
$default_editor_styles_file_contents = file_get_contents( $default_editor_styles_file );
204-
}
205-
206-
$default_editor_styles = array();
207-
if ( $default_editor_styles_file_contents ) {
208-
$default_editor_styles = array(
209-
array( 'css' => $default_editor_styles_file_contents ),
210-
);
211-
}
197+
/*
198+
* These styles are used when the "Use theme styles" preference is turned off
199+
* and in the Customizer widgets editor.
200+
*
201+
* They were previously read from `css/dist/block-editor/default-editor-styles.css`,
202+
* which the block editor package no longer ships.
203+
*/
204+
$default_editor_styles = array(
205+
array(
206+
'css' => 'body{font-family:-apple-system,system-ui,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif;font-size:18px;line-height:1.5;--wp--style--block-gap:2em}p{line-height:1.8}',
207+
),
208+
);
212209

213210
$editor_settings = array(
214211
'alignWide' => get_theme_support( 'align-wide' ),

‎tests/phpunit/tests/blocks/editor.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,7 @@ public function test_get_allowed_block_types_deprecated_filter_post_editor() {
247247

248248
/**
249249
* @ticket 52920
250+
* @ticket 66762
250251
*/
251252
public function test_get_default_block_editor_settings() {
252253
$settings = get_default_block_editor_settings();
@@ -300,6 +301,8 @@ public function test_get_default_block_editor_settings() {
300301
$this->assertFalse( $settings['disableCustomFontSizes'] );
301302
$this->assertFalse( $settings['disableCustomGradients'] );
302303
$this->assertFalse( $settings['disableLayoutStyles'] );
304+
$this->assertCount( 1, $settings['defaultEditorStyles'] );
305+
$this->assertStringContainsString( 'font-size:18px', $settings['defaultEditorStyles'][0]['css'] );
303306
$this->assertFalse( $settings['enableCustomLineHeight'] );
304307
$this->assertFalse( $settings['enableCustomSpacing'] );
305308
$this->assertFalse( $settings['enableCustomUnits'] );

0 commit comments

Comments
 (0)