Skip to content

Commit e04cba5

Browse files
committed
MC-2294: Architectural Review for MC-2294
- Updated with feedback
1 parent ce6181d commit e04cba5

File tree

8 files changed

+12
-31
lines changed

8 files changed

+12
-31
lines changed

app/code/Magento/PageBuilder/view/adminhtml/web/js/converter/attribute/src.js

Lines changed: 1 addition & 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/converter/style/background-image.js

Lines changed: 1 addition & 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/utils/directives.js

Lines changed: 2 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/utils/image.js

Lines changed: 2 additions & 9 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/ts/js/converter/attribute/src.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,9 @@ export default class Src implements ConverterInterface {
3939
return "";
4040
}
4141
const imageUrl = value[0].url;
42-
const imageId = value[0].id;
4342
const mediaUrl = convertUrlToPathIfOtherUrlIsOnlyAPath(Config.getConfig("media_url"), imageUrl);
4443

4544
const mediaPath = imageUrl.split(mediaUrl);
46-
return "{{media url=" + mediaPath[1] + (imageId ? " id=" + imageId : "") + "}}";
45+
return "{{media url=" + mediaPath[1] + "}}";
4746
}
4847
}

app/code/Magento/PageBuilder/view/adminhtml/web/ts/js/converter/style/background-image.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,10 @@ export default class BackgroundImage implements ConverterInterface {
4040
return "";
4141
}
4242
const imageUrl = value[0].url;
43-
const imageId = value[0].id;
4443
const mediaUrl = convertUrlToPathIfOtherUrlIsOnlyAPath(Config.getConfig("media_url"), imageUrl);
4544

4645
const mediaPath = imageUrl.split(mediaUrl);
47-
const directive = "{{media url=" + mediaPath[1] + (imageId ? " id=" + imageId : "") + "}}";
46+
const directive = "{{media url=" + mediaPath[1] + "}}";
4847
return "url(\'" + toDataUrl(directive) + "\')";
4948
}
5049
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,13 @@ export function getImageUrl(image: any[]) {
8787
*/
8888
export function removeQuotesInMediaDirectives(html: string): string {
8989
const mediaDirectiveRegExp = /\{\{\s*media\s+url\s*=\s*(.*?)\s*\}\}/g;
90-
const urlRegExp = /\{\{\s*media\s+url\s*=\s*(.*?)\s*(?:id\s*=(.*?))?\s*\}\}/;
90+
const urlRegExp = /\{\{\s*media\s+url\s*=\s*(.*)\s*\}\}/;
9191
const mediaDirectiveMatches = html.match(mediaDirectiveRegExp);
9292
if (mediaDirectiveMatches) {
9393
mediaDirectiveMatches.forEach((mediaDirective: string) => {
9494
const urlMatches = mediaDirective.match(urlRegExp);
9595
if (urlMatches && urlMatches[1] !== undefined) {
96-
const directiveWithOutQuotes = "{{media url=" + urlMatches[1].replace(/("|"|\s)/g, "") +
97-
(urlMatches[2] ? " id=" + urlMatches[2].replace(/("|"|\s)/g, "") : "") +
98-
"}}";
96+
const directiveWithOutQuotes = "{{media url=" + urlMatches[1].replace(/("|"|\s)/g, "") + "}}";
9997
html = html.replace(mediaDirective, directiveWithOutQuotes);
10098
}
10199
});

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,15 @@ import Config from "../config";
1515
export function decodeUrl(value: string): string | [object] {
1616
let result: any = "";
1717
value = decodeURIComponent((value).replace(window.location.href, ""));
18-
const regexp = /{{.*\s*url="?(.*\.([a-z|A-Z]*))"?.*?}}/;
18+
const regexp = /{{.*\s*url="?(.*\.([a-z|A-Z]*))"?\s*}}/;
1919
if (regexp.test(value)) {
2020
const [, url, type] = regexp.exec(value);
2121
const image = {
2222
name: url.split("/").pop(),
2323
size: 0,
2424
type: "image/" + type,
25-
url: Config.getConfig("media_url") + url,
26-
id: "",
25+
url: Config.getConfig("media_url") + url
2726
};
28-
const imageIdMatch = value.match(/{{.*\s*id\s*="?([a-zA-Z0-9-]*)"?\s*}}/);
29-
30-
if (imageIdMatch) {
31-
image.id = imageIdMatch[1];
32-
}
3327

3428
result = [image];
3529
}

0 commit comments

Comments
 (0)