@useinsider/guido 3.8.0 → 3.8.1-beta.110be29
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/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/usePreviewInteractionGuard.js +17 -0
- package/dist/composables/useSave.js +14 -14
- package/dist/composables/validators/useUnsubscribeBlockValidator.js +26 -17
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +19 -25
- package/dist/extensions/Blocks/Recommendation/constants/selectors.js +11 -10
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +24 -26
- package/dist/extensions/Blocks/Recommendation/controls/main/layoutOrientation.js +30 -39
- package/dist/extensions/Blocks/Recommendation/controls/main/productLayout.js +28 -34
- package/dist/extensions/Blocks/Recommendation/controls/main/utils.js +285 -333
- package/dist/extensions/Blocks/Recommendation/extension.js +6 -5
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +3 -2
- package/dist/extensions/Blocks/Recommendation/templates/grid/elementRenderer.js +142 -173
- package/dist/extensions/Blocks/Recommendation/templates/grid/template.js +56 -30
- package/dist/extensions/Blocks/Recommendation/templates/index.js +29 -8
- package/dist/extensions/Blocks/Recommendation/templates/list/elementRenderer.js +132 -105
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +44 -23
- package/dist/extensions/Blocks/Recommendation/templates/utils.js +112 -64
- package/dist/extensions/Blocks/Recommendation/utils/captureStyleTemplates.js +219 -0
- package/dist/extensions/Blocks/Recommendation/utils/preserveTextStyles.js +24 -19
- package/dist/extensions/Blocks/Recommendation/utils/tagName.js +30 -22
- package/dist/extensions/Blocks/Unsubscribe/block.js +40 -37
- package/dist/extensions/Blocks/Unsubscribe/control.js +19 -16
- package/dist/extensions/Blocks/controlFactories.js +159 -133
- package/dist/guido.css +1 -1
- package/dist/src/composables/usePreviewInteractionGuard.d.ts +3 -0
- package/dist/src/composables/validators/useUnsubscribeBlockValidator.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/controls/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/constants/selectors.d.ts +2 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/button/index.d.ts +1 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/layoutOrientation.d.ts +2 -1
- package/dist/src/extensions/Blocks/Recommendation/controls/main/utils.d.ts +20 -47
- 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/template.d.ts +3 -2
- package/dist/src/extensions/Blocks/Recommendation/templates/utils.d.ts +165 -11
- package/dist/src/extensions/Blocks/Recommendation/utils/captureStyleTemplates.d.ts +78 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/preserveTextStyles.d.ts +15 -0
- package/dist/src/extensions/Blocks/Recommendation/utils/tagName.d.ts +29 -9
- package/dist/src/extensions/Blocks/controlFactories.d.ts +11 -1
- package/dist/src/stores/unsubscribe.d.ts +11 -1
- package/dist/stores/unsubscribe.js +8 -7
- package/package.json +1 -1
- package/dist/src/extensions/Blocks/Recommendation/utils/stylePreserver.d.ts +0 -113
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { RecommendationBlockId as c } from "../constants/blockIds.js";
|
|
2
|
+
import { DESKTOP_CONTAINER_SELECTOR as S, ATTR_PRODUCT_NAME as k, ATTR_PRODUCT_PRICE as E, ATTR_PRODUCT_OLD_PRICE as h, ATTR_PRODUCT_OMNIBUS_PRICE as y, ATTR_PRODUCT_OMNIBUS_DISCOUNT as m, ATTR_PRODUCT_BUTTON as P, ATTR_PRODUCT_IMAGE as x, ATTR_PRODUCT_ATTR as v } from "../constants/selectors.js";
|
|
3
|
+
import { CSS_CLASS_TEXT_TRIM as B } from "../controls/shared/textTrimCssRules.js";
|
|
4
|
+
import { toCustomCompositionKey as U } from "../templates/utils.js";
|
|
5
|
+
import { extractWrapperTags as C } from "./preserveTextStyles.js";
|
|
6
|
+
import { hasQuerySelectorAll as A, hasGetAttribute as l, hasGetStyle as R, hasGetComputedStyle as q } from "./tagName.js";
|
|
7
|
+
const s = [
|
|
8
|
+
"font-size",
|
|
9
|
+
"font-family",
|
|
10
|
+
"font-weight",
|
|
11
|
+
"font-style",
|
|
12
|
+
"color",
|
|
13
|
+
"text-align",
|
|
14
|
+
"line-height",
|
|
15
|
+
"text-decoration"
|
|
16
|
+
], N = [
|
|
17
|
+
"background",
|
|
18
|
+
"background-color",
|
|
19
|
+
"border-width",
|
|
20
|
+
"border-color",
|
|
21
|
+
"border-style",
|
|
22
|
+
"border-radius"
|
|
23
|
+
], M = [
|
|
24
|
+
...s,
|
|
25
|
+
"background",
|
|
26
|
+
"background-color",
|
|
27
|
+
// Stripo's Border Radius control writes the radius to the anchor too, not just the
|
|
28
|
+
// border span — capture it so it survives regeneration (symmetric with BUTTON_BORDER_PROPS).
|
|
29
|
+
"border-radius",
|
|
30
|
+
"padding",
|
|
31
|
+
"width",
|
|
32
|
+
"mso-border-alt",
|
|
33
|
+
"mso-padding-alt"
|
|
34
|
+
], D = [
|
|
35
|
+
"display",
|
|
36
|
+
"width",
|
|
37
|
+
"height",
|
|
38
|
+
"max-width",
|
|
39
|
+
"border-radius",
|
|
40
|
+
"margin"
|
|
41
|
+
], b = /* @__PURE__ */ new Set(["transparent", "rgba(0, 0, 0, 0)"]), G = [
|
|
42
|
+
{ attrKey: k, blockId: c.NAME, kind: "text" },
|
|
43
|
+
{ attrKey: E, blockId: c.PRICE, kind: "text" },
|
|
44
|
+
{ attrKey: h, blockId: c.OLD_PRICE, kind: "text" },
|
|
45
|
+
{ attrKey: y, blockId: c.OMNIBUS_PRICE, kind: "text" },
|
|
46
|
+
{ attrKey: m, blockId: c.OMNIBUS_DISCOUNT, kind: "text" },
|
|
47
|
+
{ attrKey: P, blockId: c.BUTTON, kind: "button" },
|
|
48
|
+
{ attrKey: x, blockId: c.IMAGE, kind: "image" }
|
|
49
|
+
];
|
|
50
|
+
function _(t) {
|
|
51
|
+
return t && "getInnerHTML" in t && typeof t.getInnerHTML == "function" ? t.getInnerHTML().trim() : "";
|
|
52
|
+
}
|
|
53
|
+
function L(t) {
|
|
54
|
+
return t && "getInnerText" in t && typeof t.getInnerText == "function" ? t.getInnerText().trim() : "";
|
|
55
|
+
}
|
|
56
|
+
function a(t, e, r) {
|
|
57
|
+
!e || !R(e) || r.forEach((n) => {
|
|
58
|
+
const i = e.getStyle(n);
|
|
59
|
+
i && i !== "inherit" && i !== "initial" && (t[n] = i);
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
function I(t) {
|
|
63
|
+
return Object.entries(t).map(([e, r]) => `${e}: ${r};`).join(" ");
|
|
64
|
+
}
|
|
65
|
+
function O(t) {
|
|
66
|
+
if (!t || !R(t))
|
|
67
|
+
return;
|
|
68
|
+
const e = t.getStyle("background-color") || t.getStyle("background");
|
|
69
|
+
return e && !b.has(e) ? e : void 0;
|
|
70
|
+
}
|
|
71
|
+
function g(t, e) {
|
|
72
|
+
const r = {};
|
|
73
|
+
return a(r, t, e), I(r);
|
|
74
|
+
}
|
|
75
|
+
function w(t) {
|
|
76
|
+
const e = t.querySelector("p"), r = {};
|
|
77
|
+
a(r, t, s), a(r, e, s), a(r, t.querySelector("strong"), s), a(r, t.querySelector("em"), s), a(r, t.querySelector("s"), s);
|
|
78
|
+
const n = I(r), { openTags: i, closeTags: o } = C(_(e));
|
|
79
|
+
return !n && !i ? null : { pStyle: n || void 0, openTags: i, closeTags: o };
|
|
80
|
+
}
|
|
81
|
+
function K(t) {
|
|
82
|
+
const e = t.querySelector(".es-button-border"), r = t.querySelector("a.es-button") ?? t.querySelector("a"), n = g(e, N), i = g(r, M), o = e && "getAttribute" in e ? e.getAttribute("class") ?? "" : "", u = /\bes-fw\b/.test(o), { openTags: T, closeTags: d } = C(_(r)), p = L(r);
|
|
83
|
+
return !n && !i && !u && !T && !p ? null : {
|
|
84
|
+
buttonBorderStyle: n || void 0,
|
|
85
|
+
buttonAnchorStyle: i || void 0,
|
|
86
|
+
buttonFitToContainer: u || void 0,
|
|
87
|
+
buttonText: p || void 0,
|
|
88
|
+
openTags: T,
|
|
89
|
+
closeTags: d
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
function H(t) {
|
|
93
|
+
const e = g(t.querySelector("img"), D);
|
|
94
|
+
return e ? { imgStyle: e } : null;
|
|
95
|
+
}
|
|
96
|
+
function $(t, e) {
|
|
97
|
+
return e === "button" ? K(t) : e === "image" ? H(t) : w(t);
|
|
98
|
+
}
|
|
99
|
+
function f(t, e) {
|
|
100
|
+
if (!t || !("querySelector" in t))
|
|
101
|
+
return;
|
|
102
|
+
const r = t.querySelector(S) ?? t;
|
|
103
|
+
if (G.forEach(({ attrKey: o, blockId: u, kind: T }) => {
|
|
104
|
+
const d = r.querySelector(`[esd-extension-block-id="${u}"]`);
|
|
105
|
+
d && e(d, o, T);
|
|
106
|
+
}), !A(r))
|
|
107
|
+
return;
|
|
108
|
+
const n = /* @__PURE__ */ new Set();
|
|
109
|
+
r.querySelectorAll(
|
|
110
|
+
`[esd-extension-block-id="${c.CUSTOM_ATTRIBUTE}"]`
|
|
111
|
+
).forEach((o) => {
|
|
112
|
+
const u = l(o) ? o.getAttribute(v) : null;
|
|
113
|
+
!u || n.has(u) || (n.add(u), e(o, U(u), "text"));
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
function F(t) {
|
|
117
|
+
const e = {};
|
|
118
|
+
return f(t, (r, n, i) => {
|
|
119
|
+
if (!("querySelector" in r))
|
|
120
|
+
return;
|
|
121
|
+
const o = $(r, i);
|
|
122
|
+
o && (e[n] = o);
|
|
123
|
+
}), e;
|
|
124
|
+
}
|
|
125
|
+
function j(t) {
|
|
126
|
+
if (!t || !("querySelector" in t))
|
|
127
|
+
return;
|
|
128
|
+
const e = t.querySelector(S) ?? t, r = e.querySelector(".product-card-segment") ?? e.querySelector(".product-card-wrapper");
|
|
129
|
+
return O(r);
|
|
130
|
+
}
|
|
131
|
+
function X(t) {
|
|
132
|
+
if (!t)
|
|
133
|
+
return;
|
|
134
|
+
const e = l(t) ? t.getAttribute("bgcolor") : null;
|
|
135
|
+
if (e && !b.has(e))
|
|
136
|
+
return e;
|
|
137
|
+
const r = O(t);
|
|
138
|
+
if (r)
|
|
139
|
+
return r;
|
|
140
|
+
const n = q(t) ? t.getComputedStyle("background-color") : void 0;
|
|
141
|
+
return n && !b.has(n) ? n : void 0;
|
|
142
|
+
}
|
|
143
|
+
function z(t) {
|
|
144
|
+
const e = {};
|
|
145
|
+
return f(t, (r, n, i) => {
|
|
146
|
+
if (i !== "text")
|
|
147
|
+
return;
|
|
148
|
+
const o = X(r);
|
|
149
|
+
o && (e[n] = o);
|
|
150
|
+
}), e;
|
|
151
|
+
}
|
|
152
|
+
function Q(t) {
|
|
153
|
+
const e = {};
|
|
154
|
+
return f(t, (r, n, i) => {
|
|
155
|
+
if (i === "image")
|
|
156
|
+
return;
|
|
157
|
+
const o = l(r) ? r.getAttribute("align") : null;
|
|
158
|
+
o && (e[n] = o);
|
|
159
|
+
}), e;
|
|
160
|
+
}
|
|
161
|
+
const V = /^es-[pm]\d+[trbl]?$/;
|
|
162
|
+
function W(t) {
|
|
163
|
+
const e = l(t) ? t.getAttribute("class") : null;
|
|
164
|
+
if (!e)
|
|
165
|
+
return;
|
|
166
|
+
const r = e.split(/\s+/).filter((n) => V.test(n) || n === B);
|
|
167
|
+
return r.length ? r.join(" ") : void 0;
|
|
168
|
+
}
|
|
169
|
+
function Y(t) {
|
|
170
|
+
const e = {};
|
|
171
|
+
return f(t, (r, n, i) => {
|
|
172
|
+
if (i === "image")
|
|
173
|
+
return;
|
|
174
|
+
const o = W(r);
|
|
175
|
+
o && (e[n] = o);
|
|
176
|
+
}), e;
|
|
177
|
+
}
|
|
178
|
+
function J(t) {
|
|
179
|
+
const e = {};
|
|
180
|
+
return f(t, (r, n) => {
|
|
181
|
+
if (n !== y && n !== m || !l(r))
|
|
182
|
+
return;
|
|
183
|
+
const i = r.getAttribute("data-text-before"), o = r.getAttribute("data-text-after");
|
|
184
|
+
(i != null || o != null) && (e[n] = { before: i ?? void 0, after: o ?? void 0 });
|
|
185
|
+
}), e;
|
|
186
|
+
}
|
|
187
|
+
function Z(t) {
|
|
188
|
+
const e = {};
|
|
189
|
+
if (!t || !("querySelector" in t))
|
|
190
|
+
return e;
|
|
191
|
+
const r = t.querySelector(S) ?? t;
|
|
192
|
+
return A(r) && r.querySelectorAll(".recommendation-attribute-row").forEach((n) => {
|
|
193
|
+
if (!l(n))
|
|
194
|
+
return;
|
|
195
|
+
const i = n.getAttribute("data-attribute-type"), o = n.getAttribute("data-visibility");
|
|
196
|
+
i && o != null && (e[i] = o !== "0");
|
|
197
|
+
}), e;
|
|
198
|
+
}
|
|
199
|
+
function ut(t) {
|
|
200
|
+
return {
|
|
201
|
+
styleTemplates: F(t),
|
|
202
|
+
cardBackgroundColor: j(t),
|
|
203
|
+
cellBackgroundColors: z(t),
|
|
204
|
+
cellAlignments: Q(t),
|
|
205
|
+
cellClasses: Y(t),
|
|
206
|
+
omnibusTexts: J(t),
|
|
207
|
+
visibility: Z(t)
|
|
208
|
+
};
|
|
209
|
+
}
|
|
210
|
+
export {
|
|
211
|
+
F as captureAttributeStyleTemplates,
|
|
212
|
+
j as captureCardBackgroundColor,
|
|
213
|
+
Q as captureCellAlignments,
|
|
214
|
+
z as captureCellBackgroundColors,
|
|
215
|
+
Y as captureCellClasses,
|
|
216
|
+
J as captureOmnibusTexts,
|
|
217
|
+
ut as captureStyles,
|
|
218
|
+
Z as captureVisibility
|
|
219
|
+
};
|
|
@@ -1,27 +1,32 @@
|
|
|
1
|
-
import { escapeHtml as
|
|
2
|
-
function
|
|
3
|
-
return "getInnerHTML" in
|
|
1
|
+
import { escapeHtml as g } from "../../../../utils/htmlEscape.js";
|
|
2
|
+
function u(n) {
|
|
3
|
+
return "getInnerHTML" in n && typeof n.getInnerHTML == "function" ? n.getInnerHTML().trim() : "innerHTML" in n ? n.innerHTML : "";
|
|
4
4
|
}
|
|
5
|
-
function
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
return n;
|
|
9
|
-
const r = T(t);
|
|
10
|
-
if (!r || r.trim() === "" || !/<(strong|em|u|s|b|i)\b/i.test(r))
|
|
11
|
-
return n;
|
|
12
|
-
const e = [], s = [];
|
|
13
|
-
let o = r.trim();
|
|
5
|
+
function T(n) {
|
|
6
|
+
const s = [], t = [];
|
|
7
|
+
let r = n.trim();
|
|
14
8
|
for (; ; ) {
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
9
|
+
const e = r.match(/^<(strong|em|u|s|b|i)(\s[^>]*)?>(.*)$/is);
|
|
10
|
+
if (!e)
|
|
17
11
|
break;
|
|
18
|
-
const [, i, a = "",
|
|
19
|
-
if (!
|
|
12
|
+
const [, i, a = "", o] = e, c = new RegExp(`</${i}>$`, "i");
|
|
13
|
+
if (!c.test(o))
|
|
20
14
|
break;
|
|
21
|
-
|
|
15
|
+
s.push(`<${i}${a}>`), t.unshift(`</${i}>`), r = o.replace(c, "").trim();
|
|
22
16
|
}
|
|
23
|
-
return
|
|
17
|
+
return { openTags: s.join(""), closeTags: t.join("") };
|
|
18
|
+
}
|
|
19
|
+
function p(n, s) {
|
|
20
|
+
const t = g(s);
|
|
21
|
+
if (!n)
|
|
22
|
+
return t;
|
|
23
|
+
const r = u(n);
|
|
24
|
+
if (!r || r.trim() === "")
|
|
25
|
+
return t;
|
|
26
|
+
const { openTags: e, closeTags: i } = T(r);
|
|
27
|
+
return e ? e + t + i : t;
|
|
24
28
|
}
|
|
25
29
|
export {
|
|
26
|
-
|
|
30
|
+
T as extractWrapperTags,
|
|
31
|
+
p as preserveTextStyles
|
|
27
32
|
};
|
|
@@ -1,46 +1,54 @@
|
|
|
1
|
-
function
|
|
1
|
+
function r(t) {
|
|
2
2
|
return typeof t == "object" && t !== null && "tagName" in t && typeof t.tagName == "string";
|
|
3
3
|
}
|
|
4
|
-
function
|
|
4
|
+
function u(t) {
|
|
5
5
|
return typeof t == "object" && t !== null && "getTagName" in t && typeof t.getTagName == "function";
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function n(t) {
|
|
8
8
|
return typeof t == "object" && t !== null && "getStyle" in t && typeof t.getStyle == "function";
|
|
9
9
|
}
|
|
10
|
-
function
|
|
11
|
-
return typeof t == "object" && t !== null && "
|
|
10
|
+
function p(t) {
|
|
11
|
+
return typeof t == "object" && t !== null && "getComputedStyle" in t && typeof t.getComputedStyle == "function";
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return typeof t == "object" && t !== null && "
|
|
13
|
+
function y(t) {
|
|
14
|
+
return typeof t == "object" && t !== null && "getAttribute" in t && typeof t.getAttribute == "function";
|
|
15
15
|
}
|
|
16
|
-
function
|
|
17
|
-
return
|
|
16
|
+
function o(t) {
|
|
17
|
+
return typeof t == "object" && t !== null && "querySelectorAll" in t && typeof t.querySelectorAll == "function";
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
return
|
|
19
|
+
function l(t) {
|
|
20
|
+
return typeof t == "object" && t !== null && "parent" in t && typeof t.parent == "function";
|
|
21
21
|
}
|
|
22
|
-
function
|
|
23
|
-
return t
|
|
22
|
+
function g(t, e) {
|
|
23
|
+
return !t || !n(t) ? null : t.getStyle(e);
|
|
24
|
+
}
|
|
25
|
+
function s(t) {
|
|
26
|
+
return !t || !l(t) ? null : t.parent() ?? null;
|
|
27
|
+
}
|
|
28
|
+
function a(t, e = "UNKNOWN") {
|
|
29
|
+
return t ? r(t) ? t.tagName.toUpperCase() : u(t) ? t.getTagName().toUpperCase() : e : e;
|
|
24
30
|
}
|
|
25
31
|
const f = /* @__PURE__ */ new Set(["TD", "BLOCK_IMAGE", "BLOCK_BUTTON"]);
|
|
26
32
|
function i(t) {
|
|
27
33
|
return f.has(t.toUpperCase());
|
|
28
34
|
}
|
|
29
35
|
function c(t) {
|
|
30
|
-
const e =
|
|
36
|
+
const e = a(t);
|
|
31
37
|
return i(e);
|
|
32
38
|
}
|
|
33
|
-
function
|
|
39
|
+
function N(t) {
|
|
34
40
|
return c(t) ? "table-cell" : "table-row";
|
|
35
41
|
}
|
|
36
42
|
export {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
N as getTableDisplayValue,
|
|
44
|
+
a as getTagName,
|
|
45
|
+
y as hasGetAttribute,
|
|
46
|
+
p as hasGetComputedStyle,
|
|
47
|
+
n as hasGetStyle,
|
|
48
|
+
l as hasParent,
|
|
49
|
+
o as hasQuerySelectorAll,
|
|
41
50
|
c as isTableCellNode,
|
|
42
51
|
i as isTableCellTag,
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
p as safeGetStyle
|
|
52
|
+
s as safeGetParent,
|
|
53
|
+
g as safeGetStyle
|
|
46
54
|
};
|
|
@@ -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)), !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(),
|
|
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
|
};
|