@useinsider/guido 3.9.0-beta.c3e1698 → 3.9.0-beta.dd40fcd
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.
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
var x = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var
|
|
2
|
+
var E = (o, e, t) => e in o ? x(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
|
+
var h = (o, e, t) => E(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
4
|
import { MERGE_TAGS as f, PAGE_TYPES as p } from "../../enums/unsubscribe.js";
|
|
5
|
-
import {
|
|
6
|
-
import { useUnsubscribeStore as
|
|
7
|
-
class
|
|
5
|
+
import { DATA_ATTRIBUTES as A } from "../../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
6
|
+
import { useUnsubscribeStore as B } from "../../stores/unsubscribe.js";
|
|
7
|
+
class C {
|
|
8
8
|
constructor() {
|
|
9
|
-
|
|
9
|
+
h(this, "parser");
|
|
10
10
|
this.parser = new DOMParser();
|
|
11
11
|
}
|
|
12
12
|
async migrate(e) {
|
|
13
13
|
try {
|
|
14
14
|
const t = this.parser.parseFromString(e, "text/html"), r = t.querySelectorAll("td.unsubscribe-block");
|
|
15
15
|
if (r.length) {
|
|
16
|
-
const s =
|
|
16
|
+
const s = B();
|
|
17
17
|
await s.fetchTemplates(), this.migrateLegacyBlocks(r, s);
|
|
18
18
|
}
|
|
19
19
|
const n = this.repairUnsubscribeLinks(t);
|
|
@@ -24,24 +24,24 @@ class $ {
|
|
|
24
24
|
}
|
|
25
25
|
migrateLegacyBlocks(e, t) {
|
|
26
26
|
e.forEach((r) => {
|
|
27
|
-
const n = r.getAttribute("id"), s = this.extractPaddingClass(r), l = r.getAttribute("bgcolor") || "", a = this.extractUnsubscribeContent(r),
|
|
27
|
+
const n = r.getAttribute("id"), s = this.extractPaddingClass(r), l = r.getAttribute("bgcolor") || "", a = this.extractUnsubscribeContent(r), c = this.getCollectionTypeFromMergeTag(a.linkHref), b = t.getSelectedUnsubscribePagesByCollection(c);
|
|
28
28
|
console.debug("[UnsubscribeMigrator]", {
|
|
29
29
|
mergeTag: a.linkHref,
|
|
30
|
-
collectionType:
|
|
30
|
+
collectionType: c,
|
|
31
31
|
pageIds: b,
|
|
32
32
|
paddingClass: s,
|
|
33
33
|
bgColor: l
|
|
34
34
|
});
|
|
35
35
|
const u = this.buildUnsubscribeBlock(
|
|
36
36
|
a,
|
|
37
|
-
|
|
37
|
+
c,
|
|
38
38
|
b,
|
|
39
39
|
s,
|
|
40
40
|
l
|
|
41
41
|
), i = this.parser.parseFromString(
|
|
42
42
|
`<table id="tempDoc"><tbody><tr>${u}</tr></tbody></table>`,
|
|
43
43
|
"text/html"
|
|
44
|
-
).querySelector(
|
|
44
|
+
).querySelector(".unsubscribe-block-v2");
|
|
45
45
|
i && r.parentNode && (i.setAttribute("id", n || ""), r.parentNode.replaceChild(i, r));
|
|
46
46
|
});
|
|
47
47
|
}
|
|
@@ -49,17 +49,17 @@ class $ {
|
|
|
49
49
|
// block whose anchor href is missing or the legacy default. Returns true when
|
|
50
50
|
// at least one href was rewritten. Typed tags and custom URLs are left intact.
|
|
51
51
|
repairUnsubscribeLinks(e) {
|
|
52
|
-
const t = e.querySelectorAll(
|
|
52
|
+
const t = e.querySelectorAll(".unsubscribe-block-v2[data-unsubscribe-page-type]");
|
|
53
53
|
let r = !1;
|
|
54
54
|
return t.forEach((n) => {
|
|
55
55
|
const s = n.querySelector('a[data-unsubscribe-link="true"], a.unsubscribe-link');
|
|
56
56
|
if (!s)
|
|
57
57
|
return;
|
|
58
58
|
const l = s.getAttribute("href") || "";
|
|
59
|
-
if (l && l !== f.default)
|
|
59
|
+
if (l !== "" && l !== f.default)
|
|
60
60
|
return;
|
|
61
|
-
const a = Number(n.getAttribute(
|
|
62
|
-
|
|
61
|
+
const a = Number(n.getAttribute("data-unsubscribe-page-type")), c = f[a];
|
|
62
|
+
c && (s.setAttribute("href", c), r = !0);
|
|
63
63
|
}), r;
|
|
64
64
|
}
|
|
65
65
|
extractPaddingClass(e) {
|
|
@@ -94,15 +94,15 @@ class $ {
|
|
|
94
94
|
align: r,
|
|
95
95
|
paragraphStyle: n
|
|
96
96
|
};
|
|
97
|
-
const l = ((d = s.textContent) == null ? void 0 : d.trim()) || "unsubscribe", a = s.getAttribute("href") || "{{ins-unsubscribe-link}}",
|
|
97
|
+
const l = ((d = s.textContent) == null ? void 0 : d.trim()) || "unsubscribe", a = s.getAttribute("href") || "{{ins-unsubscribe-link}}", c = s.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.", k = !!t.querySelector("b, strong"), m = !!t.querySelector("i, em");
|
|
98
98
|
return {
|
|
99
99
|
textBefore: g,
|
|
100
100
|
linkText: l,
|
|
101
101
|
linkHref: this.normalizeUnsubscribeHref(a),
|
|
102
|
-
linkStyle:
|
|
102
|
+
linkStyle: c,
|
|
103
103
|
textAfter: i,
|
|
104
|
-
isBold:
|
|
105
|
-
isItalic:
|
|
104
|
+
isBold: k,
|
|
105
|
+
isItalic: m,
|
|
106
106
|
align: r,
|
|
107
107
|
paragraphStyle: n
|
|
108
108
|
};
|
|
@@ -112,13 +112,13 @@ class $ {
|
|
|
112
112
|
e.textBefore && g.push(e.textBefore), g.push(u), e.textAfter && g.push(e.textAfter);
|
|
113
113
|
let i = g.join(" ");
|
|
114
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
|
|
115
|
+
const k = e.align ? ` align="${e.align}"` : "", m = s ? ` bgcolor="${s}"` : "", d = e.paragraphStyle ? ` style="${e.paragraphStyle}"` : "", S = r.length > 0 ? ` ${A.PAGE_LIST}="${r.join(",")}"` : "", T = ` ${A.PAGE_TYPE}="${t}"`, y = "esd-block-text unsubscribe-block-v2 esd-block-unsubscribe esd-unsubscribe-block esd-extension-block";
|
|
116
116
|
return `
|
|
117
117
|
<td
|
|
118
118
|
data-migration="true"
|
|
119
119
|
esd-extension-block-id="unsubscribe-block"
|
|
120
|
-
class="${n ? `${
|
|
121
|
-
${
|
|
120
|
+
class="${n ? `${y} ${n}` : y}"
|
|
121
|
+
${k}${m}${T}${S}
|
|
122
122
|
>
|
|
123
123
|
<p path="1"${d}>
|
|
124
124
|
${i}
|
|
@@ -138,9 +138,9 @@ class $ {
|
|
|
138
138
|
), "{{ins-unsubscribe-link}}") : e;
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
|
-
async function
|
|
142
|
-
return new
|
|
141
|
+
async function H(o) {
|
|
142
|
+
return new C().migrate(o);
|
|
143
143
|
}
|
|
144
144
|
export {
|
|
145
|
-
|
|
145
|
+
H as migrateUnsubscribe
|
|
146
146
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.9.0-beta.
|
|
3
|
+
"version": "3.9.0-beta.dd40fcd",
|
|
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",
|