- */
- 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 '
-
-
-
-
-
-
-
-
-
-
-
-
-
- ' . 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 '
-
-
+
+
-
-
+
+