Skip to content

Commit c784a83

Browse files
committed
Merge remote-tracking branch 'origin/develop' into MC-33556
2 parents 20a7d0a + 4947b61 commit c784a83

File tree

2 files changed

+33
-3
lines changed
  • app/code/Magento/PageBuilder/view/adminhtml/web

2 files changed

+33
-3
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/text/preview.js

Lines changed: 15 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/text/preview.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,14 @@ import events from "Magento_PageBuilder/js/events";
88
import _ from "underscore";
99
import HideShowOption from "../../content-type-menu/hide-show-option";
1010
import {OptionsInterface} from "../../content-type-menu/option.types";
11+
import {DataObject} from "../../data-store";
1112
import delayUntil from "../../utils/delay-until";
1213
import {
13-
createBookmark, createDoubleClickEvent,
14-
findNodeIndex, getActiveEditor, getNodeByIndex,
14+
createBookmark,
15+
createDoubleClickEvent,
16+
findNodeIndex,
17+
getActiveEditor,
18+
getNodeByIndex,
1519
isWysiwygSupported,
1620
lockImageSize,
1721
moveToBookmark,
@@ -300,6 +304,18 @@ export default class Preview extends BasePreview {
300304
protected bindEvents() {
301305
super.bindEvents();
302306

307+
this.contentType.dataStore.subscribe((state: DataObject) => {
308+
// Find html elements which attributes contain magento variables directives
309+
const sanitizedContent = state.content.replace(/<([a-z0-9\-\_]+)([^>]+?[a-z0-9\-\_]+="[^"]*?\{\{.+?\}\}.*?".*?)>/gi, (match1: string, tag: string, attributes: string) => {
310+
// Replace double quote with single quote within magento variable directive
311+
const sanitizedAttributes = attributes.replace(/\{\{[^\{\}]+\}\}/gi, (match2: string) => match2.replace(/"/g, "'"));
312+
return "<" + tag + sanitizedAttributes + ">";
313+
});
314+
if (sanitizedContent !== state.content) {
315+
state.content = sanitizedContent;
316+
}
317+
});
318+
303319
// After drop of new content type open TinyMCE and focus
304320
events.on("text:dropAfter", (args: ContentTypeMountEventParamsInterface) => {
305321
if (args.id === this.contentType.id) {

0 commit comments

Comments
 (0)