Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6ec6804

Browse files
authoredAug 14, 2020
Merge pull request #607 from magento/MC-36202
[1.3.3] Support same site
2 parents 68eb162 + 06fa360 commit 6ec6804

File tree

9 files changed

+50
-12
lines changed

9 files changed

+50
-12
lines changed
 

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

+1-1
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/content-type/observable-updater/html.js

+6-1
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/master-format/render/frame.js

+1-1
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/directives.js

+15-3
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/attributes.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default function generate(
4242
value = converterPool.get(converter).toDom(attributeConfig.var, data);
4343
}
4444

45-
// Replacing src attribute with data-src to prevent img requests in iframe during master format rendering
45+
// Replacing src attribute with data-tmp-src to prevent img requests in iframe during master format rendering
4646
if (attributeConfig.name === "src" && !value.indexOf("{{media url=") && Config.getMode() !== "Preview") {
4747
attributeData["data-tmp-" + attributeConfig.name] = value;
4848
// @ts-ignore

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

+7
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,11 @@
33
* See COPYING.txt for license details.
44
*/
55

6+
import Config from "../../config";
67
import {ContentTypeConfigAppearanceElementInterface} from "../../content-type-config.types";
78
import ConverterPool from "../../converter/converter-pool";
89
import {DataObject} from "../../data-store";
10+
import { replaceWithDataSrc } from "../../utils/directives";
911
import {get} from "../../utils/object";
1012

1113
/**
@@ -33,5 +35,10 @@ export default function generate(
3335
if (typeof value === "string" && !value.length && config.html.placeholder) {
3436
value = config.html.placeholder;
3537
}
38+
// Replacing src attribute with data-tmp-src to prevent img requests in iframe during master format rendering
39+
if (Config.getMode() !== "Preview" && typeof value === "string" && value.indexOf("{{media url=") !== -1) {
40+
value = replaceWithDataSrc(value);
41+
}
42+
3643
return value;
3744
}

‎app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/master-format/render/frame.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import ConfigInterface from "../../config.types";
1313
import ContentTypeCollectionInterface from "../../content-type-collection.types";
1414
import createContentType from "../../content-type-factory";
1515
import ContentTypeInterface from "../../content-type.types";
16-
import decodeAllDataUrlsInString, { replaceSrc } from "../../utils/directives";
16+
import decodeAllDataUrlsInString, { replaceWithSrc } from "../../utils/directives";
1717
import filterHtml from "../filter-html";
1818
import { TreeItem } from "./serialize";
1919

@@ -160,7 +160,7 @@ function render(message: {stageId: string, tree: TreeItem}) {
160160
observer.disconnect();
161161
ko.cleanNode(element);
162162
const filtered: JQuery = filterHtml($(element));
163-
const output = replaceSrc(decodeAllDataUrlsInString(filtered.html()));
163+
const output = replaceWithSrc(decodeAllDataUrlsInString(filtered.html()));
164164
resolve(output);
165165
});
166166

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

+15-2
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,27 @@ export function convertMediaDirectivesToUrls(html: string): string {
133133
}
134134

135135
/**
136-
* Replace data-src attribute with src.
136+
* Replace data-tmp-src attribute with src.
137137
*
138138
* @param {string} html
139139
* @returns {string}
140140
*/
141-
export function replaceSrc(html: string): string {
141+
export function replaceWithSrc(html: string): string {
142142
return html.replace(
143143
new RegExp("data-tmp-src=\"\{\{", "g"),
144144
"src=\"{{",
145145
);
146146
}
147+
148+
/**
149+
* Replace src attribute with data-tmp-src.
150+
*
151+
* @param {string} html
152+
* @returns {string}
153+
*/
154+
export function replaceWithDataSrc(html: string): string {
155+
return html.replace(
156+
new RegExp("src=\"\{\{", "g"),
157+
"data-tmp-src=\"{{",
158+
);
159+
}

‎dev/tests/js/jasmine/tests/app/code/Magento/PageBuilder/view/adminhtml/web/js/content-type/text/preview.test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
/* jscs:disable jsDoc*/
99
define([
1010
'Magento_PageBuilder/js/content-type/text/preview',
11-
'Magento_PageBuilder/js/content-type'
11+
'Magento_PageBuilder/js/content-type',
12+
'Magento_PageBuilder/js/resource/babel/polyfill'
1213
], function (Preview, ContentType) {
1314
'use strict';
1415

0 commit comments

Comments
 (0)
Please sign in to comment.