@useinsider/guido 3.9.0-beta.7791f66 → 3.9.0-beta.f67c6c8
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/@types/config/schemas.js +70 -66
- package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue.js +8 -8
- package/dist/components/organisms/email-preview/desktop-preview/DesktopPreview.vue2.js +15 -12
- package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue.js +5 -5
- package/dist/components/organisms/email-preview/mobile-preview/ContentView.vue2.js +16 -15
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue.js +5 -5
- package/dist/components/organisms/unsubscribe/UnsubscribePageSelection.vue2.js +42 -37
- package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue.js +3 -3
- package/dist/components/organisms/unsubscribe/UnsubscribeTypeSelection.vue2.js +40 -37
- package/dist/composables/useHtmlCompiler.js +13 -10
- package/dist/composables/usePreviewInteractionGuard.js +17 -0
- package/dist/composables/usePreviewMode.js +15 -14
- package/dist/composables/useRecommendationPreview.js +111 -0
- package/dist/composables/useSave.js +14 -14
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +26 -17
- package/dist/config/compiler/htmlCompilerRules.js +38 -10
- package/dist/config/compiler/recommendationCompilerRules.js +84 -109
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +110 -98
- package/dist/config/migrator/recommendation/htmlBuilder.js +53 -52
- package/dist/config/migrator/recommendation/settingsMapper.js +38 -33
- package/dist/enums/html-validator.js +6 -5
- package/dist/extensions/Blocks/Items/block.js +48 -29
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +62 -45
- package/dist/extensions/Blocks/Recommendation/block.js +64 -42
- package/dist/extensions/Blocks/Recommendation/canvasPreview.css.js +16 -0
- package/dist/extensions/Blocks/Recommendation/constants/defaultConfig.js +41 -32
- package/dist/extensions/Blocks/Recommendation/controls/cardComposition/index.js +461 -363
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +99 -87
- package/dist/extensions/Blocks/Recommendation/controls/main/pricePlacement.js +133 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +160 -158
- package/dist/extensions/Blocks/Recommendation/extension.js +30 -29
- package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +21 -7
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +64 -4
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +3 -1
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +130 -96
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +43 -54
- package/dist/extensions/Blocks/Recommendation/templates/index.js +17 -14
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +86 -80
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +31 -40
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +155 -102
- package/dist/extensions/Blocks/Unsubscribe/block.js +40 -37
- package/dist/extensions/Blocks/Unsubscribe/control.js +19 -16
- package/dist/extensions/Blocks/controlFactories.js +76 -57
- package/dist/guido.css +1 -1
- package/dist/src/@types/config/schemas.d.ts +16 -0
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/composables/usePreviewInteractionGuard.d.ts +3 -0
- package/dist/src/composables/useRecommendationPreview.d.ts +10 -0
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +1 -0
- package/dist/src/config/migrator/recommendation/settingsMapper.d.ts +1 -1
- package/dist/src/extensions/Blocks/CouponBlock/controls/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Items/block.d.ts +8 -0
- package/dist/src/extensions/Blocks/Items/controls/index.d.ts +3 -3
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +10 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/cardComposition/index.d.ts +29 -3
- package/dist/src/extensions/Blocks/Recommendation/controls/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/index.d.ts +3 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/pricePlacement.d.ts +59 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/name/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/oldPrice/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusDiscount/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/omnibusPrice/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/price/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/store/recommendation.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/elementRenderer.d.ts +13 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/grid/template.d.ts +4 -4
- package/dist/src/extensions/Blocks/Recommendation/templates/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/list/elementRenderer.d.ts +10 -1
- package/dist/src/extensions/Blocks/Recommendation/templates/list/template.d.ts +3 -3
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +51 -1
- package/dist/src/extensions/Blocks/Recommendation/types/nodeConfig.d.ts +15 -0
- package/dist/src/extensions/Blocks/controlFactories.d.ts +10 -1
- package/dist/src/stores/config.d.ts +36 -0
- package/dist/src/stores/unsubscribe.d.ts +11 -1
- package/dist/src/utils/ampErrorFilter.d.ts +1 -0
- package/dist/stores/unsubscribe.js +8 -7
- package/dist/utils/ampErrorFilter.js +6 -5
- package/package.json +1 -1
|
@@ -1,101 +1,148 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
1
|
+
import { ATTR_PRODUCT_PRICE as c, ATTR_PRODUCT_OLD_PRICE as l, ATTR_CUSTOM_PREFIX as a, PRODUCT_ATTRIBUTE_PREFIX as u, ATTR_PRODUCT_IMAGE as f, ATTR_PRODUCT_NAME as T, ATTR_PRODUCT_OMNIBUS_PRICE as C, ATTR_PRODUCT_OMNIBUS_DISCOUNT as p, ATTR_PRODUCT_BUTTON as _ } from "../constants/selectors.js";
|
|
2
|
+
import { useRecommendationExtensionStore as D } from "../store/recommendation.js";
|
|
3
|
+
import { formatPrice as O } from "../utils/priceFormatter.js";
|
|
4
|
+
function E() {
|
|
5
|
+
const t = D(), { currencySettings: e } = t.recommendationConfigs;
|
|
6
|
+
return {
|
|
7
|
+
code: e.value,
|
|
8
|
+
symbol: e.symbol,
|
|
9
|
+
alignment: e.alignment === "0" ? "before" : "after",
|
|
10
|
+
decimalCount: parseInt(e.decimalCount) || 2,
|
|
11
|
+
decimalSeparator: e.decimalSeparator,
|
|
12
|
+
thousandSeparator: e.thousandSeparator
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
function m(t, e = "price") {
|
|
16
|
+
const n = E(), o = t[e], r = (o == null ? void 0 : o[n.code]) ?? Object.values(o ?? {})[0] ?? 0;
|
|
17
|
+
return O({
|
|
18
|
+
price: r,
|
|
19
|
+
currency: n
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function Y(t) {
|
|
23
|
+
return m(t, "price") === m(t, "original_price");
|
|
24
|
+
}
|
|
25
|
+
function I(t) {
|
|
26
|
+
return t.replace(/_/g, " ").replace(/\b\w/g, (e) => e.toUpperCase());
|
|
27
|
+
}
|
|
28
|
+
function G(t) {
|
|
29
|
+
const e = t.indexOf(c), n = t.indexOf(l), o = n !== -1 && (e === -1 || n < e);
|
|
30
|
+
return {
|
|
31
|
+
originalFirst: o,
|
|
32
|
+
anchor: o ? l : c,
|
|
33
|
+
skip: o ? c : l
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
function $(t) {
|
|
37
|
+
const e = Array.isArray(t) ? t[t.length - 1] : t;
|
|
38
|
+
if (typeof e == "string")
|
|
39
|
+
return e;
|
|
40
|
+
if (typeof e == "number")
|
|
41
|
+
return String(e);
|
|
42
|
+
}
|
|
43
|
+
function h(t, e) {
|
|
44
|
+
const n = Object.values(e).find((o) => o.attributeName === t);
|
|
45
|
+
return (n == null ? void 0 : n.type) === "defaultAttribute";
|
|
46
|
+
}
|
|
47
|
+
function L(t, e) {
|
|
48
|
+
return h(t, e) ? t : `${u}${t}`;
|
|
49
|
+
}
|
|
50
|
+
function j(t) {
|
|
51
|
+
const e = t.startsWith(u) ? t.substring(u.length) : t;
|
|
52
|
+
return `${a}${e}`;
|
|
53
|
+
}
|
|
54
|
+
const x = Symbol("customCellHtml");
|
|
55
|
+
function z(t, e, n = {}) {
|
|
56
|
+
const o = t[x];
|
|
26
57
|
if (!o)
|
|
27
58
|
return { ...t };
|
|
28
|
-
const
|
|
29
|
-
return
|
|
30
|
-
const i =
|
|
31
|
-
s
|
|
32
|
-
var
|
|
33
|
-
const
|
|
34
|
-
return o(
|
|
59
|
+
const r = { ...t };
|
|
60
|
+
return e.filter((s) => s.startsWith(a) && !r[s]).forEach((s) => {
|
|
61
|
+
const i = s.substring(a.length), d = I(i), S = L(i, n), A = h(i, n);
|
|
62
|
+
r[s] = (g, R) => {
|
|
63
|
+
var b;
|
|
64
|
+
const P = A ? g[i] : (b = g.product_attributes) == null ? void 0 : b[i], U = $(P) ?? d;
|
|
65
|
+
return o(S, U, R);
|
|
35
66
|
};
|
|
36
|
-
}),
|
|
67
|
+
}), r;
|
|
68
|
+
}
|
|
69
|
+
function V(t, e) {
|
|
70
|
+
var n, o, r, s, i;
|
|
71
|
+
return {
|
|
72
|
+
cellPadding: e.cellPadding,
|
|
73
|
+
cardBackgroundColor: e.cardBackgroundColor,
|
|
74
|
+
cellBackgroundColor: (n = e.cellBackgroundColors) == null ? void 0 : n[t],
|
|
75
|
+
cellAlignment: (o = e.cellAlignments) == null ? void 0 : o[t],
|
|
76
|
+
cellClasses: (r = e.cellClasses) == null ? void 0 : r[t],
|
|
77
|
+
omnibusText: (s = e.omnibusTexts) == null ? void 0 : s[t],
|
|
78
|
+
styleTemplate: (i = e.styleTemplates) == null ? void 0 : i[t]
|
|
79
|
+
};
|
|
37
80
|
}
|
|
38
|
-
const
|
|
81
|
+
const X = {
|
|
39
82
|
TITLE: "You May Also Like!"
|
|
40
|
-
},
|
|
41
|
-
b,
|
|
42
|
-
T,
|
|
43
|
-
g,
|
|
44
|
-
_,
|
|
83
|
+
}, K = [
|
|
45
84
|
f,
|
|
85
|
+
T,
|
|
86
|
+
l,
|
|
87
|
+
c,
|
|
88
|
+
C,
|
|
46
89
|
p,
|
|
47
|
-
|
|
48
|
-
],
|
|
49
|
-
[
|
|
90
|
+
_
|
|
91
|
+
], q = {
|
|
92
|
+
[f]: !0,
|
|
50
93
|
[T]: !0,
|
|
51
|
-
[
|
|
52
|
-
[
|
|
53
|
-
[
|
|
94
|
+
[c]: !0,
|
|
95
|
+
[l]: !0,
|
|
96
|
+
[C]: !1,
|
|
54
97
|
[p]: !1,
|
|
55
|
-
[
|
|
56
|
-
},
|
|
57
|
-
function
|
|
98
|
+
[_]: !0
|
|
99
|
+
}, B = 10;
|
|
100
|
+
function k(t = B) {
|
|
58
101
|
return `
|
|
59
102
|
<tr>
|
|
60
103
|
<td class="spacer" style="height: ${t}px;"></td>
|
|
61
104
|
</tr>
|
|
62
105
|
`;
|
|
63
106
|
}
|
|
64
|
-
const
|
|
65
|
-
function w(t,
|
|
66
|
-
return
|
|
107
|
+
const v = k();
|
|
108
|
+
function w(t, e) {
|
|
109
|
+
return e ? e.pStyle ?? "" : t;
|
|
67
110
|
}
|
|
68
|
-
function
|
|
69
|
-
const o = w(
|
|
70
|
-
return `<p contenteditable="false" style="${o}">${
|
|
111
|
+
function J(t, e, n) {
|
|
112
|
+
const o = w(e.pStyle, n), r = n ? n.openTags ?? "" : e.openTags, s = n ? n.closeTags ?? "" : e.closeTags;
|
|
113
|
+
return `<p contenteditable="false" style="${o}">${r}${t}${s}</p>`;
|
|
71
114
|
}
|
|
72
|
-
function
|
|
73
|
-
const
|
|
74
|
-
return t &&
|
|
115
|
+
function Q(t, e) {
|
|
116
|
+
const n = [];
|
|
117
|
+
return t && n.push(t), e && n.push(`background-color: ${e};`), n.join(" ");
|
|
75
118
|
}
|
|
76
|
-
function
|
|
77
|
-
return t ? `
|
|
119
|
+
function N(t) {
|
|
120
|
+
return t ? ` background-color: ${t};` : "";
|
|
121
|
+
}
|
|
122
|
+
function Z(t) {
|
|
123
|
+
const e = N(t);
|
|
124
|
+
return e ? ` style="${e.trim()}"` : "";
|
|
78
125
|
}
|
|
79
|
-
function
|
|
126
|
+
function tt(t, e = "") {
|
|
80
127
|
return {
|
|
81
|
-
before: (t == null ? void 0 : t.before) ??
|
|
128
|
+
before: (t == null ? void 0 : t.before) ?? e,
|
|
82
129
|
after: (t == null ? void 0 : t.after) ?? ""
|
|
83
130
|
};
|
|
84
131
|
}
|
|
85
|
-
function
|
|
86
|
-
return `${(
|
|
132
|
+
function et(t, e) {
|
|
133
|
+
return `${(e == null ? void 0 : e.openTags) ?? ""}${t}${(e == null ? void 0 : e.closeTags) ?? ""}`;
|
|
87
134
|
}
|
|
88
|
-
function
|
|
135
|
+
function nt(t) {
|
|
89
136
|
return t != null && t.buttonFitToContainer ? "es-button-border es-fw" : "es-button-border";
|
|
90
137
|
}
|
|
91
|
-
const
|
|
92
|
-
function
|
|
93
|
-
return !t || typeof t != "string" || t.trim() === "" ?
|
|
138
|
+
const ot = "display: block; max-width: 100%; height: auto;", rt = "border-width: 1px; background: rgb(217, 234, 211); border-color: rgb(106, 168, 79);", st = "color: rgb(56, 118, 29); background: rgb(217, 234, 211); font-family: arial, 'helvetica neue', helvetica, sans-serif; font-size: 16px; font-weight: normal; line-height: 120%; mso-border-alt: 10px solid rgb(217, 234, 211); mso-padding-alt: 0;", y = "https://email-static.useinsider.com/stripo/modules/email-recommendation-v3/assets/images/image-placeholder.png";
|
|
139
|
+
function it(t) {
|
|
140
|
+
return !t || typeof t != "string" || t.trim() === "" ? y : t.startsWith("http://") ? t.replace("http://", "https://") : t;
|
|
94
141
|
}
|
|
95
|
-
function
|
|
142
|
+
function F(t) {
|
|
96
143
|
return {
|
|
97
144
|
name: "Product Name",
|
|
98
|
-
image_url:
|
|
145
|
+
image_url: y,
|
|
99
146
|
price: { USD: 18 },
|
|
100
147
|
original_price: { USD: 20 },
|
|
101
148
|
discount: { USD: 2 },
|
|
@@ -107,19 +154,19 @@ function B(t) {
|
|
|
107
154
|
category: []
|
|
108
155
|
};
|
|
109
156
|
}
|
|
110
|
-
function
|
|
157
|
+
function ct(t = 6) {
|
|
111
158
|
return Array.from(
|
|
112
159
|
{ length: t },
|
|
113
|
-
(
|
|
160
|
+
(e, n) => F(String(n + 1))
|
|
114
161
|
);
|
|
115
162
|
}
|
|
116
|
-
function
|
|
117
|
-
const
|
|
118
|
-
data-layout="list"` : "", o =
|
|
163
|
+
function lt(t = "grid", e) {
|
|
164
|
+
const n = t === "list" ? `
|
|
165
|
+
data-layout="list"` : "", o = e ? ` ${e}` : "";
|
|
119
166
|
return `
|
|
120
167
|
<td
|
|
121
168
|
align="left"
|
|
122
|
-
class="${`recommendation-block-v2 esd-block-recommendation-v3-block es-p20${t === "list" ? " es-m-p0 ins-recommendation-list-layout" : ""}${o}`}"${
|
|
169
|
+
class="${`recommendation-block-v2 esd-block-recommendation-v3-block es-p20${t === "list" ? " es-m-p0 ins-recommendation-list-layout" : ""}${o}`}"${n}>
|
|
123
170
|
<table width="100%" cellpadding="0" cellspacing="0" border="0">
|
|
124
171
|
<tr>
|
|
125
172
|
<td align="center">
|
|
@@ -151,7 +198,7 @@ function Q(t = "grid", n) {
|
|
|
151
198
|
</table>
|
|
152
199
|
</td>
|
|
153
200
|
</tr>
|
|
154
|
-
${
|
|
201
|
+
${v}
|
|
155
202
|
<tr>
|
|
156
203
|
<td>
|
|
157
204
|
<table
|
|
@@ -190,31 +237,37 @@ function Q(t = "grid", n) {
|
|
|
190
237
|
`;
|
|
191
238
|
}
|
|
192
239
|
export {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
240
|
+
x as CUSTOM_CELL_HTML,
|
|
241
|
+
X as DEFAULTS,
|
|
242
|
+
st as DEFAULT_BUTTON_ANCHOR_STYLE,
|
|
243
|
+
rt as DEFAULT_BUTTON_BORDER_STYLE,
|
|
244
|
+
K as DEFAULT_CARD_COMPOSITION,
|
|
245
|
+
q as DEFAULT_CARD_VISIBILITY,
|
|
246
|
+
ot as DEFAULT_IMG_STYLE,
|
|
247
|
+
B as DEFAULT_ROW_SPACING_PX,
|
|
248
|
+
y as PLACEHOLDER_IMAGE,
|
|
249
|
+
N as bgColorFragment,
|
|
250
|
+
V as buildCellOptions,
|
|
251
|
+
z as buildElementRenderer,
|
|
252
|
+
k as buildSpacer,
|
|
253
|
+
Z as cellBgStyleAttr,
|
|
254
|
+
lt as createBlockTemplate,
|
|
255
|
+
m as formatProductPrice,
|
|
256
|
+
E as getCurrentCurrencyConfig,
|
|
257
|
+
ct as getDefaultProducts,
|
|
258
|
+
h as isDefaultAttribute,
|
|
259
|
+
Y as isSamePrice,
|
|
260
|
+
et as renderButtonLabel,
|
|
261
|
+
J as renderStyledParagraph,
|
|
262
|
+
nt as resolveButtonBorderClass,
|
|
263
|
+
G as resolveInlinePriceOrder,
|
|
264
|
+
tt as resolveOmnibusText,
|
|
212
265
|
w as resolvePStyle,
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
266
|
+
L as resolveProductAttrValue,
|
|
267
|
+
Q as resolveSegmentBgStyle,
|
|
268
|
+
it as sanitizeImageUrl,
|
|
269
|
+
v as spacer,
|
|
270
|
+
j as toCustomCompositionKey,
|
|
271
|
+
I as toDisplayName,
|
|
272
|
+
$ as toDisplayableAttributeValue
|
|
220
273
|
};
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
var S = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var a = (c, o, e) =>
|
|
4
|
-
import { useToaster as
|
|
2
|
+
var f = (c, o, e) => o in c ? S(c, o, { enumerable: !0, configurable: !0, writable: !0, value: e }) : c[o] = e;
|
|
3
|
+
var a = (c, o, e) => f(c, typeof o != "symbol" ? o + "" : o, e);
|
|
4
|
+
import { useToaster as L } from "../../../composables/useToaster.js";
|
|
5
5
|
import { ToasterTypeOptions as A } from "../../../enums/toaster.js";
|
|
6
6
|
import { PAGE_TYPES as h } from "../../../enums/unsubscribe.js";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
7
|
+
import { useEditorStore as y } from "../../../stores/editor.js";
|
|
8
|
+
import { useUnsubscribeStore as l } from "../../../stores/unsubscribe.js";
|
|
9
|
+
import { Block as T, BlockCompositionType as I, ContextActionType as B, ModificationDescription as d, BlockType as v } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
10
|
+
import { getDefaultTemplate as C } from "./template.js";
|
|
10
11
|
import { UNSUBSCRIBE_BLOCK_SELECTOR as m, DATA_ATTRIBUTES as n, UNSUBSCRIBE_EVENTS as b } from "./utils/constants.js";
|
|
11
|
-
import { parsePageList as
|
|
12
|
-
const
|
|
12
|
+
import { parsePageList as _ } from "./utils/utils.js";
|
|
13
|
+
const N = "unsubscribe-block", E = 'a[data-unsubscribe-link="true"]', U = "{{ins-unsubscribe-link}}", R = "https://academy.insiderone.com/docs/adding-unsubscribe-pages-into-emails", D = "Removing the unsubscribe text leaves an empty block, but an active unsubscribe link is required. Undo your last action to restore the text, or delete the unsubscribe block entirely.", w = {
|
|
13
14
|
[h.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
|
|
14
15
|
[h.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
|
|
15
|
-
},
|
|
16
|
-
class
|
|
16
|
+
}, P = 3;
|
|
17
|
+
class W extends T {
|
|
17
18
|
constructor() {
|
|
18
19
|
super();
|
|
19
20
|
a(this, "selectEventListener", null);
|
|
@@ -29,13 +30,13 @@ class H extends y {
|
|
|
29
30
|
a(this, "guardAttemptsByBlockId", /* @__PURE__ */ new Map());
|
|
30
31
|
}
|
|
31
32
|
getId() {
|
|
32
|
-
return
|
|
33
|
+
return N;
|
|
33
34
|
}
|
|
34
35
|
getIcon() {
|
|
35
36
|
return "unsubscribe-icon";
|
|
36
37
|
}
|
|
37
38
|
getBlockCompositionType() {
|
|
38
|
-
return
|
|
39
|
+
return I.BLOCK;
|
|
39
40
|
}
|
|
40
41
|
getName() {
|
|
41
42
|
return this.api.translate("Unsubscribe Block");
|
|
@@ -44,15 +45,16 @@ class H extends y {
|
|
|
44
45
|
return this.api.translate("Unsubscribe Block Description");
|
|
45
46
|
}
|
|
46
47
|
getTemplate() {
|
|
47
|
-
return
|
|
48
|
+
return C();
|
|
48
49
|
}
|
|
49
50
|
getContextActionsIds() {
|
|
50
|
-
return [
|
|
51
|
+
return [B.MOVE, B.REMOVE];
|
|
51
52
|
}
|
|
52
53
|
onSelect(e) {
|
|
53
|
-
this.currentNode = e
|
|
54
|
+
if (this.currentNode = e, y().isPreviewModeOpen)
|
|
55
|
+
return;
|
|
54
56
|
const t = this._getOrAssignBlockId(e);
|
|
55
|
-
t && this.linkStateByBlockId.set(t, this._hasUnsubscribeLink(e)), this._setupSelectEventListener(), this._setupCancelEventListener(), !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), this._loadBlockState(e), this._checkExistingBlocks(), this._openDrawer());
|
|
57
|
+
t && this.linkStateByBlockId.set(t, this._hasUnsubscribeLink(e)), this._setupSelectEventListener(), this._setupCancelEventListener(t), !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), t && (l().pendingBlockId = t), this._loadBlockState(e), this._checkExistingBlocks(), this._openDrawer());
|
|
56
58
|
}
|
|
57
59
|
onCreated(e) {
|
|
58
60
|
this._ensureLeadingTextGuard(e);
|
|
@@ -107,9 +109,9 @@ class H extends y {
|
|
|
107
109
|
const g = this._getOrAssignBlockId(e);
|
|
108
110
|
if (!g)
|
|
109
111
|
return;
|
|
110
|
-
const
|
|
111
|
-
if (!(
|
|
112
|
-
this.guardAttemptsByBlockId.set(g,
|
|
112
|
+
const k = this.guardAttemptsByBlockId.get(g) ?? 0;
|
|
113
|
+
if (!(k >= P)) {
|
|
114
|
+
this.guardAttemptsByBlockId.set(g, k + 1);
|
|
113
115
|
try {
|
|
114
116
|
this.api.getDocumentModifier().modifyHtml(r).prepend(" ").apply(new d("Ensure unsubscribe link text guard"));
|
|
115
117
|
} catch (p) {
|
|
@@ -154,8 +156,8 @@ class H extends y {
|
|
|
154
156
|
const t = this.api.getDocumentRoot();
|
|
155
157
|
t && "querySelectorAll" in t && t.querySelectorAll(m).forEach((r) => {
|
|
156
158
|
if ("getAttribute" in r) {
|
|
157
|
-
const i = r.getAttribute(n.BLOCK_ID),
|
|
158
|
-
|
|
159
|
+
const i = r.getAttribute(n.BLOCK_ID), u = i ? parseInt(i) : 0;
|
|
160
|
+
u > e && (e = u);
|
|
159
161
|
}
|
|
160
162
|
});
|
|
161
163
|
} catch {
|
|
@@ -164,14 +166,14 @@ class H extends y {
|
|
|
164
166
|
}
|
|
165
167
|
_warnLinkRemoved() {
|
|
166
168
|
try {
|
|
167
|
-
const { showToaster: e } =
|
|
169
|
+
const { showToaster: e } = L();
|
|
168
170
|
e({
|
|
169
171
|
type: A.Warning,
|
|
170
|
-
message: this.api.translate(
|
|
172
|
+
message: this.api.translate(D),
|
|
171
173
|
actionButton: {
|
|
172
174
|
text: this.api.translate("Visit Academy"),
|
|
173
175
|
onClick: () => {
|
|
174
|
-
window.open(
|
|
176
|
+
window.open(R, "_blank", "noopener,noreferrer");
|
|
175
177
|
}
|
|
176
178
|
}
|
|
177
179
|
});
|
|
@@ -188,9 +190,10 @@ class H extends y {
|
|
|
188
190
|
_removeSelectEventListener() {
|
|
189
191
|
this.selectEventListener && (document.removeEventListener(b.SELECT, this.selectEventListener), this.selectEventListener = null);
|
|
190
192
|
}
|
|
191
|
-
_setupCancelEventListener() {
|
|
192
|
-
this._removeCancelEventListener(), this.cancelEventListener = () => {
|
|
193
|
-
|
|
193
|
+
_setupCancelEventListener(e) {
|
|
194
|
+
this._removeCancelEventListener(), this.cancelEventListener = (t) => {
|
|
195
|
+
const { detail: s } = t;
|
|
196
|
+
((s == null ? void 0 : s.blockId) ?? null) === e && this._handleCancel();
|
|
194
197
|
}, document.addEventListener(b.CANCEL, this.cancelEventListener);
|
|
195
198
|
}
|
|
196
199
|
_removeCancelEventListener() {
|
|
@@ -200,7 +203,7 @@ class H extends y {
|
|
|
200
203
|
try {
|
|
201
204
|
if (!this.currentNode)
|
|
202
205
|
return;
|
|
203
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).replaceWith(`<${
|
|
206
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).replaceWith(`<${v.EMPTY_CONTAINER}/>`).apply(new d("Removed unsubscribe block due to cancel"));
|
|
204
207
|
} catch (e) {
|
|
205
208
|
console.warn("[UnsubscribeBlock] Failed to remove unsubscribe block:", e);
|
|
206
209
|
}
|
|
@@ -218,19 +221,19 @@ class H extends y {
|
|
|
218
221
|
this.api.getDocumentModifier().modifyHtml(s).setAttribute("href", r).apply(new d(`Updated unsubscribe link to ${r}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(n.PAGE_TYPE, e.toString()).setAttribute(n.PAGE_LIST, t).apply(new d("Updated unsubscribe block metadata"));
|
|
219
222
|
}
|
|
220
223
|
_getMergeTag(e) {
|
|
221
|
-
return
|
|
224
|
+
return w[e] ?? U;
|
|
222
225
|
}
|
|
223
226
|
_openDrawer() {
|
|
224
227
|
if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
|
|
225
228
|
try {
|
|
226
|
-
const e =
|
|
229
|
+
const e = l();
|
|
227
230
|
e.typeSelectionDrawerStatus = !0;
|
|
228
231
|
} catch (e) {
|
|
229
232
|
console.error("[UnsubscribeBlock] Failed to open drawer:", e);
|
|
230
233
|
}
|
|
231
234
|
}
|
|
232
235
|
_checkExistingBlocks() {
|
|
233
|
-
const e =
|
|
236
|
+
const e = l();
|
|
234
237
|
e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(m).forEach((s) => {
|
|
235
238
|
if ("getAttribute" in s) {
|
|
236
239
|
const r = s.getAttribute(n.PAGE_TYPE);
|
|
@@ -247,11 +250,11 @@ class H extends y {
|
|
|
247
250
|
const t = e.getAttribute(n.PAGE_TYPE), s = e.getAttribute(n.PAGE_LIST);
|
|
248
251
|
if (!t || !s)
|
|
249
252
|
return;
|
|
250
|
-
const r =
|
|
251
|
-
await r.fetchTemplates(), r.setCollectionWithoutAutoSelection(i), r.loadSelectedTemplates(
|
|
253
|
+
const r = l(), i = Number(t), u = _(s);
|
|
254
|
+
await r.fetchTemplates(), r.setCollectionWithoutAutoSelection(i), r.loadSelectedTemplates(u);
|
|
252
255
|
}
|
|
253
256
|
_resetStoreState() {
|
|
254
|
-
|
|
257
|
+
l().$reset();
|
|
255
258
|
}
|
|
256
259
|
_removeBlockTemplatesFromStore(e) {
|
|
257
260
|
if (!("getAttribute" in e))
|
|
@@ -259,11 +262,11 @@ class H extends y {
|
|
|
259
262
|
const t = e.getAttribute(n.PAGE_LIST);
|
|
260
263
|
if (!t)
|
|
261
264
|
return;
|
|
262
|
-
const s =
|
|
265
|
+
const s = l(), r = _(t);
|
|
263
266
|
s.removeUnsubscribePages(r);
|
|
264
267
|
}
|
|
265
268
|
}
|
|
266
269
|
export {
|
|
267
|
-
|
|
268
|
-
|
|
270
|
+
N as UNSUBSCRIBE_BLOCK_ID,
|
|
271
|
+
W as UnsubscribeBlock
|
|
269
272
|
};
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
var T = Object.defineProperty;
|
|
2
|
-
var p = (
|
|
3
|
-
var c = (
|
|
2
|
+
var p = (a, s, e) => s in a ? T(a, s, { enumerable: !0, configurable: !0, writable: !0, value: e }) : a[s] = e;
|
|
3
|
+
var c = (a, s, e) => p(a, typeof s != "symbol" ? s + "" : s, e);
|
|
4
|
+
import { useEditorStore as _ } from "../../../stores/editor.js";
|
|
4
5
|
import { useUnsubscribeStore as l } from "../../../stores/unsubscribe.js";
|
|
5
|
-
import { Control as
|
|
6
|
+
import { Control as g, UEAttr as i, UIElementType as n } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
6
7
|
import { DATA_ATTRIBUTES as d } from "./utils/constants.js";
|
|
7
8
|
import { parsePageList as h } from "./utils/utils.js";
|
|
8
|
-
const
|
|
9
|
+
const v = "ui-elements-unsubscribe", r = {
|
|
9
10
|
SELECT_BUTTON: "selectTemplateButton",
|
|
10
11
|
PREV_BUTTON: "prevButton",
|
|
11
12
|
NEXT_BUTTON: "nextButton",
|
|
12
13
|
COUNTER_TEXT: "counterText",
|
|
13
14
|
PREVIEW_IMAGE: "previewImage"
|
|
14
15
|
};
|
|
15
|
-
class
|
|
16
|
+
class w extends g {
|
|
16
17
|
constructor() {
|
|
17
18
|
super(...arguments);
|
|
18
19
|
c(this, "currentPreviewIndex", 0);
|
|
@@ -22,7 +23,7 @@ class B extends _ {
|
|
|
22
23
|
c(this, "lastParsedAttribute");
|
|
23
24
|
}
|
|
24
25
|
getId() {
|
|
25
|
-
return
|
|
26
|
+
return v;
|
|
26
27
|
}
|
|
27
28
|
getTemplate() {
|
|
28
29
|
return `
|
|
@@ -59,10 +60,12 @@ class B extends _ {
|
|
|
59
60
|
this.api.onValueChanged(r.NEXT_BUTTON, () => this._onNextClick())
|
|
60
61
|
);
|
|
61
62
|
}
|
|
62
|
-
_onButtonClick() {
|
|
63
|
+
async _onButtonClick() {
|
|
63
64
|
try {
|
|
65
|
+
if (_().isPreviewModeOpen)
|
|
66
|
+
return;
|
|
64
67
|
const e = l();
|
|
65
|
-
this._reseedSelectionFromBlock(), e.activeType = e.getSelectedCollection[this.currentPreviewIndex], e.pageSelectionUpdateStatus = !0, e.pageSelectionDrawerStatus = !0;
|
|
68
|
+
await e.fetchTemplates(!0), this._reseedSelectionFromBlock(), e.activeType = e.getSelectedCollection[this.currentPreviewIndex], e.pageSelectionUpdateStatus = !0, e.pageSelectionDrawerStatus = !0;
|
|
66
69
|
} catch (e) {
|
|
67
70
|
console.error("[UnsubscribeControl] Failed to open drawer:", e);
|
|
68
71
|
}
|
|
@@ -71,8 +74,8 @@ class B extends _ {
|
|
|
71
74
|
const e = l();
|
|
72
75
|
if (e.$reset(), !this.currentNode || !("getAttribute" in this.currentNode))
|
|
73
76
|
return;
|
|
74
|
-
const t = this.currentNode.getAttribute(d.PAGE_TYPE),
|
|
75
|
-
!t || !
|
|
77
|
+
const t = this.currentNode.getAttribute(d.PAGE_TYPE), o = this.currentNode.getAttribute(d.PAGE_LIST);
|
|
78
|
+
!t || !o || (e.setCollectionWithoutAutoSelection(Number(t)), e.loadSelectedTemplates(h(o)));
|
|
76
79
|
}
|
|
77
80
|
_onPrevClick() {
|
|
78
81
|
this.currentPreviewIndex > 0 && (this.currentPreviewIndex--, this._updatePreview(), this._updateCounter());
|
|
@@ -100,8 +103,8 @@ class B extends _ {
|
|
|
100
103
|
}
|
|
101
104
|
}
|
|
102
105
|
_updateCounter() {
|
|
103
|
-
const e = this.currentPreviewIndex + 1, t = this.totalTemplates,
|
|
104
|
-
this.api.setUIEAttribute(r.PREV_BUTTON, i.BUTTON.disabled,
|
|
106
|
+
const e = this.currentPreviewIndex + 1, t = this.totalTemplates, o = this.currentPreviewIndex === 0, u = this.currentPreviewIndex >= t - 1;
|
|
107
|
+
this.api.setUIEAttribute(r.PREV_BUTTON, i.BUTTON.disabled, o), this.api.setUIEAttribute(r.NEXT_BUTTON, i.BUTTON.disabled, u), this.api.setUIEAttribute(
|
|
105
108
|
r.COUNTER_TEXT,
|
|
106
109
|
i.LABEL.text,
|
|
107
110
|
`${this.api.translate("Showing")} ${e} ${this.api.translate("of")} ${t}`
|
|
@@ -142,8 +145,8 @@ class B extends _ {
|
|
|
142
145
|
</${n.LABEL}>
|
|
143
146
|
`;
|
|
144
147
|
}
|
|
145
|
-
_getIconButton(e, t,
|
|
146
|
-
const u =
|
|
148
|
+
_getIconButton(e, t, o) {
|
|
149
|
+
const u = o ? `${i.BUTTON.disabled}="true"` : "";
|
|
147
150
|
return `
|
|
148
151
|
<${n.BUTTON}
|
|
149
152
|
id="${e}"
|
|
@@ -172,6 +175,6 @@ class B extends _ {
|
|
|
172
175
|
}
|
|
173
176
|
}
|
|
174
177
|
export {
|
|
175
|
-
|
|
176
|
-
|
|
178
|
+
v as UNSUBSCRIBE_CONTROL_ID,
|
|
179
|
+
w as UnsubscribeControl
|
|
177
180
|
};
|