@useinsider/guido 3.5.1-beta.4b9dd49 → 3.5.1-beta.ff14e7c
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/config/compiler/utils/recommendationCompilerUtils.js +78 -84
- package/dist/config/migrator/checkboxMigrator.js +69 -20
- package/dist/config/migrator/radioButtonMigrator.js +91 -36
- package/dist/static/styles/components/wide-panel.css.js +0 -5
- package/package.json +1 -1
- package/dist/config/migrator/textBlockMigration.js +0 -65
- package/dist/src/config/migrator/textBlockMigration.d.ts +0 -24
|
@@ -1,133 +1,127 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { useRecommendation as
|
|
3
|
-
import { CSS_CLASS_RECO_BUTTON as
|
|
4
|
-
import { useRecommendationExtensionStore as
|
|
5
|
-
function y(r,
|
|
6
|
-
const
|
|
7
|
-
return o === "before" ? `${t} ${
|
|
1
|
+
import { useConfig as S } from "../../../composables/useConfig.js";
|
|
2
|
+
import { useRecommendation as g } from "../../../composables/useRecommendation.js";
|
|
3
|
+
import { CSS_CLASS_RECO_BUTTON as _ } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
|
+
import { useRecommendationExtensionStore as q } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
+
function y(r, c, e, o, s = "") {
|
|
6
|
+
const n = `{{${s}${r}_${c}_${e}}}`, t = `{{${s}${r}_${c}_currency}}`;
|
|
7
|
+
return o === "before" ? `${t} ${n}` : `${n} ${t}`;
|
|
8
8
|
}
|
|
9
|
-
function
|
|
10
|
-
|
|
11
|
-
for (; n.children.length === 1; )
|
|
12
|
-
[n] = n.children;
|
|
13
|
-
return n;
|
|
14
|
-
}
|
|
15
|
-
function f(r, n, e, o, i, c) {
|
|
16
|
-
switch (n) {
|
|
9
|
+
function f(r, c, e, o, s, n) {
|
|
10
|
+
switch (c) {
|
|
17
11
|
case "productImage": {
|
|
18
12
|
const t = r.querySelector("img");
|
|
19
|
-
t && (t.setAttribute("src", `{{${
|
|
20
|
-
const
|
|
21
|
-
|
|
13
|
+
t && (t.setAttribute("src", `{{${n}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${n}${e}_${o}_name}}`));
|
|
14
|
+
const i = r.querySelector("a");
|
|
15
|
+
i && (i.setAttribute("href", `{{${n}${e}_${o}_url}}`), i.classList.add(_));
|
|
22
16
|
break;
|
|
23
17
|
}
|
|
24
18
|
case "productName": {
|
|
25
19
|
const t = r.querySelector("p");
|
|
26
20
|
if (t) {
|
|
27
|
-
const
|
|
28
|
-
|
|
21
|
+
const i = t.querySelector("strong") || t;
|
|
22
|
+
i.textContent = `{{${n}${e}_${o}_name}}`;
|
|
29
23
|
}
|
|
30
24
|
break;
|
|
31
25
|
}
|
|
32
26
|
case "productPrice": {
|
|
33
27
|
const t = r.querySelector("p");
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
o,
|
|
37
|
-
|
|
38
|
-
i,
|
|
39
|
-
c
|
|
40
|
-
));
|
|
28
|
+
if (t) {
|
|
29
|
+
const i = t.querySelector("strong") || t;
|
|
30
|
+
i.textContent = y(e, o, "price", s, n);
|
|
31
|
+
}
|
|
41
32
|
break;
|
|
42
33
|
}
|
|
43
34
|
case "productOldPrice": {
|
|
44
35
|
const t = r.querySelector("p");
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
36
|
+
if (t) {
|
|
37
|
+
const i = t.querySelector("strong") || t;
|
|
38
|
+
i.textContent = y(
|
|
39
|
+
e,
|
|
40
|
+
o,
|
|
41
|
+
"original_price",
|
|
42
|
+
s,
|
|
43
|
+
n
|
|
44
|
+
), t.setAttribute("product-attr", "discount");
|
|
45
|
+
}
|
|
52
46
|
break;
|
|
53
47
|
}
|
|
54
48
|
case "productButton": {
|
|
55
49
|
const t = r.querySelector("a");
|
|
56
|
-
t && t.setAttribute("href", `{{${
|
|
50
|
+
t && t.setAttribute("href", `{{${n}${e}_${o}_url}}`);
|
|
57
51
|
break;
|
|
58
52
|
}
|
|
59
53
|
case "productOmnibusPrice": {
|
|
60
54
|
const t = r.querySelector(".omnibus-price-value");
|
|
61
55
|
if (t) {
|
|
62
|
-
t.textContent = `{{${
|
|
63
|
-
const
|
|
64
|
-
|
|
56
|
+
t.textContent = `{{${n}${e}_${o}_omnibus_price}}`;
|
|
57
|
+
const i = t.closest("p");
|
|
58
|
+
i && (i.setAttribute("product-attr", "omnibus_price"), i.setAttribute("composition", "true"));
|
|
65
59
|
}
|
|
66
60
|
break;
|
|
67
61
|
}
|
|
68
62
|
case "productOmnibusDiscount": {
|
|
69
63
|
const t = r.querySelector(".omnibus-discount-value");
|
|
70
64
|
if (t) {
|
|
71
|
-
t.textContent = `{{${
|
|
72
|
-
const
|
|
73
|
-
|
|
65
|
+
t.textContent = `{{${n}${e}_${o}_omnibus_discount}}`;
|
|
66
|
+
const i = t.closest("p");
|
|
67
|
+
i && (i.setAttribute("product-attr", "omnibus_discount"), i.setAttribute("composition", "true"));
|
|
74
68
|
}
|
|
75
69
|
break;
|
|
76
70
|
}
|
|
77
71
|
default: {
|
|
78
72
|
const t = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
|
|
79
73
|
if (t) {
|
|
80
|
-
const
|
|
74
|
+
const i = t.getAttribute("product-attr"), a = t.querySelector("p");
|
|
81
75
|
if (a) {
|
|
82
76
|
const u = a.querySelector("strong") || a;
|
|
83
|
-
u.textContent = `{{${
|
|
77
|
+
u.textContent = `{{${n}${e}_${o}_${i}}}`;
|
|
84
78
|
}
|
|
85
79
|
}
|
|
86
80
|
break;
|
|
87
81
|
}
|
|
88
82
|
}
|
|
89
83
|
}
|
|
90
|
-
function
|
|
91
|
-
r.querySelectorAll(".recommendation-product-row").forEach((
|
|
92
|
-
|
|
84
|
+
function C(r, c, e, o) {
|
|
85
|
+
r.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
|
|
86
|
+
n.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
93
87
|
const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
|
|
94
88
|
p.length > 0 ? p.forEach((l) => {
|
|
95
|
-
f(l, u,
|
|
96
|
-
}) : f(a, u,
|
|
89
|
+
f(l, u, c, t, e, o);
|
|
90
|
+
}) : f(a, u, c, t, e, o);
|
|
97
91
|
});
|
|
98
92
|
});
|
|
99
93
|
}
|
|
100
|
-
function E(r,
|
|
101
|
-
const
|
|
102
|
-
if (!
|
|
94
|
+
function E(r, c, e, o) {
|
|
95
|
+
const s = r.querySelectorAll(".recommendation-product-row");
|
|
96
|
+
if (!s.length)
|
|
103
97
|
return;
|
|
104
|
-
const [
|
|
105
|
-
|
|
98
|
+
const [n] = s, t = n.querySelector("[data-attribute-type]"), i = t ? t.querySelectorAll(".attribute-cell").length : 1;
|
|
99
|
+
s.forEach((a, u) => {
|
|
106
100
|
a.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
107
101
|
const d = l.getAttribute("data-attribute-type") || "";
|
|
108
|
-
l.querySelectorAll(".attribute-cell").forEach((
|
|
109
|
-
const
|
|
110
|
-
f(
|
|
102
|
+
l.querySelectorAll(".attribute-cell").forEach((A, h) => {
|
|
103
|
+
const $ = u * i + h;
|
|
104
|
+
f(A, d, c, $, e, o);
|
|
111
105
|
});
|
|
112
106
|
});
|
|
113
107
|
});
|
|
114
108
|
}
|
|
115
|
-
function
|
|
116
|
-
r.querySelectorAll(".ins-recommendation-product-container").forEach((
|
|
117
|
-
E(
|
|
109
|
+
function w(r, c, e, o) {
|
|
110
|
+
r.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
|
|
111
|
+
E(n, c, e, o);
|
|
118
112
|
});
|
|
119
113
|
}
|
|
120
|
-
function
|
|
121
|
-
const o = r.getAttribute("data-layout") || "grid",
|
|
122
|
-
o === "list" ?
|
|
114
|
+
function R(r, c, e) {
|
|
115
|
+
const o = r.getAttribute("data-layout") || "grid", s = r.getAttribute("currency-alignment") || "after";
|
|
116
|
+
o === "list" ? C(r, c, s, e) : w(r, c, s, e);
|
|
123
117
|
}
|
|
124
|
-
function b(r,
|
|
125
|
-
const o = new RegExp(`${
|
|
126
|
-
return
|
|
118
|
+
function b(r, c, e) {
|
|
119
|
+
const o = new RegExp(`${c}\\s*:\\s*(\\d+)\\s*px`, "i"), s = r.match(o);
|
|
120
|
+
return s ? parseInt(s[1]) : e;
|
|
127
121
|
}
|
|
128
|
-
function
|
|
122
|
+
function P(r, c) {
|
|
129
123
|
let e = r.parentElement;
|
|
130
|
-
for (; e && e !==
|
|
124
|
+
for (; e && e !== c; ) {
|
|
131
125
|
if (e.tagName === "TD") {
|
|
132
126
|
const o = e.getAttribute("width");
|
|
133
127
|
if (o && o.endsWith("%") && parseFloat(o) < 100)
|
|
@@ -137,40 +131,40 @@ function T(r, n) {
|
|
|
137
131
|
}
|
|
138
132
|
return null;
|
|
139
133
|
}
|
|
140
|
-
function
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
if (
|
|
134
|
+
function T(r) {
|
|
135
|
+
const c = r.getAttribute("style") || "", e = b(c, "width", 600), o = b(c, "padding", 0) * 2, s = Math.max(0, e - o);
|
|
136
|
+
s !== 0 && r.querySelectorAll("img.adapt-img").forEach((n) => {
|
|
137
|
+
if (n.hasAttribute("width"))
|
|
144
138
|
return;
|
|
145
|
-
const t =
|
|
139
|
+
const t = P(n, r);
|
|
146
140
|
if (!t)
|
|
147
141
|
return;
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
const d =
|
|
142
|
+
const i = t.getAttribute("width"), a = parseFloat(i), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(s * a / 100), l = Math.max(1, p - u);
|
|
143
|
+
n.setAttribute("width", String(l));
|
|
144
|
+
const d = n.getAttribute("style") || "";
|
|
151
145
|
if (!/\bwidth\s*:\s*\d/i.test(d)) {
|
|
152
146
|
const m = d && !d.trim().endsWith(";") ? "; " : "";
|
|
153
|
-
|
|
147
|
+
n.setAttribute("style", `${d}${m}width: ${l}px`);
|
|
154
148
|
}
|
|
155
149
|
});
|
|
156
150
|
}
|
|
157
|
-
function
|
|
151
|
+
function v(r, c) {
|
|
158
152
|
const e = r.match(/<!DOCTYPE[^>]*>/i);
|
|
159
153
|
return (e ? `${e[0]}
|
|
160
|
-
` : "") +
|
|
154
|
+
` : "") + c.documentElement.outerHTML;
|
|
161
155
|
}
|
|
162
156
|
function N(r) {
|
|
163
|
-
const
|
|
157
|
+
const c = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(c, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
164
158
|
if (!o.length)
|
|
165
159
|
return r;
|
|
166
|
-
const { buildCampaignUrl:
|
|
167
|
-
|
|
168
|
-
const { isFeatureEnabled: t } =
|
|
160
|
+
const { buildCampaignUrl: s } = g(), n = q();
|
|
161
|
+
n.recommendationCampaignUrls = {};
|
|
162
|
+
const { isFeatureEnabled: t } = S(), i = t("liquidSyntax") ? "reco_" : "";
|
|
169
163
|
return o.forEach((u) => {
|
|
170
164
|
var l, d;
|
|
171
165
|
const p = u.getAttribute("recommendation-id");
|
|
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()),
|
|
173
|
-
}),
|
|
166
|
+
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()), s(p), R(u, p, i), T(u));
|
|
167
|
+
}), v(c, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
174
168
|
}
|
|
175
169
|
export {
|
|
176
170
|
y as formatPriceVariable,
|
|
@@ -1,36 +1,85 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
class C {
|
|
1
|
+
var x = Object.defineProperty;
|
|
2
|
+
var y = (s, t, e) => t in s ? x(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
|
|
3
|
+
var m = (s, t, e) => y(s, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import b from "../../extensions/Blocks/Checkbox/template.js";
|
|
5
|
+
class f {
|
|
7
6
|
constructor() {
|
|
8
|
-
|
|
7
|
+
m(this, "parser");
|
|
9
8
|
this.parser = new DOMParser();
|
|
10
9
|
}
|
|
11
10
|
migrate(t) {
|
|
12
11
|
try {
|
|
13
|
-
const e = this.parser.parseFromString(t, "text/html"),
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
let i = !1;
|
|
17
|
-
return n.forEach((o) => {
|
|
18
|
-
if (o.classList.contains("checkbox-block-v2"))
|
|
12
|
+
const e = this.parser.parseFromString(t, "text/html"), i = e.querySelectorAll("td.checkbox-block");
|
|
13
|
+
return i.length === 0 ? t : (i.forEach((r) => {
|
|
14
|
+
if (r.classList.contains("checkbox-block-v2"))
|
|
19
15
|
return;
|
|
20
|
-
const
|
|
21
|
-
`<table id="tempDoc"><tbody><tr>${
|
|
16
|
+
const n = r.getAttribute("id"), l = this.extractTextFromElement(r, "ins-title"), c = this.extractTextFromElement(r, "ins-description"), a = this.buildTextBlock(l), p = this.buildTextBlock(c), g = b.replace("{-{-TITLE-}-}", a).replace("{-{-DESCRIPTION-}-}", p), o = this.parser.parseFromString(
|
|
17
|
+
`<table id="tempDoc"><tbody><tr>${g}</tr></tbody></table>`,
|
|
22
18
|
"text/html"
|
|
23
19
|
).querySelector(".checkbox-block-v2");
|
|
24
|
-
|
|
25
|
-
}),
|
|
20
|
+
o && r.parentNode && (o.setAttribute("id", n || ""), r.parentNode.replaceChild(o, r));
|
|
21
|
+
}), e.documentElement.outerHTML);
|
|
26
22
|
} catch (e) {
|
|
27
23
|
return console.error("CheckboxMigrator failed:", e), t;
|
|
28
24
|
}
|
|
29
25
|
}
|
|
26
|
+
extractTextFromElement(t, e) {
|
|
27
|
+
var o, d;
|
|
28
|
+
const i = t.querySelector(`.${e}`);
|
|
29
|
+
if (!i)
|
|
30
|
+
return {
|
|
31
|
+
text: e === "ins-title" ? "Title" : "Description",
|
|
32
|
+
isBold: !1,
|
|
33
|
+
isItalic: !1,
|
|
34
|
+
align: "left",
|
|
35
|
+
styles: ""
|
|
36
|
+
};
|
|
37
|
+
const r = i.querySelector("p");
|
|
38
|
+
if (!r)
|
|
39
|
+
return {
|
|
40
|
+
text: ((o = i.textContent) == null ? void 0 : o.trim()) || (e === "ins-title" ? "Title" : "Description"),
|
|
41
|
+
isBold: !1,
|
|
42
|
+
isItalic: !1,
|
|
43
|
+
align: i.getAttribute("align") || "left",
|
|
44
|
+
styles: ""
|
|
45
|
+
};
|
|
46
|
+
const n = ((d = r.textContent) == null ? void 0 : d.trim()) || (e === "ins-title" ? "Title" : "Description"), l = r.getAttribute("style") || "", c = i.getAttribute("align") || r.getAttribute("align") || "left", a = /font-weight\s*:\s*bold/i.test(l) || !!r.querySelector("b, strong"), p = /font-style\s*:\s*italic/i.test(l) || !!r.querySelector("i, em"), g = this.removeStyleProperties(l, ["font-weight", "font-style"]), u = this.convertInlineToBlock(g);
|
|
47
|
+
return {
|
|
48
|
+
text: n,
|
|
49
|
+
isBold: a,
|
|
50
|
+
isItalic: p,
|
|
51
|
+
align: c,
|
|
52
|
+
styles: u
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
buildTextBlock(t) {
|
|
56
|
+
let e = t.text;
|
|
57
|
+
t.isBold && t.isItalic ? e = `<strong path="1,0"><em path="1,0,0">${e}</em></strong>` : t.isBold ? e = `<strong path="1,0">${e}</strong>` : t.isItalic && (e = `<em path="1,0">${e}</em>`);
|
|
58
|
+
const i = t.align ? ` align="${t.align}"` : "", r = t.styles ? ` style="${t.styles}"` : "";
|
|
59
|
+
return `
|
|
60
|
+
<td class="esd-block-text" ${i}>
|
|
61
|
+
<p path="1" ${r}>
|
|
62
|
+
${e}
|
|
63
|
+
</p>
|
|
64
|
+
</td>
|
|
65
|
+
`;
|
|
66
|
+
}
|
|
67
|
+
removeStyleProperties(t, e) {
|
|
68
|
+
return t ? e.reduce((r, n) => {
|
|
69
|
+
const l = new RegExp(`${n}\\s*:\\s*[^;]*;?`, "gi");
|
|
70
|
+
return r.replace(l, "");
|
|
71
|
+
}, t).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
|
|
72
|
+
}
|
|
73
|
+
convertInlineToBlock(t) {
|
|
74
|
+
if (!t)
|
|
75
|
+
return "";
|
|
76
|
+
let e = t.replace(/display\s*:\s*inline/gi, "display: block");
|
|
77
|
+
return /display\s*:/i.test(e) || (e = e ? `${e}; display: block` : "display: block"), e.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
|
|
78
|
+
}
|
|
30
79
|
}
|
|
31
|
-
function
|
|
32
|
-
return new
|
|
80
|
+
function k(s) {
|
|
81
|
+
return new f().migrate(s);
|
|
33
82
|
}
|
|
34
83
|
export {
|
|
35
|
-
|
|
84
|
+
k as migrateCheckbox
|
|
36
85
|
};
|
|
@@ -1,54 +1,109 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
class R {
|
|
1
|
+
var x = Object.defineProperty;
|
|
2
|
+
var T = (l, e, t) => e in l ? x(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
|
|
3
|
+
var b = (l, e, t) => T(l, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import S from "../../extensions/Blocks/RadioButton/template.js";
|
|
5
|
+
class B {
|
|
7
6
|
constructor() {
|
|
8
|
-
|
|
7
|
+
b(this, "parser");
|
|
9
8
|
this.parser = new DOMParser();
|
|
10
9
|
}
|
|
11
|
-
migrate(
|
|
10
|
+
migrate(e) {
|
|
12
11
|
try {
|
|
13
|
-
const
|
|
14
|
-
if (
|
|
15
|
-
return
|
|
16
|
-
let
|
|
17
|
-
return
|
|
12
|
+
const t = this.parser.parseFromString(e, "text/html"), s = t.querySelectorAll("td.radio-button-block"), i = t.querySelectorAll("td.radio-button-v2");
|
|
13
|
+
if (s.length === 0 && i.length === 0)
|
|
14
|
+
return e;
|
|
15
|
+
let o = !1;
|
|
16
|
+
return s.forEach((r) => {
|
|
18
17
|
if (r.classList.contains("radio-button-v2"))
|
|
19
18
|
return;
|
|
20
|
-
const
|
|
21
|
-
`<table id="tempDoc"><tbody><tr>${
|
|
19
|
+
const n = r.getAttribute("id"), a = this.extractTextFromElement(r, "ins-title"), g = this.extractTextFromElement(r, "ins-description"), c = this.extractTextFromElement(r, "ins-subscribe"), u = this.extractTextFromElement(r, "ins-unsubscribe"), p = this.buildTextBlock(a), d = this.buildTextBlock(g), y = this.buildTextBlock({ ...c, classList: "" }), f = this.buildTextBlock({ ...u, classList: "" }), h = S.replace("{-{-TITLE-}-}", p).replace("{-{-DESCRIPTION-}-}", d).replace("{-{-YES-}-}", y).replace("{-{-NO-}-}", f), m = this.parser.parseFromString(
|
|
20
|
+
`<table id="tempDoc"><tbody><tr>${h}</tr></tbody></table>`,
|
|
22
21
|
"text/html"
|
|
23
22
|
).querySelector(".radio-button-v2");
|
|
24
|
-
|
|
25
|
-
}),
|
|
26
|
-
} catch (
|
|
27
|
-
return console.error("RadioButtonMigrator failed:",
|
|
23
|
+
m && r.parentNode && (m.setAttribute("id", n || ""), r.parentNode.replaceChild(m, r), o = !0);
|
|
24
|
+
}), o = this.healRadioButtonV2(t) || o, o ? t.documentElement.outerHTML : e;
|
|
25
|
+
} catch (t) {
|
|
26
|
+
return console.error("RadioButtonMigrator failed:", t), e;
|
|
28
27
|
}
|
|
29
28
|
}
|
|
30
|
-
healRadioButtonV2(
|
|
31
|
-
let
|
|
32
|
-
return
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
29
|
+
healRadioButtonV2(e) {
|
|
30
|
+
let t = !1;
|
|
31
|
+
return e.querySelectorAll("td.radio-button-v2").forEach((s) => {
|
|
32
|
+
var d;
|
|
33
|
+
s.classList.contains("radio-button-block") || (s.classList.add("radio-button-block"), t = !0);
|
|
34
|
+
const i = s.querySelector("input#radioYes"), o = s.querySelector("input#radioNo");
|
|
35
|
+
if (!i || !o)
|
|
37
36
|
return;
|
|
38
|
-
const r = ((
|
|
39
|
-
if (!r && !
|
|
37
|
+
const r = ((d = i.parentElement) == null ? void 0 : d.querySelector(":scope > p")) || null;
|
|
38
|
+
if (!r && !i.hasAttribute("align"))
|
|
40
39
|
return;
|
|
41
|
-
const
|
|
42
|
-
if (!
|
|
40
|
+
const n = i.closest("tr"), a = o.closest("tr");
|
|
41
|
+
if (!n || !a || n === a || !n.parentNode)
|
|
43
42
|
return;
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
}),
|
|
43
|
+
const g = (r == null ? void 0 : r.innerHTML.trim()) || "Yes", c = a.cloneNode(!0), u = c.querySelector("input#radioNo"), p = c.querySelector("p");
|
|
44
|
+
u && (u.setAttribute("id", "radioYes"), u.removeAttribute("align")), p && (p.innerHTML = g), n.parentNode.replaceChild(c, n), t = !0;
|
|
45
|
+
}), t;
|
|
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();
|
|
47
102
|
}
|
|
48
103
|
}
|
|
49
|
-
function
|
|
50
|
-
return new
|
|
104
|
+
function L(l) {
|
|
105
|
+
return new B().migrate(l);
|
|
51
106
|
}
|
|
52
107
|
export {
|
|
53
|
-
|
|
108
|
+
L as migrateRadioButton
|
|
54
109
|
};
|
|
@@ -11,11 +11,6 @@ ue-description a {
|
|
|
11
11
|
display: none;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
/* Override the rule above for the Gmail Promotions switcher docs link — remove with DT-28355. */
|
|
15
|
-
ue-lock-container.e2e-promotions-switcher ue-description a {
|
|
16
|
-
display: unset;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
14
|
.label {
|
|
20
15
|
font-size: 13px;
|
|
21
16
|
color: var(--guido-color-gray-800);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.5.1-beta.
|
|
3
|
+
"version": "3.5.1-beta.ff14e7c",
|
|
4
4
|
"description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
|
|
5
5
|
"main": "./dist/guido.umd.cjs",
|
|
6
6
|
"module": "./dist/library.js",
|
|
@@ -1,65 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared text-block migration helpers used by both `radioButtonMigrator` and
|
|
3
|
-
* `checkboxMigrator`. Extracts a legacy v1 `.ins-title` / `.ins-description`
|
|
4
|
-
* cell into a paragraph descriptor and rebuilds it as a v2 `esd-block-text`
|
|
5
|
-
* cell — preserving every <p>, every inline tag (<u>, <a>, <br>, <strong>,
|
|
6
|
-
* <em>) and re-encoding bold/italic detection as canonical tags.
|
|
7
|
-
*/
|
|
8
|
-
export type InsCellClass = 'ins-title' | 'ins-description' | 'ins-subscribe' | 'ins-unsubscribe';
|
|
9
|
-
type ParagraphContent = {
|
|
10
|
-
innerHtml: string;
|
|
11
|
-
isBold: boolean;
|
|
12
|
-
isItalic: boolean;
|
|
13
|
-
styles: string;
|
|
14
|
-
};
|
|
15
|
-
export type TextContent = {
|
|
16
|
-
paragraphs: ParagraphContent[];
|
|
17
|
-
align: string;
|
|
18
|
-
};
|
|
19
|
-
export type ExtractedTextContent = TextContent & {
|
|
20
|
-
containerClass: string;
|
|
21
|
-
};
|
|
22
|
-
export declare function extractTextFromElement(parent: Element, className: InsCellClass): ExtractedTextContent;
|
|
23
|
-
export declare function buildTextBlock(content: TextContent, extraClass?: string): string;
|
|
24
|
-
export {};
|