@useinsider/guido 3.8.0 → 3.8.1-beta.1a5be20
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/useHtmlValidator.js +180 -133
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +64 -69
- package/dist/config/compiler/utils/recommendationIgnoreUtils.js +15 -0
- package/dist/config/migrator/recommendation/extractors.js +44 -22
- package/dist/config/migrator/recommendation/htmlBuilder.js +175 -169
- package/dist/config/migrator/recommendationMigrator.js +30 -31
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +22 -15
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +55 -41
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +42 -43
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +48 -45
- package/dist/extensions/Blocks/Recommendation/controls/main/productCount.js +3 -2
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +64 -60
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +294 -335
- package/dist/extensions/Blocks/Recommendation/controls/syncInfoMessage.js +7 -6
- package/dist/extensions/Blocks/Recommendation/extension.js +7 -5
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +4 -2
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +3 -2
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +142 -173
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +56 -29
- package/dist/extensions/Blocks/Recommendation/templates/index.js +30 -8
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +132 -105
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +44 -23
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +112 -64
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +219 -0
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +24 -19
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +30 -22
- package/dist/extensions/Blocks/Unsubscribe/block.js +1 -1
- package/dist/extensions/Blocks/controlFactories.js +159 -133
- package/dist/src/composables/useHtmlValidator.d.ts +27 -0
- package/dist/src/composables/useHtmlValidator.test.d.ts +1 -0
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.d.ts +17 -0
- package/dist/src/config/compiler/utils/recommendationIgnoreUtils.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/extractors.d.ts +15 -0
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +8 -0
- package/dist/src/extensions/Blocks/Items/controls/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +23 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +7 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +7 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/productLayout.d.ts +6 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +29 -47
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -2
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +165 -11
- package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +78 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +29 -9
- package/dist/src/extensions/Blocks/controlFactories.d.ts +11 -1
- package/package.json +1 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +0 -113
|
@@ -1,66 +1,101 @@
|
|
|
1
|
-
import { ATTR_CUSTOM_PREFIX as
|
|
2
|
-
function y(t) {
|
|
3
|
-
return t.replace(/_/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
|
|
4
|
-
}
|
|
1
|
+
import { ATTR_CUSTOM_PREFIX as c, PRODUCT_ATTRIBUTE_PREFIX as l, ATTR_PRODUCT_IMAGE as b, ATTR_PRODUCT_NAME as T, ATTR_PRODUCT_OLD_PRICE as g, ATTR_PRODUCT_PRICE as _, ATTR_PRODUCT_OMNIBUS_PRICE as f, ATTR_PRODUCT_OMNIBUS_DISCOUNT as p, ATTR_PRODUCT_BUTTON as m } from "../constants/selectors.js";
|
|
5
2
|
function U(t) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
return t.replace(/_/g, " ").replace(/\b\w/g, (n) => n.toUpperCase());
|
|
4
|
+
}
|
|
5
|
+
function S(t) {
|
|
6
|
+
const n = Array.isArray(t) ? t[t.length - 1] : t;
|
|
7
|
+
if (typeof n == "string")
|
|
8
|
+
return n;
|
|
9
|
+
if (typeof n == "number")
|
|
10
|
+
return String(n);
|
|
11
|
+
}
|
|
12
|
+
function C(t, n) {
|
|
13
|
+
const e = Object.values(n).find((o) => o.attributeName === t);
|
|
14
|
+
return (e == null ? void 0 : e.type) === "defaultAttribute";
|
|
11
15
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
return (n == null ? void 0 : n.type) === "defaultAttribute";
|
|
16
|
+
function E(t, n) {
|
|
17
|
+
return C(t, n) ? t : `${l}${t}`;
|
|
15
18
|
}
|
|
16
|
-
function
|
|
17
|
-
|
|
19
|
+
function M(t) {
|
|
20
|
+
const n = t.startsWith(l) ? t.substring(l.length) : t;
|
|
21
|
+
return `${c}${n}`;
|
|
18
22
|
}
|
|
19
23
|
const P = Symbol("customCellHtml");
|
|
20
|
-
function
|
|
21
|
-
const
|
|
22
|
-
if (!
|
|
24
|
+
function k(t, n, e = {}) {
|
|
25
|
+
const o = t[P];
|
|
26
|
+
if (!o)
|
|
23
27
|
return { ...t };
|
|
24
|
-
const
|
|
25
|
-
return
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
var
|
|
29
|
-
const D = R ?
|
|
30
|
-
return
|
|
28
|
+
const s = { ...t };
|
|
29
|
+
return n.filter((r) => r.startsWith(c) && !s[r]).forEach((r) => {
|
|
30
|
+
const i = r.substring(c.length), a = U(i), y = E(i, e), R = C(i, e);
|
|
31
|
+
s[r] = (d, A) => {
|
|
32
|
+
var u;
|
|
33
|
+
const D = R ? d[i] : (u = d.product_attributes) == null ? void 0 : u[i], O = S(D) ?? a;
|
|
34
|
+
return o(y, O, A);
|
|
31
35
|
};
|
|
32
|
-
}),
|
|
36
|
+
}), s;
|
|
33
37
|
}
|
|
34
|
-
const
|
|
38
|
+
const x = {
|
|
35
39
|
TITLE: "You May Also Like!"
|
|
36
|
-
},
|
|
37
|
-
u,
|
|
38
|
-
p,
|
|
39
|
-
m,
|
|
40
|
+
}, v = [
|
|
40
41
|
b,
|
|
41
42
|
T,
|
|
43
|
+
g,
|
|
42
44
|
_,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
f,
|
|
46
|
+
p,
|
|
47
|
+
m
|
|
48
|
+
], F = {
|
|
47
49
|
[b]: !0,
|
|
48
|
-
[
|
|
49
|
-
[
|
|
50
|
-
[
|
|
51
|
-
[
|
|
52
|
-
|
|
50
|
+
[T]: !0,
|
|
51
|
+
[_]: !0,
|
|
52
|
+
[g]: !0,
|
|
53
|
+
[f]: !1,
|
|
54
|
+
[p]: !1,
|
|
55
|
+
[m]: !0
|
|
56
|
+
}, I = 10;
|
|
57
|
+
function $(t = I) {
|
|
58
|
+
return `
|
|
53
59
|
<tr>
|
|
54
|
-
<td class="spacer" style="height:
|
|
60
|
+
<td class="spacer" style="height: ${t}px;"></td>
|
|
55
61
|
</tr>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
`;
|
|
63
|
+
}
|
|
64
|
+
const L = $();
|
|
65
|
+
function w(t, n) {
|
|
66
|
+
return n ? n.pStyle ?? "" : t;
|
|
67
|
+
}
|
|
68
|
+
function W(t, n, e) {
|
|
69
|
+
const o = w(n.pStyle, e), s = e ? e.openTags ?? "" : n.openTags, r = e ? e.closeTags ?? "" : n.closeTags;
|
|
70
|
+
return `<p contenteditable="false" style="${o}">${s}${t}${r}</p>`;
|
|
71
|
+
}
|
|
72
|
+
function H(t, n) {
|
|
73
|
+
const e = [];
|
|
74
|
+
return t && e.push(t), n && e.push(`background-color: ${n};`), e.join(" ");
|
|
75
|
+
}
|
|
76
|
+
function Y(t) {
|
|
77
|
+
return t ? ` style="background-color: ${t};"` : "";
|
|
78
|
+
}
|
|
79
|
+
function G(t, n = "") {
|
|
80
|
+
return {
|
|
81
|
+
before: (t == null ? void 0 : t.before) ?? n,
|
|
82
|
+
after: (t == null ? void 0 : t.after) ?? ""
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function z(t, n) {
|
|
86
|
+
return `${(n == null ? void 0 : n.openTags) ?? ""}${t}${(n == null ? void 0 : n.closeTags) ?? ""}`;
|
|
87
|
+
}
|
|
88
|
+
function X(t) {
|
|
89
|
+
return t != null && t.buttonFitToContainer ? "es-button-border es-fw" : "es-button-border";
|
|
90
|
+
}
|
|
91
|
+
const j = "display: block; max-width: 100%; height: auto;", V = "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;", h = "https://email-static.useinsider.com/stripo/modules/email-recommendation-v3/assets/images/image-placeholder.png";
|
|
92
|
+
function q(t) {
|
|
93
|
+
return !t || typeof t != "string" || t.trim() === "" ? h : t.startsWith("http://") ? t.replace("http://", "https://") : t;
|
|
59
94
|
}
|
|
60
|
-
function
|
|
95
|
+
function B(t) {
|
|
61
96
|
return {
|
|
62
97
|
name: "Product Name",
|
|
63
|
-
image_url:
|
|
98
|
+
image_url: h,
|
|
64
99
|
price: { USD: 18 },
|
|
65
100
|
original_price: { USD: 20 },
|
|
66
101
|
discount: { USD: 2 },
|
|
@@ -72,19 +107,19 @@ function E(t) {
|
|
|
72
107
|
category: []
|
|
73
108
|
};
|
|
74
109
|
}
|
|
75
|
-
function
|
|
110
|
+
function J(t = 6) {
|
|
76
111
|
return Array.from(
|
|
77
112
|
{ length: t },
|
|
78
|
-
(
|
|
113
|
+
(n, e) => B(String(e + 1))
|
|
79
114
|
);
|
|
80
115
|
}
|
|
81
|
-
function
|
|
82
|
-
const
|
|
83
|
-
data-layout="list"` : "",
|
|
116
|
+
function Q(t = "grid", n) {
|
|
117
|
+
const e = t === "list" ? `
|
|
118
|
+
data-layout="list"` : "", o = n ? ` ${n}` : "";
|
|
84
119
|
return `
|
|
85
120
|
<td
|
|
86
121
|
align="left"
|
|
87
|
-
class="${`recommendation-block-v2 esd-block-recommendation-v3-block es-p20${t === "list" ? " es-m-p0 ins-recommendation-list-layout" : ""}${
|
|
122
|
+
class="${`recommendation-block-v2 esd-block-recommendation-v3-block es-p20${t === "list" ? " es-m-p0 ins-recommendation-list-layout" : ""}${o}`}"${e}>
|
|
88
123
|
<table width="100%" cellpadding="0" cellspacing="0" border="0">
|
|
89
124
|
<tr>
|
|
90
125
|
<td align="center">
|
|
@@ -116,7 +151,7 @@ function x(t = "grid", e) {
|
|
|
116
151
|
</table>
|
|
117
152
|
</td>
|
|
118
153
|
</tr>
|
|
119
|
-
${
|
|
154
|
+
${L}
|
|
120
155
|
<tr>
|
|
121
156
|
<td>
|
|
122
157
|
<table
|
|
@@ -156,17 +191,30 @@ function x(t = "grid", e) {
|
|
|
156
191
|
}
|
|
157
192
|
export {
|
|
158
193
|
P as CUSTOM_CELL_HTML,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
194
|
+
x as DEFAULTS,
|
|
195
|
+
K as DEFAULT_BUTTON_ANCHOR_STYLE,
|
|
196
|
+
V as DEFAULT_BUTTON_BORDER_STYLE,
|
|
197
|
+
v as DEFAULT_CARD_COMPOSITION,
|
|
198
|
+
F as DEFAULT_CARD_VISIBILITY,
|
|
199
|
+
j as DEFAULT_IMG_STYLE,
|
|
200
|
+
I as DEFAULT_ROW_SPACING_PX,
|
|
201
|
+
h as PLACEHOLDER_IMAGE,
|
|
202
|
+
k as buildElementRenderer,
|
|
203
|
+
$ as buildSpacer,
|
|
204
|
+
Y as cellBgStyleAttr,
|
|
205
|
+
Q as createBlockTemplate,
|
|
206
|
+
J as getDefaultProducts,
|
|
166
207
|
C as isDefaultAttribute,
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
208
|
+
z as renderButtonLabel,
|
|
209
|
+
W as renderStyledParagraph,
|
|
210
|
+
X as resolveButtonBorderClass,
|
|
211
|
+
G as resolveOmnibusText,
|
|
212
|
+
w as resolvePStyle,
|
|
213
|
+
E as resolveProductAttrValue,
|
|
214
|
+
H as resolveSegmentBgStyle,
|
|
215
|
+
q as sanitizeImageUrl,
|
|
216
|
+
L as spacer,
|
|
217
|
+
M as toCustomCompositionKey,
|
|
218
|
+
U as toDisplayName,
|
|
219
|
+
S as toDisplayableAttributeValue
|
|
172
220
|
};
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { RecommendationBlockId as c } from "../constants/blockIds.js";
|
|
2
|
+
import { DESKTOP_CONTAINER_SELECTOR as S, ATTR_PRODUCT_NAME as k, ATTR_PRODUCT_PRICE as E, ATTR_PRODUCT_OLD_PRICE as h, ATTR_PRODUCT_OMNIBUS_PRICE as y, ATTR_PRODUCT_OMNIBUS_DISCOUNT as m, ATTR_PRODUCT_BUTTON as P, ATTR_PRODUCT_IMAGE as x, ATTR_PRODUCT_ATTR as v } from "../constants/selectors.js";
|
|
3
|
+
import { CSS_CLASS_TEXT_TRIM as B } from "../controls/shared/textTrimCssRules.js";
|
|
4
|
+
import { toCustomCompositionKey as U } from "../templates/utils.js";
|
|
5
|
+
import { extractWrapperTags as C } from "./preserveTextStyles.js";
|
|
6
|
+
import { hasQuerySelectorAll as A, hasGetAttribute as l, hasGetStyle as R, hasGetComputedStyle as q } from "./tagName.js";
|
|
7
|
+
const s = [
|
|
8
|
+
"font-size",
|
|
9
|
+
"font-family",
|
|
10
|
+
"font-weight",
|
|
11
|
+
"font-style",
|
|
12
|
+
"color",
|
|
13
|
+
"text-align",
|
|
14
|
+
"line-height",
|
|
15
|
+
"text-decoration"
|
|
16
|
+
], N = [
|
|
17
|
+
"background",
|
|
18
|
+
"background-color",
|
|
19
|
+
"border-width",
|
|
20
|
+
"border-color",
|
|
21
|
+
"border-style",
|
|
22
|
+
"border-radius"
|
|
23
|
+
], M = [
|
|
24
|
+
...s,
|
|
25
|
+
"background",
|
|
26
|
+
"background-color",
|
|
27
|
+
// Stripo's Border Radius control writes the radius to the anchor too, not just the
|
|
28
|
+
// border span — capture it so it survives regeneration (symmetric with BUTTON_BORDER_PROPS).
|
|
29
|
+
"border-radius",
|
|
30
|
+
"padding",
|
|
31
|
+
"width",
|
|
32
|
+
"mso-border-alt",
|
|
33
|
+
"mso-padding-alt"
|
|
34
|
+
], D = [
|
|
35
|
+
"display",
|
|
36
|
+
"width",
|
|
37
|
+
"height",
|
|
38
|
+
"max-width",
|
|
39
|
+
"border-radius",
|
|
40
|
+
"margin"
|
|
41
|
+
], b = /* @__PURE__ */ new Set(["transparent", "rgba(0, 0, 0, 0)"]), G = [
|
|
42
|
+
{ attrKey: k, blockId: c.NAME, kind: "text" },
|
|
43
|
+
{ attrKey: E, blockId: c.PRICE, kind: "text" },
|
|
44
|
+
{ attrKey: h, blockId: c.OLD_PRICE, kind: "text" },
|
|
45
|
+
{ attrKey: y, blockId: c.OMNIBUS_PRICE, kind: "text" },
|
|
46
|
+
{ attrKey: m, blockId: c.OMNIBUS_DISCOUNT, kind: "text" },
|
|
47
|
+
{ attrKey: P, blockId: c.BUTTON, kind: "button" },
|
|
48
|
+
{ attrKey: x, blockId: c.IMAGE, kind: "image" }
|
|
49
|
+
];
|
|
50
|
+
function _(t) {
|
|
51
|
+
return t && "getInnerHTML" in t && typeof t.getInnerHTML == "function" ? t.getInnerHTML().trim() : "";
|
|
52
|
+
}
|
|
53
|
+
function L(t) {
|
|
54
|
+
return t && "getInnerText" in t && typeof t.getInnerText == "function" ? t.getInnerText().trim() : "";
|
|
55
|
+
}
|
|
56
|
+
function a(t, e, r) {
|
|
57
|
+
!e || !R(e) || r.forEach((n) => {
|
|
58
|
+
const i = e.getStyle(n);
|
|
59
|
+
i && i !== "inherit" && i !== "initial" && (t[n] = i);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function I(t) {
|
|
63
|
+
return Object.entries(t).map(([e, r]) => `${e}: ${r};`).join(" ");
|
|
64
|
+
}
|
|
65
|
+
function O(t) {
|
|
66
|
+
if (!t || !R(t))
|
|
67
|
+
return;
|
|
68
|
+
const e = t.getStyle("background-color") || t.getStyle("background");
|
|
69
|
+
return e && !b.has(e) ? e : void 0;
|
|
70
|
+
}
|
|
71
|
+
function g(t, e) {
|
|
72
|
+
const r = {};
|
|
73
|
+
return a(r, t, e), I(r);
|
|
74
|
+
}
|
|
75
|
+
function w(t) {
|
|
76
|
+
const e = t.querySelector("p"), r = {};
|
|
77
|
+
a(r, t, s), a(r, e, s), a(r, t.querySelector("strong"), s), a(r, t.querySelector("em"), s), a(r, t.querySelector("s"), s);
|
|
78
|
+
const n = I(r), { openTags: i, closeTags: o } = C(_(e));
|
|
79
|
+
return !n && !i ? null : { pStyle: n || void 0, openTags: i, closeTags: o };
|
|
80
|
+
}
|
|
81
|
+
function K(t) {
|
|
82
|
+
const e = t.querySelector(".es-button-border"), r = t.querySelector("a.es-button") ?? t.querySelector("a"), n = g(e, N), i = g(r, M), o = e && "getAttribute" in e ? e.getAttribute("class") ?? "" : "", u = /\bes-fw\b/.test(o), { openTags: T, closeTags: d } = C(_(r)), p = L(r);
|
|
83
|
+
return !n && !i && !u && !T && !p ? null : {
|
|
84
|
+
buttonBorderStyle: n || void 0,
|
|
85
|
+
buttonAnchorStyle: i || void 0,
|
|
86
|
+
buttonFitToContainer: u || void 0,
|
|
87
|
+
buttonText: p || void 0,
|
|
88
|
+
openTags: T,
|
|
89
|
+
closeTags: d
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function H(t) {
|
|
93
|
+
const e = g(t.querySelector("img"), D);
|
|
94
|
+
return e ? { imgStyle: e } : null;
|
|
95
|
+
}
|
|
96
|
+
function $(t, e) {
|
|
97
|
+
return e === "button" ? K(t) : e === "image" ? H(t) : w(t);
|
|
98
|
+
}
|
|
99
|
+
function f(t, e) {
|
|
100
|
+
if (!t || !("querySelector" in t))
|
|
101
|
+
return;
|
|
102
|
+
const r = t.querySelector(S) ?? t;
|
|
103
|
+
if (G.forEach(({ attrKey: o, blockId: u, kind: T }) => {
|
|
104
|
+
const d = r.querySelector(`[esd-extension-block-id="${u}"]`);
|
|
105
|
+
d && e(d, o, T);
|
|
106
|
+
}), !A(r))
|
|
107
|
+
return;
|
|
108
|
+
const n = /* @__PURE__ */ new Set();
|
|
109
|
+
r.querySelectorAll(
|
|
110
|
+
`[esd-extension-block-id="${c.CUSTOM_ATTRIBUTE}"]`
|
|
111
|
+
).forEach((o) => {
|
|
112
|
+
const u = l(o) ? o.getAttribute(v) : null;
|
|
113
|
+
!u || n.has(u) || (n.add(u), e(o, U(u), "text"));
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function F(t) {
|
|
117
|
+
const e = {};
|
|
118
|
+
return f(t, (r, n, i) => {
|
|
119
|
+
if (!("querySelector" in r))
|
|
120
|
+
return;
|
|
121
|
+
const o = $(r, i);
|
|
122
|
+
o && (e[n] = o);
|
|
123
|
+
}), e;
|
|
124
|
+
}
|
|
125
|
+
function j(t) {
|
|
126
|
+
if (!t || !("querySelector" in t))
|
|
127
|
+
return;
|
|
128
|
+
const e = t.querySelector(S) ?? t, r = e.querySelector(".product-card-segment") ?? e.querySelector(".product-card-wrapper");
|
|
129
|
+
return O(r);
|
|
130
|
+
}
|
|
131
|
+
function X(t) {
|
|
132
|
+
if (!t)
|
|
133
|
+
return;
|
|
134
|
+
const e = l(t) ? t.getAttribute("bgcolor") : null;
|
|
135
|
+
if (e && !b.has(e))
|
|
136
|
+
return e;
|
|
137
|
+
const r = O(t);
|
|
138
|
+
if (r)
|
|
139
|
+
return r;
|
|
140
|
+
const n = q(t) ? t.getComputedStyle("background-color") : void 0;
|
|
141
|
+
return n && !b.has(n) ? n : void 0;
|
|
142
|
+
}
|
|
143
|
+
function z(t) {
|
|
144
|
+
const e = {};
|
|
145
|
+
return f(t, (r, n, i) => {
|
|
146
|
+
if (i !== "text")
|
|
147
|
+
return;
|
|
148
|
+
const o = X(r);
|
|
149
|
+
o && (e[n] = o);
|
|
150
|
+
}), e;
|
|
151
|
+
}
|
|
152
|
+
function Q(t) {
|
|
153
|
+
const e = {};
|
|
154
|
+
return f(t, (r, n, i) => {
|
|
155
|
+
if (i === "image")
|
|
156
|
+
return;
|
|
157
|
+
const o = l(r) ? r.getAttribute("align") : null;
|
|
158
|
+
o && (e[n] = o);
|
|
159
|
+
}), e;
|
|
160
|
+
}
|
|
161
|
+
const V = /^es-[pm]\d+[trbl]?$/;
|
|
162
|
+
function W(t) {
|
|
163
|
+
const e = l(t) ? t.getAttribute("class") : null;
|
|
164
|
+
if (!e)
|
|
165
|
+
return;
|
|
166
|
+
const r = e.split(/\s+/).filter((n) => V.test(n) || n === B);
|
|
167
|
+
return r.length ? r.join(" ") : void 0;
|
|
168
|
+
}
|
|
169
|
+
function Y(t) {
|
|
170
|
+
const e = {};
|
|
171
|
+
return f(t, (r, n, i) => {
|
|
172
|
+
if (i === "image")
|
|
173
|
+
return;
|
|
174
|
+
const o = W(r);
|
|
175
|
+
o && (e[n] = o);
|
|
176
|
+
}), e;
|
|
177
|
+
}
|
|
178
|
+
function J(t) {
|
|
179
|
+
const e = {};
|
|
180
|
+
return f(t, (r, n) => {
|
|
181
|
+
if (n !== y && n !== m || !l(r))
|
|
182
|
+
return;
|
|
183
|
+
const i = r.getAttribute("data-text-before"), o = r.getAttribute("data-text-after");
|
|
184
|
+
(i != null || o != null) && (e[n] = { before: i ?? void 0, after: o ?? void 0 });
|
|
185
|
+
}), e;
|
|
186
|
+
}
|
|
187
|
+
function Z(t) {
|
|
188
|
+
const e = {};
|
|
189
|
+
if (!t || !("querySelector" in t))
|
|
190
|
+
return e;
|
|
191
|
+
const r = t.querySelector(S) ?? t;
|
|
192
|
+
return A(r) && r.querySelectorAll(".recommendation-attribute-row").forEach((n) => {
|
|
193
|
+
if (!l(n))
|
|
194
|
+
return;
|
|
195
|
+
const i = n.getAttribute("data-attribute-type"), o = n.getAttribute("data-visibility");
|
|
196
|
+
i && o != null && (e[i] = o !== "0");
|
|
197
|
+
}), e;
|
|
198
|
+
}
|
|
199
|
+
function ut(t) {
|
|
200
|
+
return {
|
|
201
|
+
styleTemplates: F(t),
|
|
202
|
+
cardBackgroundColor: j(t),
|
|
203
|
+
cellBackgroundColors: z(t),
|
|
204
|
+
cellAlignments: Q(t),
|
|
205
|
+
cellClasses: Y(t),
|
|
206
|
+
omnibusTexts: J(t),
|
|
207
|
+
visibility: Z(t)
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
export {
|
|
211
|
+
F as captureAttributeStyleTemplates,
|
|
212
|
+
j as captureCardBackgroundColor,
|
|
213
|
+
Q as captureCellAlignments,
|
|
214
|
+
z as captureCellBackgroundColors,
|
|
215
|
+
Y as captureCellClasses,
|
|
216
|
+
J as captureOmnibusTexts,
|
|
217
|
+
ut as captureStyles,
|
|
218
|
+
Z as captureVisibility
|
|
219
|
+
};
|
|
@@ -1,27 +1,32 @@
|
|
|
1
|
-
import { escapeHtml as
|
|
2
|
-
function
|
|
3
|
-
return "getInnerHTML" in
|
|
1
|
+
import { escapeHtml as g } from "../../../../utils/htmlEscape.js";
|
|
2
|
+
function u(n) {
|
|
3
|
+
return "getInnerHTML" in n && typeof n.getInnerHTML == "function" ? n.getInnerHTML().trim() : "innerHTML" in n ? n.innerHTML : "";
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
return n;
|
|
9
|
-
const r = T(t);
|
|
10
|
-
if (!r || r.trim() === "" || !/<(strong|em|u|s|b|i)\b/i.test(r))
|
|
11
|
-
return n;
|
|
12
|
-
const e = [], s = [];
|
|
13
|
-
let o = r.trim();
|
|
5
|
+
function T(n) {
|
|
6
|
+
const s = [], t = [];
|
|
7
|
+
let r = n.trim();
|
|
14
8
|
for (; ; ) {
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
9
|
+
const e = r.match(/^<(strong|em|u|s|b|i)(\s[^>]*)?>(.*)$/is);
|
|
10
|
+
if (!e)
|
|
17
11
|
break;
|
|
18
|
-
const [, i, a = "",
|
|
19
|
-
if (!
|
|
12
|
+
const [, i, a = "", o] = e, c = new RegExp(`</${i}>$`, "i");
|
|
13
|
+
if (!c.test(o))
|
|
20
14
|
break;
|
|
21
|
-
|
|
15
|
+
s.push(`<${i}${a}>`), t.unshift(`</${i}>`), r = o.replace(c, "").trim();
|
|
22
16
|
}
|
|
23
|
-
return
|
|
17
|
+
return { openTags: s.join(""), closeTags: t.join("") };
|
|
18
|
+
}
|
|
19
|
+
function p(n, s) {
|
|
20
|
+
const t = g(s);
|
|
21
|
+
if (!n)
|
|
22
|
+
return t;
|
|
23
|
+
const r = u(n);
|
|
24
|
+
if (!r || r.trim() === "")
|
|
25
|
+
return t;
|
|
26
|
+
const { openTags: e, closeTags: i } = T(r);
|
|
27
|
+
return e ? e + t + i : t;
|
|
24
28
|
}
|
|
25
29
|
export {
|
|
26
|
-
|
|
30
|
+
T as extractWrapperTags,
|
|
31
|
+
p as preserveTextStyles
|
|
27
32
|
};
|
|
@@ -1,46 +1,54 @@
|
|
|
1
|
-
function
|
|
1
|
+
function r(t) {
|
|
2
2
|
return typeof t == "object" && t !== null && "tagName" in t && typeof t.tagName == "string";
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function u(t) {
|
|
5
5
|
return typeof t == "object" && t !== null && "getTagName" in t && typeof t.getTagName == "function";
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function n(t) {
|
|
8
8
|
return typeof t == "object" && t !== null && "getStyle" in t && typeof t.getStyle == "function";
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return typeof t == "object" && t !== null && "
|
|
10
|
+
function p(t) {
|
|
11
|
+
return typeof t == "object" && t !== null && "getComputedStyle" in t && typeof t.getComputedStyle == "function";
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return typeof t == "object" && t !== null && "
|
|
13
|
+
function y(t) {
|
|
14
|
+
return typeof t == "object" && t !== null && "getAttribute" in t && typeof t.getAttribute == "function";
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
return
|
|
16
|
+
function o(t) {
|
|
17
|
+
return typeof t == "object" && t !== null && "querySelectorAll" in t && typeof t.querySelectorAll == "function";
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return
|
|
19
|
+
function l(t) {
|
|
20
|
+
return typeof t == "object" && t !== null && "parent" in t && typeof t.parent == "function";
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return t
|
|
22
|
+
function g(t, e) {
|
|
23
|
+
return !t || !n(t) ? null : t.getStyle(e);
|
|
24
|
+
}
|
|
25
|
+
function s(t) {
|
|
26
|
+
return !t || !l(t) ? null : t.parent() ?? null;
|
|
27
|
+
}
|
|
28
|
+
function a(t, e = "UNKNOWN") {
|
|
29
|
+
return t ? r(t) ? t.tagName.toUpperCase() : u(t) ? t.getTagName().toUpperCase() : e : e;
|
|
24
30
|
}
|
|
25
31
|
const f = /* @__PURE__ */ new Set(["TD", "BLOCK_IMAGE", "BLOCK_BUTTON"]);
|
|
26
32
|
function i(t) {
|
|
27
33
|
return f.has(t.toUpperCase());
|
|
28
34
|
}
|
|
29
35
|
function c(t) {
|
|
30
|
-
const e =
|
|
36
|
+
const e = a(t);
|
|
31
37
|
return i(e);
|
|
32
38
|
}
|
|
33
|
-
function
|
|
39
|
+
function N(t) {
|
|
34
40
|
return c(t) ? "table-cell" : "table-row";
|
|
35
41
|
}
|
|
36
42
|
export {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
N as getTableDisplayValue,
|
|
44
|
+
a as getTagName,
|
|
45
|
+
y as hasGetAttribute,
|
|
46
|
+
p as hasGetComputedStyle,
|
|
47
|
+
n as hasGetStyle,
|
|
48
|
+
l as hasParent,
|
|
49
|
+
o as hasQuerySelectorAll,
|
|
41
50
|
c as isTableCellNode,
|
|
42
51
|
i as isTableCellTag,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
p as safeGetStyle
|
|
52
|
+
s as safeGetParent,
|
|
53
|
+
g as safeGetStyle
|
|
46
54
|
};
|
|
@@ -52,7 +52,7 @@ class H extends y {
|
|
|
52
52
|
onSelect(e) {
|
|
53
53
|
this.currentNode = e;
|
|
54
54
|
const t = this._getOrAssignBlockId(e);
|
|
55
|
-
t && this.linkStateByBlockId.set(t, this._hasUnsubscribeLink(e)), !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), this._loadBlockState(e), this.
|
|
55
|
+
t && this.linkStateByBlockId.set(t, this._hasUnsubscribeLink(e)), this._setupSelectEventListener(), this._setupCancelEventListener(), !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), this._loadBlockState(e), this._checkExistingBlocks(), this._openDrawer());
|
|
56
56
|
}
|
|
57
57
|
onCreated(e) {
|
|
58
58
|
this._ensureLeadingTextGuard(e);
|