diff --git a/mailpoet/assets/js/src/email-editor/engine/components/styles-sidebar/index.scss b/mailpoet/assets/js/src/email-editor/engine/components/styles-sidebar/index.scss index ffaea95d2f..cad3af7174 100644 --- a/mailpoet/assets/js/src/email-editor/engine/components/styles-sidebar/index.scss +++ b/mailpoet/assets/js/src/email-editor/engine/components/styles-sidebar/index.scss @@ -7,6 +7,12 @@ .components-navigator-provider, .components-navigator-screen { height: 100%; + overflow: hidden; + } + + .components-navigator-screen { + overflow-x: hidden; + overflow-y: auto; } .components-navigator-button { diff --git a/mailpoet/lib/EmailEditor/Engine/Renderer/ContentRenderer/ContentRenderer.php b/mailpoet/lib/EmailEditor/Engine/Renderer/ContentRenderer/ContentRenderer.php index ffd8ddbb5a..1ebd45e1d3 100644 --- a/mailpoet/lib/EmailEditor/Engine/Renderer/ContentRenderer/ContentRenderer.php +++ b/mailpoet/lib/EmailEditor/Engine/Renderer/ContentRenderer/ContentRenderer.php @@ -84,7 +84,7 @@ class ContentRenderer { */ private function inlineStyles($html, WP_Post $post) { $styles = (string)file_get_contents(dirname(__FILE__) . '/' . self::CONTENT_STYLES_FILE); - $styles .= $this->themeController->getStylesheetForRendering(); + $styles .= $this->themeController->getStylesheetForRendering($post); $styles = ''; return $this->postProcessTemplate( diff --git a/mailpoet/lib/EmailEditor/Engine/ThemeController.php b/mailpoet/lib/EmailEditor/Engine/ThemeController.php index f7c3cb7815..5b67e371d4 100644 --- a/mailpoet/lib/EmailEditor/Engine/ThemeController.php +++ b/mailpoet/lib/EmailEditor/Engine/ThemeController.php @@ -35,7 +35,7 @@ class ThemeController { return $emailEditorThemeSettings; } - public function getStylesheetForRendering(): string { + public function getStylesheetForRendering($post = null): string { $emailThemeSettings = $this->getSettings(); $cssPresets = ''; @@ -64,7 +64,16 @@ class ThemeController { // Element specific styles // Because the section styles is not a part of the output the `get_styles_block_nodes` method, we need to get it separately - $elementsStyles = $this->getTheme()->get_raw_data()['styles']['elements'] ?? []; + if ($post) { + $postTheme = (array)get_post_meta($post->ID, 'mailpoet_email_theme', true); + $postStyles = (array)($postTheme['styles'] ?? []); + $postElements = $postStyles['elements'] ?? []; + } else { + $postElements = []; + } + $jsonElements = $this->getTheme()->get_raw_data()['styles']['elements'] ?? []; + $elementsStyles = array_merge_recursive((array)$jsonElements, (array)$postElements); + $cssElements = ''; foreach ($elementsStyles as $key => $elementsStyle) { $selector = $key; diff --git a/mailpoet/lib/EmailEditor/Integrations/Core/Renderer/Blocks/Heading.php b/mailpoet/lib/EmailEditor/Integrations/Core/Renderer/Blocks/Heading.php deleted file mode 100644 index ede677dc77..0000000000 --- a/mailpoet/lib/EmailEditor/Integrations/Core/Renderer/Blocks/Heading.php +++ /dev/null @@ -1,97 +0,0 @@ -adjustStyleAttribute($blockContent, $parsedBlock, $settingsController, ['tag_name' => "h$level"]); - - return str_replace('{heading_content}', $blockContent, $this->getBlockWrapper($blockContent, $parsedBlock, $settingsController)); - } - - /** - * Based on MJML - */ - private function getBlockWrapper($blockContent, array $parsedBlock, SettingsController $settingsController): string { - $level = $parsedBlock['attrs']['level'] ?? 2; // default level is 2 - $classes = (new DomDocumentHelper($blockContent))->getAttributeValueByTagName("h$level", 'class') ?? ''; - - // Styles for padding need to be set on the wrapping table cell due to support in Outlook - $styles = [ - 'min-width' => '100%', // prevent Gmail App from shrinking the table on mobile devices - ]; - - $paddingStyles = wp_style_engine_get_styles(['spacing' => ['padding' => $parsedBlock['attrs']['style']['spacing']['padding'] ?? null]]); - $styles = array_merge($styles, $paddingStyles['declarations'] ?? []); - - if (isset($parsedBlock['attrs']['textAlign'])) { - $styles['text-align'] = $parsedBlock['attrs']['textAlign']; - } - - if (isset($parsedBlock['attrs']['style']['color']['background'])) { - $styles['background-color'] = $parsedBlock['attrs']['style']['color']['background']; - } - - if (isset($parsedBlock['attrs']['style']['color']['text'])) { - $styles['color'] = $parsedBlock['attrs']['style']['color']['text']; - } - - // fetch Block Style Typography e.g., fontStyle, fontWeight, etc - $attrs = $parsedBlock['attrs'] ?? []; - if (isset($attrs['style']['typography'])) { - $blockStyleTypographyKeys = array_keys($attrs['style']['typography']); - foreach ($blockStyleTypographyKeys as $blockStyleTypographyKey) { - $styles[Helpers::camelCaseToKebabCase($blockStyleTypographyKey)] = $attrs['style']['typography'][$blockStyleTypographyKey]; - } - } - - return ' - - - - - -
- {heading_content} -
- - - '; - } - - /** - * 1) We need to remove padding because we render padding on wrapping table cell - * 2) We also need to replace font-size to avoid clamp() because clamp() is not supported in many email clients. - * The font size values is automatically converted to clamp() when WP site theme is configured to use fluid layouts. - * Currently (WP 6.4), there is no way to disable this behavior. - * @param array{tag_name: string, class_name?: string} $tag - */ - private function adjustStyleAttribute($blockContent, array $parsedBlock, SettingsController $settingsController, array $tag): string { - $html = new \WP_HTML_Tag_Processor($blockContent); - $themeData = $settingsController->getTheme()->get_data(); - $fontSize = 'font-size:' . ($parsedBlock['email_attrs']['font-size'] ?? $themeData['styles']['typography']['fontSize']) . ';'; - - if ($html->next_tag($tag)) { - $elementStyle = $html->get_attribute('style') ?? ''; - // Padding may contain value like 10px or variable like var(--spacing-10) - $elementStyle = preg_replace('/padding.*:.?[0-9a-z-()]+;?/', '', $elementStyle); - $elementStyle = preg_replace('/font-size:[^;]+;?/', $fontSize, $elementStyle); - $html->set_attribute('style', $elementStyle); - $blockContent = $html->get_updated_html(); - } - - return $blockContent; - } -} diff --git a/mailpoet/lib/EmailEditor/Integrations/Core/Renderer/Blocks/Text.php b/mailpoet/lib/EmailEditor/Integrations/Core/Renderer/Blocks/Text.php index dbda0ac356..79bd38c463 100644 --- a/mailpoet/lib/EmailEditor/Integrations/Core/Renderer/Blocks/Text.php +++ b/mailpoet/lib/EmailEditor/Integrations/Core/Renderer/Blocks/Text.php @@ -10,7 +10,10 @@ use MailPoet\EmailEditor\Engine\SettingsController; class Text extends AbstractBlockRenderer { protected function renderContent(string $blockContent, array $parsedBlock, SettingsController $settingsController): string { $blockContent = $this->adjustStyleAttribute($blockContent); - + $blockAttributes = wp_parse_args($parsedBlock['attrs'] ?? [], [ + 'textAlign' => 'left', + 'style' => [], + ]); $html = new \WP_HTML_Tag_Processor($blockContent); $classes = ''; if ($html->next_tag()) { @@ -18,9 +21,9 @@ class Text extends AbstractBlockRenderer { } $blockStyles = $this->getStylesFromBlock([ - 'color' => $parsedBlock['attrs']['style']['color'] ?? [], - 'spacing' => $parsedBlock['attrs']['style']['spacing'] ?? [], - 'typography' => $parsedBlock['attrs']['style']['typography'] ?? [], + 'color' => $blockAttributes['style']['color'] ?? [], + 'spacing' => $blockAttributes['style']['spacing'] ?? [], + 'typography' => $blockAttributes['style']['typography'] ?? [], ]); $styles = [ diff --git a/mailpoet/lib/EmailEditor/Integrations/MailPoet/EmailEditor.php b/mailpoet/lib/EmailEditor/Integrations/MailPoet/EmailEditor.php index 78c3007014..711c9788a7 100644 --- a/mailpoet/lib/EmailEditor/Integrations/MailPoet/EmailEditor.php +++ b/mailpoet/lib/EmailEditor/Integrations/MailPoet/EmailEditor.php @@ -58,27 +58,4 @@ class EmailEditor { 'schema' => $this->emailApiController->getEmailDataSchema(), ]); } - - public function getEmailDefaultContent(): string { - return ' - -
Your Logo
- - -

- - -
- - -

- - -

' . esc_html__('You received this email because you are subscribed to the [site:title]', 'mailpoet') . '

- - -

' . esc_html__('Unsubscribe', 'mailpoet') . ' | ' . esc_html__('Manage subscription', 'mailpoet') . '

- - '; - } } diff --git a/mailpoet/lib/Newsletter/NewsletterSaveController.php b/mailpoet/lib/Newsletter/NewsletterSaveController.php index 914571df06..e0f13e5874 100644 --- a/mailpoet/lib/Newsletter/NewsletterSaveController.php +++ b/mailpoet/lib/Newsletter/NewsletterSaveController.php @@ -475,11 +475,11 @@ class NewsletterSaveController { private function getEmailDefaultContent(): string { return ' - -
Your Logo
+ +
Your Logo
- -

+ +