-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add default editor styles applied to themes without theme.json and wi…
…thout editor styles (#34439) Co-authored-by: jasmussen <joen@automattic.com> Co-authored-by: Kjell Reigstad <kjell.reigstad@automattic.com>
- Loading branch information
1 parent
c0c8ca0
commit 1ad7a0b
Showing
6 changed files
with
74 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* Loads the default editor styles. | ||
* | ||
* @package gutenberg | ||
*/ | ||
|
||
/** | ||
* Load the default editor styles. | ||
* These styles are used if the "no theme styles" options is triggered | ||
* or on themes without their own editor styles. | ||
* | ||
* @param array $settings Default editor settings. | ||
* | ||
* @return array Filtered editor settings. | ||
*/ | ||
function gutenberg_extend_block_editor_settings_with_default_editor_styles( $settings ) { | ||
$default_editor_styles_file = gutenberg_dir_path() . 'build/block-editor/default-editor-styles.css'; | ||
$settings['defaultEditorStyles'] = array( | ||
array( | ||
'css' => file_get_contents( $default_editor_styles_file ), | ||
), | ||
); | ||
|
||
// Remove the default font addition from Core Code. | ||
$styles_without_core_styles = array(); | ||
if ( isset( $settings['styles'] ) ) { | ||
foreach ( $settings['styles'] as $style ) { | ||
if ( 'core' !== $style['__unstableType'] ) { | ||
$styles_without_core_styles[] = $style; | ||
} | ||
} | ||
} | ||
$settings['styles'] = $styles_without_core_styles; | ||
|
||
return $settings; | ||
} | ||
add_filter( 'block_editor_settings_all', 'gutenberg_extend_block_editor_settings_with_default_editor_styles' ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* Default editor styles. | ||
* | ||
* These styles are shown if a theme does not register its own editor style, | ||
* a theme.json file, or has toggled off "Use theme styles" in preferences. | ||
*/ | ||
|
||
body { | ||
font-family: $default-font; | ||
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters