Skip to content

Commit a461025

Browse files
MC-36202: Support same site
1 parent ef55838 commit a461025

File tree

7 files changed

+35
-11
lines changed

7 files changed

+35
-11
lines changed

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

Lines changed: 6 additions & 2 deletions
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

Lines changed: 3 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/directives.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/template/content-type/image/full-width/master.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,25 @@
77

88
<figure attr="data.main.attributes" ko-style="Object.assign({}, data.main.style(), !data.desktop_image.attributes().src ? {} : {borderStyle: 'none'})" css="data.main.css">
99
<a if="data.link.attributes().href" attr="data.link.attributes" ko-style="data.link.style" css="data.link.css">
10-
<img if="data.desktop_image.attributes().src"
10+
<img if="data.desktop_image.attributes()['data-src']"
1111
attr="data.desktop_image.attributes"
1212
class="pagebuilder-mobile-hidden"
1313
css="data.desktop_image.css"
1414
ko-style="data.desktop_image.style" />
15-
<img if="data.mobile_image.attributes().src"
15+
<img if="data.mobile_image.attributes()['data-src']"
1616
attr="data.mobile_image.attributes"
1717
class="pagebuilder-mobile-only"
1818
css="data.mobile_image.css"
1919
ko-style="data.mobile_image.style" />
2020
</a>
2121

2222
<ifnot args="data.link.attributes().href">
23-
<img if="data.desktop_image.attributes().src"
23+
<img if="data.desktop_image.attributes()['data-src']"
2424
attr="data.desktop_image.attributes"
2525
class="pagebuilder-mobile-hidden"
2626
css="data.desktop_image.css"
2727
ko-style="data.desktop_image.style"/>
28-
<img if="data.mobile_image.attributes().src"
28+
<img if="data.mobile_image.attributes()['data-src']"
2929
attr="data.mobile_image.attributes"
3030
class="pagebuilder-mobile-only"
3131
css="data.mobile_image.css"

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
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";
@@ -39,7 +40,12 @@ export default function generate(
3940
if (converterPool.get(converter)) {
4041
value = converterPool.get(converter).toDom(attributeConfig.var, data);
4142
}
42-
attributeData[attributeConfig.name] = value;
43+
44+
if (attributeConfig.name === "src" && Config.getMode() !== "Preview") {
45+
attributeData["data-" + attributeConfig.name] = value;
46+
} else {
47+
attributeData[attributeConfig.name] = value;
48+
}
4349
}
4450

4551
attributeData["data-element"] = elementName;

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

Lines changed: 2 additions & 2 deletions
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 from "../../utils/directives";
16+
import decodeAllDataUrlsInString, { replaceSrc } 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 = decodeAllDataUrlsInString(filtered.html());
163+
const output = replaceSrc(decodeAllDataUrlsInString(filtered.html()));
164164
resolve(output);
165165
});
166166

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,10 @@ export function convertMediaDirectivesToUrls(html: string): string {
131131
}
132132
return html;
133133
}
134+
135+
export function replaceSrc(html: string): string {
136+
return html.replace(
137+
new RegExp("data-src=\"\{\{", "g"),
138+
"src=\"{{",
139+
);
140+
}

0 commit comments

Comments
 (0)