diff --git a/vendor/magento/module-page-builder/view/adminhtml/web/js/content-type/products/mass-converter/carousel-widget-directive.js b/vendor/magento/module-page-builder/view/adminhtml/web/js/content-type/products/mass-converter/carousel-widget-directive.js index efb1c68faf..3748825ccd 100644 --- a/vendor/magento/module-page-builder/view/adminhtml/web/js/content-type/products/mass-converter/carousel-widget-directive.js +++ b/vendor/magento/module-page-builder/view/adminhtml/web/js/content-type/products/mass-converter/carousel-widget-directive.js @@ -38,7 +38,7 @@ define(["Magento_PageBuilder/js/mass-converter/widget-directive-abstract", "Mage data.carousel_products_count = attributes.products_count; data.sort_order = attributes.sort_order; data.condition_option = attributes.condition_option || "condition"; - data[data.condition_option] = this.decodeWysiwygCharacters(attributes.condition_option_value || ""); + data[data.condition_option] = this.decodeWysiwygCharacters(this.decodeHtmlCharacters(attributes.condition_option_value || "")); data.conditions_encoded = this.decodeWysiwygCharacters(attributes.conditions_encoded || ""); data[data.condition_option + "_source"] = data.conditions_encoded; return data; @@ -98,6 +98,22 @@ define(["Magento_PageBuilder/js/mass-converter/widget-directive-abstract", "Mage _proto.decodeWysiwygCharacters = function decodeWysiwygCharacters(content) { return content.replace(/\^\[/g, "{").replace(/\^\]/g, "}").replace(/`/g, "\"").replace(/\|/g, "\\").replace(/</g, "<").replace(/>/g, ">"); + } + /** + * Decode html special characters + * + * @param {string} content + * @returns {string} + */ + ; + + _proto.decodeHtmlCharacters = function decodeHtmlCharacters(content) { + if (content) { + var htmlDocument = new DOMParser().parseFromString(content, "text/html"); + return htmlDocument.body ? htmlDocument.body.textContent : content; + } + + return content; }; return WidgetDirective; diff --git a/vendor/magento/module-page-builder/view/adminhtml/web/js/content-type/products/mass-converter/widget-directive.js b/vendor/magento/module-page-builder/view/adminhtml/web/js/content-type/products/mass-converter/widget-directive.js index 92b0f780ba..e97221fbda 100644 --- a/vendor/magento/module-page-builder/view/adminhtml/web/js/content-type/products/mass-converter/widget-directive.js +++ b/vendor/magento/module-page-builder/view/adminhtml/web/js/content-type/products/mass-converter/widget-directive.js @@ -38,7 +38,7 @@ define(["Magento_PageBuilder/js/mass-converter/widget-directive-abstract", "Mage data.products_count = attributes.products_count; data.sort_order = attributes.sort_order; data.condition_option = attributes.condition_option || "condition"; - data[data.condition_option] = this.decodeWysiwygCharacters(attributes.condition_option_value || ""); + data[data.condition_option] = this.decodeWysiwygCharacters(this.decodeHtmlCharacters(attributes.condition_option_value || "")); data.conditions_encoded = this.decodeWysiwygCharacters(attributes.conditions_encoded || ""); data[data.condition_option + "_source"] = data.conditions_encoded; return data; @@ -98,6 +98,22 @@ define(["Magento_PageBuilder/js/mass-converter/widget-directive-abstract", "Mage _proto.decodeWysiwygCharacters = function decodeWysiwygCharacters(content) { return content.replace(/\^\[/g, "{").replace(/\^\]/g, "}").replace(/`/g, "\"").replace(/\|/g, "\\").replace(/</g, "<").replace(/>/g, ">"); + } + /** + * Decode html special characters + * + * @param {string} content + * @returns {string} + */ + ; + + _proto.decodeHtmlCharacters = function decodeHtmlCharacters(content) { + if (content) { + var htmlDocument = new DOMParser().parseFromString(content, "text/html"); + return htmlDocument.body ? htmlDocument.body.textContent : content; + } + + return content; }; return WidgetDirective; diff --git a/vendor/magento/module-page-builder/view/adminhtml/web/ts/js/content-type/products/mass-converter/carousel-widget-directive.ts b/vendor/magento/module-page-builder/view/adminhtml/web/ts/js/content-type/products/mass-converter/carousel-widget-directive.ts index 6be8e995c4..3911205bf9 100644 --- a/vendor/magento/module-page-builder/view/adminhtml/web/ts/js/content-type/products/mass-converter/carousel-widget-directive.ts +++ b/vendor/magento/module-page-builder/view/adminhtml/web/ts/js/content-type/products/mass-converter/carousel-widget-directive.ts @@ -30,7 +30,9 @@ export default class WidgetDirective extends BaseWidgetDirective { data.carousel_products_count = attributes.products_count; data.sort_order = attributes.sort_order; data.condition_option = attributes.condition_option || "condition"; - data[data.condition_option] = this.decodeWysiwygCharacters(attributes.condition_option_value || ""); + data[data.condition_option] = this.decodeWysiwygCharacters( + this.decodeHtmlCharacters(attributes.condition_option_value || ""), + ); data.conditions_encoded = this.decodeWysiwygCharacters(attributes.conditions_encoded || ""); data[data.condition_option + "_source"] = data.conditions_encoded; return data; @@ -98,4 +100,20 @@ export default class WidgetDirective extends BaseWidgetDirective { .replace(/</g, "<") .replace(/>/g, ">"); } + + /** + * Decode html special characters + * + * @param {string} content + * @returns {string} + */ + private decodeHtmlCharacters(content: string) { + if (content) { + const htmlDocument = new DOMParser().parseFromString(content, "text/html"); + + return htmlDocument.body ? htmlDocument.body.textContent : content; + } + + return content; + } } diff --git a/vendor/magento/module-page-builder/view/adminhtml/web/ts/js/content-type/products/mass-converter/widget-directive.ts b/vendor/magento/module-page-builder/view/adminhtml/web/ts/js/content-type/products/mass-converter/widget-directive.ts index e8bd376101..32ab4c8a09 100644 --- a/vendor/magento/module-page-builder/view/adminhtml/web/ts/js/content-type/products/mass-converter/widget-directive.ts +++ b/vendor/magento/module-page-builder/view/adminhtml/web/ts/js/content-type/products/mass-converter/widget-directive.ts @@ -30,7 +30,9 @@ export default class WidgetDirective extends BaseWidgetDirective { data.products_count = attributes.products_count; data.sort_order = attributes.sort_order; data.condition_option = attributes.condition_option || "condition"; - data[data.condition_option] = this.decodeWysiwygCharacters(attributes.condition_option_value || ""); + data[data.condition_option] = this.decodeWysiwygCharacters( + this.decodeHtmlCharacters(attributes.condition_option_value || ""), + ); data.conditions_encoded = this.decodeWysiwygCharacters(attributes.conditions_encoded || ""); data[data.condition_option + "_source"] = data.conditions_encoded; return data; @@ -98,4 +100,20 @@ export default class WidgetDirective extends BaseWidgetDirective { .replace(/</g, "<") .replace(/>/g, ">"); } + + /** + * Decode html special characters + * + * @param {string} content + * @returns {string} + */ + private decodeHtmlCharacters(content: string) { + if (content) { + const htmlDocument = new DOMParser().parseFromString(content, "text/html"); + + return htmlDocument.body ? htmlDocument.body.textContent : content; + } + + return content; + } }