Refactor getSettings to work with the mered theme

The method was loading both themes separately. This commit changes
the behavior so that it uses only the email theme which contains
also the core theme settings.
Instead of modifying the core theme settings in PHP we can now
move these settings into the email editor theme, which is merged
into the core theme.
[MAILPOET-5740]
This commit is contained in:
Rostislav Wolny
2024-01-16 16:51:00 +01:00
committed by Jan Lysý
parent 512d47609e
commit b9b57cc574
2 changed files with 9 additions and 13 deletions

View File

@ -60,19 +60,8 @@ class SettingsController {
public function getSettings(): array {
$coreDefaultSettings = get_default_block_editor_settings();
$coreThemeData = \WP_Theme_JSON_Resolver::get_core_data();
$coreSettings = $coreThemeData->get_settings();
// Email Editor Theme
$editorTheme = $this->getTheme();
// Enable custom spacing
$coreSettings['spacing']['units'] = ['px'];
$coreSettings['spacing']['padding'] = true;
// Typography
$coreSettings['typography']['dropCap'] = false; // Showing large initial letter cannot be implemented in emails
$coreSettings['typography']['fontWeight'] = false; // Font weight will be handled by the font family later
$coreSettings['typography']['fontFamilies']['default'] = $editorTheme->get_data()['settings']['typography']['fontFamilies'];
$themeSettings = $editorTheme->get_settings();
// body selector is later transformed to .editor-styles-wrapper
// setting padding for bottom and top is needed because \WP_Theme_JSON::get_stylesheet() set them only for .wp-site-blocks selector
@ -94,7 +83,7 @@ class SettingsController {
['css' => $flexEmailLayoutStyles],
];
$settings['__experimentalFeatures'] = $coreSettings;
$settings['__experimentalFeatures'] = $themeSettings;
// Enable border radius, color, style and width where possible
$settings['__experimentalFeatures']['border'] = [
"radius" => true,

View File

@ -5,7 +5,14 @@
"layout": {
"contentSize": "660px"
},
"spacing": {
"units": ["px"],
"padding": true,
"margin": false
},
"typography": {
"dropCap": false,
"fontWeight": false,
"fontFamilies": [
{
"name": "Arial",