Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 12 additions & 15 deletions src/wp-includes/block-editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,21 +194,18 @@ function get_default_block_editor_settings() {
}
}

// These styles are used if the "no theme styles" options is triggered or on
// themes without their own editor styles.
$default_editor_styles_file = ABSPATH . WPINC . '/css/dist/block-editor/default-editor-styles.css';

static $default_editor_styles_file_contents = false;
if ( ! $default_editor_styles_file_contents && file_exists( $default_editor_styles_file ) ) {
$default_editor_styles_file_contents = file_get_contents( $default_editor_styles_file );
}

$default_editor_styles = array();
if ( $default_editor_styles_file_contents ) {
$default_editor_styles = array(
array( 'css' => $default_editor_styles_file_contents ),
);
}
/*
* These styles are used if the "no theme styles" option is triggered or on
* themes without their own editor styles.
*
* They were previously read from `css/dist/block-editor/default-editor-styles.css`,
* which the block editor package no longer ships.
*/
$default_editor_styles = array(
array(
'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}.editor-post-title__block{margin-top:2em;margin-bottom:1em;font-size:2.5em;font-weight:800}',
),
);

$editor_settings = array(
'alignWide' => get_theme_support( 'align-wide' ),
Expand Down
11 changes: 11 additions & 0 deletions tests/phpunit/tests/blocks/editor.php
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,17 @@ public static function data_get_default_block_editor_settings_auto_attach_media_
);
}

/**
* Tests that the default editor styles are provided without the removed block editor stylesheet.
*/
public function test_get_default_block_editor_settings_default_editor_styles() {
$settings = get_default_block_editor_settings();

$this->assertCount( 1, $settings['defaultEditorStyles'], 'There should be one default editor style.' );
$this->assertStringContainsString( 'font-size:18px', $settings['defaultEditorStyles'][0]['css'], 'The default editor style should set the body font size.' );
$this->assertStringContainsString( '.editor-post-title__block', $settings['defaultEditorStyles'][0]['css'], 'The default editor style should style the post title.' );
}

/**
* @ticket 56815
*/
Expand Down
Loading