@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
package/README.md
CHANGED
|
@@ -8,6 +8,8 @@
|
|
|
8
8
|
|
|
9
9
|
# @useinsider/guido
|
|
10
10
|
|
|
11
|
+
[](http://coverus.internal.dataforce/app/project/github/useinsider/guido)
|
|
12
|
+
|
|
11
13
|
Guido is a Vue 2 + TypeScript wrapper for the Stripo Email Editor plugin. Easily embed the professional email editor in your Vue applications with a clean, type-safe configuration.
|
|
12
14
|
|
|
13
15
|
## Installation
|
|
@@ -21,9 +21,9 @@ const v = () => {
|
|
|
21
21
|
resetDataSavedFlag: !1,
|
|
22
22
|
disableLineHeightsReplace: !0
|
|
23
23
|
}, ...t }, s = {
|
|
24
|
-
callback: (l,
|
|
24
|
+
callback: (l, p, d, c, u) => {
|
|
25
25
|
l ? a(l) : e({
|
|
26
|
-
html:
|
|
26
|
+
html: p,
|
|
27
27
|
ampHtml: d,
|
|
28
28
|
ampErrors: c,
|
|
29
29
|
displayConditions: u
|
|
@@ -36,11 +36,11 @@ const v = () => {
|
|
|
36
36
|
return {
|
|
37
37
|
getCompiledEmail: m,
|
|
38
38
|
getTemplateData: () => new Promise((t) => {
|
|
39
|
-
const e = ({ html: a, css: i, width: o, height:
|
|
39
|
+
const e = ({ html: a, css: i, width: o, height: r, utmParams: s, syncModulesIds: l }) => t({
|
|
40
40
|
html: a,
|
|
41
41
|
css: i,
|
|
42
42
|
width: o,
|
|
43
|
-
height:
|
|
43
|
+
height: r,
|
|
44
44
|
utmParams: s,
|
|
45
45
|
syncModulesIds: l
|
|
46
46
|
});
|
|
@@ -91,7 +91,11 @@ const v = () => {
|
|
|
91
91
|
},
|
|
92
92
|
editorSave: () => new Promise((t) => {
|
|
93
93
|
window.StripoEditorApi.actionsApi.save((e) => {
|
|
94
|
-
|
|
94
|
+
if (e) {
|
|
95
|
+
n(e, "Failed to save template"), t(!1);
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
t(!0);
|
|
95
99
|
});
|
|
96
100
|
})
|
|
97
101
|
};
|
|
@@ -1,32 +1,31 @@
|
|
|
1
1
|
import { useActionsApi as x } from "./useActionsApi.js";
|
|
2
2
|
import { useConfig as y } from "./useConfig.js";
|
|
3
3
|
import { useSaveStart as w, useSaveComplete as C } from "./useGuidoActions.js";
|
|
4
|
-
import { useSyncModuleExtractor as
|
|
5
|
-
import { useStripoApi as
|
|
6
|
-
import { useTemplatePreparation as
|
|
7
|
-
import { useHtmlValidator as
|
|
8
|
-
import { useCouponBlockValidator as
|
|
9
|
-
import { useLiquidValidator as
|
|
10
|
-
const
|
|
11
|
-
const o = w(), s = C(), { validateHtml: r } =
|
|
4
|
+
import { useSyncModuleExtractor as E } from "./useSyncModuleExtractor.js";
|
|
5
|
+
import { useStripoApi as H } from "../services/stripoApi.js";
|
|
6
|
+
import { useTemplatePreparation as b } from "../utils/templatePreparation.js";
|
|
7
|
+
import { useHtmlValidator as q } from "./useHtmlValidator.js";
|
|
8
|
+
import { useCouponBlockValidator as L } from "./validators/useCouponBlockValidator.js";
|
|
9
|
+
import { useLiquidValidator as P } from "./validators/useLiquidValidator.js";
|
|
10
|
+
const z = () => {
|
|
11
|
+
const o = w(), s = C(), { validateHtml: r } = q(), { validateLiquidSyntax: n } = P(), { validateCouponBlockTags: l } = L(), { callbacks: a, isFeatureEnabled: d } = y(), { extractSyncModuleData: u } = E(), { setSyncModuleUnsubscriptionPages: c } = H(), { editorSave: m } = x();
|
|
12
12
|
return { save: async (p = !1, f = !1) => {
|
|
13
13
|
var i;
|
|
14
14
|
o();
|
|
15
|
-
const { prepareTemplateDetails: v } =
|
|
16
|
-
if (!
|
|
15
|
+
const { prepareTemplateDetails: v } = b(), t = await v();
|
|
16
|
+
if (!l(t.compiledHtml))
|
|
17
17
|
return;
|
|
18
18
|
if (d("liquidSyntax")) {
|
|
19
|
-
if (!await
|
|
19
|
+
if (!await n(t.compiledHtml))
|
|
20
20
|
return;
|
|
21
21
|
} else if (!await r(t.compiledHtml, t.dynamicContentList, !0))
|
|
22
22
|
return;
|
|
23
|
-
if ((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(t))
|
|
23
|
+
if ((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(t) || !await m())
|
|
24
24
|
return;
|
|
25
|
-
await m();
|
|
26
25
|
const { unsubscribePayload: S, stripoModules: V } = u(t.rawHtml);
|
|
27
26
|
return await c(S), t.modules = V, p || s({ ...t, silent: f }), t;
|
|
28
27
|
} };
|
|
29
28
|
};
|
|
30
29
|
export {
|
|
31
|
-
|
|
30
|
+
z as useSave
|
|
32
31
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useRecommendation as
|
|
2
|
-
import { DUMMY_IMAGE_MAPPINGS as
|
|
1
|
+
import { useRecommendation as h } from "../../composables/useRecommendation.js";
|
|
2
|
+
import { DUMMY_IMAGE_MAPPINGS as N, REGEX as T, VerticalOrientation as M, CSS as E, ATTRIBUTES as A, CONDITIONS as y, HTML as C } from "../../enums/recommendation.js";
|
|
3
3
|
import { prepareRecommendationBlocks as x } from "./utils/recommendationCompilerUtils.js";
|
|
4
4
|
const w = [
|
|
5
5
|
{
|
|
@@ -8,7 +8,7 @@ const w = [
|
|
|
8
8
|
type: "custom",
|
|
9
9
|
processor: (c) => {
|
|
10
10
|
let e = c;
|
|
11
|
-
return Object.entries(
|
|
11
|
+
return Object.entries(N).forEach(([, l]) => {
|
|
12
12
|
Object.entries(l).forEach(([n, s]) => {
|
|
13
13
|
e = e.replaceAll(s, `{{${n}}}`);
|
|
14
14
|
});
|
|
@@ -25,12 +25,24 @@ const w = [
|
|
|
25
25
|
replaceAll: !0,
|
|
26
26
|
priority: 51
|
|
27
27
|
},
|
|
28
|
+
{
|
|
29
|
+
id: "rename-legacy-buy-button-class",
|
|
30
|
+
// Templates saved before the buy-button → reco-v3-button rename still
|
|
31
|
+
// carry the old class in their persisted HTML; rewrite on export so the
|
|
32
|
+
// downstream button identification selector keeps working.
|
|
33
|
+
description: "Rename legacy buy-button class to reco-v3-button on product button anchors",
|
|
34
|
+
type: "replace",
|
|
35
|
+
search: "es-button buy-button",
|
|
36
|
+
replacement: "es-button reco-v3-button",
|
|
37
|
+
replaceAll: !0,
|
|
38
|
+
priority: 49
|
|
39
|
+
},
|
|
28
40
|
{
|
|
29
41
|
id: "add-recommendation-unresponsive-css",
|
|
30
42
|
description: "Adding recommendation unresponsive css",
|
|
31
43
|
type: "custom",
|
|
32
44
|
processor: (c) => {
|
|
33
|
-
const { calculateCardWidth: e, getRecommendationCampaignData: l } =
|
|
45
|
+
const { calculateCardWidth: e, getRecommendationCampaignData: l } = h();
|
|
34
46
|
let n = c;
|
|
35
47
|
const s = n.match(T.ID);
|
|
36
48
|
if (s) {
|
|
@@ -60,7 +72,7 @@ const w = [
|
|
|
60
72
|
type: "custom",
|
|
61
73
|
processor: (c) => {
|
|
62
74
|
let e = c;
|
|
63
|
-
const l = e.match(T.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: n } =
|
|
75
|
+
const l = e.match(T.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: n } = h();
|
|
64
76
|
return l !== null && l.forEach((s) => {
|
|
65
77
|
const a = s.match(T.CUSTOM_FIELD);
|
|
66
78
|
if (!a)
|
|
@@ -68,17 +80,17 @@ const w = [
|
|
|
68
80
|
const [i] = a, u = i.match(T.CUSTOM_FIELD_INDEXES_PART), _ = i.match(T.CUSTOM_FIELD_NAME_PART), R = s.match(T.ATTRIBUTE_PARAGRAPH_START_TAG);
|
|
69
81
|
if (!u || !_ || !R)
|
|
70
82
|
return;
|
|
71
|
-
const [
|
|
83
|
+
const [b] = u, [I] = _, [d] = R, o = I.substring(1, I.length - 2), r = d.match(T.COMPOSITION) !== null;
|
|
72
84
|
let t = i;
|
|
73
85
|
if (r) {
|
|
74
|
-
const
|
|
86
|
+
const S = b.substring(2, b.length - 3), m = n(S);
|
|
75
87
|
o === A.OMNIBUS_PRICE && (m.priceBeforeTextValue && (t = `${m.priceBeforeTextValue}${t}`), m.priceAfterTextValue && (t = `${t}${m.priceAfterTextValue}`)), o === A.OMNIBUS_DISCOUNT && (m.discountBeforeTextValue && (t = `${m.discountBeforeTextValue}${t}`), m.discountAfterTextValue && (t = `${t}${m.discountAfterTextValue}`));
|
|
76
88
|
}
|
|
77
|
-
const p =
|
|
89
|
+
const p = b.substring(2);
|
|
78
90
|
let f = "";
|
|
79
|
-
o in
|
|
80
|
-
const
|
|
81
|
-
e = e.replace(s,
|
|
91
|
+
o in y.IF && (f = y.IF[o].replaceAll(`{${A.DISCOUNT}}`, `${p}${A.DISCOUNT}`).replaceAll(`{${A.OMNIBUS_DISCOUNT}}`, `${p}${A.OMNIBUS_DISCOUNT}`).replaceAll(`{${A.OMNIBUS_PRICE}}`, `${p}${A.OMNIBUS_PRICE}`));
|
|
92
|
+
const g = `${d}${t}${C.PARAGRAPH_END_TAG}`, $ = `${f}${r ? g : s}${y.ELSE}${d}${C.PARAGRAPH_END_TAG}${y.END_IF}`;
|
|
93
|
+
e = e.replace(s, $);
|
|
82
94
|
}), e;
|
|
83
95
|
},
|
|
84
96
|
priority: 53
|
|
@@ -116,7 +128,7 @@ const w = [
|
|
|
116
128
|
/ class="(?:product-card-segment|attribute-cell|recommendation-attribute-row|product-image|product-name|product-price|product-old-price|product-omnibus-price|product-omnibus-discount|product-button|recommendation-product-row|product-card-wrapper)"/g,
|
|
117
129
|
""
|
|
118
130
|
);
|
|
119
|
-
return e = e.replaceAll("
|
|
131
|
+
return e = e.replaceAll("ins-recommendation-product-container ", ""), e;
|
|
120
132
|
},
|
|
121
133
|
priority: 56
|
|
122
134
|
},
|
|
@@ -174,10 +186,10 @@ const w = [
|
|
|
174
186
|
let o = e;
|
|
175
187
|
return o = o.replaceAll("<!--REC_START-->", ""), o = o.replaceAll("<!--REC_END-->", ""), o;
|
|
176
188
|
}
|
|
177
|
-
const R = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
189
|
+
const R = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), b = (o, r) => `${o.slice(0, -1)} ${r}"`, I = /* @__PURE__ */ new Map();
|
|
178
190
|
i.forEach((o, r) => {
|
|
179
191
|
const t = R(r);
|
|
180
|
-
|
|
192
|
+
I.set(r, {
|
|
181
193
|
caseA: new RegExp(`(class="[^"]*")((?:[^>]*?)) style="${t}"`, "g"),
|
|
182
194
|
caseB: new RegExp(` style="${t}"((?:[^>]*?))(class="[^"]*")`, "g")
|
|
183
195
|
});
|
|
@@ -188,13 +200,13 @@ const w = [
|
|
|
188
200
|
(o, r) => {
|
|
189
201
|
let t = r;
|
|
190
202
|
return i.forEach((p, f) => {
|
|
191
|
-
const
|
|
203
|
+
const g = I.get(f);
|
|
192
204
|
t = t.replace(
|
|
193
|
-
|
|
194
|
-
(
|
|
205
|
+
g.caseA,
|
|
206
|
+
($, S, m) => b(S, p) + m
|
|
195
207
|
), t = t.replace(
|
|
196
|
-
|
|
197
|
-
(
|
|
208
|
+
g.caseB,
|
|
209
|
+
($, S, m) => S + b(m, p)
|
|
198
210
|
), t = t.replaceAll(` style="${f}"`, ` class="${p}"`);
|
|
199
211
|
}), t;
|
|
200
212
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { useRecommendation as
|
|
3
|
-
import {
|
|
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";
|
|
4
5
|
function y(r, c, e, o, s = "") {
|
|
5
6
|
const n = `{{${s}${r}_${c}_${e}}}`, t = `{{${s}${r}_${c}_currency}}`;
|
|
6
7
|
return o === "before" ? `${t} ${n}` : `${n} ${t}`;
|
|
@@ -11,7 +12,7 @@ function f(r, c, e, o, s, n) {
|
|
|
11
12
|
const t = r.querySelector("img");
|
|
12
13
|
t && (t.setAttribute("src", `{{${n}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${n}${e}_${o}_name}}`));
|
|
13
14
|
const i = r.querySelector("a");
|
|
14
|
-
i && i.setAttribute("href", `{{${n}${e}_${o}_url}}`);
|
|
15
|
+
i && (i.setAttribute("href", `{{${n}${e}_${o}_url}}`), i.classList.add(_));
|
|
15
16
|
break;
|
|
16
17
|
}
|
|
17
18
|
case "productName": {
|
|
@@ -80,7 +81,7 @@ function f(r, c, e, o, s, n) {
|
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
}
|
|
83
|
-
function
|
|
84
|
+
function C(r, c, e, o) {
|
|
84
85
|
r.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
|
|
85
86
|
n.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
86
87
|
const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
|
|
@@ -90,7 +91,7 @@ function q(r, c, e, o) {
|
|
|
90
91
|
});
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
|
-
function
|
|
94
|
+
function E(r, c, e, o) {
|
|
94
95
|
const s = r.querySelectorAll(".recommendation-product-row");
|
|
95
96
|
if (!s.length)
|
|
96
97
|
return;
|
|
@@ -105,14 +106,14 @@ function w(r, c, e, o) {
|
|
|
105
106
|
});
|
|
106
107
|
});
|
|
107
108
|
}
|
|
108
|
-
function
|
|
109
|
+
function w(r, c, e, o) {
|
|
109
110
|
r.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
|
|
110
|
-
|
|
111
|
+
E(n, c, e, o);
|
|
111
112
|
});
|
|
112
113
|
}
|
|
113
|
-
function
|
|
114
|
+
function R(r, c, e) {
|
|
114
115
|
const o = r.getAttribute("data-layout") || "grid", s = r.getAttribute("currency-alignment") || "after";
|
|
115
|
-
o === "list" ?
|
|
116
|
+
o === "list" ? C(r, c, s, e) : w(r, c, s, e);
|
|
116
117
|
}
|
|
117
118
|
function b(r, c, e) {
|
|
118
119
|
const o = new RegExp(`${c}\\s*:\\s*(\\d+)\\s*px`, "i"), s = r.match(o);
|
|
@@ -130,7 +131,7 @@ function P(r, c) {
|
|
|
130
131
|
}
|
|
131
132
|
return null;
|
|
132
133
|
}
|
|
133
|
-
function
|
|
134
|
+
function T(r) {
|
|
134
135
|
const c = r.getAttribute("style") || "", e = b(c, "width", 600), o = b(c, "padding", 0) * 2, s = Math.max(0, e - o);
|
|
135
136
|
s !== 0 && r.querySelectorAll("img.adapt-img").forEach((n) => {
|
|
136
137
|
if (n.hasAttribute("width"))
|
|
@@ -152,20 +153,20 @@ function v(r, c) {
|
|
|
152
153
|
return (e ? `${e[0]}
|
|
153
154
|
` : "") + c.documentElement.outerHTML;
|
|
154
155
|
}
|
|
155
|
-
function
|
|
156
|
+
function N(r) {
|
|
156
157
|
const c = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(c, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
157
158
|
if (!o.length)
|
|
158
159
|
return r;
|
|
159
|
-
const { buildCampaignUrl: s } =
|
|
160
|
+
const { buildCampaignUrl: s } = g(), n = q();
|
|
160
161
|
n.recommendationCampaignUrls = {};
|
|
161
|
-
const { isFeatureEnabled: t } =
|
|
162
|
+
const { isFeatureEnabled: t } = S(), i = t("liquidSyntax") ? "reco_" : "";
|
|
162
163
|
return o.forEach((u) => {
|
|
163
164
|
var l, d;
|
|
164
165
|
const p = u.getAttribute("recommendation-id");
|
|
165
|
-
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),
|
|
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));
|
|
166
167
|
}), v(c, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
167
168
|
}
|
|
168
169
|
export {
|
|
169
170
|
y as formatPriceVariable,
|
|
170
|
-
|
|
171
|
+
N as prepareRecommendationBlocks
|
|
171
172
|
};
|
|
@@ -1,85 +1,36 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
|
|
1
|
+
var h = Object.defineProperty;
|
|
2
|
+
var g = (r, t, e) => t in r ? h(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var l = (r, t, e) => g(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import f from "../../extensions/Blocks/Checkbox/template.js";
|
|
5
|
+
import { extractTextFromElement as m, buildTextBlock as p } from "./textBlockMigration.js";
|
|
6
|
+
class C {
|
|
6
7
|
constructor() {
|
|
7
|
-
|
|
8
|
+
l(this, "parser");
|
|
8
9
|
this.parser = new DOMParser();
|
|
9
10
|
}
|
|
10
11
|
migrate(t) {
|
|
11
12
|
try {
|
|
12
|
-
const e = this.parser.parseFromString(t, "text/html"),
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const e = this.parser.parseFromString(t, "text/html"), n = e.querySelectorAll("td.checkbox-block");
|
|
14
|
+
if (n.length === 0)
|
|
15
|
+
return t;
|
|
16
|
+
let i = !1;
|
|
17
|
+
return n.forEach((o) => {
|
|
18
|
+
if (o.classList.contains("checkbox-block-v2"))
|
|
15
19
|
return;
|
|
16
|
-
const
|
|
17
|
-
`<table id="tempDoc"><tbody><tr>${
|
|
20
|
+
const b = o.getAttribute("id"), s = m(o, "ins-title"), a = m(o, "ins-description"), u = p(s, s.containerClass), x = p(a, a.containerClass), d = f.replace("{-{-TITLE-}-}", u).replace("{-{-DESCRIPTION-}-}", x), c = this.parser.parseFromString(
|
|
21
|
+
`<table id="tempDoc"><tbody><tr>${d}</tr></tbody></table>`,
|
|
18
22
|
"text/html"
|
|
19
23
|
).querySelector(".checkbox-block-v2");
|
|
20
|
-
|
|
21
|
-
}), e.documentElement.outerHTML
|
|
24
|
+
c && o.parentNode && (c.setAttribute("id", b || ""), o.parentNode.replaceChild(c, o), i = !0);
|
|
25
|
+
}), i ? e.documentElement.outerHTML : t;
|
|
22
26
|
} catch (e) {
|
|
23
27
|
return console.error("CheckboxMigrator failed:", e), t;
|
|
24
28
|
}
|
|
25
29
|
}
|
|
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
|
-
}
|
|
79
30
|
}
|
|
80
|
-
function
|
|
81
|
-
return new
|
|
31
|
+
function E(r) {
|
|
32
|
+
return new C().migrate(r);
|
|
82
33
|
}
|
|
83
34
|
export {
|
|
84
|
-
|
|
35
|
+
E as migrateCheckbox
|
|
85
36
|
};
|
|
@@ -155,6 +155,8 @@ class z {
|
|
|
155
155
|
}
|
|
156
156
|
migrate(t) {
|
|
157
157
|
try {
|
|
158
|
+
if (!this.containsItemsBlock(t))
|
|
159
|
+
return t;
|
|
158
160
|
let o = this.removeJinjaConditionals(t);
|
|
159
161
|
o = this.replaceTemplateVariables(o);
|
|
160
162
|
const l = this.parser.parseFromString(o, "text/html"), a = l.querySelectorAll(
|
|
@@ -178,15 +180,15 @@ class z {
|
|
|
178
180
|
originalPriceStyles: e.originalPriceStyles,
|
|
179
181
|
quantityStyles: e.quantityStyles,
|
|
180
182
|
nodeConfig: R(e.configBlockAttributes)
|
|
181
|
-
}),
|
|
183
|
+
}), u = this.parser.parseFromString(
|
|
182
184
|
`<table><tbody><tr>${c}</tr></tbody></table>`,
|
|
183
185
|
"text/html"
|
|
184
186
|
).querySelector("td");
|
|
185
|
-
if (
|
|
187
|
+
if (u && i.parentNode) {
|
|
186
188
|
const p = R(e.configBlockAttributes);
|
|
187
|
-
|
|
188
|
-
const
|
|
189
|
-
|
|
189
|
+
u.setAttribute("esd-ext-config", JSON.stringify(p));
|
|
190
|
+
const d = u.querySelector("esd-config-block");
|
|
191
|
+
d && d.remove(), i.parentNode.replaceChild(u, i);
|
|
190
192
|
}
|
|
191
193
|
}), l.documentElement.outerHTML);
|
|
192
194
|
} catch (o) {
|
|
@@ -201,22 +203,22 @@ class z {
|
|
|
201
203
|
*/
|
|
202
204
|
extractConfiguration(t) {
|
|
203
205
|
var C, D, P;
|
|
204
|
-
const o = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(l) - 1, n = T[o], i = ((P = n == null ? void 0 : n[a]) == null ? void 0 : P.value) || n[0].value, e = t.querySelector('[product-attr="price"]'), c = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD",
|
|
206
|
+
const o = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", l = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(l) - 1, n = T[o], i = ((P = n == null ? void 0 : n[a]) == null ? void 0 : P.value) || n[0].value, e = t.querySelector('[product-attr="price"]'), c = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", u = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", p = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", d = this.extractConfigBlockAttributes(t, o, l), S = d["data-card_orientation_control_value"];
|
|
205
207
|
let b;
|
|
206
208
|
S ? b = S === "horizontal" ? "horizontal" : "vertical" : b = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
|
|
207
|
-
const y = t.querySelector('a[product-attr="name"]'), I = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0,
|
|
209
|
+
const y = t.querySelector('a[product-attr="name"]'), I = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0, k = (e == null ? void 0 : e.getAttribute("style")) || void 0, A = t.querySelector("p.original-price"), h = (A == null ? void 0 : A.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), L = (E == null ? void 0 : E.getAttribute("style")) || void 0;
|
|
208
210
|
return {
|
|
209
211
|
orientation: b,
|
|
210
212
|
itemsType: o,
|
|
211
213
|
itemId: i,
|
|
212
214
|
currencySymbol: c,
|
|
213
|
-
currencyLocation:
|
|
215
|
+
currencyLocation: u,
|
|
214
216
|
formattedPrice: p,
|
|
215
|
-
configBlockAttributes:
|
|
217
|
+
configBlockAttributes: d,
|
|
216
218
|
nameStyles: I,
|
|
217
219
|
buttonStyles: m,
|
|
218
|
-
priceStyles:
|
|
219
|
-
originalPriceStyles:
|
|
220
|
+
priceStyles: k,
|
|
221
|
+
originalPriceStyles: h,
|
|
220
222
|
quantityStyles: L
|
|
221
223
|
};
|
|
222
224
|
}
|
|
@@ -296,6 +298,14 @@ class z {
|
|
|
296
298
|
"data-product_button_link": "{{Abandoned Cart Item (1) Url}}"
|
|
297
299
|
};
|
|
298
300
|
}
|
|
301
|
+
/**
|
|
302
|
+
* Fast check for the presence of any items block (cart / browsed / purchased)
|
|
303
|
+
* in the raw HTML. Used to gate the migration pipeline so non-items templates
|
|
304
|
+
* are returned untouched.
|
|
305
|
+
*/
|
|
306
|
+
containsItemsBlock(t) {
|
|
307
|
+
return t.includes("esd-cart-items-block") || t.includes("esd-browsed-items-block") || t.includes("esd-purchased-items-block");
|
|
308
|
+
}
|
|
299
309
|
/**
|
|
300
310
|
* Removes Jinja2 conditional statements from HTML
|
|
301
311
|
* Handles all items block types:
|
|
@@ -337,18 +347,18 @@ class z {
|
|
|
337
347
|
const [, i, e, c] = n, _ = x[i];
|
|
338
348
|
if (!_)
|
|
339
349
|
return console.warn(`Unknown variable prefix: ${i}`), l;
|
|
340
|
-
const
|
|
341
|
-
if (!
|
|
350
|
+
const u = q[e];
|
|
351
|
+
if (!u)
|
|
342
352
|
return console.warn(`Unknown variable suffix mapping for: ${e}`), l;
|
|
343
|
-
const { pairsKey: p, defaultKey:
|
|
353
|
+
const { pairsKey: p, defaultKey: d, isArray: S } = u, y = o[p][_];
|
|
344
354
|
if (!y)
|
|
345
355
|
return console.warn(`No data found for: ${p}.${_}`), l;
|
|
346
356
|
if (S) {
|
|
347
|
-
const f = parseInt(c) - 1, m = y[
|
|
348
|
-
return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${p}.${_}.${
|
|
357
|
+
const f = parseInt(c) - 1, m = y[d];
|
|
358
|
+
return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${p}.${_}.${d}[${f}]`), l);
|
|
349
359
|
}
|
|
350
|
-
const I = y[
|
|
351
|
-
return I !== void 0 ? String(I) : (console.warn(`Default value not found: ${p}.${_}.${
|
|
360
|
+
const I = y[d];
|
|
361
|
+
return I !== void 0 ? String(I) : (console.warn(`Default value not found: ${p}.${_}.${d}`), l);
|
|
352
362
|
});
|
|
353
363
|
}
|
|
354
364
|
}
|