@useinsider/guido 3.6.0-beta.7ac8612 → 3.6.0-beta.804c9cb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/composables/useActionsApi.js +16 -15
- package/dist/composables/useHtmlCompiler.js +40 -22
- package/dist/composables/useHtmlValidator.js +102 -131
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +27 -28
- package/dist/config/migrator/recommendation/extractors.js +22 -44
- package/dist/config/migrator/recommendation/htmlBuilder.js +169 -175
- package/dist/config/migrator/recommendationMigrator.js +31 -30
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +15 -21
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +24 -38
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +38 -39
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +34 -45
- package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +2 -3
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +52 -62
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +67 -74
- package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +6 -7
- package/dist/extensions/Blocks/Recommendation/extension.js +5 -6
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +2 -3
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +2 -3
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +2 -3
- package/dist/extensions/Blocks/Recommendation/templates/index.js +4 -5
- package/dist/src/composables/useHtmlCompiler.d.ts +1 -0
- package/dist/src/composables/useHtmlValidator.d.ts +0 -9
- package/dist/src/config/migrator/recommendation/extractors.d.ts +0 -15
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +0 -8
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +0 -21
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +0 -7
- package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +0 -5
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +0 -6
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +0 -9
- package/dist/src/utils/ampErrorFilter.d.ts +2 -0
- package/dist/utils/ampErrorFilter.js +8 -0
- package/dist/utils/templatePreparation.js +53 -53
- package/package.json +1 -1
- package/dist/config/compiler/utils/recommendationIgnoreUtils.js +0 -15
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.d.ts +0 -17
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.test.d.ts +0 -1
- /package/dist/src/{composables/useHtmlValidator.test.d.ts → utils/ampErrorFilter.test.d.ts} +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { filterAmpErrors as w } from "../utils/ampErrorFilter.js";
|
|
2
|
+
import { useToaster as A } from "./useToaster.js";
|
|
3
|
+
const D = () => {
|
|
4
|
+
const { handleError: n } = A(), s = (t = {}) => new Promise((e, a) => {
|
|
4
5
|
const o = { ...{
|
|
5
6
|
minimize: !0,
|
|
6
7
|
utmEntity: {
|
|
@@ -20,29 +21,29 @@ const v = () => {
|
|
|
20
21
|
forceAmp: !1,
|
|
21
22
|
resetDataSavedFlag: !1,
|
|
22
23
|
disableLineHeightsReplace: !0
|
|
23
|
-
}, ...t },
|
|
24
|
-
callback: (
|
|
25
|
-
|
|
24
|
+
}, ...t }, l = {
|
|
25
|
+
callback: (r, p, d, c, u) => {
|
|
26
|
+
r ? a(r) : e({
|
|
26
27
|
html: p,
|
|
27
28
|
ampHtml: d,
|
|
28
|
-
ampErrors: c,
|
|
29
|
+
ampErrors: w(c ?? []),
|
|
29
30
|
displayConditions: u
|
|
30
31
|
});
|
|
31
32
|
},
|
|
32
33
|
...o
|
|
33
34
|
};
|
|
34
|
-
window.StripoEditorApi.actionsApi.compileEmail(
|
|
35
|
+
window.StripoEditorApi.actionsApi.compileEmail(l);
|
|
35
36
|
});
|
|
36
37
|
return {
|
|
37
|
-
getCompiledEmail:
|
|
38
|
+
getCompiledEmail: s,
|
|
38
39
|
getTemplateData: () => new Promise((t) => {
|
|
39
|
-
const e = ({ html: a, css: i, width: o, height:
|
|
40
|
+
const e = ({ html: a, css: i, width: o, height: m, utmParams: l, syncModulesIds: r }) => t({
|
|
40
41
|
html: a,
|
|
41
42
|
css: i,
|
|
42
43
|
width: o,
|
|
43
|
-
height:
|
|
44
|
-
utmParams:
|
|
45
|
-
syncModulesIds:
|
|
44
|
+
height: m,
|
|
45
|
+
utmParams: l,
|
|
46
|
+
syncModulesIds: r
|
|
46
47
|
});
|
|
47
48
|
window.StripoEditorApi.actionsApi.getTemplateData(e);
|
|
48
49
|
}),
|
|
@@ -56,7 +57,7 @@ const v = () => {
|
|
|
56
57
|
displayConditions: a,
|
|
57
58
|
ampHtml: i = "",
|
|
58
59
|
ampErrors: o = []
|
|
59
|
-
} = await
|
|
60
|
+
} = await s({ minimize: !1, resetDataSavedFlag: !1, ...t });
|
|
60
61
|
return {
|
|
61
62
|
html: e,
|
|
62
63
|
ampHtml: i,
|
|
@@ -101,5 +102,5 @@ const v = () => {
|
|
|
101
102
|
};
|
|
102
103
|
};
|
|
103
104
|
export {
|
|
104
|
-
|
|
105
|
+
D as useActionsApi
|
|
105
106
|
};
|
|
@@ -1,30 +1,48 @@
|
|
|
1
|
-
import { defaultHtmlCompilerRules as
|
|
2
|
-
import { itemsCompilerRules as
|
|
3
|
-
import { liquidCompilerRules as
|
|
4
|
-
import { outlookCompilerRules as
|
|
5
|
-
import { recommendationCompilerRules as
|
|
6
|
-
import { socialCompilerRules as
|
|
7
|
-
import { unsubscribeCompilerRules as
|
|
8
|
-
import { createHtmlCompiler as
|
|
9
|
-
import { useConfig as
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
1
|
+
import { defaultHtmlCompilerRules as R } from "../config/compiler/htmlCompilerRules.js";
|
|
2
|
+
import { itemsCompilerRules as g } from "../config/compiler/itemsCompilerRules.js";
|
|
3
|
+
import { liquidCompilerRules as C } from "../config/compiler/liquidCompilerRules.js";
|
|
4
|
+
import { outlookCompilerRules as b } from "../config/compiler/outlookCompilerRules.js";
|
|
5
|
+
import { recommendationCompilerRules as v } from "../config/compiler/recommendationCompilerRules.js";
|
|
6
|
+
import { socialCompilerRules as H } from "../config/compiler/socialCompilerRules.js";
|
|
7
|
+
import { unsubscribeCompilerRules as x } from "../config/compiler/unsubscribeCompilerRules.js";
|
|
8
|
+
import { createHtmlCompiler as s } from "../utils/htmlCompiler.js";
|
|
9
|
+
import { useConfig as k } from "./useConfig.js";
|
|
10
|
+
const y = /* @__PURE__ */ new Set([
|
|
11
|
+
// URL/tag encoding fixes — keep merge-tag and placeholder integrity intact.
|
|
12
|
+
"fix-url-encoding-start",
|
|
13
|
+
"fix-url-encoding-end",
|
|
14
|
+
"fix-tags-start",
|
|
15
|
+
"fix-tags-end",
|
|
16
|
+
// Image domain corrections — plain string replacement.
|
|
17
|
+
"replace-old-image-domain",
|
|
18
|
+
"replace-old-v2-image-domain",
|
|
19
|
+
// Unsubscribe domain — the actual fix: injects the real unsubscribe href in
|
|
20
|
+
// place of the `{{ins-*-unsubscribe-link}}` placeholders, plus related
|
|
21
|
+
// unsubscribe-only cleanups. All pure regex/text, no AMP-forbidden output.
|
|
22
|
+
"add-unsubscribe-link-values",
|
|
23
|
+
"remove-data-ogsb-button-styles",
|
|
24
|
+
"format-comment-braces",
|
|
25
|
+
"add-universal-link-flags",
|
|
26
|
+
// Coupon placeholder replacement (only present when liquidSyntax is enabled).
|
|
27
|
+
"liquid-coupon-code"
|
|
28
|
+
]), M = () => {
|
|
29
|
+
var m, t, r;
|
|
30
|
+
const { compiler: e, isFeatureEnabled: a, partner: n } = k(), u = ((m = e.value) == null ? void 0 : m.customRules) || [], l = [
|
|
31
|
+
...!!((t = e.value) != null && t.ignoreDefaultRules) ? [] : R,
|
|
32
|
+
...v,
|
|
33
|
+
...x,
|
|
15
34
|
...g,
|
|
16
|
-
...f,
|
|
17
|
-
...C,
|
|
18
35
|
...b,
|
|
19
|
-
...
|
|
20
|
-
...
|
|
36
|
+
...H,
|
|
37
|
+
...a("liquidSyntax") ? C : [],
|
|
38
|
+
...u.map((o, f) => ({
|
|
21
39
|
...o,
|
|
22
|
-
priority: o.priority + 1e3 +
|
|
40
|
+
priority: o.priority + 1e3 + f
|
|
23
41
|
// Ensure additional rules run after default rules
|
|
24
42
|
}))
|
|
25
|
-
], p =
|
|
26
|
-
return { compileHtml: (o) => p.compile(o, void 0,
|
|
43
|
+
], p = s(l), c = l.filter((o) => y.has(o.id)), d = s(c), i = (r = n.value) == null ? void 0 : r.fallbackFont;
|
|
44
|
+
return { compileHtml: (o) => p.compile(o, void 0, i), compileAmpHtml: (o) => d.compile(o, void 0, i) };
|
|
27
45
|
};
|
|
28
46
|
export {
|
|
29
|
-
|
|
47
|
+
M as useHtmlCompiler
|
|
30
48
|
};
|
|
@@ -1,195 +1,166 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { DISPLAY_CONDITIONS_REGEX as $, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as X, CampaignCouldNotBeSavedKey as j, CanNotMakeAnyChangesForRunningKey as q } from "../enums/html-validator.js";
|
|
1
|
+
import { useConfig as _ } from "./useConfig.js";
|
|
2
|
+
import { TemplateTypes as H } from "../enums/defaults.js";
|
|
3
|
+
import { DISPLAY_CONDITIONS_REGEX as P, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as G, CampaignCouldNotBeSavedKey as M, CanNotMakeAnyChangesForRunningKey as $ } from "../enums/html-validator.js";
|
|
5
4
|
import { ToasterTypeOptions as c } from "../enums/toaster.js";
|
|
6
|
-
import { itemsBlockDynamicVariables as
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return [...o.matchAll(se)].map((d) => d[1]);
|
|
5
|
+
import { itemsBlockDynamicVariables as q } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
6
|
+
import { useRecommendationExtensionStore as X } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
7
|
+
import { RecommendationRequiredFieldsKey as j } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
|
|
8
|
+
import { useRecommendationStore as K } from "../stores/recommendation.js";
|
|
9
|
+
import { base64EncodeWithSpecialChars as z } from "../utils/base64.js";
|
|
10
|
+
import { useHttp as U } from "./useHttp.js";
|
|
11
|
+
import { useToaster as Y } from "./useToaster.js";
|
|
12
|
+
import { useTranslations as Z } from "./useTranslations.js";
|
|
13
|
+
const J = /recommendation-id="(\d+)"/g;
|
|
14
|
+
function Q(a) {
|
|
15
|
+
return [...a.matchAll(J)].map((u) => u[1]);
|
|
18
16
|
}
|
|
19
|
-
function
|
|
20
|
-
return
|
|
17
|
+
function ee(a, u) {
|
|
18
|
+
return u.some((d) => a.startsWith(`${d}_`));
|
|
21
19
|
}
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const d =
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
const we = () => {
|
|
28
|
-
var E, b;
|
|
29
|
-
const { showToaster: o } = ee(), { post: d } = Q(), { config: g } = H(), i = te(), v = Z(), p = K(), C = ((b = (E = g.value) == null ? void 0 : E.partner) == null ? void 0 : b.messageType) === P.transactional, w = async (e) => {
|
|
30
|
-
if (e.size === 0)
|
|
31
|
-
return /* @__PURE__ */ new Set();
|
|
32
|
-
try {
|
|
33
|
-
await p.fetchRecommendationFilters();
|
|
34
|
-
} catch {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
const s = new Set(z);
|
|
38
|
-
return Object.values(p.filterList).forEach((t) => {
|
|
39
|
-
s.add(t.attributeName.toLowerCase());
|
|
40
|
-
}), s;
|
|
41
|
-
}, I = async (e) => {
|
|
42
|
-
const t = await d(
|
|
20
|
+
const ge = () => {
|
|
21
|
+
var y, h;
|
|
22
|
+
const { showToaster: a } = Y(), { post: u } = U(), { config: d } = _(), r = Z(), g = K(), S = X(), p = ((h = (y = d.value) == null ? void 0 : y.partner) == null ? void 0 : h.messageType) === H.transactional, b = async (e) => {
|
|
23
|
+
const t = await u(
|
|
43
24
|
"/newsletter/template-library/check-template-html-body",
|
|
44
|
-
{ html:
|
|
45
|
-
), { status: n, message:
|
|
46
|
-
return n ||
|
|
25
|
+
{ html: z(e) }
|
|
26
|
+
), { status: n, message: l } = t.data;
|
|
27
|
+
return n || a({
|
|
47
28
|
type: c.Alert,
|
|
48
|
-
message: n === void 0 ?
|
|
49
|
-
}),
|
|
29
|
+
message: n === void 0 ? l : r("newsletter.invalid-url-link-for-toaster")
|
|
30
|
+
}), r(M), l === r($) && a({
|
|
50
31
|
type: c.Alert,
|
|
51
|
-
message:
|
|
32
|
+
message: r("newsletter.already-in-progress")
|
|
52
33
|
}), n;
|
|
53
|
-
},
|
|
34
|
+
}, w = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), E = (e) => ["if", "endif"].includes(e.toLowerCase()), A = (e, s) => {
|
|
54
35
|
const t = e.match(/({%(.*?)%})/g);
|
|
55
36
|
let n = !0;
|
|
56
|
-
return t !== null && !
|
|
57
|
-
const
|
|
58
|
-
if (
|
|
59
|
-
const [
|
|
60
|
-
|
|
37
|
+
return t !== null && !p && t.forEach((l) => {
|
|
38
|
+
const o = l.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
|
|
39
|
+
if (o && o.length > 0) {
|
|
40
|
+
const [i] = o;
|
|
41
|
+
w(i) && !s.includes(i) && (a({
|
|
61
42
|
type: c.Warning,
|
|
62
|
-
message:
|
|
43
|
+
message: r("custom-fields.invalid-custom-fields")
|
|
63
44
|
}), n = !1);
|
|
64
45
|
}
|
|
65
46
|
}), n;
|
|
66
|
-
},
|
|
67
|
-
const n = t ? await
|
|
68
|
-
return
|
|
69
|
-
},
|
|
47
|
+
}, k = async (e, s, t) => {
|
|
48
|
+
const n = t ? await b(e) : !0;
|
|
49
|
+
return A(e, s) && n;
|
|
50
|
+
}, x = (e) => e.length > 0 ? !0 : (a({
|
|
70
51
|
type: c.Warning,
|
|
71
|
-
message:
|
|
72
|
-
}), !1),
|
|
52
|
+
message: r("newsletter.html-content-is-empty")
|
|
53
|
+
}), !1), I = (e) => {
|
|
73
54
|
const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
|
|
74
|
-
return s > t &&
|
|
55
|
+
return s > t && a({
|
|
75
56
|
type: c.Warning,
|
|
76
|
-
message:
|
|
77
|
-
}), s < t &&
|
|
57
|
+
message: r("custom-fields.missing-closing-braces")
|
|
58
|
+
}), s < t && a({
|
|
78
59
|
type: c.Warning,
|
|
79
|
-
message:
|
|
60
|
+
message: r("custom-fields.missing-opening-braces")
|
|
80
61
|
}), s === t;
|
|
81
|
-
},
|
|
62
|
+
}, F = (e) => {
|
|
82
63
|
const s = e.match(/{{\s*(\w+\s+((\w+\|\w+)|(\w+)))\s*}}/gm) === null;
|
|
83
|
-
return s ||
|
|
64
|
+
return s || a({
|
|
84
65
|
type: c.Warning,
|
|
85
|
-
message:
|
|
66
|
+
message: r("custom-fields.invalid-custom-fields")
|
|
86
67
|
}), s;
|
|
87
|
-
},
|
|
88
|
-
const
|
|
89
|
-
if (
|
|
90
|
-
const
|
|
91
|
-
if (
|
|
92
|
-
const m =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
const
|
|
96
|
-
if (y && t.has(y.recoId)) {
|
|
97
|
-
if (!n || n.has(y.attribute))
|
|
98
|
-
return;
|
|
99
|
-
f.push(m);
|
|
100
|
-
return;
|
|
101
|
-
}
|
|
102
|
-
oe(m, l) || f.push(m);
|
|
103
|
-
}), f.length > 0) {
|
|
104
|
-
const u = `
|
|
68
|
+
}, T = (e, s) => {
|
|
69
|
+
const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
|
|
70
|
+
if (t && !p) {
|
|
71
|
+
const n = new Set(s.map((i) => i.toLowerCase())), l = Q(e), o = [];
|
|
72
|
+
if (t.forEach((i) => {
|
|
73
|
+
const m = i.slice(2, -2).trim().toLowerCase();
|
|
74
|
+
(!n.has(m) || m === "") && !ee(m, l) && o.push(m);
|
|
75
|
+
}), o.length > 0) {
|
|
76
|
+
const i = `
|
|
105
77
|
<ul>
|
|
106
|
-
${
|
|
78
|
+
${o.map((m) => `<li>${m}</li>`).join("")}
|
|
107
79
|
</ul>
|
|
108
80
|
`;
|
|
109
|
-
return
|
|
81
|
+
return a({
|
|
110
82
|
type: c.Alert,
|
|
111
|
-
message:
|
|
83
|
+
message: r("custom-fields.invalid-custom-fields") + i
|
|
112
84
|
}), !1;
|
|
113
85
|
}
|
|
114
86
|
}
|
|
115
87
|
return !0;
|
|
116
|
-
},
|
|
88
|
+
}, R = (e) => {
|
|
117
89
|
const s = e.match(/{%(.*?)%}/g), t = [];
|
|
118
90
|
let n = !0;
|
|
119
|
-
if (s && s.forEach((
|
|
120
|
-
const
|
|
121
|
-
(!
|
|
91
|
+
if (s && s.forEach((l) => {
|
|
92
|
+
const o = l.match(P), i = l.match(G), m = (o == null ? void 0 : o.join("")) || "";
|
|
93
|
+
(!o || l !== m) && !i && (a({
|
|
122
94
|
type: c.Alert,
|
|
123
|
-
message:
|
|
124
|
-
}), n = !1),
|
|
125
|
-
|
|
95
|
+
message: r("newsletter.display-conditions-invalid-syntax")
|
|
96
|
+
}), n = !1), o && o.forEach((f) => {
|
|
97
|
+
f.trim() === "=" && (a({
|
|
126
98
|
type: c.Alert,
|
|
127
|
-
message:
|
|
99
|
+
message: r("custom-conditions.wrong-equality-operators")
|
|
128
100
|
}), n = !1);
|
|
129
|
-
const
|
|
130
|
-
|
|
131
|
-
|
|
101
|
+
const v = f.match(/^[a-zA-Z]*$/g);
|
|
102
|
+
v && v.forEach((C) => {
|
|
103
|
+
E(C) && t.push(C);
|
|
132
104
|
});
|
|
133
105
|
});
|
|
134
106
|
}), t.length) {
|
|
135
|
-
const
|
|
136
|
-
|
|
107
|
+
const l = t.filter((i) => i === "if"), o = t.filter((i) => i === "endif");
|
|
108
|
+
l.length !== o.length && (a({
|
|
137
109
|
type: c.Alert,
|
|
138
|
-
message:
|
|
110
|
+
message: r("custom-conditions.missing-if-endif-tag")
|
|
139
111
|
}), n = !1);
|
|
140
112
|
}
|
|
141
113
|
return n;
|
|
142
|
-
},
|
|
114
|
+
}, B = (e) => {
|
|
143
115
|
const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
|
|
144
|
-
return n ||
|
|
116
|
+
return n || a({
|
|
145
117
|
type: c.Warning,
|
|
146
|
-
message:
|
|
118
|
+
message: r("custom-conditions.no-space-after-braces")
|
|
147
119
|
}), n;
|
|
148
|
-
},
|
|
120
|
+
}, W = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (a({
|
|
149
121
|
type: c.Warning,
|
|
150
|
-
message:
|
|
151
|
-
}), !1) : !0,
|
|
122
|
+
message: r("custom-conditions.no-braces-inside-if-tag")
|
|
123
|
+
}), !1) : !0, N = () => S.hasInvalidBlock() ? (a({
|
|
152
124
|
type: c.Alert,
|
|
153
|
-
message:
|
|
154
|
-
}), !1) : !0,
|
|
125
|
+
message: r(j)
|
|
126
|
+
}), !1) : !0, O = () => g.recommendationConfigs && Object.values(g.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (a({
|
|
155
127
|
type: c.Alert,
|
|
156
|
-
message:
|
|
157
|
-
}), !1) : !0,
|
|
128
|
+
message: r("newsletter.fill-all-necessary-fields")
|
|
129
|
+
}), !1) : !0, D = (e) => {
|
|
158
130
|
const s = /src="[^"]*\.(svg|pst)"/gm;
|
|
159
|
-
return e.match(s) === null ? !0 : (
|
|
131
|
+
return e.match(s) === null ? !0 : (a({
|
|
160
132
|
type: c.Alert,
|
|
161
|
-
message:
|
|
133
|
+
message: r("newsletter.invalid-image-type")
|
|
162
134
|
}), !1);
|
|
163
|
-
},
|
|
135
|
+
}, L = (e) => {
|
|
164
136
|
const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
|
|
165
|
-
return Array.from(n).find((
|
|
166
|
-
var
|
|
167
|
-
return !((
|
|
168
|
-
}) ? (
|
|
137
|
+
return Array.from(n).find((o) => {
|
|
138
|
+
var i;
|
|
139
|
+
return !((i = o.id) != null && i.trim());
|
|
140
|
+
}) ? (a({
|
|
169
141
|
type: c.Alert,
|
|
170
|
-
message:
|
|
142
|
+
message: r("unsubscribe-templates.select-checkbox-groups")
|
|
171
143
|
}), !1) : !0;
|
|
172
|
-
},
|
|
144
|
+
}, V = (e) => {
|
|
173
145
|
const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
|
|
174
|
-
return Array.from(n).find((
|
|
175
|
-
var
|
|
176
|
-
return !((
|
|
177
|
-
}) ? (
|
|
146
|
+
return Array.from(n).find((o) => {
|
|
147
|
+
var i;
|
|
148
|
+
return !((i = o.id) != null && i.trim());
|
|
149
|
+
}) ? (a({
|
|
178
150
|
type: c.Alert,
|
|
179
|
-
message:
|
|
151
|
+
message: r("unsubscribe-templates.select-radio-button-groups")
|
|
180
152
|
}), !1) : !0;
|
|
181
153
|
};
|
|
182
154
|
return { validateHtml: async (e, s, t = !1) => {
|
|
183
|
-
var
|
|
155
|
+
var o, i;
|
|
184
156
|
const n = [
|
|
185
157
|
...s.map((m) => m.value),
|
|
186
|
-
...
|
|
187
|
-
...((
|
|
188
|
-
]
|
|
189
|
-
return await
|
|
158
|
+
...q,
|
|
159
|
+
...((i = (o = d.value) == null ? void 0 : o.template) == null ? void 0 : i.customFieldAttributes) ?? []
|
|
160
|
+
];
|
|
161
|
+
return await k(e, n, t) && x(e) && I(e) && F(e) && T(e, n) && R(e) && B(e) && W(e) && N() && O() && D(e) && L(e) && V(e);
|
|
190
162
|
} };
|
|
191
163
|
};
|
|
192
164
|
export {
|
|
193
|
-
|
|
194
|
-
we as useHtmlValidator
|
|
165
|
+
ge as useHtmlValidator
|
|
195
166
|
};
|
|
@@ -2,7 +2,6 @@ import { useConfig as g } from "../../../composables/useConfig.js";
|
|
|
2
2
|
import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
|
|
3
3
|
import { CSS_CLASS_RECO_BUTTON as q } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
4
|
import { useRecommendationExtensionStore as C } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
-
import { isIgnoredRecommendationBlock as w } from "./recommendationIgnoreUtils.js";
|
|
6
5
|
function y(r, n, e, o, i = "") {
|
|
7
6
|
const c = `{{${i}${r}_${n}_${e}}}`, t = `{{${i}${r}_${n}_currency}}`;
|
|
8
7
|
return o === "before" ? `${t} ${c}` : `${c} ${t}`;
|
|
@@ -13,7 +12,7 @@ function A(r) {
|
|
|
13
12
|
[n] = n.children;
|
|
14
13
|
return n;
|
|
15
14
|
}
|
|
16
|
-
function
|
|
15
|
+
function f(r, n, e, o, i, c) {
|
|
17
16
|
switch (n) {
|
|
18
17
|
case "productImage": {
|
|
19
18
|
const t = r.querySelector("img");
|
|
@@ -88,45 +87,45 @@ function b(r, n, e, o, i, c) {
|
|
|
88
87
|
}
|
|
89
88
|
}
|
|
90
89
|
}
|
|
91
|
-
function
|
|
90
|
+
function w(r, n, e, o) {
|
|
92
91
|
r.querySelectorAll(".recommendation-product-row").forEach((c, t) => {
|
|
93
92
|
c.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
94
93
|
const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
|
|
95
94
|
p.length > 0 ? p.forEach((l) => {
|
|
96
|
-
|
|
97
|
-
}) :
|
|
95
|
+
f(l, u, n, t, e, o);
|
|
96
|
+
}) : f(a, u, n, t, e, o);
|
|
98
97
|
});
|
|
99
98
|
});
|
|
100
99
|
}
|
|
101
|
-
function
|
|
100
|
+
function E(r, n, e, o) {
|
|
102
101
|
const i = r.querySelectorAll(".recommendation-product-row");
|
|
103
102
|
if (!i.length)
|
|
104
103
|
return;
|
|
105
104
|
const [c] = i, t = c.querySelector("[data-attribute-type]"), s = t ? t.querySelectorAll(".attribute-cell").length : 1;
|
|
106
105
|
i.forEach((a, u) => {
|
|
107
106
|
a.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
108
|
-
const
|
|
107
|
+
const d = l.getAttribute("data-attribute-type") || "";
|
|
109
108
|
l.querySelectorAll(".attribute-cell").forEach((h, $) => {
|
|
110
109
|
const S = u * s + $;
|
|
111
|
-
|
|
110
|
+
f(h, d, n, S, e, o);
|
|
112
111
|
});
|
|
113
112
|
});
|
|
114
113
|
});
|
|
115
114
|
}
|
|
116
|
-
function
|
|
115
|
+
function R(r, n, e, o) {
|
|
117
116
|
r.querySelectorAll(".ins-recommendation-product-container").forEach((c) => {
|
|
118
|
-
|
|
117
|
+
E(c, n, e, o);
|
|
119
118
|
});
|
|
120
119
|
}
|
|
121
|
-
function
|
|
120
|
+
function P(r, n, e) {
|
|
122
121
|
const o = r.getAttribute("data-layout") || "grid", i = r.getAttribute("currency-alignment") || "after";
|
|
123
|
-
o === "list" ?
|
|
122
|
+
o === "list" ? w(r, n, i, e) : R(r, n, i, e);
|
|
124
123
|
}
|
|
125
|
-
function
|
|
124
|
+
function b(r, n, e) {
|
|
126
125
|
const o = new RegExp(`${n}\\s*:\\s*(\\d+)\\s*px`, "i"), i = r.match(o);
|
|
127
126
|
return i ? parseInt(i[1]) : e;
|
|
128
127
|
}
|
|
129
|
-
function
|
|
128
|
+
function T(r, n) {
|
|
130
129
|
let e = r.parentElement;
|
|
131
130
|
for (; e && e !== n; ) {
|
|
132
131
|
if (e.tagName === "TD") {
|
|
@@ -138,29 +137,29 @@ function v(r, n) {
|
|
|
138
137
|
}
|
|
139
138
|
return null;
|
|
140
139
|
}
|
|
141
|
-
function
|
|
142
|
-
const n = r.getAttribute("style") || "", e =
|
|
140
|
+
function v(r) {
|
|
141
|
+
const n = r.getAttribute("style") || "", e = b(n, "width", 600), o = b(n, "padding", 0) * 2, i = Math.max(0, e - o);
|
|
143
142
|
i !== 0 && r.querySelectorAll("img.adapt-img").forEach((c) => {
|
|
144
143
|
if (c.hasAttribute("width"))
|
|
145
144
|
return;
|
|
146
|
-
const t =
|
|
145
|
+
const t = T(c, r);
|
|
147
146
|
if (!t)
|
|
148
147
|
return;
|
|
149
|
-
const s = t.getAttribute("width"), a = parseFloat(s), u =
|
|
148
|
+
const s = t.getAttribute("width"), a = parseFloat(s), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(i * a / 100), l = Math.max(1, p - u);
|
|
150
149
|
c.setAttribute("width", String(l));
|
|
151
|
-
const
|
|
152
|
-
if (!/\bwidth\s*:\s*\d/i.test(
|
|
153
|
-
const
|
|
154
|
-
c.setAttribute("style", `${
|
|
150
|
+
const d = c.getAttribute("style") || "";
|
|
151
|
+
if (!/\bwidth\s*:\s*\d/i.test(d)) {
|
|
152
|
+
const m = d && !d.trim().endsWith(";") ? "; " : "";
|
|
153
|
+
c.setAttribute("style", `${d}${m}width: ${l}px`);
|
|
155
154
|
}
|
|
156
155
|
});
|
|
157
156
|
}
|
|
158
|
-
function
|
|
157
|
+
function O(r, n) {
|
|
159
158
|
const e = r.match(/<!DOCTYPE[^>]*>/i);
|
|
160
159
|
return (e ? `${e[0]}
|
|
161
160
|
` : "") + n.documentElement.outerHTML;
|
|
162
161
|
}
|
|
163
|
-
function
|
|
162
|
+
function N(r) {
|
|
164
163
|
const n = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(n, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
165
164
|
if (!o.length)
|
|
166
165
|
return r;
|
|
@@ -168,12 +167,12 @@ function F(r) {
|
|
|
168
167
|
c.recommendationCampaignUrls = {};
|
|
169
168
|
const { isFeatureEnabled: t } = g(), s = t("liquidSyntax") ? "reco_" : "";
|
|
170
169
|
return o.forEach((u) => {
|
|
171
|
-
var l,
|
|
170
|
+
var l, d;
|
|
172
171
|
const p = u.getAttribute("recommendation-id");
|
|
173
|
-
p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (
|
|
174
|
-
}),
|
|
172
|
+
p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((m) => m.remove()), i(p), P(u, p, s), v(u));
|
|
173
|
+
}), O(n, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
175
174
|
}
|
|
176
175
|
export {
|
|
177
176
|
y as formatPriceVariable,
|
|
178
|
-
|
|
177
|
+
N as prepareRecommendationBlocks
|
|
179
178
|
};
|
|
@@ -1,49 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return e && e.length > 0 ? e : c;
|
|
1
|
+
const i = "You May Also Like!";
|
|
2
|
+
function s(r) {
|
|
3
|
+
var e;
|
|
4
|
+
const o = r.querySelector(".ext-recommendation-title");
|
|
5
|
+
if (!o)
|
|
6
|
+
return i;
|
|
7
|
+
const t = (e = o.textContent) == null ? void 0 : e.trim();
|
|
8
|
+
return t && t.length > 0 ? t : i;
|
|
10
9
|
}
|
|
11
|
-
function
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
...Array.from(
|
|
10
|
+
function u(r) {
|
|
11
|
+
const o = [
|
|
12
|
+
r,
|
|
13
|
+
...Array.from(r.querySelectorAll(".product-card, .ext-recommendation-card"))
|
|
15
14
|
];
|
|
16
|
-
let
|
|
17
|
-
return
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
return
|
|
21
|
-
const
|
|
22
|
-
return
|
|
23
|
-
}),
|
|
24
|
-
}
|
|
25
|
-
function l(t) {
|
|
26
|
-
const r = t.getAttribute(n.CURRENCY);
|
|
27
|
-
if (!r)
|
|
28
|
-
return;
|
|
29
|
-
const e = t.getAttribute(n.SYMBOL);
|
|
30
|
-
return {
|
|
31
|
-
value: r,
|
|
32
|
-
// An empty `currency-symbol` is omitted so `mapCurrency` falls back to
|
|
33
|
-
// the currency code as the symbol.
|
|
34
|
-
...e ? { symbol: e } : {},
|
|
35
|
-
alignment: t.getAttribute(n.ALIGNMENT) ?? "",
|
|
36
|
-
decimalCount: t.getAttribute(n.DECIMAL_COUNT) ?? "",
|
|
37
|
-
decimalSeparator: t.getAttribute(n.DECIMAL_SEPARATOR) ?? "",
|
|
38
|
-
thousandSeparator: t.getAttribute(n.THOUSAND_SEPARATOR) ?? ""
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
function d(t) {
|
|
42
|
-
return /\{\{[^}]+\}\}/.test(t.innerHTML);
|
|
15
|
+
let t = "";
|
|
16
|
+
return o.some((e) => {
|
|
17
|
+
const n = e.getAttribute("bgcolor");
|
|
18
|
+
if (n && n.trim())
|
|
19
|
+
return t = n.trim(), !0;
|
|
20
|
+
const c = (e.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
|
|
21
|
+
return c && c[1] ? (t = c[1].trim(), !0) : !1;
|
|
22
|
+
}), t;
|
|
43
23
|
}
|
|
44
24
|
export {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
A as extractTitleText,
|
|
48
|
-
d as isCustomizedBlock
|
|
25
|
+
u as extractCardBgColor,
|
|
26
|
+
s as extractTitleText
|
|
49
27
|
};
|