Skip to content

Commit a9cb003

Browse files
arcangeliniwoocommercebot
authored andcommitted
Mirror package @woocommerce/email-editor-config from WooCommerce
Upstream-Ref: woocommerce/woocommerce@a145c65
1 parent 02dd391 commit a9cb003

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

changelog.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22

33
This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
44

5+
## [2.3.0](https://github.com/woocommerce/email-editor/releases/tag/2.3.0) - 2026-01-05
6+
7+
- Patch - Email Editor: prevent fatal type errors in Blocks_Width_Preprocessor [#62524]
8+
- Minor - Email editor: Add text alignment for has-text-align-* classes. [#62588]
9+
510
## [2.2.0](https://github.com/woocommerce/email-editor/releases/tag/2.2.0) - 2025-12-15
611

712
- Minor - Add category tabs navigation to email template selection modal. [#62441]
@@ -25,7 +30,7 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
2530

2631
- Patch - Fix core/post-content block rendering empty on second email in batch processing by overriding WordPress render callback with stateless version [#61546]
2732
- Minor - Extend Rendering_Context with email-specific context support (user_id, order_id, recipient_email), add woocommerce_email_editor_rendering_email_context filter [#61546]
28-
- Major - ** BREAKING CHANGE ** Updated all PHP dependencies. [#61753]
33+
- Major [ **BREAKING CHANGE** ] - ** BREAKING CHANGE ** Updated all PHP dependencies. [#61753]
2934

3035
## [1.9.0](https://github.com/woocommerce/email-editor/releases/tag/1.9.0) - 2025-10-31
3136

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"license": "GPL-2.0-or-later",
66
"prefer-stable": true,
77
"minimum-stability": "dev",
8-
"version": "2.2.0",
8+
"version": "2.3.0",
99
"autoload": {
1010
"classmap": [
1111
"src/",

src/Engine/Renderer/ContentRenderer/Preprocessors/class-blocks-width-preprocessor.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function preprocess( array $parsed_blocks, array $layout, array $styles )
3636
// Currently we support only % and px units in case only the number is provided we assume it's %
3737
// because editor saves percent values as a number.
3838
$width_input = is_numeric( $width_input ) ? "$width_input%" : $width_input;
39+
$width_input = is_string( $width_input ) ? $width_input : '100%';
3940
$width = $this->convert_width_to_pixels( $width_input, $layout_width );
4041

4142
if ( 'core/columns' === $block['blockName'] ) {

src/Engine/Renderer/ContentRenderer/Preprocessors/class-cleanup-preprocessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public function preprocess( array $parsed_blocks, array $layout, array $styles )
2525
// https://core.trac.wordpress.org/ticket/45312
2626
// \WP_Block_Parser::parse_blocks() sometimes add a block with name null that can cause unexpected spaces in rendered content
2727
// This behavior was reported as an issue, but it was closed as won't fix.
28-
if ( null === $block['blockName'] ) {
28+
if ( null === $block['blockName'] && '' === trim( $block['innerHTML'] ?? '' ) ) {
2929
unset( $parsed_blocks[ $key ] );
3030
}
3131
}

src/Integrations/Core/Renderer/Blocks/class-text.php

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,32 @@ protected function render_content( string $block_content, array $parsed_block, R
3030
return '';
3131
}
3232

33-
$block_content = $this->adjustStyleAttribute( $block_content );
34-
$block_attributes = wp_parse_args(
33+
$block_content = $this->adjustStyleAttribute( $block_content );
34+
$block_attributes = wp_parse_args(
3535
$parsed_block['attrs'] ?? array(),
3636
array(
3737
'textAlign' => 'left',
3838
'style' => array(),
3939
)
4040
);
41-
$html = new \WP_HTML_Tag_Processor( $block_content );
42-
$classes = 'email-text-block';
41+
$html = new \WP_HTML_Tag_Processor( $block_content );
42+
$classes = 'email-text-block';
43+
$alignment_from_class = null;
4344
if ( $html->next_tag() ) {
4445
/** @var string $block_classes */ // phpcs:ignore Generic.Commenting.DocComment.MissingShort -- used for phpstan
4546
$block_classes = $html->get_attribute( 'class' ) ?? '';
4647
$classes .= ' ' . $block_classes;
48+
49+
// Extract text alignment from has-text-align-* classes before they're potentially modified.
50+
$class_attr = (string) $block_classes;
51+
if ( false !== strpos( $class_attr, 'has-text-align-center' ) ) {
52+
$alignment_from_class = 'center';
53+
} elseif ( false !== strpos( $class_attr, 'has-text-align-right' ) ) {
54+
$alignment_from_class = 'right';
55+
} elseif ( false !== strpos( $class_attr, 'has-text-align-left' ) ) {
56+
$alignment_from_class = 'left';
57+
}
58+
4759
// remove has-background to prevent double padding applied for wrapper and inner element.
4860
$block_classes = str_replace( 'has-background', '', $block_classes );
4961
// remove border related classes because we handle border on wrapping table cell.
@@ -69,6 +81,8 @@ protected function render_content( string $block_content, array $parsed_block, R
6981
$additional_styles['text-align'] = $parsed_block['attrs']['textAlign'];
7082
} elseif ( in_array( $parsed_block['attrs']['align'] ?? null, array( 'left', 'center', 'right' ), true ) ) {
7183
$additional_styles['text-align'] = $parsed_block['attrs']['align'];
84+
} elseif ( null !== $alignment_from_class ) {
85+
$additional_styles['text-align'] = $alignment_from_class;
7286
}
7387

7488
$block_styles = Styles_Helper::extend_block_styles( $block_styles, $additional_styles );

0 commit comments

Comments
 (0)