@useinsider/guido 3.26.0-beta.d0b09c0 → 3.26.0-beta.e0662fe
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 +10 -5
- package/dist/components/Guido.vue.js +7 -7
- package/dist/components/Guido.vue2.js +82 -79
- package/dist/components/organisms/dynamic-content/AmbiguousDynamicContentModal.vue.js +22 -0
- package/dist/components/organisms/dynamic-content/AmbiguousDynamicContentModal.vue2.js +54 -0
- package/dist/composables/useAmbiguousDynamicContent.js +62 -0
- package/dist/composables/useHtmlCompiler.js +9 -8
- package/dist/composables/useModuleRepair.js +55 -31
- package/dist/config/compiler/htmlCompilerRules.js +16 -6
- package/dist/config/migrator/unsubscribeMigrator.js +100 -114
- package/dist/enums/dynamic-content.js +4 -0
- package/dist/extensions/Blocks/Unsubscribe/block.js +96 -104
- package/dist/extensions/Blocks/Unsubscribe/utils/constants.js +3 -4
- package/dist/guido.css +1 -1
- package/dist/package.json.js +4 -4
- package/dist/src/@types/generic.d.ts +7 -0
- package/dist/src/components/organisms/dynamic-content/AmbiguousDynamicContentModal.vue.d.ts +2 -0
- package/dist/src/composables/useAmbiguousDynamicContent.d.ts +6 -0
- package/dist/src/enums/dynamic-content.d.ts +3 -0
- package/dist/src/extensions/Blocks/Unsubscribe/utils/constants.d.ts +0 -1
- package/dist/src/stores/module-dynamic-content.d.ts +30 -0
- package/dist/src/utils/dynamicContentConverter.d.ts +20 -18
- package/dist/src/utils/dynamicContentPendingMarker.d.ts +2 -0
- package/dist/src/utils/genericUtil.d.ts +4 -8
- package/dist/stores/module-dynamic-content.js +20 -0
- package/dist/utils/dynamicContentConverter.js +41 -27
- package/dist/utils/dynamicContentPendingMarker.js +6 -0
- package/dist/utils/genericUtil.js +39 -39
- package/package.json +1 -1
- package/dist/extensions/Blocks/Unsubscribe/utils/swapMergeTagInHref.js +0 -5
- package/dist/src/extensions/Blocks/Unsubscribe/utils/swapMergeTagInHref.d.ts +0 -1
|
@@ -1,37 +1,61 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { useToaster as
|
|
3
|
-
import { useTranslations as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
1
|
+
import { useConfig as A } from "./useConfig.js";
|
|
2
|
+
import { useToaster as v } from "./useToaster.js";
|
|
3
|
+
import { useTranslations as O } from "./useTranslations.js";
|
|
4
|
+
import { ModuleDynamicContentAttribute as E } from "../enums/dynamic-content.js";
|
|
5
|
+
import { ToasterTypeOptions as L } from "../enums/toaster.js";
|
|
6
|
+
import { itemsBlockDynamicVariables as S } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
7
|
+
import { useDynamicContentStore as U } from "../stores/dynamic-content.js";
|
|
8
|
+
import { useEditorStore as _ } from "../stores/editor.js";
|
|
9
|
+
import { useModuleDynamicContentStore as F } from "../stores/module-dynamic-content.js";
|
|
10
|
+
import { buildDynamicContentLookup as P, convertModuleDynamicContent as q } from "../utils/dynamicContentConverter.js";
|
|
11
|
+
import { stripPendingMarker as N } from "../utils/dynamicContentPendingMarker.js";
|
|
12
|
+
import { flattenDynamicContentCandidates as R } from "../utils/genericUtil.js";
|
|
13
|
+
import { repairItemsCurrencyAttributes as k } from "../utils/itemsCurrencyRepair.js";
|
|
14
|
+
import { convertLegacyUnsubscribeInModuleHtml as $ } from "../utils/legacyUnsubscribeConversion.js";
|
|
15
|
+
import { extractUsedDynamicContent as x } from "../utils/registerUsedDynamicContent.js";
|
|
16
|
+
const H = "dynamic-content.unresolved-attributes-on-drop", I = /^(\s*<[a-zA-Z][a-zA-Z0-9-]*)/;
|
|
17
|
+
let M = 0;
|
|
18
|
+
const z = (o) => {
|
|
19
|
+
M += 1;
|
|
20
|
+
const r = `${Date.now().toString(36)}-${M}`;
|
|
21
|
+
return { html: o.replace(I, `$1 ${E.Pending}="${r}"`), id: r };
|
|
22
|
+
}, Y = (o, r) => {
|
|
23
|
+
try {
|
|
24
|
+
const n = x(o, r.map(({ text: c, value: a }) => ({ text: c, value: a })));
|
|
25
|
+
n.length > 0 && U().registerDynamicContent(n);
|
|
26
|
+
} catch (n) {
|
|
27
|
+
console.error("Failed to register module dynamic content:", n);
|
|
28
|
+
}
|
|
29
|
+
}, ne = () => {
|
|
30
|
+
const { template: o, isFeatureEnabled: r } = A(), { showToaster: n } = v(), c = O();
|
|
31
|
+
return { handleModuleAdd: (i, s) => {
|
|
32
|
+
var d, p, y, g;
|
|
14
33
|
try {
|
|
15
|
-
if ((
|
|
34
|
+
if ((i == null ? void 0 : i.action) !== "ADD" && (i == null ? void 0 : i.action) !== "COPY")
|
|
16
35
|
return;
|
|
17
|
-
const e = (
|
|
18
|
-
if (!e || typeof
|
|
36
|
+
const e = (d = s == null ? void 0 : s.getTargetNode) == null ? void 0 : d.call(s), u = (p = e == null ? void 0 : e.getOuterHTML) == null ? void 0 : p.call(e);
|
|
37
|
+
if (!e || typeof u != "string")
|
|
19
38
|
return;
|
|
20
|
-
let
|
|
21
|
-
convertToPriceFormat:
|
|
22
|
-
}),
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
let
|
|
26
|
-
if (
|
|
39
|
+
let t = N(k(u, {
|
|
40
|
+
convertToPriceFormat: r("itemsPriceFormatting")
|
|
41
|
+
})), f = !1;
|
|
42
|
+
r("legacyUnsubscribeConversion") && ({ html: t, converted: f } = $(t));
|
|
43
|
+
const b = r("liquidSyntax"), C = b ? [] : R((y = o.value) == null ? void 0 : y.dynamicContentList), D = P(C);
|
|
44
|
+
let h = [], l = [], m = null;
|
|
45
|
+
if (D.size > 0 && ({ html: t, unresolved: h, ambiguous: l } = q(
|
|
46
|
+
t,
|
|
47
|
+
D,
|
|
48
|
+
b,
|
|
49
|
+
[...((g = o.value) == null ? void 0 : g.customFieldAttributes) ?? [], ...S]
|
|
50
|
+
)), l.length > 0 && ({ html: t, id: m } = z(t)), t !== u && s.modifyHtml(e).replaceWith(t), Y(t, C), f)
|
|
27
51
|
try {
|
|
28
|
-
|
|
29
|
-
} catch (
|
|
30
|
-
console.error("Failed to request the legacy unsubscribe modal:",
|
|
52
|
+
_().isLegacyUnsubscribeModalRequested = !0;
|
|
53
|
+
} catch (T) {
|
|
54
|
+
console.error("Failed to request the legacy unsubscribe modal:", T);
|
|
31
55
|
}
|
|
32
|
-
|
|
33
|
-
type:
|
|
34
|
-
message:
|
|
56
|
+
m && F().enqueue({ id: m, items: l }), h.length > 0 && n({
|
|
57
|
+
type: L.Warning,
|
|
58
|
+
message: c(H)
|
|
35
59
|
});
|
|
36
60
|
} catch (e) {
|
|
37
61
|
console.error("Failed to repair module on add:", e);
|
|
@@ -39,6 +63,6 @@ const E = "dynamic-content.unresolved-attributes-on-drop", S = () => {
|
|
|
39
63
|
} };
|
|
40
64
|
};
|
|
41
65
|
export {
|
|
42
|
-
|
|
43
|
-
|
|
66
|
+
H as UNRESOLVED_DYNAMIC_CONTENT_ON_DROP_KEY,
|
|
67
|
+
ne as useModuleRepair
|
|
44
68
|
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { PENDING_MARKER_PATTERN as c } from "../../utils/dynamicContentPendingMarker.js";
|
|
2
|
+
import { stripFontTags as l } from "../../utils/stripFontTags.js";
|
|
3
|
+
import { trimHrefWhitespace as d } from "../../utils/trimHrefWhitespace.js";
|
|
4
|
+
const y = [
|
|
4
5
|
{
|
|
5
6
|
id: "fix-url-encoding-start",
|
|
6
7
|
description: "Replace {%22 with %7B%22 to fix URL encoding",
|
|
@@ -59,14 +60,14 @@ const f = [
|
|
|
59
60
|
id: "strip-font-tags",
|
|
60
61
|
description: 'Unwrap browser-translate-injected <font dir="auto"> tags, keeping inner content; other <font> elements are left intact.',
|
|
61
62
|
type: "custom",
|
|
62
|
-
processor: (e) =>
|
|
63
|
+
processor: (e) => l(e),
|
|
63
64
|
priority: 15
|
|
64
65
|
},
|
|
65
66
|
{
|
|
66
67
|
id: "trim-href-whitespace",
|
|
67
68
|
description: "Trim leading/trailing whitespace and from every href value",
|
|
68
69
|
type: "custom",
|
|
69
|
-
processor: (e) =>
|
|
70
|
+
processor: (e) => d(e),
|
|
70
71
|
priority: 16
|
|
71
72
|
},
|
|
72
73
|
{
|
|
@@ -183,6 +184,15 @@ const f = [
|
|
|
183
184
|
flags: "g",
|
|
184
185
|
priority: 45
|
|
185
186
|
},
|
|
187
|
+
{
|
|
188
|
+
id: "remove-dc-pending-marker",
|
|
189
|
+
description: "Strip the editor-only pending dynamic-content choice marker from compiled output",
|
|
190
|
+
type: "regex",
|
|
191
|
+
pattern: c,
|
|
192
|
+
replacement: "",
|
|
193
|
+
flags: "g",
|
|
194
|
+
priority: 46
|
|
195
|
+
},
|
|
186
196
|
{
|
|
187
197
|
id: "remove-script-tags",
|
|
188
198
|
// SD-145051: parity with HB HtmlCleaner.removeUnsafeHtmlTags — strip <script> from
|
|
@@ -208,5 +218,5 @@ const f = [
|
|
|
208
218
|
}
|
|
209
219
|
];
|
|
210
220
|
export {
|
|
211
|
-
|
|
221
|
+
y as defaultHtmlCompilerRules
|
|
212
222
|
};
|
|
@@ -1,160 +1,146 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { MERGE_TAGS as
|
|
5
|
-
import { UNSUBSCRIBE_BLOCK_SELECTOR as
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import { useUnsubscribeStore as M } from "../../stores/unsubscribe.js";
|
|
9
|
-
import { escapeHtml as A } from "../../utils/htmlEscape.js";
|
|
10
|
-
const S = "unsubscribe", N = "You can ", R = " from our emails, if you need to.", C = "{-{-UNSUBSCRIBE-LINK-}-}";
|
|
11
|
-
class H {
|
|
1
|
+
var x = Object.defineProperty;
|
|
2
|
+
var B = (c, e, r) => e in c ? x(c, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : c[e] = r;
|
|
3
|
+
var A = (c, e, r) => B(c, typeof e != "symbol" ? e + "" : e, r);
|
|
4
|
+
import { MERGE_TAGS as f, PAGE_TYPES as p } from "../../enums/unsubscribe.js";
|
|
5
|
+
import { UNSUBSCRIBE_BLOCK_SELECTOR as h, DATA_ATTRIBUTES as k } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
6
|
+
import { useUnsubscribeStore as C } from "../../stores/unsubscribe.js";
|
|
7
|
+
class $ {
|
|
12
8
|
constructor() {
|
|
13
|
-
|
|
9
|
+
A(this, "parser");
|
|
14
10
|
this.parser = new DOMParser();
|
|
15
11
|
}
|
|
16
12
|
async migrate(e) {
|
|
17
13
|
try {
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
const
|
|
21
|
-
await
|
|
14
|
+
const r = this.parser.parseFromString(e, "text/html"), t = r.querySelectorAll("td.unsubscribe-block");
|
|
15
|
+
if (t.length) {
|
|
16
|
+
const s = C();
|
|
17
|
+
await s.fetchTemplates(), this.migrateLegacyBlocks(t, s);
|
|
22
18
|
}
|
|
23
|
-
const
|
|
24
|
-
return !
|
|
25
|
-
} catch (
|
|
26
|
-
return console.error("UnsubscribeMigrator failed:",
|
|
19
|
+
const n = this.repairUnsubscribeLinks(r);
|
|
20
|
+
return !t.length && !n ? e : r.documentElement.outerHTML;
|
|
21
|
+
} catch (r) {
|
|
22
|
+
return console.error("UnsubscribeMigrator failed:", r), e;
|
|
27
23
|
}
|
|
28
24
|
}
|
|
29
|
-
migrateLegacyBlocks(e,
|
|
30
|
-
e.forEach((
|
|
31
|
-
const
|
|
25
|
+
migrateLegacyBlocks(e, r) {
|
|
26
|
+
e.forEach((t) => {
|
|
27
|
+
const n = t.getAttribute("id"), s = this.extractPaddingClass(t), l = t.getAttribute("bgcolor") || "", a = this.extractUnsubscribeContent(t), o = this.getCollectionTypeFromMergeTag(a.linkHref), b = r.getSelectedUnsubscribePagesByCollection(o);
|
|
32
28
|
console.debug("[UnsubscribeMigrator]", {
|
|
33
29
|
mergeTag: a.linkHref,
|
|
34
|
-
collectionType:
|
|
35
|
-
pageIds:
|
|
36
|
-
paddingClass:
|
|
37
|
-
bgColor:
|
|
30
|
+
collectionType: o,
|
|
31
|
+
pageIds: b,
|
|
32
|
+
paddingClass: s,
|
|
33
|
+
bgColor: l
|
|
38
34
|
});
|
|
39
|
-
const
|
|
35
|
+
const u = this.buildUnsubscribeBlock(
|
|
40
36
|
a,
|
|
37
|
+
o,
|
|
41
38
|
b,
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
`<table id="tempDoc"><tbody><tr>${l}</tr></tbody></table>`,
|
|
39
|
+
s,
|
|
40
|
+
l
|
|
41
|
+
), i = this.parser.parseFromString(
|
|
42
|
+
`<table id="tempDoc"><tbody><tr>${u}</tr></tbody></table>`,
|
|
47
43
|
"text/html"
|
|
48
|
-
).querySelector(
|
|
49
|
-
|
|
44
|
+
).querySelector(h);
|
|
45
|
+
i && t.parentNode && (i.setAttribute("id", n || ""), t.parentNode.replaceChild(i, t));
|
|
50
46
|
});
|
|
51
47
|
}
|
|
52
|
-
// The compiler resolves a typed tag only through a block that lists pages, so a page-less block carries no tag.
|
|
53
|
-
collectBlockTags(e, t) {
|
|
54
|
-
const r = /* @__PURE__ */ new Set();
|
|
55
|
-
return e.querySelectorAll(y).forEach((s) => {
|
|
56
|
-
var a, b, u;
|
|
57
|
-
if (!P(s.getAttribute(d.PAGE_LIST) || "").length)
|
|
58
|
-
return;
|
|
59
|
-
const i = Number(s.getAttribute(d.PAGE_TYPE)), n = c[i];
|
|
60
|
-
if (n) {
|
|
61
|
-
r.add(n);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const o = (u = (b = (a = this.findLinkCandidates(s).primary) == null ? void 0 : a.getAttribute("href")) == null ? void 0 : b.match(h)) == null ? void 0 : u[0];
|
|
65
|
-
o && r.add(c[this.getCollectionTypeFromMergeTag(o)]);
|
|
66
|
-
}), e.querySelectorAll("td.unsubscribe-block").forEach((s) => {
|
|
67
|
-
const i = this.getCollectionTypeFromMergeTag(this.getLegacyLinkTag(s));
|
|
68
|
-
t.getSelectedUnsubscribePagesByCollection(i).length && r.add(c[i]);
|
|
69
|
-
}), r;
|
|
70
|
-
}
|
|
71
|
-
// Mirrors extractUnsubscribeContent: without a <p> the block migrates on the default tag.
|
|
72
|
-
getLegacyLinkTag(e) {
|
|
73
|
-
var r, s;
|
|
74
|
-
const { primary: t } = this.findLinkCandidates(e);
|
|
75
|
-
return !t || !(t.closest("p") || e.querySelector("p")) ? c.default : ((s = (r = t.getAttribute("href")) == null ? void 0 : r.match(h)) == null ? void 0 : s[0]) ?? c.default;
|
|
76
|
-
}
|
|
77
48
|
// Re-derives the typed merge tag from data-unsubscribe-page-type for any v2
|
|
78
49
|
// block whose anchor href is missing or the legacy default. Returns true when
|
|
79
50
|
// at least one href was rewritten. Typed tags and custom URLs are left intact.
|
|
80
51
|
repairUnsubscribeLinks(e) {
|
|
81
|
-
const
|
|
82
|
-
let
|
|
83
|
-
return
|
|
84
|
-
const
|
|
85
|
-
if (!
|
|
52
|
+
const r = e.querySelectorAll(`${h}[${k.PAGE_TYPE}]`);
|
|
53
|
+
let t = !1;
|
|
54
|
+
return r.forEach((n) => {
|
|
55
|
+
const s = n.querySelector('a[data-unsubscribe-link="true"], a.unsubscribe-link');
|
|
56
|
+
if (!s)
|
|
86
57
|
return;
|
|
87
|
-
const
|
|
88
|
-
if (
|
|
58
|
+
const l = s.getAttribute("href") || "";
|
|
59
|
+
if (l && l !== f.default)
|
|
89
60
|
return;
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
}),
|
|
61
|
+
const a = Number(n.getAttribute(k.PAGE_TYPE)), o = f[a];
|
|
62
|
+
o && (s.setAttribute("href", o), t = !0);
|
|
63
|
+
}), t;
|
|
93
64
|
}
|
|
94
65
|
extractPaddingClass(e) {
|
|
95
|
-
const
|
|
96
|
-
return
|
|
97
|
-
}
|
|
98
|
-
hasVisibleContent(e) {
|
|
99
|
-
var t;
|
|
100
|
-
return !!((t = e.textContent) != null && t.trim() || e.querySelector("img"));
|
|
66
|
+
const t = (e.getAttribute("class") || "").match(/\bes-p\d+\b/);
|
|
67
|
+
return t ? t[0] : "";
|
|
101
68
|
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
69
|
+
extractUnsubscribeContent(e) {
|
|
70
|
+
var d;
|
|
71
|
+
const r = e.querySelector("a.unsubscribe-link") || e.querySelector('a[href*="unsubscribe"]'), t = (r == null ? void 0 : r.closest("p")) || e.querySelector("p");
|
|
72
|
+
if (!t)
|
|
73
|
+
return {
|
|
74
|
+
textBefore: "You can ",
|
|
75
|
+
linkText: "unsubscribe",
|
|
76
|
+
linkHref: "{{ins-unsubscribe-link}}",
|
|
77
|
+
linkStyle: "",
|
|
78
|
+
textAfter: " from our emails, if you need to.",
|
|
79
|
+
isBold: !1,
|
|
80
|
+
isItalic: !1,
|
|
81
|
+
align: "center",
|
|
82
|
+
paragraphStyle: ""
|
|
83
|
+
};
|
|
84
|
+
const n = e.getAttribute("align") || t.getAttribute("align") || "center", s = t.getAttribute("style") || "";
|
|
85
|
+
if (!r)
|
|
86
|
+
return {
|
|
87
|
+
textBefore: "You can ",
|
|
88
|
+
linkText: "unsubscribe",
|
|
89
|
+
linkHref: "{{ins-unsubscribe-link}}",
|
|
90
|
+
linkStyle: "",
|
|
91
|
+
textAfter: " from our emails, if you need to.",
|
|
92
|
+
isBold: !1,
|
|
93
|
+
isItalic: !1,
|
|
94
|
+
align: n,
|
|
95
|
+
paragraphStyle: s
|
|
96
|
+
};
|
|
97
|
+
const l = ((d = r.textContent) == null ? void 0 : d.trim()) || "unsubscribe", a = r.getAttribute("href") || "{{ins-unsubscribe-link}}", o = r.getAttribute("style") || "", b = t.textContent || "", u = b.indexOf(l), g = u >= 0 ? b.substring(0, u).trim() : "You can ", i = u >= 0 ? b.substring(u + l.length).trim() : " from our emails, if you need to.", m = !!t.querySelector("b, strong"), y = !!t.querySelector("i, em");
|
|
98
|
+
return {
|
|
99
|
+
textBefore: g,
|
|
100
|
+
linkText: l,
|
|
101
|
+
linkHref: this.normalizeUnsubscribeHref(a),
|
|
102
|
+
linkStyle: o,
|
|
103
|
+
textAfter: i,
|
|
104
|
+
isBold: m,
|
|
105
|
+
isItalic: y,
|
|
106
|
+
align: n,
|
|
107
|
+
paragraphStyle: s
|
|
117
108
|
};
|
|
118
|
-
if (!o || (a.align = e.getAttribute("align") || o.getAttribute("align") || "center", n || (a.paragraphStyle = o.getAttribute("style") || ""), !i))
|
|
119
|
-
return a;
|
|
120
|
-
if (a.linkText = this.hasVisibleContent(i) ? i.innerHTML.trim() : S, a.linkHref = this.normalizeUnsubscribeHref(i.getAttribute("href") || c.default), a.linkStyle = i.getAttribute("style") || "", n) {
|
|
121
|
-
const b = this.getCollectionTypeFromMergeTag(a.linkHref), u = c[b];
|
|
122
|
-
r.querySelectorAll("a[href]").forEach((l) => {
|
|
123
|
-
var m;
|
|
124
|
-
const p = l.getAttribute("href") || "", g = (m = p.match(h)) == null ? void 0 : m[0];
|
|
125
|
-
g && l.setAttribute("href", B(p, t.has(g) ? g : u));
|
|
126
|
-
}), s.filter((l) => l !== i && !this.hasVisibleContent(l)).forEach((l) => l.replaceWith(...Array.from(l.childNodes))), i.replaceWith(r.ownerDocument.createTextNode(C)), a.footerHtml = r.innerHTML.trim();
|
|
127
|
-
}
|
|
128
|
-
return a;
|
|
129
109
|
}
|
|
130
|
-
buildUnsubscribeBlock(e, t,
|
|
131
|
-
const
|
|
110
|
+
buildUnsubscribeBlock(e, r, t, n, s) {
|
|
111
|
+
const l = e.linkStyle ? ` style="${e.linkStyle}"` : "", u = `<a ${`href="${Object.values(f).includes(e.linkHref) ? f[r] : e.linkHref}" class="unsubscribe-link" target="_blank" data-unsubscribe-link="true"`}${l}>${e.linkText}</a>`, g = [];
|
|
112
|
+
e.textBefore && g.push(e.textBefore), g.push(u), e.textAfter && g.push(e.textAfter);
|
|
113
|
+
let i = g.join(" ");
|
|
114
|
+
e.isBold && e.isItalic ? i = `<strong path="1,0"><em path="1,0,0">${i}</em></strong>` : e.isBold ? i = `<strong path="1,0">${i}</strong>` : e.isItalic && (i = `<em path="1,0">${i}</em>`);
|
|
115
|
+
const m = e.align ? ` align="${e.align}"` : "", y = s ? ` bgcolor="${s}"` : "", d = e.paragraphStyle ? ` style="${e.paragraphStyle}"` : "", T = t.length > 0 ? ` ${k.PAGE_LIST}="${t.join(",")}"` : "", E = ` ${k.PAGE_TYPE}="${r}"`, S = "esd-block-text unsubscribe-block-v2 esd-block-unsubscribe esd-unsubscribe-block esd-extension-block";
|
|
132
116
|
return `
|
|
133
117
|
<td
|
|
134
118
|
data-migration="true"
|
|
135
119
|
esd-extension-block-id="unsubscribe-block"
|
|
136
|
-
class="${
|
|
137
|
-
${
|
|
120
|
+
class="${n ? `${S} ${n}` : S}"
|
|
121
|
+
${m}${y}${E}${T}
|
|
138
122
|
>
|
|
139
|
-
${
|
|
123
|
+
<p path="1"${d}>
|
|
124
|
+
${i}
|
|
125
|
+
</p>
|
|
140
126
|
</td>
|
|
141
127
|
`;
|
|
142
128
|
}
|
|
143
129
|
getCollectionTypeFromMergeTag(e) {
|
|
144
|
-
return e ===
|
|
130
|
+
return e === f[p.SUBSCRIPTION_PREFERENCE_CENTER] ? p.SUBSCRIPTION_PREFERENCE_CENTER : e === f[p.GLOBAL_UNSUBSCRIBE] ? p.GLOBAL_UNSUBSCRIBE : p.GLOBAL_UNSUBSCRIBE;
|
|
145
131
|
}
|
|
146
132
|
normalizeUnsubscribeHref(e) {
|
|
147
|
-
if (Object.values(
|
|
133
|
+
if (Object.values(f).includes(e))
|
|
148
134
|
return e;
|
|
149
|
-
const
|
|
150
|
-
return
|
|
135
|
+
const t = e.match(/{{ins-(?:global-)?(?:preferences-)?unsubscribe-link}}/);
|
|
136
|
+
return t ? t[0] : e.includes("unsubscribe") || e.includes("unsub") ? (console.warn(
|
|
151
137
|
`[UnsubscribeMigrator] Unrecognized unsubscribe href format: "${e}". Defaulting to {{ins-unsubscribe-link}}`
|
|
152
138
|
), "{{ins-unsubscribe-link}}") : e;
|
|
153
139
|
}
|
|
154
140
|
}
|
|
155
|
-
async function
|
|
156
|
-
return new
|
|
141
|
+
async function M(c) {
|
|
142
|
+
return new $().migrate(c);
|
|
157
143
|
}
|
|
158
144
|
export {
|
|
159
|
-
|
|
145
|
+
M as migrateUnsubscribe
|
|
160
146
|
};
|