@useinsider/guido 3.4.0-beta.5d19726 → 3.4.1-beta.00eb92e
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/README.md +2 -0
- package/dist/composables/useActionsApi.js +9 -5
- package/dist/composables/useSave.js +13 -14
- package/dist/config/compiler/recommendationCompilerRules.js +31 -19
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +17 -16
- package/dist/config/migrator/checkboxMigrator.js +20 -69
- package/dist/config/migrator/itemsBlockMigrator.js +28 -18
- package/dist/config/migrator/radioButtonMigrator.js +36 -91
- package/dist/config/migrator/recommendation/htmlBuilder.js +73 -73
- package/dist/config/migrator/textBlockMigration.js +65 -0
- package/dist/extensions/Blocks/Recommendation/block.js +9 -6
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +12 -11
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +23 -23
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +22 -22
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +3 -3
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +9 -9
- package/dist/src/composables/useActionsApi.d.ts +1 -1
- package/dist/src/config/migrator/textBlockMigration.d.ts +24 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +6 -0
- package/dist/src/stores/config.test.d.ts +1 -0
- package/dist/src/vitest.setup.d.ts +0 -0
- package/dist/static/styles/components/wide-panel.css.js +5 -0
- package/dist/stores/config.js +24 -23
- package/dist/utils/templatePreparation.js +51 -43
- package/package.json +3 -2
- /package/dist/src/extensions/Blocks/Recommendation/{validation/requiredFields.test.d.ts → utils/filterUtil.test.d.ts} +0 -0
|
@@ -1,109 +1,54 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
var q = Object.defineProperty;
|
|
2
|
+
var C = (o, t, e) => t in o ? q(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
|
|
3
|
+
var g = (o, t, e) => C(o, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import N from "../../extensions/Blocks/RadioButton/template.js";
|
|
5
|
+
import { extractTextFromElement as b, buildTextBlock as f } from "./textBlockMigration.js";
|
|
6
|
+
class R {
|
|
6
7
|
constructor() {
|
|
7
|
-
|
|
8
|
+
g(this, "parser");
|
|
8
9
|
this.parser = new DOMParser();
|
|
9
10
|
}
|
|
10
|
-
migrate(
|
|
11
|
+
migrate(t) {
|
|
11
12
|
try {
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
14
|
-
return
|
|
15
|
-
let
|
|
16
|
-
return
|
|
13
|
+
const e = this.parser.parseFromString(t, "text/html"), n = e.querySelectorAll("td.radio-button-block"), a = e.querySelectorAll("td.radio-button-v2");
|
|
14
|
+
if (n.length === 0 && a.length === 0)
|
|
15
|
+
return t;
|
|
16
|
+
let i = !1;
|
|
17
|
+
return n.forEach((r) => {
|
|
17
18
|
if (r.classList.contains("radio-button-v2"))
|
|
18
19
|
return;
|
|
19
|
-
const
|
|
20
|
-
`<table id="tempDoc"><tbody><tr>${
|
|
20
|
+
const s = r.getAttribute("id"), c = b(r, "ins-title"), d = b(r, "ins-description"), u = b(r, "ins-subscribe"), l = b(r, "ins-unsubscribe"), p = f(c, c.containerClass), m = f(d, d.containerClass), h = f(u), S = f(l), T = N.replace("{-{-TITLE-}-}", p).replace("{-{-DESCRIPTION-}-}", m).replace("{-{-YES-}-}", h).replace("{-{-NO-}-}", S), y = this.parser.parseFromString(
|
|
21
|
+
`<table id="tempDoc"><tbody><tr>${T}</tr></tbody></table>`,
|
|
21
22
|
"text/html"
|
|
22
23
|
).querySelector(".radio-button-v2");
|
|
23
|
-
|
|
24
|
-
}),
|
|
25
|
-
} catch (
|
|
26
|
-
return console.error("RadioButtonMigrator failed:",
|
|
24
|
+
y && r.parentNode && (y.setAttribute("id", s || ""), r.parentNode.replaceChild(y, r), i = !0);
|
|
25
|
+
}), i = this.healRadioButtonV2(e) || i, i ? e.documentElement.outerHTML : t;
|
|
26
|
+
} catch (e) {
|
|
27
|
+
return console.error("RadioButtonMigrator failed:", e), t;
|
|
27
28
|
}
|
|
28
29
|
}
|
|
29
|
-
healRadioButtonV2(
|
|
30
|
-
let
|
|
31
|
-
return
|
|
32
|
-
var
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
if (!
|
|
30
|
+
healRadioButtonV2(t) {
|
|
31
|
+
let e = !1;
|
|
32
|
+
return t.querySelectorAll("td.radio-button-v2").forEach((n) => {
|
|
33
|
+
var m;
|
|
34
|
+
n.classList.contains("radio-button-block") || (n.classList.add("radio-button-block"), e = !0);
|
|
35
|
+
const a = n.querySelector("input#radioYes"), i = n.querySelector("input#radioNo");
|
|
36
|
+
if (!a || !i)
|
|
36
37
|
return;
|
|
37
|
-
const r = ((
|
|
38
|
-
if (!r && !
|
|
38
|
+
const r = ((m = a.parentElement) == null ? void 0 : m.querySelector(":scope > p")) || null;
|
|
39
|
+
if (!r && !a.hasAttribute("align"))
|
|
39
40
|
return;
|
|
40
|
-
const
|
|
41
|
-
if (!
|
|
41
|
+
const s = a.closest("tr"), c = i.closest("tr");
|
|
42
|
+
if (!s || !c || s === c || !s.parentNode)
|
|
42
43
|
return;
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
}),
|
|
46
|
-
}
|
|
47
|
-
extractTextFromElement(e, t) {
|
|
48
|
-
var d, y;
|
|
49
|
-
const s = e.querySelector(`.${t}`);
|
|
50
|
-
if (!s)
|
|
51
|
-
return {
|
|
52
|
-
text: t === "ins-title" ? "Title" : "Description",
|
|
53
|
-
isBold: !1,
|
|
54
|
-
isItalic: !1,
|
|
55
|
-
align: "left",
|
|
56
|
-
styles: "",
|
|
57
|
-
classList: ""
|
|
58
|
-
};
|
|
59
|
-
const i = s.querySelector("p");
|
|
60
|
-
if (!i)
|
|
61
|
-
return {
|
|
62
|
-
text: ((d = s.textContent) == null ? void 0 : d.trim()) || (t === "ins-title" ? "Title" : "Description"),
|
|
63
|
-
isBold: !1,
|
|
64
|
-
isItalic: !1,
|
|
65
|
-
align: s.getAttribute("align") || "left",
|
|
66
|
-
styles: "",
|
|
67
|
-
classList: ""
|
|
68
|
-
};
|
|
69
|
-
const o = ((y = i.textContent) == null ? void 0 : y.trim()) || (t === "ins-title" ? "Title" : "Description"), r = i.getAttribute("style") || "", n = s.getAttribute("align") || i.getAttribute("align") || "left", a = /font-weight\s*:\s*bold/i.test(r) || !!i.querySelector("b, strong"), g = /font-style\s*:\s*italic/i.test(r) || !!i.querySelector("i, em"), c = this.removeStyleProperties(r, ["font-weight", "font-style"]), u = this.convertInlineToBlock(c), p = s.getAttribute("class") || "";
|
|
70
|
-
return {
|
|
71
|
-
text: o,
|
|
72
|
-
isBold: a,
|
|
73
|
-
isItalic: g,
|
|
74
|
-
align: n,
|
|
75
|
-
styles: u,
|
|
76
|
-
classList: p
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
buildTextBlock(e) {
|
|
80
|
-
let t = e.text;
|
|
81
|
-
e.isBold && e.isItalic ? t = `<strong path="1,0"><em path="1,0,0">${t}</em></strong>` : e.isBold ? t = `<strong path="1,0">${t}</strong>` : e.isItalic && (t = `<em path="1,0">${t}</em>`);
|
|
82
|
-
const s = e.align ? ` align="${e.align}"` : "", i = e.styles ? ` style="${e.styles.replaceAll('"', "'")}"` : "";
|
|
83
|
-
return `
|
|
84
|
-
<td class="esd-block-text ${e.classList}" ${s}>
|
|
85
|
-
<p path="1" ${i}>
|
|
86
|
-
${t}
|
|
87
|
-
</p>
|
|
88
|
-
</td>
|
|
89
|
-
`;
|
|
90
|
-
}
|
|
91
|
-
removeStyleProperties(e, t) {
|
|
92
|
-
return e ? t.reduce((i, o) => {
|
|
93
|
-
const r = new RegExp(`${o}\\s*:\\s*[^;]*;?`, "gi");
|
|
94
|
-
return i.replace(r, "");
|
|
95
|
-
}, e).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
|
|
96
|
-
}
|
|
97
|
-
convertInlineToBlock(e) {
|
|
98
|
-
if (!e)
|
|
99
|
-
return "";
|
|
100
|
-
let t = e.replace(/display\s*:\s*inline/gi, "display: block");
|
|
101
|
-
return /display\s*:/i.test(t) || (t = t ? `${t}; display: block` : "display: block"), t.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
|
|
44
|
+
const d = (r == null ? void 0 : r.innerHTML.trim()) || "Yes", u = c.cloneNode(!0), l = u.querySelector("input#radioNo"), p = u.querySelector("p");
|
|
45
|
+
l && (l.setAttribute("id", "radioYes"), l.removeAttribute("align")), p && (p.innerHTML = d), s.parentNode.replaceChild(u, s), e = !0;
|
|
46
|
+
}), e;
|
|
102
47
|
}
|
|
103
48
|
}
|
|
104
|
-
function
|
|
105
|
-
return new
|
|
49
|
+
function w(o) {
|
|
50
|
+
return new R().migrate(o);
|
|
106
51
|
}
|
|
107
52
|
export {
|
|
108
|
-
|
|
53
|
+
w as migrateRadioButton
|
|
109
54
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { RecommendationBlockId as g } from "../../../extensions/Blocks/Recommendation/constants/blockIds.js";
|
|
2
|
-
import { CURRENCY_ATTR as R, ATTR_PRODUCT_IMAGE as I, ATTR_PRODUCT_BUTTON as
|
|
3
|
-
import { formatPrice as
|
|
2
|
+
import { CURRENCY_ATTR as R, ATTR_PRODUCT_IMAGE as I, ATTR_PRODUCT_BUTTON as N, CSS_CLASS_RECO_BUTTON as z, ATTR_PRODUCT_NAME as G, ATTR_PRODUCT_PRICE as H, ATTR_PRODUCT_OLD_PRICE as j, ATTR_PRODUCT_OMNIBUS_PRICE as U, ATTR_PRODUCT_OMNIBUS_DISCOUNT as V, ATTR_CUSTOM_PREFIX as E } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
3
|
+
import { formatPrice as v } from "../../../extensions/Blocks/Recommendation/utils/priceFormatter.js";
|
|
4
4
|
import { escapeHtml as c } from "../../../utils/htmlEscape.js";
|
|
5
5
|
import { appendStyle as $ } from "./themeMapper.js";
|
|
6
|
-
const
|
|
7
|
-
function
|
|
6
|
+
const Y = "https://email-static.useinsider.com/stripo/modules/email-recommendation-v3/assets/images/image-placeholder.png", F = "attribute-cell", J = "Buy", X = "border-width: 1px; background: rgb(217, 234, 211); border-color: rgb(106, 168, 79)", K = "color: rgb(56, 118, 29); background: rgb(217, 234, 211); font-family: arial, 'helvetica neue', helvetica, sans-serif; font-size: 16px; font-weight: normal; line-height: 120%; mso-border-alt: 10px solid rgb(217, 234, 211); mso-padding-alt: 0", ot = "ins-recommendation-product-container ins-recommendation-desktop-container";
|
|
7
|
+
function nt(t) {
|
|
8
8
|
return t.replace(/>\s+</g, "><").trim();
|
|
9
9
|
}
|
|
10
10
|
function y(t) {
|
|
@@ -19,10 +19,10 @@ function _() {
|
|
|
19
19
|
textTrimming: !1
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
|
-
function
|
|
22
|
+
function q(t) {
|
|
23
23
|
return t ? { ...t, wrapBold: !0 } : { ..._(), wrapBold: !0 };
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function k(t, o) {
|
|
26
26
|
let e = c(t);
|
|
27
27
|
return o.wrapBold && o.wrapItalic ? e = `<strong><em>${e}</em></strong>` : o.wrapBold ? e = `<strong>${e}</strong>` : o.wrapItalic && (e = `<em>${e}</em>`), e;
|
|
28
28
|
}
|
|
@@ -30,9 +30,9 @@ function b(t) {
|
|
|
30
30
|
return t ? ` style="${c(t)}"` : "";
|
|
31
31
|
}
|
|
32
32
|
function O(t, o) {
|
|
33
|
-
return `<td width="${t}%" class="${
|
|
33
|
+
return `<td width="${t}%" class="${F}" ${o}`;
|
|
34
34
|
}
|
|
35
|
-
function
|
|
35
|
+
function lt(t, o, e, l) {
|
|
36
36
|
const s = t.width ? ` width="${t.width}"` : "", n = t.height ? ` height="${t.height}"` : "", i = ["display: block", "max-width: 100%", "height: auto"];
|
|
37
37
|
t.width && i.push(`width: ${t.width}px`), t.height && i.push(`height: ${t.height}px`);
|
|
38
38
|
const a = i.join("; "), r = e ? ` style="background-color: ${c(e)}"` : "";
|
|
@@ -46,7 +46,7 @@ function nt(t, o, e, l) {
|
|
|
46
46
|
class="esd-block-image product-image es-p5"
|
|
47
47
|
esd-extension-block-id="${g.IMAGE}">
|
|
48
48
|
<a target="_blank" href="https://example.com/product/${o + 1}">
|
|
49
|
-
<img src="${
|
|
49
|
+
<img src="${Y}" alt="Product Name"
|
|
50
50
|
class="adapt-img"${s}${n}
|
|
51
51
|
style="${a}">
|
|
52
52
|
</a>
|
|
@@ -57,7 +57,7 @@ function nt(t, o, e, l) {
|
|
|
57
57
|
</td>
|
|
58
58
|
`;
|
|
59
59
|
}
|
|
60
|
-
function
|
|
60
|
+
function L(t, o, e, l, s, n, i) {
|
|
61
61
|
const r = `table-layout: fixed${n ? `; background-color: ${c(n)}` : ""}`, d = b(s.tdStyle), p = y(s.align), u = `esd-block-text ${o}`.trim(), m = $(l, s.pStyle);
|
|
62
62
|
return `
|
|
63
63
|
${O(i, 'valign="top" style="padding: 0 5px; height: 100%"')}>
|
|
@@ -68,7 +68,7 @@ function D(t, o, e, l, s, n, i) {
|
|
|
68
68
|
<td${p}
|
|
69
69
|
class="${u}"
|
|
70
70
|
esd-extension-block-id="${t}"${d}>
|
|
71
|
-
<p contenteditable="false"${b(m)}>${
|
|
71
|
+
<p contenteditable="false"${b(m)}>${k(e, s)}</p>
|
|
72
72
|
</td>
|
|
73
73
|
</tr>
|
|
74
74
|
</tbody>
|
|
@@ -76,7 +76,7 @@ function D(t, o, e, l, s, n, i) {
|
|
|
76
76
|
</td>
|
|
77
77
|
`;
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function st(t, o, e, l) {
|
|
80
80
|
const s = o ? ` style="background-color: ${c(o)}"` : "", n = b(t.tdStyle), i = y(t.align), r = $("font-size: 14px; color: #999999", t.pStyle);
|
|
81
81
|
return `
|
|
82
82
|
${O(e, 'valign="top" style="padding: 0 5px; height: 100%"')}>
|
|
@@ -88,7 +88,7 @@ function lt(t, o, e, l) {
|
|
|
88
88
|
class="esd-block-text product-old-price es-p15l es-p15r"
|
|
89
89
|
esd-extension-block-id="${g.OLD_PRICE}"${n}>
|
|
90
90
|
<p contenteditable="false"${b(r)}>
|
|
91
|
-
<s>${
|
|
91
|
+
<s>${k(l, t)}</s>
|
|
92
92
|
</p>
|
|
93
93
|
</td>
|
|
94
94
|
</tr>
|
|
@@ -97,7 +97,7 @@ function lt(t, o, e, l) {
|
|
|
97
97
|
</td>
|
|
98
98
|
`;
|
|
99
99
|
}
|
|
100
|
-
function
|
|
100
|
+
function D(t, o, e, l, s, n, i) {
|
|
101
101
|
const a = s ? `; background-color: ${c(s)}` : "", r = b(l.tdStyle), d = y(l.align), u = $("font-size: 12px; color: #666666", l.pStyle);
|
|
102
102
|
return `
|
|
103
103
|
${O(i, 'valign="top" style="padding: 0 5px; height: 100%"')}>
|
|
@@ -121,8 +121,8 @@ function L(t, o, e, l, s, n, i) {
|
|
|
121
121
|
</td>
|
|
122
122
|
`;
|
|
123
123
|
}
|
|
124
|
-
function
|
|
125
|
-
const s = e ? ` style="background-color: ${c(e)}"` : "", n = $("padding: 0 5px; height: 100%", o.tdStyle), i = y(o.align), a = o.text ||
|
|
124
|
+
function it(t, o, e, l) {
|
|
125
|
+
const s = e ? ` style="background-color: ${c(e)}"` : "", n = $("padding: 0 5px; height: 100%", o.tdStyle), i = y(o.align), a = o.text || J, r = $(X, o.spanStyle), d = $(K, o.aStyle);
|
|
126
126
|
return `
|
|
127
127
|
${O(l, `valign="top" style="${c(n)}"`)}>
|
|
128
128
|
<table width="100%" height="100%" cellpadding="0" cellspacing="0" border="0"
|
|
@@ -134,7 +134,7 @@ function st(t, o, e, l) {
|
|
|
134
134
|
esd-extension-block-id="${g.BUTTON}">
|
|
135
135
|
<span class="es-button-border" style="${c(r)}">
|
|
136
136
|
<a href="https://example.com/product/${t + 1}" target="_blank"
|
|
137
|
-
class="es-button
|
|
137
|
+
class="es-button ${z}"
|
|
138
138
|
style="${c(d)}">${c(a)}</a>
|
|
139
139
|
</span>
|
|
140
140
|
</td>
|
|
@@ -144,7 +144,7 @@ function st(t, o, e, l) {
|
|
|
144
144
|
</td>
|
|
145
145
|
`;
|
|
146
146
|
}
|
|
147
|
-
function
|
|
147
|
+
function ct(t, o, e, l, s) {
|
|
148
148
|
const n = l ? `; background-color: ${c(l)}` : "", i = b(e.tdStyle), a = y(e.align), d = $("font-size: 12px; color: #666666; margin: 0", e.pStyle), p = o.replace(/_/g, " ").replace(/\b\w/g, (u) => u.toUpperCase());
|
|
149
149
|
return `
|
|
150
150
|
${O(s, 'valign="middle" style="padding: 0 5px; height: 100%"')}>
|
|
@@ -163,18 +163,18 @@ function it(t, o, e, l, s) {
|
|
|
163
163
|
</td>
|
|
164
164
|
`;
|
|
165
165
|
}
|
|
166
|
-
function
|
|
166
|
+
function at(t, o, e, l, s, n, i) {
|
|
167
167
|
const a = o[t], r = a ?? _();
|
|
168
168
|
switch (t) {
|
|
169
169
|
case I:
|
|
170
|
-
return
|
|
170
|
+
return lt(
|
|
171
171
|
a ?? {},
|
|
172
172
|
s,
|
|
173
173
|
l,
|
|
174
174
|
n
|
|
175
175
|
);
|
|
176
|
-
case
|
|
177
|
-
return
|
|
176
|
+
case G:
|
|
177
|
+
return L(
|
|
178
178
|
g.NAME,
|
|
179
179
|
"product-name es-p10t es-p10b es-p15l es-p15r",
|
|
180
180
|
"Product Name",
|
|
@@ -183,20 +183,20 @@ function ct(t, o, e, l, s, n, i) {
|
|
|
183
183
|
l,
|
|
184
184
|
n
|
|
185
185
|
);
|
|
186
|
-
case
|
|
187
|
-
return
|
|
186
|
+
case H:
|
|
187
|
+
return L(
|
|
188
188
|
g.PRICE,
|
|
189
189
|
"product-price es-p15l es-p15r",
|
|
190
190
|
i.pricePlaceholder,
|
|
191
191
|
"font-size: 16px; color: #333333",
|
|
192
|
-
|
|
192
|
+
q(a),
|
|
193
193
|
l,
|
|
194
194
|
n
|
|
195
195
|
);
|
|
196
|
-
case
|
|
197
|
-
return
|
|
196
|
+
case j:
|
|
197
|
+
return st(r, l, n, i.oldPricePlaceholder);
|
|
198
198
|
case U:
|
|
199
|
-
return
|
|
199
|
+
return D(
|
|
200
200
|
g.OMNIBUS_PRICE,
|
|
201
201
|
"omnibus-price-value",
|
|
202
202
|
i.omnibusPricePlaceholder,
|
|
@@ -205,8 +205,8 @@ function ct(t, o, e, l, s, n, i) {
|
|
|
205
205
|
"product-omnibus-price",
|
|
206
206
|
n
|
|
207
207
|
);
|
|
208
|
-
case
|
|
209
|
-
return
|
|
208
|
+
case V:
|
|
209
|
+
return D(
|
|
210
210
|
g.OMNIBUS_DISCOUNT,
|
|
211
211
|
"omnibus-discount-value",
|
|
212
212
|
"-10%",
|
|
@@ -215,8 +215,8 @@ function ct(t, o, e, l, s, n, i) {
|
|
|
215
215
|
"product-omnibus-discount",
|
|
216
216
|
n
|
|
217
217
|
);
|
|
218
|
-
case
|
|
219
|
-
return
|
|
218
|
+
case N:
|
|
219
|
+
return it(
|
|
220
220
|
s,
|
|
221
221
|
a ?? {},
|
|
222
222
|
l,
|
|
@@ -225,25 +225,25 @@ function ct(t, o, e, l, s, n, i) {
|
|
|
225
225
|
default:
|
|
226
226
|
if (t.startsWith(E)) {
|
|
227
227
|
const d = e[t] ?? t.slice(E.length), p = t.slice(E.length);
|
|
228
|
-
return
|
|
228
|
+
return ct(d, p, r, l, n);
|
|
229
229
|
}
|
|
230
230
|
return null;
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
-
const
|
|
233
|
+
const Q = `
|
|
234
234
|
<tr>
|
|
235
235
|
<td class="spacer" style="height: 10px"></td>
|
|
236
236
|
</tr>
|
|
237
237
|
`;
|
|
238
|
-
function
|
|
238
|
+
function rt(t) {
|
|
239
239
|
return {
|
|
240
|
-
pricePlaceholder:
|
|
241
|
-
oldPricePlaceholder:
|
|
242
|
-
omnibusPricePlaceholder:
|
|
240
|
+
pricePlaceholder: v({ price: 18, currency: t }),
|
|
241
|
+
oldPricePlaceholder: v({ price: 20, currency: t }),
|
|
242
|
+
omnibusPricePlaceholder: v({ price: 20, currency: t })
|
|
243
243
|
};
|
|
244
244
|
}
|
|
245
|
-
function
|
|
246
|
-
const { composition: s, visibility: n, perElement: i, customAttrValues: a, cardBg: r } = l, d = (100 / e).toFixed(2), p = e - o, u = `<td class="${
|
|
245
|
+
function dt(t, o, e, l) {
|
|
246
|
+
const { composition: s, visibility: n, perElement: i, customAttrValues: a, cardBg: r } = l, d = (100 / e).toFixed(2), p = e - o, u = `<td class="${F}" style="padding: 0 5px;" width="${d}%"></td>`, m = p > 0 ? u.repeat(p) : "";
|
|
247
247
|
return `
|
|
248
248
|
<tr class="recommendation-product-row">
|
|
249
249
|
<td>
|
|
@@ -252,7 +252,7 @@ function rt(t, o, e, l) {
|
|
|
252
252
|
<tbody>${s.map((T) => {
|
|
253
253
|
const w = n[T] !== !1, f = w ? "" : ' style="display: none"', C = w ? "1" : "0", S = [];
|
|
254
254
|
for (let x = 0; x < o; x += 1) {
|
|
255
|
-
const A =
|
|
255
|
+
const A = at(
|
|
256
256
|
T,
|
|
257
257
|
i,
|
|
258
258
|
a,
|
|
@@ -276,44 +276,44 @@ function rt(t, o, e, l) {
|
|
|
276
276
|
</tr>
|
|
277
277
|
`;
|
|
278
278
|
}
|
|
279
|
-
function
|
|
279
|
+
function pt(t, o, e) {
|
|
280
280
|
const l = [];
|
|
281
281
|
for (let s = 0; s < t; s += o) {
|
|
282
282
|
const n = Math.min(o, t - s);
|
|
283
|
-
s > 0 && l.push(
|
|
283
|
+
s > 0 && l.push(Q), l.push(dt(s, n, o, e));
|
|
284
284
|
}
|
|
285
285
|
return l.join("");
|
|
286
286
|
}
|
|
287
|
-
function
|
|
287
|
+
function ut(t, o, e, l) {
|
|
288
288
|
const s = o[t];
|
|
289
|
-
if (t ===
|
|
289
|
+
if (t === G) {
|
|
290
290
|
const n = s ?? _(), i = $("font-size: 16px; color: #333333; margin: 0", n.pStyle), a = y(n.align ?? "left");
|
|
291
291
|
return `
|
|
292
292
|
<td class="esd-block-text product-name"
|
|
293
293
|
esd-extension-block-id="${g.NAME}"${a}${b(n.tdStyle)}>
|
|
294
|
-
<p contenteditable="false"${b(i)}>${
|
|
294
|
+
<p contenteditable="false"${b(i)}>${k("Product Name", n)}</p>
|
|
295
295
|
</td>
|
|
296
296
|
`;
|
|
297
297
|
}
|
|
298
|
-
if (t ===
|
|
299
|
-
const n =
|
|
298
|
+
if (t === H) {
|
|
299
|
+
const n = q(s), i = $("font-size: 16px; color: #333333; margin: 0", n.pStyle), a = y(n.align ?? "left");
|
|
300
300
|
return `
|
|
301
301
|
<td class="esd-block-text product-price"
|
|
302
302
|
esd-extension-block-id="${g.PRICE}"${a}${b(n.tdStyle)}>
|
|
303
|
-
<p contenteditable="false"${b(i)}>${
|
|
303
|
+
<p contenteditable="false"${b(i)}>${k(l.pricePlaceholder, n)}</p>
|
|
304
304
|
</td>
|
|
305
305
|
`;
|
|
306
306
|
}
|
|
307
|
-
if (t ===
|
|
307
|
+
if (t === j) {
|
|
308
308
|
const n = s ?? _(), a = $("font-size: 14px; color: #999999; text-decoration: line-through; margin: 0", n.pStyle), r = y(n.align ?? "left");
|
|
309
309
|
return `
|
|
310
310
|
<td class="esd-block-text product-old-price"
|
|
311
311
|
esd-extension-block-id="${g.OLD_PRICE}"${r}${b(n.tdStyle)}>
|
|
312
|
-
<p contenteditable="false"${b(a)}><s>${
|
|
312
|
+
<p contenteditable="false"${b(a)}><s>${k(l.oldPricePlaceholder, n)}</s></p>
|
|
313
313
|
</td>
|
|
314
314
|
`;
|
|
315
315
|
}
|
|
316
|
-
if (t === U || t ===
|
|
316
|
+
if (t === U || t === V) {
|
|
317
317
|
const n = t === U, i = n ? g.OMNIBUS_PRICE : g.OMNIBUS_DISCOUNT, a = n ? "omnibus-price-value" : "omnibus-discount-value", r = n ? l.omnibusPricePlaceholder : "-10%", d = n ? "product-omnibus-price" : "product-omnibus-discount", p = s ?? _(), u = $("font-size: 12px; color: #666666; margin: 0", p.pStyle), m = y(p.align ?? "left");
|
|
318
318
|
return `
|
|
319
319
|
<td class="esd-block-text ${d}"
|
|
@@ -339,7 +339,7 @@ function pt(t, o, e, l) {
|
|
|
339
339
|
}
|
|
340
340
|
return null;
|
|
341
341
|
}
|
|
342
|
-
function
|
|
342
|
+
function bt(t, o) {
|
|
343
343
|
const { composition: e, visibility: l, perElement: s, customAttrValues: n, cardBg: i } = o, a = i ? `background-color: ${c(i)}` : "", r = a ? `style="table-layout: fixed; ${a}"` : 'style="table-layout: fixed"', d = s[I] ?? {}, p = l[I] !== !1, u = d.width ? ` width="${d.width}"` : "", m = p ? "" : ' style="display: none"', h = `
|
|
344
344
|
<td width="120"
|
|
345
345
|
class="esd-block-image product-image-cell recommendation-attribute-row es-p5"
|
|
@@ -348,7 +348,7 @@ function ut(t, o) {
|
|
|
348
348
|
data-visibility="${p ? "1" : "0"}"
|
|
349
349
|
align="center" valign="middle"${m}>
|
|
350
350
|
<a target="_blank" href="https://example.com/product/${t + 1}">
|
|
351
|
-
<img src="${
|
|
351
|
+
<img src="${Y}" alt="Product Name"
|
|
352
352
|
class="adapt-img product-image"${u}
|
|
353
353
|
style="display: block; max-width: 100%; height: auto">
|
|
354
354
|
</a>
|
|
@@ -357,25 +357,25 @@ function ut(t, o) {
|
|
|
357
357
|
<td class="product-info-cell" valign="middle" style="padding: 15px">
|
|
358
358
|
<table cellpadding="0" cellspacing="0" role="presentation" width="100%"
|
|
359
359
|
style="table-layout: fixed">
|
|
360
|
-
<tbody>${e.filter((P) => P !== I && P !==
|
|
361
|
-
const B = l[P] !== !1,
|
|
360
|
+
<tbody>${e.filter((P) => P !== I && P !== N).map((P) => {
|
|
361
|
+
const B = l[P] !== !1, tt = B ? "" : ' style="display: none"', et = B ? "1" : "0", M = ut(P, s, n, o);
|
|
362
362
|
return M ? `<tr class="recommendation-attribute-row"
|
|
363
363
|
data-attribute-type="${c(P)}"
|
|
364
|
-
data-visibility="${
|
|
364
|
+
data-visibility="${et}"${tt}>${M}</tr>` : "";
|
|
365
365
|
}).filter(Boolean).join(`
|
|
366
366
|
`)}</tbody>
|
|
367
367
|
</table>
|
|
368
368
|
</td>
|
|
369
|
-
`, f = s[
|
|
369
|
+
`, f = s[N] ?? {}, C = l[N] !== !1, S = f.text || J, x = $(X, f.spanStyle ?? ""), A = $(K, f.aStyle ?? ""), Z = C ? "" : ' style="display: none"', W = `
|
|
370
370
|
<td width="100"
|
|
371
371
|
class="esd-block-button button-cell recommendation-attribute-row product-button es-p5l es-p5r"
|
|
372
372
|
esd-extension-block-id="${g.BUTTON}"
|
|
373
|
-
data-attribute-type="${
|
|
373
|
+
data-attribute-type="${N}"
|
|
374
374
|
data-visibility="${C ? "1" : "0"}"
|
|
375
|
-
align="${c(f.align ?? "center")}" valign="middle"${
|
|
375
|
+
align="${c(f.align ?? "center")}" valign="middle"${Z}>
|
|
376
376
|
<span class="es-button-border" style="${c(x)}">
|
|
377
377
|
<a href="https://example.com/product/${t + 1}" target="_blank"
|
|
378
|
-
class="es-button
|
|
378
|
+
class="es-button ${z}"
|
|
379
379
|
style="${c(A)}">${c(S)}</a>
|
|
380
380
|
</span>
|
|
381
381
|
</td>
|
|
@@ -386,20 +386,20 @@ function ut(t, o) {
|
|
|
386
386
|
<table width="100%" cellpadding="0" cellspacing="0" border="0"
|
|
387
387
|
class="product-card-wrapper" ${r}>
|
|
388
388
|
<tbody>
|
|
389
|
-
<tr>${h}${w}${
|
|
389
|
+
<tr>${h}${w}${W}</tr>
|
|
390
390
|
</tbody>
|
|
391
391
|
</table>
|
|
392
392
|
</td>
|
|
393
393
|
</tr>
|
|
394
394
|
`;
|
|
395
395
|
}
|
|
396
|
-
function
|
|
396
|
+
function gt(t, o) {
|
|
397
397
|
const e = [];
|
|
398
398
|
for (let l = 0; l < t; l += 1)
|
|
399
|
-
l > 0 && e.push(
|
|
399
|
+
l > 0 && e.push(Q), e.push(bt(l, o));
|
|
400
400
|
return e.join("");
|
|
401
401
|
}
|
|
402
|
-
function
|
|
402
|
+
function mt(t, o) {
|
|
403
403
|
var r, d, p, u, m, h;
|
|
404
404
|
const e = t == null ? void 0 : t.theme, l = [];
|
|
405
405
|
(r = e == null ? void 0 : e.textStyle) != null && r["font-family"] && l.push(`font-family: ${e.textStyle["font-family"]}`), l.push(`font-size: ${((d = e == null ? void 0 : e.textStyle) == null ? void 0 : d["font-size"]) ?? "28px"}`), l.push(`color: ${((p = e == null ? void 0 : e.textColor) == null ? void 0 : p.color) ?? "#333333"}`), (u = e == null ? void 0 : e.textStyle) != null && u["font-weight"] && l.push(`font-weight: ${e.textStyle["font-weight"]}`), (m = e == null ? void 0 : e.textStyle) != null && m["font-style"] && l.push(`font-style: ${e.textStyle["font-style"]}`);
|
|
@@ -410,11 +410,11 @@ function gt(t, o) {
|
|
|
410
410
|
</td>
|
|
411
411
|
`;
|
|
412
412
|
}
|
|
413
|
-
function
|
|
413
|
+
function $t(t) {
|
|
414
414
|
const o = t.alignment === "before" ? "0" : "1";
|
|
415
415
|
return ` ${R.CURRENCY}="${c(t.code)}" ${R.SYMBOL}="${c(t.symbol)}" ${R.ALIGNMENT}="${o}" ${R.THOUSAND_SEPARATOR}="${c(t.thousandSeparator)}" ${R.DECIMAL_SEPARATOR}="${c(t.decimalSeparator)}" ${R.DECIMAL_COUNT}="${t.decimalCount}"`;
|
|
416
416
|
}
|
|
417
|
-
function
|
|
417
|
+
function Tt(t) {
|
|
418
418
|
const {
|
|
419
419
|
nodeConfig: o,
|
|
420
420
|
composition: e,
|
|
@@ -429,8 +429,8 @@ function xt(t) {
|
|
|
429
429
|
perElement: e.perElementStyles,
|
|
430
430
|
customAttrValues: e.customAttrValues,
|
|
431
431
|
cardBg: l,
|
|
432
|
-
...
|
|
433
|
-
}, m = o.layout === "list" ?
|
|
432
|
+
...rt(o.currency)
|
|
433
|
+
}, m = o.layout === "list" ? gt(r, u) : pt(r, o.cardsInRow, u), h = mt(e.titleVariable, s), T = e.composition.join(","), w = JSON.stringify(e.customAttributes), f = [
|
|
434
434
|
"recommendation-block-v2",
|
|
435
435
|
"esd-block-recommendation-v3-block",
|
|
436
436
|
`es-p20${p}`,
|
|
@@ -443,8 +443,8 @@ function xt(t) {
|
|
|
443
443
|
"esd-container-frame",
|
|
444
444
|
"ins-recommendation-no-mobile-layout",
|
|
445
445
|
n
|
|
446
|
-
].filter(Boolean).join(" "), C =
|
|
447
|
-
return
|
|
446
|
+
].filter(Boolean).join(" "), C = $t(o.currency), S = ` esd-ext-config="${c(JSON.stringify(o))}"`, x = i ? ` id="${c(i)}"` : "", A = a ? ` bgcolor="${c(a)}"` : "";
|
|
447
|
+
return nt(`
|
|
448
448
|
<td align="left"
|
|
449
449
|
esd-extension-block-id="recommendation-block"
|
|
450
450
|
width="520"
|
|
@@ -477,7 +477,7 @@ function xt(t) {
|
|
|
477
477
|
<tr>
|
|
478
478
|
<td>
|
|
479
479
|
<table width="100%" cellpadding="0" cellspacing="0" border="0"
|
|
480
|
-
class="${
|
|
480
|
+
class="${ot}">${m}
|
|
481
481
|
</table>
|
|
482
482
|
</td>
|
|
483
483
|
</tr>
|
|
@@ -492,5 +492,5 @@ function xt(t) {
|
|
|
492
492
|
`);
|
|
493
493
|
}
|
|
494
494
|
export {
|
|
495
|
-
|
|
495
|
+
Tt as buildBlockHtml
|
|
496
496
|
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
const I = {
|
|
2
|
+
"ins-title": "Title",
|
|
3
|
+
"ins-description": "Description",
|
|
4
|
+
"ins-subscribe": "Yes",
|
|
5
|
+
"ins-unsubscribe": "No"
|
|
6
|
+
}, y = /font-weight\s*:\s*[^;]*;?/gi, S = /font-style\s*:\s*[^;]*;?/gi, u = /;\s*;/g, T = /^;|;$/g, d = /display\s*:\s*inline/gi, m = /display\s*:/i, b = /font-weight\s*:\s*bold/i, A = /font-style\s*:\s*italic/i, R = /^<(?:strong|b)\b/i, $ = /^<(?:em|i)\b/i;
|
|
7
|
+
function L(t) {
|
|
8
|
+
return t ? t.replace(y, "").replace(S, "").replace(u, ";").replace(T, "").trim() : "";
|
|
9
|
+
}
|
|
10
|
+
function O(t) {
|
|
11
|
+
if (!t)
|
|
12
|
+
return "";
|
|
13
|
+
let e = t.replace(d, "display: block");
|
|
14
|
+
return m.test(e) || (e = e ? `${e}; display: block` : "display: block"), e.replace(u, ";").replace(T, "").trim();
|
|
15
|
+
}
|
|
16
|
+
function B(t, e) {
|
|
17
|
+
var c, a;
|
|
18
|
+
const o = I[e], l = t.querySelector(`.${e}`);
|
|
19
|
+
if (!l)
|
|
20
|
+
return {
|
|
21
|
+
paragraphs: [{ innerHtml: o, isBold: !1, isItalic: !1, styles: "" }],
|
|
22
|
+
align: "left",
|
|
23
|
+
containerClass: ""
|
|
24
|
+
};
|
|
25
|
+
const n = Array.from(l.querySelectorAll("p")), p = l.getAttribute("align") || ((c = n[0]) == null ? void 0 : c.getAttribute("align")) || "left", i = l.getAttribute("class") || "";
|
|
26
|
+
return n.length === 0 ? {
|
|
27
|
+
paragraphs: [{
|
|
28
|
+
innerHtml: ((a = l.textContent) == null ? void 0 : a.trim()) || o,
|
|
29
|
+
isBold: !1,
|
|
30
|
+
isItalic: !1,
|
|
31
|
+
styles: ""
|
|
32
|
+
}],
|
|
33
|
+
align: p,
|
|
34
|
+
containerClass: ""
|
|
35
|
+
} : { paragraphs: n.map((r) => {
|
|
36
|
+
const _ = r.getAttribute("style") || "", f = b.test(_) || !!r.querySelector("b, strong"), g = A.test(_) || !!r.querySelector("i, em"), E = L(_);
|
|
37
|
+
return {
|
|
38
|
+
// Legacy parity: empty <p> → fallback placeholder; <p><br></p> is not empty.
|
|
39
|
+
innerHtml: r.innerHTML.trim() || o,
|
|
40
|
+
isBold: f,
|
|
41
|
+
isItalic: g,
|
|
42
|
+
styles: O(E)
|
|
43
|
+
};
|
|
44
|
+
}), align: p, containerClass: i };
|
|
45
|
+
}
|
|
46
|
+
function C(t, e = "") {
|
|
47
|
+
const o = t.align ? ` align="${t.align}"` : "", l = t.paragraphs.map((n, p) => {
|
|
48
|
+
const i = p + 1;
|
|
49
|
+
let s = n.innerHtml;
|
|
50
|
+
const c = n.isBold && !R.test(s), a = n.isItalic && !$.test(s);
|
|
51
|
+
c && a ? s = `<strong path="${i},0"><em path="${i},0,0">${s}</em></strong>` : c ? s = `<strong path="${i},0">${s}</strong>` : a && (s = `<em path="${i},0">${s}</em>`);
|
|
52
|
+
const r = n.styles ? ` style="${n.styles.replaceAll('"', "'")}"` : "";
|
|
53
|
+
return `<p path="${i}"${r}>${s}</p>`;
|
|
54
|
+
}).join(`
|
|
55
|
+
`);
|
|
56
|
+
return `
|
|
57
|
+
<td class="esd-block-text ${e}" ${o}>
|
|
58
|
+
${l}
|
|
59
|
+
</td>
|
|
60
|
+
`;
|
|
61
|
+
}
|
|
62
|
+
export {
|
|
63
|
+
C as buildTextBlock,
|
|
64
|
+
B as extractTextFromElement
|
|
65
|
+
};
|