@useinsider/guido 3.24.0-beta.88c24c1 → 3.24.0-beta.8e9f4e2
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 +6 -2
- package/dist/@types/config/schemas.js +9 -11
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +1 -1
- package/dist/composables/useActionsApi.js +2 -2
- package/dist/composables/useEditorTrackingIds.js +49 -0
- package/dist/composables/useHtmlCompiler.js +2 -0
- package/dist/composables/useSave.js +52 -57
- package/dist/composables/useSaveValidation.js +110 -118
- package/dist/composables/useStripo.js +70 -70
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +33 -48
- package/dist/config/compiler/htmlCompilerRules.js +14 -6
- package/dist/config/migrator/recommendation/inferLegacyConfig.js +133 -0
- package/dist/config/migrator/recommendationMigrator.js +69 -63
- package/dist/enums/save-validation.js +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +10 -8
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +28 -24
- package/dist/extensions/Blocks/Recommendation/utils/nodeConfigWriter.js +23 -22
- package/dist/guido.css +1 -1
- package/dist/package.json.js +4 -4
- package/dist/services/templateLibraryApi.js +39 -36
- package/dist/src/@types/config/schemas.d.ts +0 -4
- package/dist/src/composables/useConfig.d.ts +0 -2
- package/dist/src/composables/useEditorTrackingIds.d.ts +7 -0
- package/dist/src/composables/useSaveValidation.d.ts +1 -1
- package/dist/src/composables/useStripo.d.ts +1 -1
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +0 -4
- package/dist/src/config/migrator/recommendation/inferLegacyConfig.d.ts +6 -0
- package/dist/src/config/migrator/recommendation/parseLegacyConfig.d.ts +1 -1
- package/dist/src/config/migrator/recommendationMigrator.d.ts +1 -5
- package/dist/src/enums/save-validation.d.ts +1 -2
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
- package/dist/src/stores/config.d.ts +0 -20
- package/dist/src/utils/linkTrackingIds.d.ts +19 -0
- package/dist/src/utils/trimHrefWhitespace.d.ts +5 -0
- package/dist/utils/linkTrackingIds.js +82 -48
- package/dist/utils/templatePreparation.js +30 -33
- package/dist/utils/trimHrefWhitespace.js +10 -0
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { getIgnoredRecommendationBlockIds as Y } from "../config/compiler/utils/recommendationIgnoreUtils.js";
|
|
2
|
-
import { CanNotMakeAnyChangesForRunningKey as k, DISPLAY_CONDITIONS_REGEX as
|
|
2
|
+
import { CanNotMakeAnyChangesForRunningKey as k, DISPLAY_CONDITIONS_REGEX as x, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as M } from "../enums/html-validator.js";
|
|
3
3
|
import { SaveValidationRule as o } from "../enums/save-validation.js";
|
|
4
4
|
import { ToasterTypeOptions as r } from "../enums/toaster.js";
|
|
5
|
-
import { BLOCK_ROOT_SELECTOR as
|
|
6
|
-
import { itemsBlockDynamicVariables as
|
|
7
|
-
import { BLOCK_ROOT_SELECTOR as
|
|
8
|
-
import { useRecommendationExtensionStore as
|
|
5
|
+
import { BLOCK_ROOT_SELECTOR as U } from "../extensions/Blocks/Checkbox/constants/selectors.js";
|
|
6
|
+
import { itemsBlockDynamicVariables as P } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
7
|
+
import { BLOCK_ROOT_SELECTOR as W } from "../extensions/Blocks/RadioButton/constants/selectors.js";
|
|
8
|
+
import { useRecommendationExtensionStore as G } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
9
9
|
import { getInvalidFields as q, STRATEGY_FIELD_KEY as H, RecommendationAssignStrategyKey as V, RecommendationRequiredFieldsKey as X } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
|
|
10
10
|
import { useConfigStore as j } from "../stores/config.js";
|
|
11
11
|
import { useDynamicContentStore as z } from "../stores/dynamic-content.js";
|
|
@@ -20,9 +20,9 @@ import { buildPartnerAttributeNameSet as ne, getInvalidDynamicContentTags as ie,
|
|
|
20
20
|
import { useHttp as se } from "./useHttp.js";
|
|
21
21
|
import { useTranslations as ae } from "./useTranslations.js";
|
|
22
22
|
import { findInvalidCouponBlocks as ce, COUPON_TAG_MODIFIED_KEY as le } from "./validators/useCouponBlockValidator.js";
|
|
23
|
-
import {
|
|
24
|
-
const
|
|
25
|
-
function
|
|
23
|
+
import { findDuplicateUnsubPageTypes as me, countUnsubBlocksWithoutPage as ue, EMPTY_BLOCK_KEY as de } from "./validators/useUnsubscribeBlockValidator.js";
|
|
24
|
+
const pe = "newsletter.html-content-is-empty", ge = "custom-fields.missing-closing-braces", fe = "custom-fields.missing-opening-braces", S = "custom-fields.invalid-custom-fields", ye = "newsletter.display-conditions-invalid-syntax", Ee = "custom-conditions.wrong-equality-operators", Ie = "custom-conditions.missing-if-endif-tag", Se = "custom-conditions.no-space-after-braces", _e = "custom-conditions.no-braces-inside-if-tag", Ce = "newsletter.fill-all-necessary-fields", he = "newsletter.invalid-image-type", ke = "unsubscribe-templates.select-checkbox-groups", Te = "unsubscribe-templates.select-radio-button-groups", F = "newsletter.invalid-url-link-for-toaster", R = "journey-builder.liquid-validation-failed", Fe = "/newsletter/template-library/check-template-html-body", Re = /src="[^"]*\.(svg|pst)"/gm, L = /({%(.*?)%})/g, Oe = ["if", "endif", "else", "elif", "now"], Le = (t) => !Oe.includes(t.toLowerCase()), Ne = (t) => ["if", "endif"].includes(t.toLowerCase());
|
|
25
|
+
function be(t) {
|
|
26
26
|
return ce(t).map((i) => ({
|
|
27
27
|
rule: o.CouponTagModified,
|
|
28
28
|
type: r.Warning,
|
|
@@ -30,61 +30,54 @@ function De(t) {
|
|
|
30
30
|
detail: i
|
|
31
31
|
}));
|
|
32
32
|
}
|
|
33
|
-
function
|
|
34
|
-
return
|
|
33
|
+
function Ae(t) {
|
|
34
|
+
return me(t).map((i) => ({
|
|
35
35
|
rule: o.DuplicateUnsubBlock,
|
|
36
36
|
type: r.Error,
|
|
37
37
|
key: i.messageKey
|
|
38
38
|
}));
|
|
39
39
|
}
|
|
40
|
-
function
|
|
41
|
-
return Array.from({ length:
|
|
40
|
+
function ve(t) {
|
|
41
|
+
return Array.from({ length: ue(t) }, () => ({
|
|
42
42
|
rule: o.UnsubBlockMissingTemplate,
|
|
43
43
|
type: r.Warning,
|
|
44
|
-
key:
|
|
44
|
+
key: de
|
|
45
45
|
}));
|
|
46
46
|
}
|
|
47
|
-
function
|
|
48
|
-
return ue(t) ? [{
|
|
49
|
-
rule: o.ExternallyManagedUnsubscribe,
|
|
50
|
-
type: r.Warning,
|
|
51
|
-
key: me
|
|
52
|
-
}] : [];
|
|
53
|
-
}
|
|
54
|
-
function we(t, i) {
|
|
47
|
+
function De(t, i) {
|
|
55
48
|
const n = t.match(L);
|
|
56
49
|
if (!n)
|
|
57
50
|
return [];
|
|
58
|
-
const
|
|
59
|
-
return n.forEach((
|
|
60
|
-
const c =
|
|
51
|
+
const l = [];
|
|
52
|
+
return n.forEach((u) => {
|
|
53
|
+
const c = u.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
|
|
61
54
|
if (c && c.length > 0) {
|
|
62
55
|
const [d] = c;
|
|
63
|
-
|
|
56
|
+
Le(d) && !i.includes(d) && l.push({
|
|
64
57
|
rule: o.CustomFieldScript,
|
|
65
58
|
type: r.Warning,
|
|
66
59
|
key: S,
|
|
67
60
|
detail: d
|
|
68
61
|
});
|
|
69
62
|
}
|
|
70
|
-
}),
|
|
63
|
+
}), l;
|
|
71
64
|
}
|
|
72
|
-
function
|
|
73
|
-
return t.length > 0 ? [] : [{ rule: o.EmptyHtml, type: r.Warning, key:
|
|
65
|
+
function Ke(t) {
|
|
66
|
+
return t.length > 0 ? [] : [{ rule: o.EmptyHtml, type: r.Warning, key: pe }];
|
|
74
67
|
}
|
|
75
|
-
function
|
|
68
|
+
function we(t) {
|
|
76
69
|
const i = (t.match(/{/gm) || []).length, n = (t.match(/}/gm) || []).length;
|
|
77
70
|
return i > n ? [{
|
|
78
71
|
rule: o.MismatchedBraces,
|
|
79
72
|
type: r.Warning,
|
|
80
|
-
key:
|
|
73
|
+
key: ge
|
|
81
74
|
}] : i < n ? [{
|
|
82
75
|
rule: o.MismatchedBraces,
|
|
83
76
|
type: r.Warning,
|
|
84
|
-
key:
|
|
77
|
+
key: fe
|
|
85
78
|
}] : [];
|
|
86
79
|
}
|
|
87
|
-
function
|
|
80
|
+
function Be(t) {
|
|
88
81
|
return ie(t).map((i) => ({
|
|
89
82
|
rule: o.InvalidDynamicTag,
|
|
90
83
|
type: r.Warning,
|
|
@@ -92,75 +85,75 @@ function Me(t) {
|
|
|
92
85
|
detail: i
|
|
93
86
|
}));
|
|
94
87
|
}
|
|
95
|
-
function
|
|
96
|
-
const
|
|
97
|
-
return re(t, i,
|
|
88
|
+
function Ye(t, i, n, l) {
|
|
89
|
+
const u = oe(t);
|
|
90
|
+
return re(t, i, u, n, l).map((c) => ({
|
|
98
91
|
rule: o.InvalidCustomField,
|
|
99
92
|
type: r.Error,
|
|
100
93
|
key: S,
|
|
101
94
|
detail: c
|
|
102
95
|
}));
|
|
103
96
|
}
|
|
104
|
-
function
|
|
105
|
-
const i = t.match(/{%(.*?)%}/g), n = [],
|
|
106
|
-
if (i && i.forEach((
|
|
107
|
-
const c =
|
|
108
|
-
(!c ||
|
|
97
|
+
function xe(t) {
|
|
98
|
+
const i = t.match(/{%(.*?)%}/g), n = [], l = [];
|
|
99
|
+
if (i && i.forEach((u) => {
|
|
100
|
+
const c = u.match(x), d = u.match(M), I = (c == null ? void 0 : c.join("")) || "";
|
|
101
|
+
(!c || u !== I) && !d && l.push({
|
|
109
102
|
rule: o.ConditionsSyntax,
|
|
110
103
|
type: r.Error,
|
|
111
|
-
key:
|
|
112
|
-
detail:
|
|
104
|
+
key: ye,
|
|
105
|
+
detail: u
|
|
113
106
|
}), c && c.forEach((g) => {
|
|
114
|
-
g.trim() === "=" &&
|
|
107
|
+
g.trim() === "=" && l.push({
|
|
115
108
|
rule: o.WrongEqualityOperator,
|
|
116
109
|
type: r.Error,
|
|
117
|
-
key:
|
|
110
|
+
key: Ee
|
|
118
111
|
}), (g.match(/^[a-zA-Z]*$/g) ?? []).forEach((f) => {
|
|
119
|
-
|
|
112
|
+
Ne(f) && n.push(f);
|
|
120
113
|
});
|
|
121
114
|
});
|
|
122
115
|
}), n.length) {
|
|
123
|
-
const
|
|
124
|
-
|
|
116
|
+
const u = n.filter((d) => d === "if").length, c = n.filter((d) => d === "endif").length;
|
|
117
|
+
u !== c && l.push({
|
|
125
118
|
rule: o.MissingIfEndif,
|
|
126
119
|
type: r.Error,
|
|
127
|
-
key:
|
|
120
|
+
key: Ie
|
|
128
121
|
});
|
|
129
122
|
}
|
|
130
|
-
return
|
|
123
|
+
return l;
|
|
131
124
|
}
|
|
132
|
-
function
|
|
125
|
+
function Me(t) {
|
|
133
126
|
const i = (t.match(/{% /gm) || []).length, n = (t.match(/ %}/gm) || []).length;
|
|
134
127
|
return i === n ? [] : [{
|
|
135
128
|
rule: o.ConditionTagSpacing,
|
|
136
129
|
type: r.Warning,
|
|
137
|
-
key:
|
|
130
|
+
key: Se
|
|
138
131
|
}];
|
|
139
132
|
}
|
|
140
|
-
function
|
|
141
|
-
return (t.match(L) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n,
|
|
133
|
+
function Ue(t) {
|
|
134
|
+
return (t.match(L) || []).filter((n) => n.includes("if")).map((n) => (n.match(/{{.*}}/gm) || []).length).reduce((n, l) => n + l, 0) === 0 ? [] : [{
|
|
142
135
|
rule: o.BracesInsideIfTag,
|
|
143
136
|
type: r.Warning,
|
|
144
|
-
key:
|
|
137
|
+
key: _e
|
|
145
138
|
}];
|
|
146
139
|
}
|
|
147
|
-
function
|
|
148
|
-
return (t.match(
|
|
140
|
+
function Pe(t) {
|
|
141
|
+
return (t.match(Re) ?? []).map((i) => ({
|
|
149
142
|
rule: o.InvalidImageType,
|
|
150
143
|
type: r.Error,
|
|
151
|
-
key:
|
|
144
|
+
key: he,
|
|
152
145
|
detail: i
|
|
153
146
|
}));
|
|
154
147
|
}
|
|
155
|
-
function
|
|
156
|
-
const
|
|
157
|
-
return Array.from(
|
|
148
|
+
function O(t, i, n, l) {
|
|
149
|
+
const u = new DOMParser().parseFromString(t, "text/html");
|
|
150
|
+
return Array.from(u.querySelectorAll(i)).filter((c) => {
|
|
158
151
|
var d;
|
|
159
152
|
return !((d = c.id) != null && d.trim());
|
|
160
|
-
}).map(() => ({ rule: n, type: r.Error, key:
|
|
153
|
+
}).map(() => ({ rule: n, type: r.Error, key: l }));
|
|
161
154
|
}
|
|
162
|
-
const
|
|
163
|
-
const { config: t, isFeatureEnabled: i } = ee(), n = ae(), { post:
|
|
155
|
+
const dt = () => {
|
|
156
|
+
const { config: t, isFeatureEnabled: i } = ee(), n = ae(), { post: l } = se(), { getCompiledEmail: u, getTemplateData: c } = J(), { compileHtml: d } = te(), { hydrateRecommendationStore: I } = Z(), g = z(), f = $(), y = G(), N = j(), b = (e) => ({
|
|
164
157
|
rule: e.rule,
|
|
165
158
|
type: e.type,
|
|
166
159
|
detail: e.detail,
|
|
@@ -174,24 +167,24 @@ const ft = () => {
|
|
|
174
167
|
return null;
|
|
175
168
|
}
|
|
176
169
|
return ne(y.filterList);
|
|
177
|
-
},
|
|
170
|
+
}, v = async (e) => {
|
|
178
171
|
try {
|
|
179
|
-
const
|
|
180
|
-
return
|
|
172
|
+
const s = await l(Fe, { html: T(e) }), { status: a, message: m } = s.data, p = [], E = a === void 0 && !!m && m !== n(F);
|
|
173
|
+
return a || p.push({
|
|
181
174
|
rule: o.InvalidLinks,
|
|
182
175
|
type: r.Error,
|
|
183
|
-
...E ? { message:
|
|
184
|
-
}),
|
|
176
|
+
...E ? { message: m } : { key: F }
|
|
177
|
+
}), m === n(k) && p.push({
|
|
185
178
|
rule: o.LinkCheckInProgress,
|
|
186
179
|
type: r.Error,
|
|
187
180
|
key: k
|
|
188
181
|
}), p;
|
|
189
|
-
} catch (
|
|
190
|
-
return console.warn("Link-check collector failed; skipping the link rule.",
|
|
182
|
+
} catch (s) {
|
|
183
|
+
return console.warn("Link-check collector failed; skipping the link rule.", s), [];
|
|
191
184
|
}
|
|
192
|
-
},
|
|
185
|
+
}, D = async (e) => {
|
|
193
186
|
try {
|
|
194
|
-
const
|
|
187
|
+
const s = await l("/newsletter/contents/validate-syntax", [{
|
|
195
188
|
identifier: "default",
|
|
196
189
|
syntax: "liquid",
|
|
197
190
|
contents: {
|
|
@@ -201,89 +194,88 @@ const ft = () => {
|
|
|
201
194
|
ampHtml: null
|
|
202
195
|
}
|
|
203
196
|
}]);
|
|
204
|
-
if (!Array.isArray(
|
|
205
|
-
const
|
|
197
|
+
if (!Array.isArray(s.data)) {
|
|
198
|
+
const m = s.data;
|
|
206
199
|
return [{
|
|
207
200
|
rule: o.LiquidSyntax,
|
|
208
201
|
type: r.Warning,
|
|
209
|
-
message:
|
|
202
|
+
message: m.message ?? n(R)
|
|
210
203
|
}];
|
|
211
204
|
}
|
|
212
|
-
const [
|
|
213
|
-
return Object.values((
|
|
205
|
+
const [a] = s.data;
|
|
206
|
+
return Object.values((a == null ? void 0 : a.errors) ?? {}).map((m) => ({
|
|
214
207
|
rule: o.LiquidSyntax,
|
|
215
208
|
type: r.Warning,
|
|
216
|
-
message:
|
|
209
|
+
message: m.replace(/^line \d+:\s*/, "")
|
|
217
210
|
}));
|
|
218
|
-
} catch (
|
|
219
|
-
if (
|
|
220
|
-
throw
|
|
211
|
+
} catch (s) {
|
|
212
|
+
if (s != null && s.authReported)
|
|
213
|
+
throw s;
|
|
221
214
|
return [{
|
|
222
215
|
rule: o.LiquidSyntax,
|
|
223
216
|
type: r.Error,
|
|
224
|
-
message: n(
|
|
217
|
+
message: n(R)
|
|
225
218
|
}];
|
|
226
219
|
}
|
|
227
220
|
}, K = () => {
|
|
228
|
-
const e = Object.values(y.blockStates).map((
|
|
229
|
-
const
|
|
221
|
+
const e = Object.values(y.blockStates).map((a) => q(a.recommendationConfigs, y)).filter((a) => a.length > 0).map((a) => {
|
|
222
|
+
const m = a.every((p) => p === H);
|
|
230
223
|
return {
|
|
231
224
|
rule: o.RecommendationRequiredFields,
|
|
232
|
-
type:
|
|
233
|
-
key:
|
|
225
|
+
type: m ? r.Warning : r.Error,
|
|
226
|
+
key: m ? V : X
|
|
234
227
|
};
|
|
235
|
-
}),
|
|
228
|
+
}), s = (f.recommendationConfigs ?? []).filter((a) => a.filters.some((m) => m.value === "")).map(() => ({
|
|
236
229
|
rule: o.RecommendationFilters,
|
|
237
230
|
type: r.Error,
|
|
238
|
-
key:
|
|
231
|
+
key: Ce
|
|
239
232
|
}));
|
|
240
|
-
return [...e, ...
|
|
241
|
-
},
|
|
233
|
+
return [...e, ...s];
|
|
234
|
+
}, w = async (e, s) => {
|
|
242
235
|
var C, h;
|
|
243
|
-
const
|
|
244
|
-
...
|
|
245
|
-
...
|
|
236
|
+
const a = [
|
|
237
|
+
...s.map((B) => B.value),
|
|
238
|
+
...P,
|
|
246
239
|
...((h = (C = t.value) == null ? void 0 : C.template) == null ? void 0 : h.customFieldAttributes) ?? []
|
|
247
|
-
],
|
|
240
|
+
], m = Y(e), p = await A(m), { isTransactional: E } = N;
|
|
248
241
|
return [
|
|
249
|
-
...await
|
|
250
|
-
...E ? [] :
|
|
251
|
-
...
|
|
252
|
-
...
|
|
242
|
+
...await v(e),
|
|
243
|
+
...E ? [] : De(e, a),
|
|
244
|
+
...Ke(e),
|
|
245
|
+
...we(e),
|
|
246
|
+
...Be(e),
|
|
247
|
+
...E ? [] : Ye(e, a, m, p),
|
|
248
|
+
...xe(e),
|
|
253
249
|
...Me(e),
|
|
254
|
-
...
|
|
255
|
-
...We(e),
|
|
256
|
-
...Ge(e),
|
|
257
|
-
...Pe(e),
|
|
250
|
+
...Ue(e),
|
|
258
251
|
...K(),
|
|
259
|
-
...
|
|
260
|
-
...
|
|
252
|
+
...Pe(e),
|
|
253
|
+
...O(
|
|
261
254
|
e,
|
|
262
|
-
|
|
255
|
+
U,
|
|
263
256
|
o.CheckboxUnsubGroup,
|
|
264
|
-
|
|
257
|
+
ke
|
|
265
258
|
),
|
|
266
|
-
...
|
|
259
|
+
...O(
|
|
267
260
|
e,
|
|
268
|
-
|
|
261
|
+
W,
|
|
269
262
|
o.RadioButtonUnsubGroup,
|
|
270
|
-
|
|
263
|
+
Te
|
|
271
264
|
)
|
|
272
265
|
];
|
|
273
|
-
}, _ = async (e,
|
|
274
|
-
...
|
|
275
|
-
...
|
|
266
|
+
}, _ = async (e, s) => [
|
|
267
|
+
...be(e),
|
|
268
|
+
...Ae(e),
|
|
276
269
|
...ve(e),
|
|
277
|
-
...
|
|
278
|
-
|
|
279
|
-
].map(O);
|
|
270
|
+
...i("liquidSyntax") ? await D(e) : await w(e, s)
|
|
271
|
+
].map(b);
|
|
280
272
|
return { collectSaveValidationErrors: _, validateCurrentTemplate: async () => {
|
|
281
273
|
const { html: e } = await c();
|
|
282
274
|
await I(e);
|
|
283
|
-
const { html:
|
|
284
|
-
return _(
|
|
275
|
+
const { html: s } = await u({ minimize: !0, resetDataSavedFlag: !1 }), { compiledHtml: a } = d(s);
|
|
276
|
+
return _(a, g.getSelectedDynamicContentList);
|
|
285
277
|
} };
|
|
286
278
|
};
|
|
287
279
|
export {
|
|
288
|
-
|
|
280
|
+
dt as useSaveValidation
|
|
289
281
|
};
|
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import { useBlocksConfig as
|
|
3
|
-
import { useConfig as
|
|
4
|
-
import { useCustomInterfaceAppearance as
|
|
5
|
-
import { useFullStoryBridge as
|
|
6
|
-
import { useModuleRepair as
|
|
7
|
-
import { useStripoEventHandler as
|
|
8
|
-
import { useStripoNotifications as
|
|
9
|
-
import { useToaster as
|
|
10
|
-
import { localePatch as
|
|
1
|
+
import { useActionsApi as N } from "./useActionsApi.js";
|
|
2
|
+
import { useBlocksConfig as j } from "./useBlocksConfig.js";
|
|
3
|
+
import { useConfig as z } from "./useConfig.js";
|
|
4
|
+
import { useCustomInterfaceAppearance as v } from "./useCustomInterfaceAppearance.js";
|
|
5
|
+
import { useFullStoryBridge as $ } from "./useFullStoryBridge.js";
|
|
6
|
+
import { useModuleRepair as G } from "./useModuleRepair.js";
|
|
7
|
+
import { useStripoEventHandler as X } from "./useStripoEventHandler.js";
|
|
8
|
+
import { useStripoNotifications as J } from "./useStripoNotifications.js";
|
|
9
|
+
import { useToaster as K } from "./useToaster.js";
|
|
10
|
+
import { localePatch as Q } from "../config/i18n/index.js";
|
|
11
11
|
import { en as B } from "../config/i18n/en/index.js";
|
|
12
|
-
import { ToasterTypeOptions as
|
|
13
|
-
import { useStripoApi as
|
|
14
|
-
import
|
|
15
|
-
import { useEditorStore as
|
|
16
|
-
import { buildMergeTagEntries as
|
|
17
|
-
import { getStripoRuntimeBaseUrl as
|
|
18
|
-
let d = null,
|
|
19
|
-
const
|
|
20
|
-
const { features: u, template: m, isFeatureEnabled: p } =
|
|
12
|
+
import { ToasterTypeOptions as W } from "../enums/toaster.js";
|
|
13
|
+
import { useStripoApi as Y } from "../services/stripoApi.js";
|
|
14
|
+
import Z from "../static/styles/customEditorStyle.css.js";
|
|
15
|
+
import { useEditorStore as T } from "../stores/editor.js";
|
|
16
|
+
import { buildMergeTagEntries as ee, flattenDynamicContentList as te } from "../utils/genericUtil.js";
|
|
17
|
+
import { getStripoRuntimeBaseUrl as oe } from "../utils/stripoRuntime.js";
|
|
18
|
+
let d = null, F = !1;
|
|
19
|
+
const ke = (t) => {
|
|
20
|
+
const { features: u, template: m, isFeatureEnabled: p } = z(), { handleError: f, showToaster: A } = K(), { getToken: P, getCustomFonts: R, getSyncModulesStatus: U } = Y(), { handleEvent: V } = X(), { handleModuleAdd: D } = G(), { getStripoBlocksConfig: I } = j(), { getStripoNotifications: L } = J(), g = () => d || (d = new Promise((n, a) => {
|
|
21
21
|
if (document.getElementById("UiEditorScript")) {
|
|
22
|
-
|
|
22
|
+
n();
|
|
23
23
|
return;
|
|
24
24
|
}
|
|
25
|
-
const i =
|
|
25
|
+
const i = oe();
|
|
26
26
|
if (!i) {
|
|
27
|
-
|
|
27
|
+
a(
|
|
28
28
|
new Error("guido.stripo.version is not set in package.json. Please configure the Stripo version.")
|
|
29
29
|
);
|
|
30
30
|
return;
|
|
31
31
|
}
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
},
|
|
36
|
-
|
|
37
|
-
}, document.body.appendChild(
|
|
32
|
+
const s = `${i}UIEditor.js`, e = document.createElement("script");
|
|
33
|
+
e.id = "UiEditorScript", e.type = "module", e.src = s, e.onload = () => {
|
|
34
|
+
F = !0, n();
|
|
35
|
+
}, e.onerror = () => {
|
|
36
|
+
e.remove(), a(new Error(`Failed to load Stripo UIEditor script from S3: ${s}`));
|
|
37
|
+
}, document.body.appendChild(e);
|
|
38
38
|
}), d.catch(() => {
|
|
39
39
|
d = null;
|
|
40
|
-
}), d),
|
|
41
|
-
var
|
|
42
|
-
const o =
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
40
|
+
}), d), q = async (n, a, i, s = [], e = !1, c = !1) => {
|
|
41
|
+
var w, k, b, _;
|
|
42
|
+
const o = T(), { html: S, css: y } = n, { baseBlocks: E, extensions: x } = await I();
|
|
43
|
+
t.mark("blocks_config_ready");
|
|
44
|
+
const h = ((w = u.value) == null ? void 0 : w.displayConditions) ?? !0, O = ((k = u.value) == null ? void 0 : k.modulesDisabled) ?? !1, C = c || (((b = m.value) == null ? void 0 : b.forceRecreate) ?? !1), H = "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com";
|
|
45
|
+
t.setTemplate({ html: S, css: y, forceRecreate: C }), v().importCss(), t.mark("init_editor"), await window.UIEditor.initEditor(
|
|
46
46
|
document.querySelector("#guido-editor"),
|
|
47
47
|
{
|
|
48
|
-
metadata:
|
|
49
|
-
html:
|
|
50
|
-
css:
|
|
51
|
-
forceRecreate:
|
|
48
|
+
metadata: a,
|
|
49
|
+
html: S,
|
|
50
|
+
css: y,
|
|
51
|
+
forceRecreate: C,
|
|
52
52
|
locale: "en",
|
|
53
53
|
undoButtonSelector: "#guido__undo-button",
|
|
54
54
|
redoButtonSelector: "#guido__redo-button",
|
|
@@ -58,12 +58,12 @@ const we = (e) => {
|
|
|
58
58
|
customAppearanceMergetags: !p("liquidSyntax"),
|
|
59
59
|
customAppearanceMergetagsBorderColor: "#f1f3fe",
|
|
60
60
|
customAppearanceMergetagsBackgroundColor: "#f1f3fe",
|
|
61
|
-
customViewStyles:
|
|
62
|
-
conditionsEnabled:
|
|
63
|
-
customConditionsEnabled:
|
|
61
|
+
customViewStyles: Z,
|
|
62
|
+
conditionsEnabled: h,
|
|
63
|
+
customConditionsEnabled: h,
|
|
64
64
|
enableXSSSecurity: !0,
|
|
65
|
-
modulesDisabled:
|
|
66
|
-
syncModulesEnabled:
|
|
65
|
+
modulesDisabled: O,
|
|
66
|
+
syncModulesEnabled: e,
|
|
67
67
|
messageSettingsEnabled: !0,
|
|
68
68
|
displayGmailAnnotations: !0,
|
|
69
69
|
displayHiddenPreheader: !1,
|
|
@@ -73,37 +73,37 @@ const we = (e) => {
|
|
|
73
73
|
copyPasteEnabled: !1,
|
|
74
74
|
selectElementAfterDrop: !0,
|
|
75
75
|
sameFontSizeForOutlook: !0,
|
|
76
|
-
allowedScriptSourceDomains:
|
|
77
|
-
...
|
|
76
|
+
allowedScriptSourceDomains: H,
|
|
77
|
+
...E ? { baseBlocks: E } : {},
|
|
78
78
|
editorFonts: {
|
|
79
79
|
showDefaultStandardFonts: !0,
|
|
80
80
|
showDefaultNotStandardFonts: !0,
|
|
81
|
-
customFonts:
|
|
81
|
+
customFonts: s
|
|
82
82
|
},
|
|
83
83
|
mergeTags: [
|
|
84
84
|
{
|
|
85
|
-
entries:
|
|
85
|
+
entries: ee(
|
|
86
86
|
i.preselectedDynamicContentList,
|
|
87
|
-
|
|
87
|
+
te((_ = m.value) == null ? void 0 : _.dynamicContentList),
|
|
88
88
|
p("liquidSyntax")
|
|
89
89
|
)
|
|
90
90
|
}
|
|
91
91
|
],
|
|
92
92
|
async onTokenRefreshRequest(r) {
|
|
93
93
|
try {
|
|
94
|
-
|
|
95
|
-
const l = await
|
|
96
|
-
|
|
94
|
+
t.mark("token_start");
|
|
95
|
+
const l = await P();
|
|
96
|
+
t.mark("token_end"), r(l);
|
|
97
97
|
} catch (l) {
|
|
98
98
|
f(l, "Failed to refresh token");
|
|
99
99
|
}
|
|
100
100
|
},
|
|
101
101
|
onTemplateLoaded() {
|
|
102
102
|
try {
|
|
103
|
-
const { activateCustomViewStyles: r, updateTimerInClonedTemplate: l } =
|
|
104
|
-
|
|
103
|
+
const { activateCustomViewStyles: r, updateTimerInClonedTemplate: l } = N(), { injectFullStory: M } = $();
|
|
104
|
+
v().importCss(), r(), M(), l(), i.onReady(), o.isStripoInitialized = !0, o.loadingStatus = !1, setTimeout(() => {
|
|
105
105
|
o.hasChanges = !1;
|
|
106
|
-
}, 1e3),
|
|
106
|
+
}, 1e3), t.markReady();
|
|
107
107
|
} catch (r) {
|
|
108
108
|
f(r, "Failed to load custom interface appearance");
|
|
109
109
|
}
|
|
@@ -120,9 +120,9 @@ const we = (e) => {
|
|
|
120
120
|
onDataChanged() {
|
|
121
121
|
o.hasChanges = !0, o.changeSeq += 1;
|
|
122
122
|
},
|
|
123
|
-
onEvent:
|
|
124
|
-
onModuleAdd:
|
|
125
|
-
notifications:
|
|
123
|
+
onEvent: V,
|
|
124
|
+
onModuleAdd: D,
|
|
125
|
+
notifications: L(),
|
|
126
126
|
// Stripo deselects the block on any click outside the canvas, so every surface
|
|
127
127
|
// that belongs to the block's own flow has to be listed here (SD-153273).
|
|
128
128
|
ignoreClickOutsideSelectors: [
|
|
@@ -132,29 +132,29 @@ const we = (e) => {
|
|
|
132
132
|
".in-modal-v2-wrapper",
|
|
133
133
|
".in-toasts-wrapper"
|
|
134
134
|
],
|
|
135
|
-
extensions:
|
|
136
|
-
localePatch:
|
|
135
|
+
extensions: x,
|
|
136
|
+
localePatch: Q
|
|
137
137
|
}
|
|
138
138
|
);
|
|
139
139
|
};
|
|
140
|
-
return { initPlugin: async (a,
|
|
141
|
-
const
|
|
140
|
+
return { initPlugin: async (n, a, i, s = !1) => {
|
|
141
|
+
const e = T();
|
|
142
142
|
try {
|
|
143
|
-
|
|
144
|
-
const [
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
t.mark("plugin_start"), t.setScriptPreloaded(F), await g(), t.mark("script_ready");
|
|
144
|
+
const [c, o] = await Promise.all([
|
|
145
|
+
R(),
|
|
146
|
+
U()
|
|
147
147
|
]);
|
|
148
|
-
|
|
148
|
+
t.mark("fonts_sync_ready"), e.syncModulesEnabled = o, await q(n, a, i, c, o, s);
|
|
149
149
|
} catch {
|
|
150
|
-
|
|
151
|
-
type:
|
|
150
|
+
e.loadingStatus = !1, A({
|
|
151
|
+
type: W.Error,
|
|
152
152
|
message: B["An error has occurred. Please report the error code to support."],
|
|
153
153
|
actionButton: {
|
|
154
154
|
text: B["Reload page"],
|
|
155
155
|
onClick: () => window.location.reload()
|
|
156
156
|
}
|
|
157
|
-
}),
|
|
157
|
+
}), t.markFailed();
|
|
158
158
|
}
|
|
159
159
|
}, preloadRuntime: () => {
|
|
160
160
|
g().catch(() => {
|
|
@@ -162,5 +162,5 @@ const we = (e) => {
|
|
|
162
162
|
} };
|
|
163
163
|
};
|
|
164
164
|
export {
|
|
165
|
-
|
|
165
|
+
ke as useStripo
|
|
166
166
|
};
|