Skip to content

Commit 1a64ad7

Browse files
#713: WYSIWYG content styles are not working on upgraded content
1 parent 9f661c6 commit 1a64ad7

File tree

4 files changed

+35
-2
lines changed

4 files changed

+35
-2
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/observable-updater/html.js

Lines changed: 6 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/js/utils/editor.js

Lines changed: 13 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/content-type/observable-updater/html.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {ContentTypeConfigAppearanceElementInterface} from "../../content-type-co
88
import ConverterPool from "../../converter/converter-pool";
99
import {DataObject} from "../../data-store";
1010
import { replaceWithDataSrc } from "../../utils/directives";
11+
import {processInlineStyles} from "../../utils/editor";
1112
import {get} from "../../utils/object";
1213

1314
/**
@@ -41,5 +42,10 @@ export default function generate(
4142
value = replaceWithDataSrc(value);
4243
}
4344

45+
// Process all desktop styles that left unprocessed after migrating from inline styles.
46+
if (typeof value === "string") {
47+
value = processInlineStyles(value);
48+
}
49+
4450
return value;
4551
}

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/utils/editor.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,16 @@ export function createDoubleClickEvent(): Event {
350350
}
351351
}
352352

353+
/**
354+
* Replace all desktop styles that left unprocessed back to style element to prevent data corruption.
355+
*/
356+
export function processInlineStyles(html: string) {
357+
const name = Config.getConfig("defaultViewport");
358+
const searchPattern = new RegExp(`data-${name}-style=`, "g");
359+
360+
return html.replace(searchPattern, "style=");
361+
}
362+
353363
/**
354364
* Move the end point of a range to handle tables
355365
*

0 commit comments

Comments
 (0)