@useinsider/guido 3.4.1-beta.c04b4e7 → 3.4.1-beta.e536d60
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/config/compiler/utils/recommendationCompilerUtils.js +62 -59
- package/dist/extensions/Blocks/Unsubscribe/block.js +53 -80
- package/dist/extensions/Blocks/Unsubscribe/template.js +8 -8
- package/dist/src/config/compiler/utils/recommendationCompilerUtils.d.ts +6 -0
- package/dist/src/config/compiler/utils/recommendationCompilerUtils.test.d.ts +1 -0
- package/dist/src/extensions/Blocks/Unsubscribe/block.d.ts +1 -5
- package/package.json +1 -1
|
@@ -2,126 +2,128 @@ import { useConfig as S } from "../../../composables/useConfig.js";
|
|
|
2
2
|
import { useRecommendation as g } from "../../../composables/useRecommendation.js";
|
|
3
3
|
import { CSS_CLASS_RECO_BUTTON as _ } from "../../../extensions/Blocks/Recommendation/constants/selectors.js";
|
|
4
4
|
import { useRecommendationExtensionStore as q } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
-
function y(r,
|
|
6
|
-
const
|
|
7
|
-
return o === "before" ? `${t} ${
|
|
5
|
+
function y(r, i, e, o, s = "") {
|
|
6
|
+
const c = `{{${s}${r}_${i}_${e}}}`, t = `{{${s}${r}_${i}_currency}}`;
|
|
7
|
+
return o === "before" ? `${t} ${c}` : `${c} ${t}`;
|
|
8
8
|
}
|
|
9
|
-
function f(r,
|
|
10
|
-
switch (
|
|
9
|
+
function f(r, i, e, o, s, c) {
|
|
10
|
+
switch (i) {
|
|
11
11
|
case "productImage": {
|
|
12
12
|
const t = r.querySelector("img");
|
|
13
|
-
t && (t.setAttribute("src", `{{${
|
|
14
|
-
const
|
|
15
|
-
|
|
13
|
+
t && (t.setAttribute("src", `{{${c}${e}_${o}_image_url}}`), t.setAttribute("alt", `{{${c}${e}_${o}_name}}`));
|
|
14
|
+
const n = r.querySelector("a");
|
|
15
|
+
n && (n.setAttribute("href", `{{${c}${e}_${o}_url}}`), n.classList.add(_));
|
|
16
16
|
break;
|
|
17
17
|
}
|
|
18
18
|
case "productName": {
|
|
19
19
|
const t = r.querySelector("p");
|
|
20
20
|
if (t) {
|
|
21
|
-
const
|
|
22
|
-
|
|
21
|
+
const n = t.querySelector("strong") || t;
|
|
22
|
+
n.textContent = `{{${c}${e}_${o}_name}}`;
|
|
23
23
|
}
|
|
24
24
|
break;
|
|
25
25
|
}
|
|
26
26
|
case "productPrice": {
|
|
27
27
|
const t = r.querySelector("p");
|
|
28
28
|
if (t) {
|
|
29
|
-
const
|
|
30
|
-
|
|
29
|
+
const n = t.querySelector("strong") || t;
|
|
30
|
+
n.textContent = y(e, o, "price", s, c);
|
|
31
31
|
}
|
|
32
32
|
break;
|
|
33
33
|
}
|
|
34
34
|
case "productOldPrice": {
|
|
35
35
|
const t = r.querySelector("p");
|
|
36
36
|
if (t) {
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
let n = t;
|
|
38
|
+
for (; n.children.length === 1; )
|
|
39
|
+
[n] = n.children;
|
|
40
|
+
n.textContent = y(
|
|
39
41
|
e,
|
|
40
42
|
o,
|
|
41
43
|
"original_price",
|
|
42
44
|
s,
|
|
43
|
-
|
|
45
|
+
c
|
|
44
46
|
), t.setAttribute("product-attr", "discount");
|
|
45
47
|
}
|
|
46
48
|
break;
|
|
47
49
|
}
|
|
48
50
|
case "productButton": {
|
|
49
51
|
const t = r.querySelector("a");
|
|
50
|
-
t && t.setAttribute("href", `{{${
|
|
52
|
+
t && t.setAttribute("href", `{{${c}${e}_${o}_url}}`);
|
|
51
53
|
break;
|
|
52
54
|
}
|
|
53
55
|
case "productOmnibusPrice": {
|
|
54
56
|
const t = r.querySelector(".omnibus-price-value");
|
|
55
57
|
if (t) {
|
|
56
|
-
t.textContent = `{{${
|
|
57
|
-
const
|
|
58
|
-
|
|
58
|
+
t.textContent = `{{${c}${e}_${o}_omnibus_price}}`;
|
|
59
|
+
const n = t.closest("p");
|
|
60
|
+
n && (n.setAttribute("product-attr", "omnibus_price"), n.setAttribute("composition", "true"));
|
|
59
61
|
}
|
|
60
62
|
break;
|
|
61
63
|
}
|
|
62
64
|
case "productOmnibusDiscount": {
|
|
63
65
|
const t = r.querySelector(".omnibus-discount-value");
|
|
64
66
|
if (t) {
|
|
65
|
-
t.textContent = `{{${
|
|
66
|
-
const
|
|
67
|
-
|
|
67
|
+
t.textContent = `{{${c}${e}_${o}_omnibus_discount}}`;
|
|
68
|
+
const n = t.closest("p");
|
|
69
|
+
n && (n.setAttribute("product-attr", "omnibus_discount"), n.setAttribute("composition", "true"));
|
|
68
70
|
}
|
|
69
71
|
break;
|
|
70
72
|
}
|
|
71
73
|
default: {
|
|
72
74
|
const t = r.getAttribute("product-attr") ? r : r.querySelector("[product-attr]");
|
|
73
75
|
if (t) {
|
|
74
|
-
const
|
|
76
|
+
const n = t.getAttribute("product-attr"), a = t.querySelector("p");
|
|
75
77
|
if (a) {
|
|
76
78
|
const u = a.querySelector("strong") || a;
|
|
77
|
-
u.textContent = `{{${
|
|
79
|
+
u.textContent = `{{${c}${e}_${o}_${n}}}`;
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
break;
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
|
-
function C(r,
|
|
85
|
-
r.querySelectorAll(".recommendation-product-row").forEach((
|
|
86
|
-
|
|
86
|
+
function C(r, i, e, o) {
|
|
87
|
+
r.querySelectorAll(".recommendation-product-row").forEach((c, t) => {
|
|
88
|
+
c.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
87
89
|
const u = a.getAttribute("data-attribute-type") || "", p = a.querySelectorAll(".attribute-cell");
|
|
88
90
|
p.length > 0 ? p.forEach((l) => {
|
|
89
|
-
f(l, u,
|
|
90
|
-
}) : f(a, u,
|
|
91
|
+
f(l, u, i, t, e, o);
|
|
92
|
+
}) : f(a, u, i, t, e, o);
|
|
91
93
|
});
|
|
92
94
|
});
|
|
93
95
|
}
|
|
94
|
-
function
|
|
96
|
+
function w(r, i, e, o) {
|
|
95
97
|
const s = r.querySelectorAll(".recommendation-product-row");
|
|
96
98
|
if (!s.length)
|
|
97
99
|
return;
|
|
98
|
-
const [
|
|
100
|
+
const [c] = s, t = c.querySelector("[data-attribute-type]"), n = t ? t.querySelectorAll(".attribute-cell").length : 1;
|
|
99
101
|
s.forEach((a, u) => {
|
|
100
102
|
a.querySelectorAll("[data-attribute-type]").forEach((l) => {
|
|
101
103
|
const d = l.getAttribute("data-attribute-type") || "";
|
|
102
104
|
l.querySelectorAll(".attribute-cell").forEach((A, h) => {
|
|
103
|
-
const $ = u *
|
|
104
|
-
f(A, d,
|
|
105
|
+
const $ = u * n + h;
|
|
106
|
+
f(A, d, i, $, e, o);
|
|
105
107
|
});
|
|
106
108
|
});
|
|
107
109
|
});
|
|
108
110
|
}
|
|
109
|
-
function
|
|
110
|
-
r.querySelectorAll(".ins-recommendation-product-container").forEach((
|
|
111
|
-
|
|
111
|
+
function E(r, i, e, o) {
|
|
112
|
+
r.querySelectorAll(".ins-recommendation-product-container").forEach((c) => {
|
|
113
|
+
w(c, i, e, o);
|
|
112
114
|
});
|
|
113
115
|
}
|
|
114
|
-
function R(r,
|
|
116
|
+
function R(r, i, e) {
|
|
115
117
|
const o = r.getAttribute("data-layout") || "grid", s = r.getAttribute("currency-alignment") || "after";
|
|
116
|
-
o === "list" ? C(r,
|
|
118
|
+
o === "list" ? C(r, i, s, e) : E(r, i, s, e);
|
|
117
119
|
}
|
|
118
|
-
function b(r,
|
|
119
|
-
const o = new RegExp(`${
|
|
120
|
+
function b(r, i, e) {
|
|
121
|
+
const o = new RegExp(`${i}\\s*:\\s*(\\d+)\\s*px`, "i"), s = r.match(o);
|
|
120
122
|
return s ? parseInt(s[1]) : e;
|
|
121
123
|
}
|
|
122
|
-
function P(r,
|
|
124
|
+
function P(r, i) {
|
|
123
125
|
let e = r.parentElement;
|
|
124
|
-
for (; e && e !==
|
|
126
|
+
for (; e && e !== i; ) {
|
|
125
127
|
if (e.tagName === "TD") {
|
|
126
128
|
const o = e.getAttribute("width");
|
|
127
129
|
if (o && o.endsWith("%") && parseFloat(o) < 100)
|
|
@@ -132,41 +134,42 @@ function P(r, c) {
|
|
|
132
134
|
return null;
|
|
133
135
|
}
|
|
134
136
|
function T(r) {
|
|
135
|
-
const
|
|
136
|
-
s !== 0 && r.querySelectorAll("img.adapt-img").forEach((
|
|
137
|
-
if (
|
|
137
|
+
const i = r.getAttribute("style") || "", e = b(i, "width", 600), o = b(i, "padding", 0) * 2, s = Math.max(0, e - o);
|
|
138
|
+
s !== 0 && r.querySelectorAll("img.adapt-img").forEach((c) => {
|
|
139
|
+
if (c.hasAttribute("width"))
|
|
138
140
|
return;
|
|
139
|
-
const t = P(
|
|
141
|
+
const t = P(c, r);
|
|
140
142
|
if (!t)
|
|
141
143
|
return;
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
const d =
|
|
144
|
+
const n = t.getAttribute("width"), a = parseFloat(n), u = b(t.getAttribute("style") || "", "padding", 0) * 2, p = Math.floor(s * a / 100), l = Math.max(1, p - u);
|
|
145
|
+
c.setAttribute("width", String(l));
|
|
146
|
+
const d = c.getAttribute("style") || "";
|
|
145
147
|
if (!/\bwidth\s*:\s*\d/i.test(d)) {
|
|
146
148
|
const m = d && !d.trim().endsWith(";") ? "; " : "";
|
|
147
|
-
|
|
149
|
+
c.setAttribute("style", `${d}${m}width: ${l}px`);
|
|
148
150
|
}
|
|
149
151
|
});
|
|
150
152
|
}
|
|
151
|
-
function v(r,
|
|
153
|
+
function v(r, i) {
|
|
152
154
|
const e = r.match(/<!DOCTYPE[^>]*>/i);
|
|
153
155
|
return (e ? `${e[0]}
|
|
154
|
-
` : "") +
|
|
156
|
+
` : "") + i.documentElement.outerHTML;
|
|
155
157
|
}
|
|
156
158
|
function N(r) {
|
|
157
|
-
const
|
|
159
|
+
const i = r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), e = new DOMParser().parseFromString(i, "text/html"), o = e.querySelectorAll(".recommendation-block-v2");
|
|
158
160
|
if (!o.length)
|
|
159
161
|
return r;
|
|
160
|
-
const { buildCampaignUrl: s } = g(),
|
|
161
|
-
|
|
162
|
-
const { isFeatureEnabled: t } = S(),
|
|
162
|
+
const { buildCampaignUrl: s } = g(), c = q();
|
|
163
|
+
c.recommendationCampaignUrls = {};
|
|
164
|
+
const { isFeatureEnabled: t } = S(), n = t("liquidSyntax") ? "reco_" : "";
|
|
163
165
|
return o.forEach((u) => {
|
|
164
166
|
var l, d;
|
|
165
167
|
const p = u.getAttribute("recommendation-id");
|
|
166
|
-
p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((m) => m.remove()), s(p), R(u, p,
|
|
167
|
-
}), v(
|
|
168
|
+
p && ((l = u.parentNode) == null || l.insertBefore(e.createComment("REC_START"), u), (d = u.parentNode) == null || d.insertBefore(e.createComment("REC_END"), u.nextSibling), u.querySelectorAll('[data-visibility="0"]').forEach((m) => m.remove()), s(p), R(u, p, n), T(u));
|
|
169
|
+
}), v(i, e).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
168
170
|
}
|
|
169
171
|
export {
|
|
170
172
|
y as formatPriceVariable,
|
|
171
|
-
N as prepareRecommendationBlocks
|
|
173
|
+
N as prepareRecommendationBlocks,
|
|
174
|
+
f as replaceAttributeContent
|
|
172
175
|
};
|
|
@@ -1,34 +1,31 @@
|
|
|
1
1
|
var d = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
[b.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
|
|
14
|
-
[b.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
|
|
2
|
+
var h = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[i] = e;
|
|
3
|
+
var u = (n, i, e) => h(n, typeof i != "symbol" ? i + "" : i, e);
|
|
4
|
+
import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
|
|
5
|
+
import { useUnsubscribeStore as c } from "../../../stores/unsubscribe.js";
|
|
6
|
+
import { Block as _, BlockCompositionType as S, BlockType as L, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
7
|
+
import { getDefaultTemplate as v } from "./template.js";
|
|
8
|
+
import { UNSUBSCRIBE_EVENTS as a, DATA_ATTRIBUTES as o } from "./utils/constants.js";
|
|
9
|
+
import { parsePageList as p } from "./utils/utils.js";
|
|
10
|
+
const g = "unsubscribe-block", T = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", B = "{{ins-unsubscribe-link}}", C = {
|
|
11
|
+
[E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
|
|
12
|
+
[E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
|
|
15
13
|
};
|
|
16
|
-
class
|
|
14
|
+
class I extends _ {
|
|
17
15
|
constructor() {
|
|
18
16
|
super();
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
c(this, "hadUnsubscribeLink", !1);
|
|
17
|
+
u(this, "selectEventListener", null);
|
|
18
|
+
u(this, "cancelEventListener", null);
|
|
19
|
+
u(this, "currentNode");
|
|
23
20
|
}
|
|
24
21
|
getId() {
|
|
25
|
-
return
|
|
22
|
+
return g;
|
|
26
23
|
}
|
|
27
24
|
getIcon() {
|
|
28
25
|
return "unsubscribe-icon";
|
|
29
26
|
}
|
|
30
27
|
getBlockCompositionType() {
|
|
31
|
-
return
|
|
28
|
+
return S.BLOCK;
|
|
32
29
|
}
|
|
33
30
|
getName() {
|
|
34
31
|
return this.api.translate("Unsubscribe Block");
|
|
@@ -37,63 +34,39 @@ class x extends g {
|
|
|
37
34
|
return this.api.translate("Unsubscribe Block Description");
|
|
38
35
|
}
|
|
39
36
|
getTemplate() {
|
|
40
|
-
return
|
|
37
|
+
return v();
|
|
41
38
|
}
|
|
42
39
|
onSelect(e) {
|
|
43
|
-
this.currentNode = e,
|
|
44
|
-
}
|
|
45
|
-
onDocumentChanged(e) {
|
|
46
|
-
const t = this._hasUnsubscribeLink(e);
|
|
47
|
-
this.hadUnsubscribeLink && !t && this._warnLinkRemoved(), this.hadUnsubscribeLink = t;
|
|
40
|
+
this.currentNode = e, !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), this._loadBlockState(e), this._setupSelectEventListener(), this._setupCancelEventListener(), this._checkExistingBlocks(), this._openDrawer());
|
|
48
41
|
}
|
|
49
42
|
onDelete(e) {
|
|
50
|
-
this._removeEventListeners(), this._removeBlockTemplatesFromStore(e), this._resetStoreState()
|
|
43
|
+
this._removeEventListeners(), this._removeBlockTemplatesFromStore(e), this._resetStoreState();
|
|
51
44
|
}
|
|
52
45
|
onDestroy() {
|
|
53
|
-
this._removeEventListeners(), this.currentNode = void 0
|
|
54
|
-
}
|
|
55
|
-
_hasUnsubscribeLink(e) {
|
|
56
|
-
return "querySelector" in e ? !!e.querySelector(p) : !1;
|
|
57
|
-
}
|
|
58
|
-
_warnLinkRemoved() {
|
|
59
|
-
try {
|
|
60
|
-
const { showToaster: e } = L();
|
|
61
|
-
e({
|
|
62
|
-
type: S.Warning,
|
|
63
|
-
message: this.api.translate(A),
|
|
64
|
-
actionButton: {
|
|
65
|
-
text: this.api.translate("Visit Academy"),
|
|
66
|
-
onClick: () => {
|
|
67
|
-
window.open(C, "_blank", "noopener,noreferrer");
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
} catch (e) {
|
|
72
|
-
console.error("[UnsubscribeBlock] Failed to show warning toaster:", e);
|
|
73
|
-
}
|
|
46
|
+
this._removeEventListeners(), this.currentNode = void 0;
|
|
74
47
|
}
|
|
75
48
|
_setupSelectEventListener() {
|
|
76
49
|
this._removeSelectEventListener(), this.selectEventListener = (e) => {
|
|
77
|
-
const
|
|
78
|
-
this._updateBlock(
|
|
79
|
-
}, document.addEventListener(
|
|
50
|
+
const r = e, { collectionType: s, selectedPages: t } = r.detail;
|
|
51
|
+
this._updateBlock(s, t.join(","));
|
|
52
|
+
}, document.addEventListener(a.SELECT, this.selectEventListener);
|
|
80
53
|
}
|
|
81
54
|
_removeSelectEventListener() {
|
|
82
|
-
this.selectEventListener && (document.removeEventListener(
|
|
55
|
+
this.selectEventListener && (document.removeEventListener(a.SELECT, this.selectEventListener), this.selectEventListener = null);
|
|
83
56
|
}
|
|
84
57
|
_setupCancelEventListener() {
|
|
85
58
|
this._removeCancelEventListener(), this.cancelEventListener = () => {
|
|
86
59
|
this._handleCancel();
|
|
87
|
-
}, document.addEventListener(
|
|
60
|
+
}, document.addEventListener(a.CANCEL, this.cancelEventListener);
|
|
88
61
|
}
|
|
89
62
|
_removeCancelEventListener() {
|
|
90
|
-
this.cancelEventListener && (document.removeEventListener(
|
|
63
|
+
this.cancelEventListener && (document.removeEventListener(a.CANCEL, this.cancelEventListener), this.cancelEventListener = null);
|
|
91
64
|
}
|
|
92
65
|
_handleCancel() {
|
|
93
66
|
try {
|
|
94
67
|
if (!this.currentNode)
|
|
95
68
|
return;
|
|
96
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).replaceWith(`<${
|
|
69
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).replaceWith(`<${L.EMPTY_CONTAINER}/>`).apply(new b("Removed unsubscribe block due to cancel"));
|
|
97
70
|
} catch (e) {
|
|
98
71
|
console.warn("[UnsubscribeBlock] Failed to remove unsubscribe block:", e);
|
|
99
72
|
}
|
|
@@ -101,35 +74,35 @@ class x extends g {
|
|
|
101
74
|
_removeEventListeners() {
|
|
102
75
|
this._removeSelectEventListener(), this._removeCancelEventListener();
|
|
103
76
|
}
|
|
104
|
-
_updateBlock(e,
|
|
77
|
+
_updateBlock(e, r) {
|
|
105
78
|
if (!this.currentNode || !("querySelector" in this.currentNode))
|
|
106
79
|
return;
|
|
107
|
-
const
|
|
108
|
-
if (!
|
|
80
|
+
const s = this.currentNode.querySelector(T);
|
|
81
|
+
if (!s)
|
|
109
82
|
return;
|
|
110
|
-
const
|
|
111
|
-
this.api.getDocumentModifier().modifyHtml(
|
|
83
|
+
const t = this._getMergeTag(e);
|
|
84
|
+
this.api.getDocumentModifier().modifyHtml(s).setAttribute("href", t).apply(new b(`Updated unsubscribe link to ${t}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, r).apply(new b("Updated unsubscribe block metadata"));
|
|
112
85
|
}
|
|
113
86
|
_getMergeTag(e) {
|
|
114
|
-
return
|
|
87
|
+
return C[e] ?? B;
|
|
115
88
|
}
|
|
116
89
|
_openDrawer() {
|
|
117
90
|
if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
|
|
118
91
|
try {
|
|
119
|
-
const e =
|
|
92
|
+
const e = c();
|
|
120
93
|
e.typeSelectionDrawerStatus = !0;
|
|
121
94
|
} catch (e) {
|
|
122
95
|
console.error("[UnsubscribeBlock] Failed to open drawer:", e);
|
|
123
96
|
}
|
|
124
97
|
}
|
|
125
98
|
_checkExistingBlocks() {
|
|
126
|
-
const e =
|
|
127
|
-
e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(
|
|
128
|
-
if ("getAttribute" in
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
131
|
-
const l = Number(
|
|
132
|
-
l ===
|
|
99
|
+
const e = c();
|
|
100
|
+
e.isGlobalUnsubscribeDisabled = !1, e.isSubscriptionPreferencesCenterDisabled = !1, this.api.getDocumentRoot().querySelectorAll(f).forEach((s) => {
|
|
101
|
+
if ("getAttribute" in s) {
|
|
102
|
+
const t = s.getAttribute(o.PAGE_TYPE);
|
|
103
|
+
if (t) {
|
|
104
|
+
const l = Number(t);
|
|
105
|
+
l === E.GLOBAL_UNSUBSCRIBE ? e.isGlobalUnsubscribeDisabled = !0 : l === E.SUBSCRIPTION_PREFERENCE_CENTER && (e.isSubscriptionPreferencesCenterDisabled = !0);
|
|
133
106
|
}
|
|
134
107
|
}
|
|
135
108
|
});
|
|
@@ -137,26 +110,26 @@ class x extends g {
|
|
|
137
110
|
async _loadBlockState(e) {
|
|
138
111
|
if (!("getAttribute" in e))
|
|
139
112
|
return;
|
|
140
|
-
const
|
|
141
|
-
if (!
|
|
113
|
+
const r = e.getAttribute(o.PAGE_TYPE), s = e.getAttribute(o.PAGE_LIST);
|
|
114
|
+
if (!r || !s)
|
|
142
115
|
return;
|
|
143
|
-
const
|
|
144
|
-
await
|
|
116
|
+
const t = c(), l = Number(r), m = p(s);
|
|
117
|
+
await t.fetchTemplates(), t.setCollectionWithoutAutoSelection(l), t.loadSelectedTemplates(m);
|
|
145
118
|
}
|
|
146
119
|
_resetStoreState() {
|
|
147
|
-
|
|
120
|
+
c().$reset();
|
|
148
121
|
}
|
|
149
122
|
_removeBlockTemplatesFromStore(e) {
|
|
150
123
|
if (!("getAttribute" in e))
|
|
151
124
|
return;
|
|
152
|
-
const
|
|
153
|
-
if (!
|
|
125
|
+
const r = e.getAttribute(o.PAGE_LIST);
|
|
126
|
+
if (!r)
|
|
154
127
|
return;
|
|
155
|
-
const
|
|
156
|
-
|
|
128
|
+
const s = c(), t = p(r);
|
|
129
|
+
s.removeUnsubscribePages(t);
|
|
157
130
|
}
|
|
158
131
|
}
|
|
159
132
|
export {
|
|
160
|
-
|
|
161
|
-
|
|
133
|
+
g as UNSUBSCRIBE_BLOCK_ID,
|
|
134
|
+
I as UnsubscribeBlock
|
|
162
135
|
};
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { BlockType as
|
|
2
|
-
const
|
|
3
|
-
<${
|
|
1
|
+
import { BlockType as e } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
+
const s = "unsubscribe", n = "{{ins-unsubscribe-link}}", t = `
|
|
3
|
+
<${e.BLOCK_TEXT}
|
|
4
4
|
class="unsubscribe-block-v2 esd-block-unsubscribe es-p0"
|
|
5
5
|
align="center"
|
|
6
6
|
data-unsubscribe-page-type=""
|
|
7
7
|
data-unsubscribe-page-list=""
|
|
8
8
|
>
|
|
9
|
-
<p
|
|
9
|
+
<p>You can <strong><a
|
|
10
10
|
href="${n}"
|
|
11
11
|
class="unsubscribe-link"
|
|
12
12
|
target="_blank"
|
|
13
13
|
data-unsubscribe-link="true"
|
|
14
|
-
>${
|
|
15
|
-
</${
|
|
14
|
+
>${s}</a></strong> from our emails, if you need to.</p>
|
|
15
|
+
</${e.BLOCK_TEXT}>
|
|
16
16
|
`;
|
|
17
|
-
function
|
|
17
|
+
function r() {
|
|
18
18
|
return t;
|
|
19
19
|
}
|
|
20
20
|
export {
|
|
21
|
-
|
|
21
|
+
r as getDefaultTemplate
|
|
22
22
|
};
|
|
@@ -7,6 +7,12 @@
|
|
|
7
7
|
* @returns Formatted price string with currency variable in correct position
|
|
8
8
|
*/
|
|
9
9
|
export declare function formatPriceVariable(campaignId: string, productIndex: number, attribute: string, alignment: string, prefix?: string): string;
|
|
10
|
+
/**
|
|
11
|
+
* Replaces a single attribute cell's content with the appropriate template variable.
|
|
12
|
+
* Stripo's compiled HTML uses `data-attribute-type` on `<tr>` elements, with
|
|
13
|
+
* individual `.attribute-cell` `<td>` elements for each product in the row.
|
|
14
|
+
*/
|
|
15
|
+
export declare function replaceAttributeContent(cell: Element, attributeType: string, campaignId: string, productIndex: number, currencyAlignment: string, prefix: string): void;
|
|
10
16
|
/**
|
|
11
17
|
* Transforms recommendation block HTML by replacing product data with
|
|
12
18
|
* template variables.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import type { ImmutableHtmlElementNode
|
|
1
|
+
import type { ImmutableHtmlElementNode } from '@stripoinc/ui-editor-extensions';
|
|
2
2
|
import { Block, BlockCompositionType } from '@stripoinc/ui-editor-extensions';
|
|
3
3
|
export declare const UNSUBSCRIBE_BLOCK_ID = "unsubscribe-block";
|
|
4
4
|
export declare class UnsubscribeBlock extends Block {
|
|
5
5
|
private selectEventListener;
|
|
6
6
|
private cancelEventListener;
|
|
7
7
|
private currentNode?;
|
|
8
|
-
private hadUnsubscribeLink;
|
|
9
8
|
constructor();
|
|
10
9
|
getId(): string;
|
|
11
10
|
getIcon(): string;
|
|
@@ -14,11 +13,8 @@ export declare class UnsubscribeBlock extends Block {
|
|
|
14
13
|
getDescription(): string;
|
|
15
14
|
getTemplate(): string;
|
|
16
15
|
onSelect(node: ImmutableHtmlElementNode): void;
|
|
17
|
-
onDocumentChanged(node: ImmutableHtmlNode): void;
|
|
18
16
|
onDelete(node: ImmutableHtmlElementNode): void;
|
|
19
17
|
onDestroy(): void;
|
|
20
|
-
private _hasUnsubscribeLink;
|
|
21
|
-
private _warnLinkRemoved;
|
|
22
18
|
private _setupSelectEventListener;
|
|
23
19
|
private _removeSelectEventListener;
|
|
24
20
|
private _setupCancelEventListener;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.4.1-beta.
|
|
3
|
+
"version": "3.4.1-beta.e536d60",
|
|
4
4
|
"description": "Guido is a Vue + TypeScript wrapper for Email Plugin. Easily embed the email editor in your Vue applications.",
|
|
5
5
|
"main": "./dist/guido.umd.cjs",
|
|
6
6
|
"module": "./dist/library.js",
|