@useinsider/guido 3.3.0-beta.0a507dd → 3.3.0-beta.1778fd7
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/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +103 -89
- package/dist/components/organisms/extensions/recommendation/FilterItem.vue.js +9 -11
- package/dist/components/organisms/extensions/recommendation/FilterItem.vue2.js +70 -35
- package/dist/components/organisms/header/MiddleSlot.vue.js +7 -7
- package/dist/composables/useCortexBlueprintBridge.js +66 -0
- package/dist/composables/useEmailTemplateApplier.js +41 -0
- package/dist/composables/useGuidoStateBridge.js +48 -0
- package/dist/composables/useHtmlValidator.js +41 -36
- package/dist/composables/useRecommendation.js +2 -2
- package/dist/composables/useStripo.js +66 -62
- package/dist/config/migrator/index.js +21 -10
- package/dist/config/migrator/radioButtonMigrator.js +72 -47
- package/dist/enums/extensions/recommendationBlock.js +101 -46
- package/dist/enums/unsubscribe.js +25 -24
- package/dist/extensions/Blocks/Checkbox/control.js +23 -23
- package/dist/extensions/Blocks/RadioButton/control.js +15 -15
- package/dist/extensions/Blocks/RadioButton/template.js +6 -6
- package/dist/extensions/Blocks/Recommendation/block.js +43 -36
- package/dist/extensions/Blocks/Recommendation/services/configService.js +33 -26
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +35 -26
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +25 -12
- package/dist/extensions/Blocks/Recommendation/validation/requiredFields.js +33 -0
- package/dist/guido.css +1 -1
- package/dist/src/composables/useCortexBlueprintBridge.d.ts +25 -0
- package/dist/src/composables/useEmailTemplateApplier.d.ts +21 -0
- package/dist/src/composables/useGuidoStateBridge.d.ts +22 -0
- package/dist/src/enums/extensions/recommendationBlock.d.ts +6 -1
- package/dist/src/enums/unsubscribe.d.ts +8 -3
- package/dist/src/extensions/Blocks/RadioButton/template.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/services/configService.d.ts +11 -3
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +7 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/filterUtil.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/validation/requiredFields.d.ts +21 -0
- package/dist/src/stores/guido-email-editor.d.ts +41 -0
- package/dist/stores/guido-email-editor.js +20 -0
- package/dist/utils/templatePreparation.js +57 -50
- package/package.json +1 -1
|
@@ -1,35 +1,37 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { TemplateTypes as
|
|
3
|
-
import { DISPLAY_CONDITIONS_REGEX as
|
|
1
|
+
import { useConfig as _ } from "./useConfig.js";
|
|
2
|
+
import { TemplateTypes as H } from "../enums/defaults.js";
|
|
3
|
+
import { DISPLAY_CONDITIONS_REGEX as P, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as G, CampaignCouldNotBeSavedKey as M, CanNotMakeAnyChangesForRunningKey as $ } from "../enums/html-validator.js";
|
|
4
4
|
import { ToasterTypeOptions as c } from "../enums/toaster.js";
|
|
5
|
-
import { itemsBlockDynamicVariables as
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
import { itemsBlockDynamicVariables as q } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
6
|
+
import { useRecommendationExtensionStore as X } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
7
|
+
import { RecommendationRequiredFieldsKey as j } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
|
|
8
|
+
import { useRecommendationStore as K } from "../stores/recommendation.js";
|
|
9
|
+
import { base64EncodeWithSpecialChars as z } from "../utils/base64.js";
|
|
10
|
+
import { useHttp as U } from "./useHttp.js";
|
|
11
|
+
import { useToaster as Y } from "./useToaster.js";
|
|
12
|
+
import { useTranslations as Z } from "./useTranslations.js";
|
|
13
|
+
const J = /recommendation-id="(\d+)"/g;
|
|
14
|
+
function Q(a) {
|
|
15
|
+
return [...a.matchAll(J)].map((u) => u[1]);
|
|
14
16
|
}
|
|
15
|
-
function
|
|
17
|
+
function ee(a, u) {
|
|
16
18
|
return u.some((d) => a.startsWith(`${d}_`));
|
|
17
19
|
}
|
|
18
|
-
const
|
|
20
|
+
const ge = () => {
|
|
19
21
|
var y, h;
|
|
20
|
-
const { showToaster: a } =
|
|
22
|
+
const { showToaster: a } = Y(), { post: u } = U(), { config: d } = _(), r = Z(), g = K(), S = X(), p = ((h = (y = d.value) == null ? void 0 : y.partner) == null ? void 0 : h.messageType) === H.transactional, b = async (e) => {
|
|
21
23
|
const t = await u(
|
|
22
24
|
"/newsletter/template-library/check-template-html-body",
|
|
23
|
-
{ html:
|
|
25
|
+
{ html: z(e) }
|
|
24
26
|
), { status: n, message: l } = t.data;
|
|
25
27
|
return n || a({
|
|
26
28
|
type: c.Alert,
|
|
27
29
|
message: n === void 0 ? l : r("newsletter.invalid-url-link-for-toaster")
|
|
28
|
-
}), r(
|
|
30
|
+
}), r(M), l === r($) && a({
|
|
29
31
|
type: c.Alert,
|
|
30
32
|
message: r("newsletter.already-in-progress")
|
|
31
33
|
}), n;
|
|
32
|
-
}, w = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()),
|
|
34
|
+
}, w = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), E = (e) => ["if", "endif"].includes(e.toLowerCase()), A = (e, s) => {
|
|
33
35
|
const t = e.match(/({%(.*?)%})/g);
|
|
34
36
|
let n = !0;
|
|
35
37
|
return t !== null && !p && t.forEach((l) => {
|
|
@@ -42,13 +44,13 @@ const ce = () => {
|
|
|
42
44
|
}), n = !1);
|
|
43
45
|
}
|
|
44
46
|
}), n;
|
|
45
|
-
},
|
|
47
|
+
}, k = async (e, s, t) => {
|
|
46
48
|
const n = t ? await b(e) : !0;
|
|
47
|
-
return
|
|
48
|
-
},
|
|
49
|
+
return A(e, s) && n;
|
|
50
|
+
}, x = (e) => e.length > 0 ? !0 : (a({
|
|
49
51
|
type: c.Warning,
|
|
50
52
|
message: r("newsletter.html-content-is-empty")
|
|
51
|
-
}), !1),
|
|
53
|
+
}), !1), I = (e) => {
|
|
52
54
|
const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
|
|
53
55
|
return s > t && a({
|
|
54
56
|
type: c.Warning,
|
|
@@ -57,7 +59,7 @@ const ce = () => {
|
|
|
57
59
|
type: c.Warning,
|
|
58
60
|
message: r("custom-fields.missing-opening-braces")
|
|
59
61
|
}), s === t;
|
|
60
|
-
},
|
|
62
|
+
}, F = (e) => {
|
|
61
63
|
const s = e.match(/{{\s*(\w+\s+((\w+\|\w+)|(\w+)))\s*}}/gm) === null;
|
|
62
64
|
return s || a({
|
|
63
65
|
type: c.Warning,
|
|
@@ -66,10 +68,10 @@ const ce = () => {
|
|
|
66
68
|
}, T = (e, s) => {
|
|
67
69
|
const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
|
|
68
70
|
if (t && !p) {
|
|
69
|
-
const n = new Set(s.map((i) => i.toLowerCase())), l =
|
|
71
|
+
const n = new Set(s.map((i) => i.toLowerCase())), l = Q(e), o = [];
|
|
70
72
|
if (t.forEach((i) => {
|
|
71
73
|
const m = i.slice(2, -2).trim().toLowerCase();
|
|
72
|
-
(!n.has(m) || m === "") && !
|
|
74
|
+
(!n.has(m) || m === "") && !ee(m, l) && o.push(m);
|
|
73
75
|
}), o.length > 0) {
|
|
74
76
|
const i = `
|
|
75
77
|
<ul>
|
|
@@ -83,11 +85,11 @@ const ce = () => {
|
|
|
83
85
|
}
|
|
84
86
|
}
|
|
85
87
|
return !0;
|
|
86
|
-
},
|
|
88
|
+
}, R = (e) => {
|
|
87
89
|
const s = e.match(/{%(.*?)%}/g), t = [];
|
|
88
90
|
let n = !0;
|
|
89
91
|
if (s && s.forEach((l) => {
|
|
90
|
-
const o = l.match(
|
|
92
|
+
const o = l.match(P), i = l.match(G), m = (o == null ? void 0 : o.join("")) || "";
|
|
91
93
|
(!o || l !== m) && !i && (a({
|
|
92
94
|
type: c.Alert,
|
|
93
95
|
message: r("newsletter.display-conditions-invalid-syntax")
|
|
@@ -98,7 +100,7 @@ const ce = () => {
|
|
|
98
100
|
}), n = !1);
|
|
99
101
|
const v = f.match(/^[a-zA-Z]*$/g);
|
|
100
102
|
v && v.forEach((C) => {
|
|
101
|
-
|
|
103
|
+
E(C) && t.push(C);
|
|
102
104
|
});
|
|
103
105
|
});
|
|
104
106
|
}), t.length) {
|
|
@@ -109,25 +111,28 @@ const ce = () => {
|
|
|
109
111
|
}), n = !1);
|
|
110
112
|
}
|
|
111
113
|
return n;
|
|
112
|
-
},
|
|
114
|
+
}, B = (e) => {
|
|
113
115
|
const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
|
|
114
116
|
return n || a({
|
|
115
117
|
type: c.Warning,
|
|
116
118
|
message: r("custom-conditions.no-space-after-braces")
|
|
117
119
|
}), n;
|
|
118
|
-
},
|
|
120
|
+
}, W = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (a({
|
|
119
121
|
type: c.Warning,
|
|
120
122
|
message: r("custom-conditions.no-braces-inside-if-tag")
|
|
123
|
+
}), !1) : !0, N = () => S.hasInvalidBlock() ? (a({
|
|
124
|
+
type: c.Alert,
|
|
125
|
+
message: r(j)
|
|
121
126
|
}), !1) : !0, O = () => g.recommendationConfigs && Object.values(g.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (a({
|
|
122
127
|
type: c.Alert,
|
|
123
128
|
message: r("newsletter.fill-all-necessary-fields")
|
|
124
|
-
}), !1) : !0,
|
|
129
|
+
}), !1) : !0, D = (e) => {
|
|
125
130
|
const s = /src="[^"]*\.(svg|pst)"/gm;
|
|
126
131
|
return e.match(s) === null ? !0 : (a({
|
|
127
132
|
type: c.Alert,
|
|
128
133
|
message: r("newsletter.invalid-image-type")
|
|
129
134
|
}), !1);
|
|
130
|
-
},
|
|
135
|
+
}, L = (e) => {
|
|
131
136
|
const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
|
|
132
137
|
return Array.from(n).find((o) => {
|
|
133
138
|
var i;
|
|
@@ -136,7 +141,7 @@ const ce = () => {
|
|
|
136
141
|
type: c.Alert,
|
|
137
142
|
message: r("unsubscribe-templates.select-checkbox-groups")
|
|
138
143
|
}), !1) : !0;
|
|
139
|
-
},
|
|
144
|
+
}, V = (e) => {
|
|
140
145
|
const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
|
|
141
146
|
return Array.from(n).find((o) => {
|
|
142
147
|
var i;
|
|
@@ -150,12 +155,12 @@ const ce = () => {
|
|
|
150
155
|
var o, i;
|
|
151
156
|
const n = [
|
|
152
157
|
...s.map((m) => m.value),
|
|
153
|
-
...
|
|
158
|
+
...q,
|
|
154
159
|
...((i = (o = d.value) == null ? void 0 : o.template) == null ? void 0 : i.customFieldAttributes) ?? []
|
|
155
160
|
];
|
|
156
|
-
return await
|
|
161
|
+
return await k(e, n, t) && x(e) && I(e) && F(e) && T(e, n) && R(e) && B(e) && W(e) && N() && O() && D(e) && L(e) && V(e);
|
|
157
162
|
} };
|
|
158
163
|
};
|
|
159
164
|
export {
|
|
160
|
-
|
|
165
|
+
ge as useHtmlValidator
|
|
161
166
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getRecommendationFeedSourceMaps as I, URLS as C } from "../enums/extensions/recommendationBlock.js";
|
|
2
2
|
import { MinDeviceViewport as R, DefaultPadding as b } from "../enums/recommendation.js";
|
|
3
3
|
import { useRecommendationExtensionStore as m } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
4
4
|
import { generateCompleteFilterQuery as h } from "../extensions/Blocks/Recommendation/utils/filterUtil.js";
|
|
@@ -63,7 +63,7 @@ const w = () => ({
|
|
|
63
63
|
shuffleProducts: o.shuffleProducts
|
|
64
64
|
};
|
|
65
65
|
}
|
|
66
|
-
const f = ((l = I.find((i) => i.key === e.strategy)) == null ? void 0 : l.path) || "", t = new URLSearchParams();
|
|
66
|
+
const f = ((l = I().find((i) => i.key === e.strategy)) == null ? void 0 : l.path) || "", t = new URLSearchParams();
|
|
67
67
|
if (t.set("locale", e.language), t.set("currency", e.currencyCode), t.set("partnerName", n.partnerName), t.set("size", e.size), t.set("details", "true"), t.set("campaignId", n.variationId), e.strategy === "manualMerchandising") {
|
|
68
68
|
const i = parseInt(e.size) || 6;
|
|
69
69
|
t.set("productId", e.productIds.slice(0, i).join(","));
|
|
@@ -1,126 +1,130 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useBlocksConfig as
|
|
3
|
-
import { useConfig as
|
|
4
|
-
import { useCustomInterfaceAppearance as
|
|
5
|
-
import { useFullStoryBridge as
|
|
6
|
-
import { useStripoEventHandler as
|
|
7
|
-
import { useToaster as
|
|
8
|
-
import { localePatch as
|
|
9
|
-
import { useStripoApi as
|
|
10
|
-
import
|
|
11
|
-
import { useEditorStore as
|
|
12
|
-
import { dynamicContentToMergeTags as
|
|
13
|
-
import
|
|
14
|
-
const
|
|
15
|
-
const { features:
|
|
16
|
-
var
|
|
17
|
-
const
|
|
18
|
-
|
|
1
|
+
import { useActionsApi as P } from "./useActionsApi.js";
|
|
2
|
+
import { useBlocksConfig as U } from "./useBlocksConfig.js";
|
|
3
|
+
import { useConfig as R } from "./useConfig.js";
|
|
4
|
+
import { useCustomInterfaceAppearance as q } from "./useCustomInterfaceAppearance.js";
|
|
5
|
+
import { useFullStoryBridge as x } from "./useFullStoryBridge.js";
|
|
6
|
+
import { useStripoEventHandler as H } from "./useStripoEventHandler.js";
|
|
7
|
+
import { useToaster as O } from "./useToaster.js";
|
|
8
|
+
import { localePatch as j } from "../config/i18n/index.js";
|
|
9
|
+
import { useStripoApi as L } from "../services/stripoApi.js";
|
|
10
|
+
import $ from "../static/styles/customEditorStyle.css.js";
|
|
11
|
+
import { useEditorStore as b } from "../stores/editor.js";
|
|
12
|
+
import { dynamicContentToMergeTags as z } from "../utils/genericUtil.js";
|
|
13
|
+
import G from "../package.json.js";
|
|
14
|
+
const nt = (w, m) => {
|
|
15
|
+
const { features: p, template: k, isFeatureEnabled: g } = R(), { handleError: f } = O(), { getToken: B, getCustomFonts: T, getSyncModulesStatus: V } = L(), { handleEvent: _ } = H(), { getStripoBlocksConfig: v } = U(), F = async (i, s = [], n = !1) => {
|
|
16
|
+
var E, h, C;
|
|
17
|
+
const t = b(), { html: u, css: a } = i, { baseBlocks: o, extensions: d } = await v(), S = ((E = p.value) == null ? void 0 : E.displayConditions) ?? !0, A = ((h = p.value) == null ? void 0 : h.modulesDisabled) ?? !1, y = ((C = k.value) == null ? void 0 : C.forceRecreate) ?? !1, D = "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com", I = (u.match(/<td[^>]*radio-button-v2[^>]*>/gi) ?? []).map((e) => {
|
|
18
|
+
var l;
|
|
19
|
+
const c = (((l = e.match(/class="([^"]*)"/)) == null ? void 0 : l[1]) ?? "").split(/\s+/).filter(Boolean);
|
|
20
|
+
return { hasBlock: c.includes("radio-button-block"), classes: c };
|
|
21
|
+
});
|
|
22
|
+
console.debug("[guido:radio-migrator] stripo:before-init", { forceRecreate: y, radioTds: I }), window.UIEditor.initEditor(
|
|
19
23
|
document.querySelector("#guido-editor"),
|
|
20
24
|
{
|
|
21
|
-
metadata:
|
|
22
|
-
html:
|
|
25
|
+
metadata: w,
|
|
26
|
+
html: u,
|
|
23
27
|
css: a,
|
|
24
|
-
forceRecreate:
|
|
28
|
+
forceRecreate: y,
|
|
25
29
|
locale: "en",
|
|
26
30
|
undoButtonSelector: "#guido__undo-button",
|
|
27
31
|
redoButtonSelector: "#guido__redo-button",
|
|
28
32
|
mobileViewButtonSelector: ".guido__view-option-selection-mobile",
|
|
29
33
|
desktopViewButtonSelector: ".guido__view-option-selection-desktop",
|
|
30
34
|
codeEditorButtonSelector: "#guido__code-button",
|
|
31
|
-
customAppearanceMergetags: !
|
|
35
|
+
customAppearanceMergetags: !g("liquidSyntax"),
|
|
32
36
|
customAppearanceMergetagsBorderColor: "#f1f3fe",
|
|
33
37
|
customAppearanceMergetagsBackgroundColor: "#f1f3fe",
|
|
34
|
-
customViewStyles:
|
|
35
|
-
conditionsEnabled:
|
|
36
|
-
customConditionsEnabled:
|
|
38
|
+
customViewStyles: $,
|
|
39
|
+
conditionsEnabled: S,
|
|
40
|
+
customConditionsEnabled: S,
|
|
37
41
|
enableXSSSecurity: !0,
|
|
38
|
-
modulesDisabled:
|
|
39
|
-
syncModulesEnabled:
|
|
42
|
+
modulesDisabled: A,
|
|
43
|
+
syncModulesEnabled: n,
|
|
40
44
|
messageSettingsEnabled: !0,
|
|
41
45
|
displayGmailAnnotations: !0,
|
|
42
46
|
displayHiddenPreheader: !1,
|
|
43
47
|
displayTitle: !1,
|
|
44
48
|
displayUTM: !1,
|
|
45
49
|
selectElementAfterDrop: !0,
|
|
46
|
-
allowedScriptSourceDomains:
|
|
50
|
+
allowedScriptSourceDomains: D,
|
|
47
51
|
...o ? { baseBlocks: o } : {},
|
|
48
52
|
editorFonts: {
|
|
49
53
|
showDefaultStandardFonts: !0,
|
|
50
54
|
showDefaultNotStandardFonts: !0,
|
|
51
|
-
customFonts:
|
|
55
|
+
customFonts: s
|
|
52
56
|
},
|
|
53
57
|
mergeTags: [
|
|
54
58
|
{
|
|
55
|
-
entries:
|
|
56
|
-
|
|
57
|
-
|
|
59
|
+
entries: z(
|
|
60
|
+
m.preselectedDynamicContentList,
|
|
61
|
+
g("liquidSyntax")
|
|
58
62
|
)
|
|
59
63
|
}
|
|
60
64
|
],
|
|
61
|
-
async onTokenRefreshRequest(
|
|
65
|
+
async onTokenRefreshRequest(e) {
|
|
62
66
|
try {
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
} catch (
|
|
66
|
-
|
|
67
|
+
const r = await B();
|
|
68
|
+
e(r);
|
|
69
|
+
} catch (r) {
|
|
70
|
+
f(r, "Failed to refresh token");
|
|
67
71
|
}
|
|
68
72
|
},
|
|
69
73
|
onTemplateLoaded() {
|
|
70
74
|
try {
|
|
71
|
-
const { importCss:
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
const { importCss: e } = q(), { activateCustomViewStyles: r, updateTimerInClonedTemplate: c } = P(), { injectFullStory: l } = x();
|
|
76
|
+
e(), r(), l(), c(), m.onReady(), t.isStripoInitialized = !0, t.loadingStatus = !1, setTimeout(() => {
|
|
77
|
+
t.hasChanges = !1;
|
|
74
78
|
}, 1e3);
|
|
75
|
-
} catch (
|
|
76
|
-
|
|
79
|
+
} catch (e) {
|
|
80
|
+
f(e, "Failed to load custom interface appearance");
|
|
77
81
|
}
|
|
78
82
|
},
|
|
79
|
-
onCodeEditorVisibilityChanged(
|
|
80
|
-
|
|
83
|
+
onCodeEditorVisibilityChanged(e) {
|
|
84
|
+
t.isCodeEditorOpen = e;
|
|
81
85
|
},
|
|
82
|
-
onEditorVisualModeChanged(
|
|
83
|
-
|
|
86
|
+
onEditorVisualModeChanged(e) {
|
|
87
|
+
t.editorVisualMode = e.toLowerCase();
|
|
84
88
|
},
|
|
85
|
-
onVersionHistoryVisibilityChanged(
|
|
86
|
-
|
|
89
|
+
onVersionHistoryVisibilityChanged(e) {
|
|
90
|
+
t.isVersionHistoryOpen = e;
|
|
87
91
|
},
|
|
88
92
|
onDataChanged() {
|
|
89
|
-
|
|
93
|
+
t.hasChanges = !0;
|
|
90
94
|
},
|
|
91
|
-
onEvent:
|
|
95
|
+
onEvent: _,
|
|
92
96
|
ignoreClickOutsideSelectors: [
|
|
93
97
|
"#guido-dynamic-content-modal",
|
|
94
98
|
".in-on-board-wrapper",
|
|
95
99
|
".in-drawer__container"
|
|
96
100
|
],
|
|
97
101
|
extensions: d,
|
|
98
|
-
localePatch:
|
|
102
|
+
localePatch: j
|
|
99
103
|
}
|
|
100
104
|
);
|
|
101
|
-
},
|
|
105
|
+
}, M = (i) => new Promise((s, n) => {
|
|
102
106
|
var d;
|
|
103
107
|
if (document.getElementById("UiEditorScript")) {
|
|
104
|
-
i(),
|
|
108
|
+
i(), s();
|
|
105
109
|
return;
|
|
106
110
|
}
|
|
107
|
-
const
|
|
111
|
+
const t = G.guido, a = `https://email-static.useinsider.com/guido/${(d = t == null ? void 0 : t.stripo) == null ? void 0 : d.version}/UIEditor.js`, o = document.createElement("script");
|
|
108
112
|
o.id = "UiEditorScript", o.type = "module", o.src = a, o.onload = () => {
|
|
109
|
-
i(),
|
|
113
|
+
i(), s();
|
|
110
114
|
}, o.onerror = () => {
|
|
111
|
-
|
|
115
|
+
n(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
|
|
112
116
|
}, document.body.appendChild(o);
|
|
113
117
|
});
|
|
114
118
|
return { initPlugin: async (i) => {
|
|
115
|
-
await
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
await M(async () => {
|
|
120
|
+
const s = b(), [n, t] = await Promise.all([
|
|
121
|
+
T(),
|
|
122
|
+
V()
|
|
119
123
|
]);
|
|
120
|
-
|
|
124
|
+
s.syncModulesEnabled = t, await F(i, n, t);
|
|
121
125
|
});
|
|
122
126
|
} };
|
|
123
127
|
};
|
|
124
128
|
export {
|
|
125
|
-
|
|
129
|
+
nt as useStripo
|
|
126
130
|
};
|
|
@@ -1,13 +1,24 @@
|
|
|
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
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { migrateCheckbox as m } from "./checkboxMigrator.js";
|
|
2
|
+
import { migrateCouponBlock as n } from "./couponBlockMigrator.js";
|
|
3
|
+
import { migrateItemsBlock as s } from "./itemsBlockMigrator.js";
|
|
4
|
+
import { migrateRadioButton as c } from "./radioButtonMigrator.js";
|
|
5
|
+
import { migrateRecommendation as d } from "./recommendationMigrator.js";
|
|
6
|
+
import { migrateUnsubscribe as g } from "./unsubscribeMigrator.js";
|
|
7
|
+
const a = (t) => (t.match(/<td[^>]*radio-button-v2[^>]*>/gi) ?? []).map((i) => {
|
|
8
|
+
var e;
|
|
9
|
+
const r = (((e = i.match(/class="([^"]*)"/)) == null ? void 0 : e[1]) ?? "").split(/\s+/).filter(Boolean);
|
|
10
|
+
return { hasBlock: r.includes("radio-button-block"), classes: r };
|
|
11
|
+
}), k = async (t, i = {}) => {
|
|
12
|
+
console.debug("[guido:radio-migrator] pipeline:start", {
|
|
13
|
+
inputLength: t.length,
|
|
14
|
+
radioTds: a(t)
|
|
15
|
+
});
|
|
16
|
+
let o = t;
|
|
17
|
+
return o = m(o), o = c(o), o = await g(o), o = n(o), o = d(o, i), o = s(o), console.debug("[guido:radio-migrator] pipeline:end", {
|
|
18
|
+
outputLength: o.length,
|
|
19
|
+
radioTds: a(o)
|
|
20
|
+
}), o;
|
|
10
21
|
};
|
|
11
22
|
export {
|
|
12
|
-
|
|
23
|
+
k as migrate
|
|
13
24
|
};
|
|
@@ -1,52 +1,77 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
class
|
|
1
|
+
var k = Object.defineProperty;
|
|
2
|
+
var v = (a, e, t) => e in a ? k(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
|
|
3
|
+
var f = (a, e, t) => v(a, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import A from "../../extensions/Blocks/RadioButton/template.js";
|
|
5
|
+
class C {
|
|
6
6
|
constructor() {
|
|
7
|
-
|
|
7
|
+
f(this, "parser");
|
|
8
8
|
this.parser = new DOMParser();
|
|
9
9
|
}
|
|
10
10
|
migrate(e) {
|
|
11
11
|
try {
|
|
12
|
-
const t = this.parser.parseFromString(e, "text/html"),
|
|
13
|
-
if (
|
|
14
|
-
return e;
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
const t = this.parser.parseFromString(e, "text/html"), o = t.querySelectorAll("td.radio-button-block"), s = t.querySelectorAll("td.radio-button-v2");
|
|
13
|
+
if (o.length === 0 && s.length === 0)
|
|
14
|
+
return console.debug("[guido:radio-migrator] skip", { reason: "no radio blocks" }), e;
|
|
15
|
+
console.debug("[guido:radio-migrator] entry", {
|
|
16
|
+
v1BlockCount: o.length,
|
|
17
|
+
v2BlockCount: s.length,
|
|
18
|
+
inputLength: e.length
|
|
19
|
+
});
|
|
20
|
+
let n = !1, i = 0;
|
|
21
|
+
o.forEach((r) => {
|
|
17
22
|
if (r.classList.contains("radio-button-v2"))
|
|
18
23
|
return;
|
|
19
|
-
const
|
|
20
|
-
`<table id="tempDoc"><tbody><tr>${
|
|
24
|
+
const d = r.getAttribute("id"), g = this.extractTextFromElement(r, "ins-title"), p = this.extractTextFromElement(r, "ins-description"), m = this.extractTextFromElement(r, "ins-subscribe"), b = this.extractTextFromElement(r, "ins-unsubscribe"), y = this.buildTextBlock(g), x = this.buildTextBlock(p), T = this.buildTextBlock({ ...m, classList: "" }), B = this.buildTextBlock({ ...b, classList: "" }), S = A.replace("{-{-TITLE-}-}", y).replace("{-{-DESCRIPTION-}-}", x).replace("{-{-YES-}-}", T).replace("{-{-NO-}-}", B), h = this.parser.parseFromString(
|
|
25
|
+
`<table id="tempDoc"><tbody><tr>${S}</tr></tbody></table>`,
|
|
21
26
|
"text/html"
|
|
22
27
|
).querySelector(".radio-button-v2");
|
|
23
|
-
|
|
24
|
-
})
|
|
28
|
+
h && r.parentNode && (h.setAttribute("id", d || ""), r.parentNode.replaceChild(h, r), n = !0, i++);
|
|
29
|
+
});
|
|
30
|
+
const l = this.healRadioButtonV2(t);
|
|
31
|
+
n = l || n;
|
|
32
|
+
const c = n ? t.documentElement.outerHTML : e, u = (c.match(/<td[^>]*radio-button-v2[^>]*>/gi) ?? []).map((r) => {
|
|
33
|
+
var g;
|
|
34
|
+
return (((g = r.match(/class="([^"]*)"/)) == null ? void 0 : g[1]) ?? "").split(/\s+/).filter(Boolean).includes("radio-button-block");
|
|
35
|
+
});
|
|
36
|
+
return console.debug("[guido:radio-migrator] exit", {
|
|
37
|
+
v1Converted: i,
|
|
38
|
+
healingMutated: l,
|
|
39
|
+
mutated: n,
|
|
40
|
+
finalV2HasBlock: u,
|
|
41
|
+
outputLength: c.length
|
|
42
|
+
}), c;
|
|
25
43
|
} catch (t) {
|
|
26
|
-
return console.error("
|
|
44
|
+
return console.error("[guido:radio-migrator] failed:", t), e;
|
|
27
45
|
}
|
|
28
46
|
}
|
|
29
47
|
healRadioButtonV2(e) {
|
|
30
|
-
let t = !1;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
48
|
+
let t = !1, o = 0, s = 0;
|
|
49
|
+
const n = e.querySelectorAll("td.radio-button-v2");
|
|
50
|
+
return n.forEach((i) => {
|
|
51
|
+
var y;
|
|
52
|
+
i.classList.contains("radio-button-block") || (i.classList.add("radio-button-block"), o++, t = !0);
|
|
53
|
+
const l = i.querySelector("input#radioYes"), c = i.querySelector("input#radioNo");
|
|
54
|
+
if (!l || !c)
|
|
35
55
|
return;
|
|
36
|
-
const
|
|
37
|
-
if (!
|
|
56
|
+
const u = ((y = l.parentElement) == null ? void 0 : y.querySelector(":scope > p")) || null;
|
|
57
|
+
if (!u && !l.hasAttribute("align"))
|
|
38
58
|
return;
|
|
39
|
-
const
|
|
40
|
-
if (!
|
|
59
|
+
const r = l.closest("tr"), d = c.closest("tr");
|
|
60
|
+
if (!r || !d || r === d || !r.parentNode)
|
|
41
61
|
return;
|
|
42
|
-
const g = (
|
|
43
|
-
|
|
62
|
+
const g = (u == null ? void 0 : u.innerHTML.trim()) || "Yes", p = d.cloneNode(!0), m = p.querySelector("input#radioNo"), b = p.querySelector("p");
|
|
63
|
+
m && (m.setAttribute("id", "radioYes"), m.removeAttribute("align")), b && (b.innerHTML = g), r.parentNode.replaceChild(p, r), s++, t = !0;
|
|
64
|
+
}), console.debug("[guido:radio-migrator] healing", {
|
|
65
|
+
v2BlockCount: n.length,
|
|
66
|
+
classAddedCount: o,
|
|
67
|
+
rowHealedCount: s,
|
|
68
|
+
mutated: t
|
|
44
69
|
}), t;
|
|
45
70
|
}
|
|
46
71
|
extractTextFromElement(e, t) {
|
|
47
|
-
var p,
|
|
48
|
-
const
|
|
49
|
-
if (!
|
|
72
|
+
var p, m;
|
|
73
|
+
const o = e.querySelector(`.${t}`);
|
|
74
|
+
if (!o)
|
|
50
75
|
return {
|
|
51
76
|
text: t === "ins-title" ? "Title" : "Description",
|
|
52
77
|
isBold: !1,
|
|
@@ -55,32 +80,32 @@ class B {
|
|
|
55
80
|
styles: "",
|
|
56
81
|
classList: ""
|
|
57
82
|
};
|
|
58
|
-
const s =
|
|
83
|
+
const s = o.querySelector("p");
|
|
59
84
|
if (!s)
|
|
60
85
|
return {
|
|
61
|
-
text: ((p =
|
|
86
|
+
text: ((p = o.textContent) == null ? void 0 : p.trim()) || (t === "ins-title" ? "Title" : "Description"),
|
|
62
87
|
isBold: !1,
|
|
63
88
|
isItalic: !1,
|
|
64
|
-
align:
|
|
89
|
+
align: o.getAttribute("align") || "left",
|
|
65
90
|
styles: "",
|
|
66
91
|
classList: ""
|
|
67
92
|
};
|
|
68
|
-
const
|
|
93
|
+
const n = ((m = s.textContent) == null ? void 0 : m.trim()) || (t === "ins-title" ? "Title" : "Description"), i = s.getAttribute("style") || "", l = o.getAttribute("align") || s.getAttribute("align") || "left", c = /font-weight\s*:\s*bold/i.test(i) || !!s.querySelector("b, strong"), u = /font-style\s*:\s*italic/i.test(i) || !!s.querySelector("i, em"), r = this.removeStyleProperties(i, ["font-weight", "font-style"]), d = this.convertInlineToBlock(r), g = o.getAttribute("class") || "";
|
|
69
94
|
return {
|
|
70
|
-
text:
|
|
71
|
-
isBold:
|
|
72
|
-
isItalic:
|
|
73
|
-
align:
|
|
74
|
-
styles:
|
|
75
|
-
classList:
|
|
95
|
+
text: n,
|
|
96
|
+
isBold: c,
|
|
97
|
+
isItalic: u,
|
|
98
|
+
align: l,
|
|
99
|
+
styles: d,
|
|
100
|
+
classList: g
|
|
76
101
|
};
|
|
77
102
|
}
|
|
78
103
|
buildTextBlock(e) {
|
|
79
104
|
let t = e.text;
|
|
80
105
|
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>`);
|
|
81
|
-
const
|
|
106
|
+
const o = e.align ? ` align="${e.align}"` : "", s = e.styles ? ` style="${e.styles.replaceAll('"', "'")}"` : "";
|
|
82
107
|
return `
|
|
83
|
-
<td class="esd-block-text ${e.classList}" ${
|
|
108
|
+
<td class="esd-block-text ${e.classList}" ${o}>
|
|
84
109
|
<p path="1" ${s}>
|
|
85
110
|
${t}
|
|
86
111
|
</p>
|
|
@@ -88,9 +113,9 @@ class B {
|
|
|
88
113
|
`;
|
|
89
114
|
}
|
|
90
115
|
removeStyleProperties(e, t) {
|
|
91
|
-
return e ? t.reduce((s,
|
|
92
|
-
const
|
|
93
|
-
return s.replace(
|
|
116
|
+
return e ? t.reduce((s, n) => {
|
|
117
|
+
const i = new RegExp(`${n}\\s*:\\s*[^;]*;?`, "gi");
|
|
118
|
+
return s.replace(i, "");
|
|
94
119
|
}, e).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
|
|
95
120
|
}
|
|
96
121
|
convertInlineToBlock(e) {
|
|
@@ -100,8 +125,8 @@ class B {
|
|
|
100
125
|
return /display\s*:/i.test(t) || (t = t ? `${t}; display: block` : "display: block"), t.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
|
|
101
126
|
}
|
|
102
127
|
}
|
|
103
|
-
function q(
|
|
104
|
-
return new
|
|
128
|
+
function q(a) {
|
|
129
|
+
return new C().migrate(a);
|
|
105
130
|
}
|
|
106
131
|
export {
|
|
107
132
|
q as migrateRadioButton
|