@useinsider/guido 3.2.0-beta.e01b42a → 3.2.0-beta.e0e56ef
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 +1 -0
- package/dist/@types/config/schemas.js +164 -96
- package/dist/components/Guido.vue.js +4 -4
- package/dist/components/Guido.vue2.js +91 -80
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue.js +7 -7
- package/dist/components/organisms/email-preview/desktop-preview/EmailSizeIndicator.vue2.js +12 -20
- package/dist/components/organisms/header/EditorActions.vue.js +2 -2
- package/dist/components/organisms/header/EditorActions.vue2.js +51 -36
- package/dist/components/organisms/header/RightSlot.vue.js +10 -10
- package/dist/components/organisms/header/RightSlot.vue2.js +16 -13
- package/dist/components/organisms/onboarding/AMPOnboarding.vue2.js +51 -31
- package/dist/components/organisms/onboarding/GenericOnboarding.vue.js +1 -1
- package/dist/components/organisms/onboarding/GenericOnboarding.vue2.js +23 -22
- package/dist/components/organisms/onboarding/ItemsOnboarding.vue.js +1 -1
- package/dist/components/organisms/onboarding/ItemsOnboarding.vue2.js +37 -39
- package/dist/components/organisms/onboarding/TextBlockOnboarding.vue.js +3 -3
- package/dist/components/organisms/onboarding/TextBlockOnboarding.vue2.js +30 -41
- package/dist/components/organisms/onboarding/VersionHistoryOnboarding.vue2.js +15 -14
- package/dist/components/organisms/save-as-template/SaveAsTemplateDrawer.vue2.js +18 -17
- package/dist/composables/useActionsApi.js +4 -4
- package/dist/composables/useFullStoryBridge.js +14 -0
- package/dist/composables/useHtmlCompiler.js +23 -21
- package/dist/composables/useHtmlValidator.js +40 -38
- package/dist/composables/usePreviewMode.js +20 -16
- package/dist/composables/useRibbonOffset.js +21 -0
- package/dist/composables/useSave.js +23 -15
- package/dist/composables/useStripo.js +52 -47
- package/dist/composables/validators/useLiquidValidator.js +42 -0
- package/dist/config/compiler/liquidCompilerRules.js +15 -0
- package/dist/config/compiler/recommendationCompilerRules.js +162 -43
- package/dist/config/compiler/unsubscribeCompilerRules.js +48 -45
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +52 -46
- package/dist/config/migrator/checkboxMigrator.js +5 -3
- package/dist/config/migrator/index.js +9 -9
- package/dist/config/migrator/radioButtonMigrator.js +14 -12
- package/dist/config/migrator/recommendation/compositionMapper.js +98 -0
- package/dist/config/migrator/recommendation/extractors.js +27 -0
- package/dist/config/migrator/recommendation/htmlBuilder.js +496 -0
- package/dist/config/migrator/recommendation/parseLegacyConfig.js +33 -0
- package/dist/config/migrator/recommendation/settingsMapper.js +78 -0
- package/dist/config/migrator/recommendation/themeMapper.js +93 -0
- package/dist/config/migrator/recommendationMigrator.js +74 -290
- package/dist/enums/extensions/recommendationBlock.js +16 -12
- package/dist/enums/onboarding.js +7 -2
- package/dist/enums/recommendation.js +2 -2
- package/dist/enums/unsubscribe.js +34 -27
- package/dist/extensions/Blocks/CouponBlock/template.js +24 -13
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +38 -38
- package/dist/extensions/Blocks/Items/enums/productEnums.js +19 -7
- package/dist/extensions/Blocks/Recommendation/block.js +35 -32
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +5 -5
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +27 -11
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +185 -172
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/index.js +21 -18
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +99 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +6 -6
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +3 -1
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +211 -162
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +27 -57
- package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +14 -0
- package/dist/extensions/Blocks/Recommendation/controls/spacing/index.js +31 -31
- package/dist/extensions/Blocks/Recommendation/services/configService.js +65 -29
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +18 -17
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +29 -25
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +7 -5
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +30 -29
- package/dist/extensions/Blocks/Recommendation/templates/index.js +7 -7
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +3 -1
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +21 -21
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +57 -50
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +17 -14
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +13 -22
- package/dist/extensions/Blocks/Unsubscribe/block.js +11 -11
- package/dist/extensions/DynamicContent/dynamic-content.js +17 -12
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +258 -235
- package/dist/node_modules/valibot/dist/index.js +450 -235
- package/dist/package.json.js +1 -1
- package/dist/services/recommendationApi.js +15 -15
- package/dist/services/stripoApi.js +9 -9
- package/dist/services/templateLibraryApi.js +48 -46
- package/dist/src/@types/config/defaults.d.ts +5 -1
- package/dist/src/@types/config/index.d.ts +3 -3
- package/dist/src/@types/config/schemas.d.ts +241 -0
- package/dist/src/@types/config/types.d.ts +11 -1
- package/dist/src/@types/generic.d.ts +0 -1
- package/dist/src/@types/save-as-template.d.ts +1 -0
- package/dist/src/components/wrappers/WpModal.vue.d.ts +1 -1
- package/dist/src/composables/useActionsApi.d.ts +1 -1
- package/dist/src/composables/useConfig.d.ts +68 -0
- package/dist/src/composables/useFullStoryBridge.d.ts +11 -0
- package/dist/src/composables/useRibbonOffset.d.ts +4 -0
- package/dist/src/composables/validators/useLiquidValidator.d.ts +3 -0
- package/dist/src/config/compiler/liquidCompilerRules.d.ts +2 -0
- package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +1 -1
- package/dist/src/config/migrator/index.d.ts +2 -1
- package/dist/src/config/migrator/recommendation/compositionMapper.d.ts +2 -0
- package/dist/src/config/migrator/recommendation/compositionMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/extractors.d.ts +7 -0
- package/dist/src/config/migrator/recommendation/extractors.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/htmlBuilder.d.ts +11 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +15 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +7 -0
- package/dist/src/config/migrator/recommendation/settingsMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/themeMapper.d.ts +5 -0
- package/dist/src/config/migrator/recommendation/themeMapper.test.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/types.d.ts +205 -0
- package/dist/src/config/migrator/recommendationMigrator.d.ts +13 -1
- package/dist/src/config/migrator/recommendationMigrator.test.d.ts +1 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +3 -0
- package/dist/src/enums/onboarding.d.ts +6 -0
- package/dist/src/enums/unsubscribe.d.ts +5 -0
- package/dist/src/extensions/Blocks/CouponBlock/template.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.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 +5 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +5 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.d.ts +35 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +3 -20
- package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +29 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/services/configService.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +20 -3
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +0 -3
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +3 -3
- package/dist/src/services/templateLibraryApi.d.ts +1 -1
- package/dist/src/stores/config.d.ts +612 -0
- package/dist/src/stores/onboarding.d.ts +4 -0
- package/dist/src/stores/preview.d.ts +3 -0
- package/dist/src/utils/genericUtil.d.ts +1 -1
- package/dist/src/utils/htmlCompiler.d.ts +2 -1
- package/dist/src/utils/htmlEscape.d.ts +5 -0
- package/dist/src/utils/htmlEscape.test.d.ts +1 -0
- package/dist/static/styles/base.css.js +7 -2
- package/dist/static/styles/components/button.css.js +3 -2
- package/dist/static/styles/components/loader.css.js +4 -0
- package/dist/stores/onboarding.js +4 -0
- package/dist/stores/preview.js +4 -3
- package/dist/utils/genericUtil.js +42 -20
- package/dist/utils/htmlCompiler.js +48 -41
- package/dist/utils/htmlEscape.js +13 -0
- package/dist/utils/templatePreparation.js +36 -25
- package/dist/utils/tooltipUtils.js +4 -5
- package/package.json +8 -4
- package/dist/extensions/Blocks/Recommendation/templates/grid/migration.js +0 -251
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { useConfig as S } from "../../../composables/useConfig.js";
|
|
2
|
+
import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
|
|
3
|
+
import { useRecommendationExtensionStore as d } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
4
|
+
function y(e, u, r, o, s = "") {
|
|
5
|
+
const n = `{{${s}${e}_${u}_${r}}}`, t = `{{${s}${e}_${u}_currency}}`;
|
|
4
6
|
return o === "before" ? `${t} ${n}` : `${n} ${t}`;
|
|
5
7
|
}
|
|
6
|
-
function
|
|
8
|
+
function m(e, u, r, o, s, n) {
|
|
7
9
|
switch (u) {
|
|
8
10
|
case "productImage": {
|
|
9
11
|
const t = e.querySelector("img");
|
|
10
|
-
t && (t.setAttribute("src", `{{${r}_${o}_image_url}}`), t.setAttribute("alt", `{{${r}_${o}_name}}`));
|
|
12
|
+
t && (t.setAttribute("src", `{{${n}${r}_${o}_image_url}}`), t.setAttribute("alt", `{{${n}${r}_${o}_name}}`));
|
|
11
13
|
const c = e.querySelector("a");
|
|
12
|
-
c && c.setAttribute("href", `{{${r}_${o}_url}}`);
|
|
14
|
+
c && c.setAttribute("href", `{{${n}${r}_${o}_url}}`);
|
|
13
15
|
break;
|
|
14
16
|
}
|
|
15
17
|
case "productName": {
|
|
16
18
|
const t = e.querySelector("p");
|
|
17
19
|
if (t) {
|
|
18
20
|
const c = t.querySelector("strong") || t;
|
|
19
|
-
c.textContent = `{{${r}_${o}_name}}`;
|
|
21
|
+
c.textContent = `{{${n}${r}_${o}_name}}`;
|
|
20
22
|
}
|
|
21
23
|
break;
|
|
22
24
|
}
|
|
@@ -24,7 +26,7 @@ function p(e, u, r, o, n) {
|
|
|
24
26
|
const t = e.querySelector("p");
|
|
25
27
|
if (t) {
|
|
26
28
|
const c = t.querySelector("strong") || t;
|
|
27
|
-
c.textContent =
|
|
29
|
+
c.textContent = y(r, o, "price", s, n);
|
|
28
30
|
}
|
|
29
31
|
break;
|
|
30
32
|
}
|
|
@@ -32,10 +34,11 @@ function p(e, u, r, o, n) {
|
|
|
32
34
|
const t = e.querySelector("p");
|
|
33
35
|
if (t) {
|
|
34
36
|
const c = t.querySelector("strong") || t;
|
|
35
|
-
c.textContent =
|
|
37
|
+
c.textContent = y(
|
|
36
38
|
r,
|
|
37
39
|
o,
|
|
38
40
|
"original_price",
|
|
41
|
+
s,
|
|
39
42
|
n
|
|
40
43
|
), t.setAttribute("product-attr", "discount");
|
|
41
44
|
}
|
|
@@ -43,13 +46,13 @@ function p(e, u, r, o, n) {
|
|
|
43
46
|
}
|
|
44
47
|
case "productButton": {
|
|
45
48
|
const t = e.querySelector("a");
|
|
46
|
-
t && t.setAttribute("href", `{{${r}_${o}_url}}`);
|
|
49
|
+
t && t.setAttribute("href", `{{${n}${r}_${o}_url}}`);
|
|
47
50
|
break;
|
|
48
51
|
}
|
|
49
52
|
case "productOmnibusPrice": {
|
|
50
53
|
const t = e.querySelector(".omnibus-price-value");
|
|
51
54
|
if (t) {
|
|
52
|
-
t.textContent = `{{${r}_${o}_omnibus_price}}`;
|
|
55
|
+
t.textContent = `{{${n}${r}_${o}_omnibus_price}}`;
|
|
53
56
|
const c = t.closest("p");
|
|
54
57
|
c && (c.setAttribute("product-attr", "omnibus_price"), c.setAttribute("composition", "true"));
|
|
55
58
|
}
|
|
@@ -58,7 +61,7 @@ function p(e, u, r, o, n) {
|
|
|
58
61
|
case "productOmnibusDiscount": {
|
|
59
62
|
const t = e.querySelector(".omnibus-discount-value");
|
|
60
63
|
if (t) {
|
|
61
|
-
t.textContent = `{{${r}_${o}_omnibus_discount}}`;
|
|
64
|
+
t.textContent = `{{${n}${r}_${o}_omnibus_discount}}`;
|
|
62
65
|
const c = t.closest("p");
|
|
63
66
|
c && (c.setAttribute("product-attr", "omnibus_discount"), c.setAttribute("composition", "true"));
|
|
64
67
|
}
|
|
@@ -67,66 +70,69 @@ function p(e, u, r, o, n) {
|
|
|
67
70
|
default: {
|
|
68
71
|
const t = e.getAttribute("product-attr") ? e : e.querySelector("[product-attr]");
|
|
69
72
|
if (t) {
|
|
70
|
-
const c = t.getAttribute("product-attr"),
|
|
71
|
-
if (
|
|
72
|
-
const i =
|
|
73
|
-
i.textContent = `{{${r}_${o}_${c}}}`;
|
|
73
|
+
const c = t.getAttribute("product-attr"), a = t.querySelector("p");
|
|
74
|
+
if (a) {
|
|
75
|
+
const i = a.querySelector("strong") || a;
|
|
76
|
+
i.textContent = `{{${n}${r}_${o}_${c}}}`;
|
|
74
77
|
}
|
|
75
78
|
}
|
|
76
79
|
break;
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
82
|
}
|
|
80
|
-
function
|
|
83
|
+
function q(e, u, r, o) {
|
|
81
84
|
e.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
|
|
82
|
-
n.querySelectorAll("[data-attribute-type]").forEach((
|
|
83
|
-
const i =
|
|
84
|
-
l.length > 0 ? l.forEach((
|
|
85
|
-
p
|
|
86
|
-
}) :
|
|
85
|
+
n.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
86
|
+
const i = a.getAttribute("data-attribute-type") || "", l = a.querySelectorAll(".attribute-cell");
|
|
87
|
+
l.length > 0 ? l.forEach((p) => {
|
|
88
|
+
m(p, i, u, t, r, o);
|
|
89
|
+
}) : m(a, i, u, t, r, o);
|
|
87
90
|
});
|
|
88
91
|
});
|
|
89
92
|
}
|
|
90
|
-
function
|
|
91
|
-
const
|
|
92
|
-
if (!
|
|
93
|
+
function g(e, u, r, o) {
|
|
94
|
+
const s = e.querySelectorAll(".recommendation-product-row");
|
|
95
|
+
if (!s.length)
|
|
93
96
|
return;
|
|
94
|
-
const [n] =
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
const
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
97
|
+
const [n] = s, t = n.querySelector("[data-attribute-type]"), c = t ? t.querySelectorAll(".attribute-cell").length : 1;
|
|
98
|
+
s.forEach((a, i) => {
|
|
99
|
+
a.querySelectorAll("[data-attribute-type]").forEach((p) => {
|
|
100
|
+
const b = p.getAttribute("data-attribute-type") || "";
|
|
101
|
+
p.querySelectorAll(".attribute-cell").forEach((f, $) => {
|
|
102
|
+
const A = i * c + $;
|
|
103
|
+
m(f, b, u, A, r, o);
|
|
101
104
|
});
|
|
102
105
|
});
|
|
103
106
|
});
|
|
104
107
|
}
|
|
105
|
-
function
|
|
108
|
+
function h(e, u, r, o) {
|
|
106
109
|
e.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
|
|
107
|
-
|
|
110
|
+
g(n, u, r, o);
|
|
108
111
|
});
|
|
109
112
|
}
|
|
110
|
-
function
|
|
111
|
-
const
|
|
112
|
-
|
|
113
|
+
function C(e, u, r) {
|
|
114
|
+
const o = e.getAttribute("data-layout") || "grid", s = e.getAttribute("currency-alignment") || "after";
|
|
115
|
+
o === "list" ? q(e, u, s, r) : h(e, u, s, r);
|
|
113
116
|
}
|
|
114
|
-
function
|
|
117
|
+
function E(e, u) {
|
|
115
118
|
const r = e.match(/<!DOCTYPE[^>]*>/i);
|
|
116
119
|
return (r ? `${r[0]}
|
|
117
120
|
` : "") + u.documentElement.outerHTML;
|
|
118
121
|
}
|
|
119
|
-
function
|
|
122
|
+
function T(e) {
|
|
120
123
|
const u = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(u, "text/html"), o = r.querySelectorAll(".recommendation-block-v2");
|
|
121
124
|
if (!o.length)
|
|
122
125
|
return e;
|
|
123
|
-
const { buildCampaignUrl:
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
126
|
+
const { buildCampaignUrl: s } = _(), n = d();
|
|
127
|
+
n.recommendationCampaignUrls = {};
|
|
128
|
+
const { isFeatureEnabled: t } = S(), c = t("liquidSyntax") ? "reco_" : "";
|
|
129
|
+
return o.forEach((i) => {
|
|
130
|
+
var p, b;
|
|
131
|
+
const l = i.getAttribute("recommendation-id");
|
|
132
|
+
l && ((p = i.parentNode) == null || p.insertBefore(r.createComment("REC_START"), i), (b = i.parentNode) == null || b.insertBefore(r.createComment("REC_END"), i.nextSibling), s(l), C(i, l, c));
|
|
133
|
+
}), E(u, r).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
128
134
|
}
|
|
129
135
|
export {
|
|
130
|
-
|
|
131
|
-
|
|
136
|
+
y as formatPriceVariable,
|
|
137
|
+
T as prepareRecommendationBlocks
|
|
132
138
|
};
|
|
@@ -11,6 +11,8 @@ class f {
|
|
|
11
11
|
try {
|
|
12
12
|
const e = this.parser.parseFromString(t, "text/html"), i = e.querySelectorAll("td.checkbox-block");
|
|
13
13
|
return i.length === 0 ? t : (i.forEach((r) => {
|
|
14
|
+
if (r.classList.contains("checkbox-block-v2"))
|
|
15
|
+
return;
|
|
14
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(
|
|
15
17
|
`<table id="tempDoc"><tbody><tr>${g}</tr></tbody></table>`,
|
|
16
18
|
"text/html"
|
|
@@ -22,7 +24,7 @@ class f {
|
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
extractTextFromElement(t, e) {
|
|
25
|
-
var o,
|
|
27
|
+
var o, d;
|
|
26
28
|
const i = t.querySelector(`.${e}`);
|
|
27
29
|
if (!i)
|
|
28
30
|
return {
|
|
@@ -41,13 +43,13 @@ class f {
|
|
|
41
43
|
align: i.getAttribute("align") || "left",
|
|
42
44
|
styles: ""
|
|
43
45
|
};
|
|
44
|
-
const n = ((
|
|
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);
|
|
45
47
|
return {
|
|
46
48
|
text: n,
|
|
47
49
|
isBold: a,
|
|
48
50
|
isItalic: p,
|
|
49
51
|
align: c,
|
|
50
|
-
styles:
|
|
52
|
+
styles: u
|
|
51
53
|
};
|
|
52
54
|
}
|
|
53
55
|
buildTextBlock(t) {
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { migrateCheckbox as
|
|
2
|
-
import { migrateCouponBlock as
|
|
3
|
-
import { migrateItemsBlock as
|
|
4
|
-
import { migrateRadioButton as
|
|
5
|
-
import { migrateRecommendation as
|
|
6
|
-
import { migrateUnsubscribe as
|
|
7
|
-
const
|
|
1
|
+
import { migrateCheckbox as o } from "./checkboxMigrator.js";
|
|
2
|
+
import { migrateCouponBlock as i } from "./couponBlockMigrator.js";
|
|
3
|
+
import { migrateItemsBlock as e } from "./itemsBlockMigrator.js";
|
|
4
|
+
import { migrateRadioButton as a } from "./radioButtonMigrator.js";
|
|
5
|
+
import { migrateRecommendation as g } from "./recommendationMigrator.js";
|
|
6
|
+
import { migrateUnsubscribe as n } from "./unsubscribeMigrator.js";
|
|
7
|
+
const b = async (r, t = {}) => {
|
|
8
8
|
let m = r;
|
|
9
|
-
return m =
|
|
9
|
+
return m = o(m), m = a(m), m = await n(m), m = i(m), m = g(m, t), m = e(m), m;
|
|
10
10
|
};
|
|
11
11
|
export {
|
|
12
|
-
|
|
12
|
+
b as migrate
|
|
13
13
|
};
|
|
@@ -1,28 +1,30 @@
|
|
|
1
|
-
var
|
|
2
|
-
var f = (r, t, e) => t in r ?
|
|
3
|
-
var
|
|
1
|
+
var x = Object.defineProperty;
|
|
2
|
+
var f = (r, t, e) => t in r ? x(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
|
|
3
|
+
var b = (r, t, e) => f(r, typeof t != "symbol" ? t + "" : t, e);
|
|
4
4
|
import h from "../../extensions/Blocks/RadioButton/template.js";
|
|
5
5
|
class T {
|
|
6
6
|
constructor() {
|
|
7
|
-
|
|
7
|
+
b(this, "parser");
|
|
8
8
|
this.parser = new DOMParser();
|
|
9
9
|
}
|
|
10
10
|
migrate(t) {
|
|
11
11
|
try {
|
|
12
12
|
const e = this.parser.parseFromString(t, "text/html"), i = e.querySelectorAll("td.radio-button-block");
|
|
13
13
|
return i.length === 0 ? t : (i.forEach((s) => {
|
|
14
|
-
|
|
14
|
+
if (s.classList.contains("radio-button-v2"))
|
|
15
|
+
return;
|
|
16
|
+
const n = s.getAttribute("id"), l = this.extractTextFromElement(s, "ins-title"), a = this.extractTextFromElement(s, "ins-description"), p = this.extractTextFromElement(s, "ins-subscribe"), u = this.extractTextFromElement(s, "ins-unsubscribe"), d = this.buildTextBlock(l), g = this.buildTextBlock(a), m = this.buildTextBlock({ ...p, classList: "" }), o = this.buildTextBlock({ ...u, classList: "" }), c = h.replace("{-{-TITLE-}-}", d).replace("{-{-DESCRIPTION-}-}", g).replace("{-{-YES-}-}", m).replace("{-{-NO-}-}", o), y = this.parser.parseFromString(
|
|
15
17
|
`<table id="tempDoc"><tbody><tr>${c}</tr></tbody></table>`,
|
|
16
18
|
"text/html"
|
|
17
19
|
).querySelector(".radio-button-v2");
|
|
18
|
-
y && s.parentNode && (y.setAttribute("id",
|
|
20
|
+
y && s.parentNode && (y.setAttribute("id", n || ""), s.parentNode.replaceChild(y, s));
|
|
19
21
|
}), e.documentElement.outerHTML);
|
|
20
22
|
} catch (e) {
|
|
21
23
|
return console.error("RadioButtonMigrator failed:", e), t;
|
|
22
24
|
}
|
|
23
25
|
}
|
|
24
26
|
extractTextFromElement(t, e) {
|
|
25
|
-
var
|
|
27
|
+
var o, c;
|
|
26
28
|
const i = t.querySelector(`.${e}`);
|
|
27
29
|
if (!i)
|
|
28
30
|
return {
|
|
@@ -36,16 +38,16 @@ class T {
|
|
|
36
38
|
const s = i.querySelector("p");
|
|
37
39
|
if (!s)
|
|
38
40
|
return {
|
|
39
|
-
text: ((
|
|
41
|
+
text: ((o = i.textContent) == null ? void 0 : o.trim()) || (e === "ins-title" ? "Title" : "Description"),
|
|
40
42
|
isBold: !1,
|
|
41
43
|
isItalic: !1,
|
|
42
44
|
align: i.getAttribute("align") || "left",
|
|
43
45
|
styles: "",
|
|
44
46
|
classList: ""
|
|
45
47
|
};
|
|
46
|
-
const
|
|
48
|
+
const n = ((c = s.textContent) == null ? void 0 : c.trim()) || (e === "ins-title" ? "Title" : "Description"), l = s.getAttribute("style") || "", a = i.getAttribute("align") || s.getAttribute("align") || "left", p = /font-weight\s*:\s*bold/i.test(l) || !!s.querySelector("b, strong"), u = /font-style\s*:\s*italic/i.test(l) || !!s.querySelector("i, em"), d = this.removeStyleProperties(l, ["font-weight", "font-style"]), g = this.convertInlineToBlock(d), m = i.getAttribute("class") || "";
|
|
47
49
|
return {
|
|
48
|
-
text:
|
|
50
|
+
text: n,
|
|
49
51
|
isBold: p,
|
|
50
52
|
isItalic: u,
|
|
51
53
|
align: a,
|
|
@@ -66,8 +68,8 @@ class T {
|
|
|
66
68
|
`;
|
|
67
69
|
}
|
|
68
70
|
removeStyleProperties(t, e) {
|
|
69
|
-
return t ? e.reduce((s,
|
|
70
|
-
const l = new RegExp(`${
|
|
71
|
+
return t ? e.reduce((s, n) => {
|
|
72
|
+
const l = new RegExp(`${n}\\s*:\\s*[^;]*;?`, "gi");
|
|
71
73
|
return s.replace(l, "");
|
|
72
74
|
}, t).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
|
|
73
75
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { DEFAULT_COMPOSITION as d, DEFAULT_VISIBILITY as I } from "../../../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
2
|
+
import { ATTR_CUSTOM_PREFIX as l, ATTR_PRODUCT_BUTTON as k, ATTR_PRODUCT_OMNIBUS_DISCOUNT as A, ATTR_PRODUCT_OMNIBUS_PRICE as x, ATTR_PRODUCT_OLD_PRICE as f, ATTR_PRODUCT_PRICE as R, ATTR_PRODUCT_NAME as h, ATTR_PRODUCT_IMAGE as y } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
3
|
+
import { mapTextTheme as E, mapButtonTheme as O, mapImageTheme as b } from "./themeMapper.js";
|
|
4
|
+
const C = "__title__", a = "product_attribute.";
|
|
5
|
+
function N(r) {
|
|
6
|
+
const t = r.variable ?? "";
|
|
7
|
+
switch (t) {
|
|
8
|
+
case "p_recommendation_title":
|
|
9
|
+
return { key: C, kind: "title" };
|
|
10
|
+
case "p_image":
|
|
11
|
+
return { key: y, kind: "image" };
|
|
12
|
+
case "p_name":
|
|
13
|
+
return { key: h, kind: "text" };
|
|
14
|
+
case "p_price":
|
|
15
|
+
return { key: R, kind: "text" };
|
|
16
|
+
case "p_original_price":
|
|
17
|
+
return { key: f, kind: "text" };
|
|
18
|
+
case "p_omnibus_price":
|
|
19
|
+
return { key: x, kind: "text" };
|
|
20
|
+
case "p_omnibus_discount":
|
|
21
|
+
return { key: A, kind: "text" };
|
|
22
|
+
case "p_button":
|
|
23
|
+
return { key: k, kind: "button" };
|
|
24
|
+
default:
|
|
25
|
+
if (r.variableType === "p_attribute" || t.startsWith("p_attribute_")) {
|
|
26
|
+
const s = r.value ?? "", o = s.startsWith(a) ? s.slice(a.length) : s;
|
|
27
|
+
return o ? {
|
|
28
|
+
key: `${l}${o}`,
|
|
29
|
+
kind: "custom",
|
|
30
|
+
customAttrName: o,
|
|
31
|
+
customAttrValue: s || `${a}${o}`
|
|
32
|
+
} : null;
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function p(r) {
|
|
38
|
+
const t = d.indexOf(r);
|
|
39
|
+
return t === -1 ? Number.POSITIVE_INFINITY : t;
|
|
40
|
+
}
|
|
41
|
+
function S(r) {
|
|
42
|
+
const t = {
|
|
43
|
+
composition: [],
|
|
44
|
+
visibility: { ...I },
|
|
45
|
+
customAttributes: [],
|
|
46
|
+
customAttrValues: {},
|
|
47
|
+
perElementStyles: {},
|
|
48
|
+
anyTextTrimming: !1
|
|
49
|
+
};
|
|
50
|
+
if (!r || r.length === 0)
|
|
51
|
+
return t.composition = [...d], t;
|
|
52
|
+
const s = [];
|
|
53
|
+
r.forEach((e, i) => {
|
|
54
|
+
const n = N(e);
|
|
55
|
+
if (n) {
|
|
56
|
+
if (n.kind === "title") {
|
|
57
|
+
t.titleVariable = e;
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
s.push({
|
|
61
|
+
key: n.key,
|
|
62
|
+
kind: n.kind,
|
|
63
|
+
hidden: e.hidden === !0,
|
|
64
|
+
positionIdx: typeof e.positionIdx == "number" ? e.positionIdx : Number.MAX_SAFE_INTEGER,
|
|
65
|
+
legacy: e,
|
|
66
|
+
customAttrName: n.customAttrName,
|
|
67
|
+
customAttrValue: n.customAttrValue,
|
|
68
|
+
originalIndex: i
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
}), s.sort((e, i) => {
|
|
72
|
+
if (e.positionIdx !== i.positionIdx)
|
|
73
|
+
return e.positionIdx - i.positionIdx;
|
|
74
|
+
const n = p(e.key), u = p(i.key);
|
|
75
|
+
return n !== u ? n - u : e.originalIndex - i.originalIndex;
|
|
76
|
+
});
|
|
77
|
+
const o = {};
|
|
78
|
+
return s.forEach((e) => {
|
|
79
|
+
const { key: i, kind: n, hidden: u, legacy: m, customAttrName: c, customAttrValue: T } = e;
|
|
80
|
+
switch (t.composition.push(i), t.visibility[i] = !u, n === "custom" && c && T && (t.customAttributes.includes(c) || t.customAttributes.push(c), t.customAttrValues[i] = T), n) {
|
|
81
|
+
case "image":
|
|
82
|
+
o[i] = b(m.theme);
|
|
83
|
+
break;
|
|
84
|
+
case "button":
|
|
85
|
+
o[i] = O(m.theme);
|
|
86
|
+
break;
|
|
87
|
+
case "text":
|
|
88
|
+
case "custom": {
|
|
89
|
+
const _ = E(m.theme);
|
|
90
|
+
o[i] = _, _.textTrimming && (t.anyTextTrimming = !0);
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}), t.perElementStyles = o, t;
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
S as mapComposition
|
|
98
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const i = "You May Also Like!";
|
|
2
|
+
function s(r) {
|
|
3
|
+
var e;
|
|
4
|
+
const o = r.querySelector(".ext-recommendation-title");
|
|
5
|
+
if (!o)
|
|
6
|
+
return i;
|
|
7
|
+
const t = (e = o.textContent) == null ? void 0 : e.trim();
|
|
8
|
+
return t && t.length > 0 ? t : i;
|
|
9
|
+
}
|
|
10
|
+
function u(r) {
|
|
11
|
+
const o = [
|
|
12
|
+
r,
|
|
13
|
+
...Array.from(r.querySelectorAll(".product-card, .ext-recommendation-card"))
|
|
14
|
+
];
|
|
15
|
+
let t = "";
|
|
16
|
+
return o.some((e) => {
|
|
17
|
+
const n = e.getAttribute("bgcolor");
|
|
18
|
+
if (n && n.trim())
|
|
19
|
+
return t = n.trim(), !0;
|
|
20
|
+
const c = (e.getAttribute("style") ?? "").match(/background-color\s*:\s*([^;]+)/i);
|
|
21
|
+
return c && c[1] ? (t = c[1].trim(), !0) : !1;
|
|
22
|
+
}), t;
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
u as extractCardBgColor,
|
|
26
|
+
s as extractTitleText
|
|
27
|
+
};
|