Enable font family selection in email editor

Initially, we use just basic serif and sans serif fonts.
[MAILPOET-5740]
This commit is contained in:
Rostislav Wolny
2024-01-11 13:15:37 +01:00
committed by Jan Lysý
parent f395580954
commit 429f0ce081
2 changed files with 19 additions and 3 deletions

View File

@@ -106,14 +106,16 @@ class SettingsController {
$coreThemeData = \WP_Theme_JSON_Resolver::get_core_data(); $coreThemeData = \WP_Theme_JSON_Resolver::get_core_data();
$coreSettings = $coreThemeData->get_settings(); $coreSettings = $coreThemeData->get_settings();
// Email Editor Theme
$editorTheme = $this->getTheme();
// Enable custom spacing // Enable custom spacing
$coreSettings['spacing']['units'] = ['px']; $coreSettings['spacing']['units'] = ['px'];
$coreSettings['spacing']['padding'] = true; $coreSettings['spacing']['padding'] = true;
// Typography // Typography
$coreSettings['typography']['dropCap'] = false; // Showing large initial letter cannot be implemented in emails $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']['fontWeight'] = false; // Font weight will be handled by the font family later
$coreSettings['typography']['fontFamilies']['default'] = $editorTheme->get_data()['settings']['typography']['fontFamilies'];
$theme = $this->getTheme();
// body selector is later transformed to .editor-styles-wrapper // 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 // setting padding for bottom and top is needed because \WP_Theme_JSON::get_stylesheet() set them only for .wp-site-blocks selector
@@ -130,7 +132,7 @@ class SettingsController {
$settings['styles'] = [ $settings['styles'] = [
$coreDefaultSettings['defaultEditorStyles'][0], $coreDefaultSettings['defaultEditorStyles'][0],
['css' => wp_get_global_stylesheet(['base-layout-styles'])], ['css' => wp_get_global_stylesheet(['base-layout-styles'])],
['css' => $theme->get_stylesheet()], ['css' => $editorTheme->get_stylesheet()],
['css' => $contentVariables], ['css' => $contentVariables],
['css' => $flexEmailLayoutStyles], ['css' => $flexEmailLayoutStyles],
]; ];

View File

@@ -5,6 +5,20 @@
"layout": { "layout": {
"contentSize": "660px" "contentSize": "660px"
}, },
"typography": {
"fontFamilies": [
{
"fontFamily": "-apple-system, BlinkMacSystemFont, avenir next, avenir, segoe ui, helvetica neue, helvetica, Cantarell, Ubuntu, roboto, noto, arial, sans-serif",
"name": "System Sans-serif",
"slug": "system-sans-serif"
},
{
"fontFamily": "Iowan Old Style, Apple Garamond, Baskerville, Times New Roman, Droid Serif, Times, Source Serif Pro, serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol",
"name": "System Serif",
"slug": "system-Serif"
}
]
},
"useRootPaddingAwareAlignments": true "useRootPaddingAwareAlignments": true
}, },
"styles": { "styles": {