Skip to content

Commit 6588511

Browse files
pavel-mailpoetwoocommercebot
authored andcommitted
Mirror package @woocommerce/email-editor-config from WooCommerce
Upstream-Ref: woocommerce/woocommerce@3d4ccab
1 parent 51dc258 commit 6588511

File tree

6 files changed

+85
-17
lines changed

6 files changed

+85
-17
lines changed

changelog.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22

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

5+
## [1.4.2](https://github.com/woocommerce/email-editor/releases/tag/1.4.2) - 2025-08-21
6+
7+
- Patch - Filter unnecessary stylesheets from iframe assets [#60354]
8+
- Patch - Fix Email editor conflict with the site editor. [#60465]
9+
- Patch - Fix horizontal scrolling issue in the email editor on mobile devices. [#60355]
10+
- Patch - Use custom log filepath defined in WP_DEBUG_LOG when specified. [#60255]
11+
512
## [1.4.1](https://github.com/woocommerce/email-editor/releases/tag/1.4.1) - 2025-08-08
613

714
- Patch - Introduce new class Assets_Manager to simplify integration. [#60165]

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": "1.4.1",
8+
"version": "1.4.2",
99
"autoload": {
1010
"classmap": [
1111
"src/"

src/Engine/Logger/class-default-email-editor-logger.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,17 @@ class Default_Email_Editor_Logger implements Email_Editor_Logger_Interface {
3636
* Constructor.
3737
*/
3838
public function __construct() {
39-
$this->log_file = defined( 'WP_DEBUG_LOG' ) && WP_DEBUG_LOG ? WP_CONTENT_DIR . '/debug.log' : '';
39+
if ( defined( 'WP_DEBUG_LOG' ) ) {
40+
if ( true === WP_DEBUG_LOG ) {
41+
$this->log_file = WP_CONTENT_DIR . '/debug.log';
42+
} elseif ( is_string( WP_DEBUG_LOG ) && ! empty( WP_DEBUG_LOG ) ) {
43+
$this->log_file = WP_DEBUG_LOG;
44+
} else {
45+
$this->log_file = '';
46+
}
47+
} else {
48+
$this->log_file = '';
49+
}
4050
}
4151

4252
/**

src/Engine/class-email-editor.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ public function initialize(): void {
105105
$this->logger->info( 'Initializing email editor' );
106106
do_action( 'woocommerce_email_editor_initialized' );
107107
add_filter( 'woocommerce_email_editor_rendering_theme_styles', array( $this, 'extend_email_theme_styles' ), 10, 2 );
108-
// Initialize the assets manager.
109-
$this->assets_manager->initialize();
110108

111109
$this->register_block_patterns();
112110
$this->register_email_post_types();
@@ -116,6 +114,8 @@ public function initialize(): void {
116114
$is_editor_page = apply_filters( 'woocommerce_is_email_editor_page', false );
117115
if ( $is_editor_page ) {
118116
$this->extend_email_post_api();
117+
// Initialize the assets manager.
118+
$this->assets_manager->initialize();
119119
}
120120
add_action( 'rest_api_init', array( $this, 'register_email_editor_api_routes' ) );
121121
add_filter( 'woocommerce_email_editor_send_preview_email', array( $this->send_preview_email, 'send_preview_email' ), 11, 1 ); // allow for other filter methods to take precedent.

src/Engine/class-settings-controller.php

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,13 @@ class Settings_Controller {
2424
*/
2525
private Theme_Controller $theme_controller;
2626

27+
/**
28+
* Allowed iframe style handles.
29+
*
30+
* @var string[]
31+
*/
32+
private array $allowed_iframe_style_handles = array();
33+
2734
/**
2835
* Assets for iframe editor (component styles, scripts, etc.)
2936
*
@@ -55,10 +62,11 @@ public function get_settings(): array {
5562

5663
$settings = array_merge( $core_default_settings, self::DEFAULT_SETTINGS );
5764
// Assets for iframe editor (component styles, scripts, etc.).
58-
$settings['__unstableResolvedAssets'] = $this->iframe_assets;
59-
$editor_content_styles = file_get_contents( __DIR__ . '/content-editor.css' );
60-
$shares_content_styles = file_get_contents( __DIR__ . '/content-shared.css' );
61-
$settings['styles'] = array(
65+
$settings['__unstableResolvedAssets'] = $this->iframe_assets;
66+
$settings['allowedIframeStyleHandles'] = $this->allowed_iframe_style_handles;
67+
$editor_content_styles = file_get_contents( __DIR__ . '/content-editor.css' );
68+
$shares_content_styles = file_get_contents( __DIR__ . '/content-shared.css' );
69+
$settings['styles'] = array(
6270
array( 'css' => $editor_content_styles ),
6371
array( 'css' => $shares_content_styles ),
6472
);
@@ -180,6 +188,42 @@ public function translate_slug_to_color( string $color_slug ): string {
180188
return $this->theme_controller->translate_slug_to_color( $color_slug );
181189
}
182190

191+
/**
192+
* Get the allowed iframe style handles.
193+
*
194+
* @return array
195+
*/
196+
private function get_allowed_iframe_style_handles() {
197+
// Core style handles.
198+
$allowed_iframe_style_handles = array(
199+
'wp-components-css',
200+
'wp-reset-editor-styles-css',
201+
'wp-block-library-css',
202+
'wp-block-editor-content-css',
203+
'wp-edit-blocks-css',
204+
);
205+
206+
foreach ( \WP_Block_Type_Registry::get_instance()->get_all_registered() as $block ) {
207+
if ( ! isset( $block->supports['email'] ) || ! $block->supports['email'] ) {
208+
continue;
209+
}
210+
211+
if ( strpos( $block->name, 'core/' ) !== false ) {
212+
continue;
213+
}
214+
215+
foreach ( $block->style_handles as $handle ) {
216+
$allowed_iframe_style_handles[] = $handle . '-css';
217+
}
218+
219+
foreach ( $block->editor_style_handles as $handle ) {
220+
$allowed_iframe_style_handles[] = $handle . '-css';
221+
}
222+
}
223+
224+
return apply_filters( 'woocommerce_email_editor_allowed_iframe_style_handles', $allowed_iframe_style_handles );
225+
}
226+
183227
/**
184228
* Method to initialize iframe assets.
185229
*
@@ -190,20 +234,19 @@ private function init_iframe_assets(): void {
190234
return;
191235
}
192236

193-
$this->iframe_assets = _wp_get_iframed_editor_assets();
237+
$this->iframe_assets = _wp_get_iframed_editor_assets();
238+
$this->allowed_iframe_style_handles = $this->get_allowed_iframe_style_handles();
194239

195-
// Remove layout styles and block library for classic themes. They are added only when a classic theme is active
196-
// and they add unwanted margins and paddings in the editor content.
197240
$cleaned_styles = array();
198241
foreach ( explode( "\n", (string) $this->iframe_assets['styles'] ) as $asset ) {
199-
if ( strpos( $asset, 'wp-editor-classic-layout-styles-css' ) !== false ) {
200-
continue;
242+
foreach ( $this->allowed_iframe_style_handles as $handle ) {
243+
if ( strpos( $asset, $handle ) !== false ) {
244+
$cleaned_styles[] = $asset;
245+
break;
246+
}
201247
}
202-
if ( strpos( $asset, 'wp-block-library-theme-css' ) !== false ) {
203-
continue;
204-
}
205-
$cleaned_styles[] = $asset;
206248
}
249+
207250
$this->iframe_assets['styles'] = implode( "\n", $cleaned_styles );
208251
}
209252
}

src/Engine/content-editor.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,3 +177,11 @@ ol {
177177
background-color:#000;
178178
color:#fff;
179179
}
180+
181+
/**
182+
* Override the default overflow-x for the iframe in the editor.
183+
* This is needed because we do want allow scrolling on small screens such as mobile devices.
184+
*/
185+
.block-editor-iframe__body {
186+
overflow-x: auto;
187+
}

0 commit comments

Comments
 (0)