@useinsider/guido 3.30.0-beta.232ea3c → 3.30.0-beta.2d741af
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 +12 -1
- package/dist/components/Guido.vue.js +5 -5
- package/dist/components/Guido.vue2.js +112 -106
- package/dist/components/organisms/unsubscribe/SfmcUnsubscribeConvertedModal.vue.js +17 -0
- package/dist/components/organisms/unsubscribe/SfmcUnsubscribeConvertedModal.vue2.js +30 -0
- package/dist/composables/useModuleRepair.js +56 -50
- package/dist/composables/useStripo.js +87 -79
- package/dist/config/migrator/index.js +10 -9
- package/dist/config/migrator/sfmcUnsubscribeTextMigrator.js +20 -0
- package/dist/enums/academy.js +2 -1
- package/dist/guido.css +1 -1
- package/dist/package.json.js +2 -2
- package/dist/src/components/organisms/unsubscribe/SfmcUnsubscribeConvertedModal.vue.d.ts +2 -0
- package/dist/src/composables/useModuleRepair.d.ts +1 -1
- package/dist/src/config/migrator/sfmcUnsubscribeTextMigrator.d.ts +1 -0
- package/dist/src/enums/academy.d.ts +1 -0
- package/dist/src/stores/editor.d.ts +54 -0
- package/dist/src/utils/legacyUnsubscribeConversion.d.ts +3 -0
- package/dist/stores/editor.js +2 -0
- package/dist/utils/legacyUnsubscribeConversion.js +69 -28
- package/package.json +1 -1
|
@@ -1,49 +1,90 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { hasInsiderUnsubscribeCode as f } from "../composables/validators/useUnsubscribeBlockValidator.js";
|
|
2
|
+
import { UNSUBSCRIBE_LINK_SELECTOR as A } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
3
|
+
import { protectLiquid as C, restoreLiquid as _ } from "./liquidProtection.js";
|
|
4
|
+
const u = "td.unsubscribe-block", p = ["a.unsubscribe-link", 'a[href*="unsubscribe"]'], v = `${u}, .unsubscribe-block-v2`, y = "esd-block-text", U = [
|
|
3
5
|
"unsubscribe-block",
|
|
4
6
|
"esd-extension",
|
|
5
7
|
"esd-extension-block",
|
|
6
8
|
"esd-unsubscribe-block",
|
|
7
9
|
"esd-block-unsubscribe"
|
|
8
|
-
],
|
|
9
|
-
e.classList.remove(...
|
|
10
|
-
},
|
|
11
|
-
const t =
|
|
12
|
-
return t.
|
|
13
|
-
},
|
|
10
|
+
], h = "unsubscribe-block-v2", T = "esd-extension-block-id", l = "data-unsubscribe-", g = "unsubscribe-link", k = "address,article,aside,blockquote,center,details,dialog,dir,div,dd,dl,dt,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,hr,li,listing,main,menu,nav,ol,p,plaintext,pre,search,section,summary,table,ul,xmp", I = new RegExp(`class\\s*=\\s*(?:["'][^"']*)?(?<![\\w-])unsubscribe-block(?![\\w-])`, "i"), N = new RegExp(`class\\s*=\\s*(?:["'][^"']*)?(?<![\\w-])unsubscribe-block(?:-v2)?(?![\\w-])`, "i"), R = (e) => typeof e == "string" && I.test(e), B = (e) => p.some((t) => e.querySelector(t) !== null), b = (e) => {
|
|
11
|
+
e.classList.remove(...U), e.classList.add(y), e.removeAttribute(T), Array.from(e.attributes).filter(({ name: t }) => t.startsWith(l)).forEach(({ name: t }) => e.removeAttribute(t)), e.querySelector(k) || (e.innerHTML = `<p path="1">${e.innerHTML}</p>`);
|
|
12
|
+
}, O = (e) => {
|
|
13
|
+
const t = e.getAttribute("href") ?? "";
|
|
14
|
+
return f(t) || t.trim() === "" && e.matches(A);
|
|
15
|
+
}, M = (e) => {
|
|
16
|
+
e.classList.remove(g), e.classList.length === 0 && e.removeAttribute("class"), Array.from(e.attributes).filter(({ name: t }) => t.startsWith(l)).forEach(({ name: t }) => e.removeAttribute(t));
|
|
17
|
+
}, x = (e) => {
|
|
18
|
+
Array.from(e.querySelectorAll("a")).forEach((t) => {
|
|
19
|
+
if (O(t)) {
|
|
20
|
+
t.replaceWith(...Array.from(t.childNodes));
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
M(t);
|
|
24
|
+
});
|
|
25
|
+
}, q = (e) => typeof e == "string" && N.test(e), D = (e) => {
|
|
26
|
+
const t = Array.from(e.querySelectorAll(v));
|
|
27
|
+
return t.forEach((r) => {
|
|
28
|
+
r.classList.remove(h), x(r), b(r);
|
|
29
|
+
}), t.length;
|
|
30
|
+
}, H = (e) => {
|
|
31
|
+
const t = Array.from(e.querySelectorAll(u)).filter((r) => !B(r));
|
|
32
|
+
return t.forEach(b), t.length;
|
|
33
|
+
}, a = (e) => {
|
|
14
34
|
const t = e.trimStart(), r = new DOMParser();
|
|
15
35
|
return /^<t[dh][\s>]/i.test(t) ? r.parseFromString(`<table><tbody><tr>${e}</tr></tbody></table>`, "text/html").querySelector("tr") : /^<tr[\s>]/i.test(t) ? r.parseFromString(`<table><tbody>${e}</tbody></table>`, "text/html").querySelector("tbody") : /^<table[\s>]/i.test(t) ? r.parseFromString(e, "text/html").body : (console.debug("[LegacyUnsubscribeConversion] Skipped module with a non-table root"), null);
|
|
16
|
-
},
|
|
36
|
+
}, d = (e) => {
|
|
17
37
|
const t = e.search(/<html[\s>]/i), r = [...e.matchAll(/<\/html\s*>/gi)].at(-1), s = (r == null ? void 0 : r.index) === void 0 ? -1 : r.index + r[0].length;
|
|
18
38
|
return t < 0 || s <= t ? { head: "", root: e, tail: "" } : { head: e.slice(0, t), root: e.slice(t, s), tail: e.slice(s) };
|
|
19
|
-
},
|
|
20
|
-
|
|
39
|
+
}, K = {
|
|
40
|
+
detect: R,
|
|
41
|
+
convertCells: H
|
|
42
|
+
}, S = {
|
|
43
|
+
detect: q,
|
|
44
|
+
convertCells: D
|
|
45
|
+
}, n = (e, t, r, s, i = K) => {
|
|
46
|
+
if (!i.detect(e))
|
|
21
47
|
return { html: e, converted: !1 };
|
|
22
48
|
try {
|
|
23
|
-
const o =
|
|
24
|
-
return !
|
|
49
|
+
const o = C(e), c = t(o);
|
|
50
|
+
return !c || i.convertCells(c) === 0 ? { html: e, converted: !1 } : { html: _(r(c, o)), converted: !0 };
|
|
25
51
|
} catch (o) {
|
|
26
52
|
return console.error(`Failed to convert legacy unsubscribe blocks in ${s}:`, o), { html: e, converted: !1 };
|
|
27
53
|
}
|
|
28
|
-
},
|
|
54
|
+
}, m = (e) => e.innerHTML, E = (e) => new DOMParser().parseFromString(d(e).root, "text/html"), L = (e, t) => {
|
|
55
|
+
const { head: r, tail: s } = d(t);
|
|
56
|
+
return `${r}${e.documentElement.outerHTML}${s}`;
|
|
57
|
+
}, F = (e) => n(
|
|
29
58
|
e,
|
|
30
|
-
|
|
31
|
-
|
|
59
|
+
a,
|
|
60
|
+
m,
|
|
32
61
|
"module"
|
|
33
|
-
),
|
|
62
|
+
), G = (e) => n(
|
|
34
63
|
e,
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const { head: s, tail: o } = c(r);
|
|
38
|
-
return `${s}${t.documentElement.outerHTML}${o}`;
|
|
39
|
-
},
|
|
64
|
+
E,
|
|
65
|
+
L,
|
|
40
66
|
"document"
|
|
67
|
+
), P = (e) => n(
|
|
68
|
+
e,
|
|
69
|
+
a,
|
|
70
|
+
m,
|
|
71
|
+
"module",
|
|
72
|
+
S
|
|
73
|
+
), V = (e) => n(
|
|
74
|
+
e,
|
|
75
|
+
E,
|
|
76
|
+
L,
|
|
77
|
+
"document",
|
|
78
|
+
S
|
|
41
79
|
);
|
|
42
80
|
export {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
81
|
+
p as LEGACY_UNSUBSCRIBE_LINK_SELECTORS,
|
|
82
|
+
u as LEGACY_UNSUBSCRIBE_SELECTOR,
|
|
83
|
+
V as convertAllUnsubscribeInDocumentHtml,
|
|
84
|
+
P as convertAllUnsubscribeInModuleHtml,
|
|
85
|
+
G as convertLegacyUnsubscribeInDocumentHtml,
|
|
86
|
+
F as convertLegacyUnsubscribeInModuleHtml,
|
|
87
|
+
H as convertLinklessLegacyUnsubscribeBlocks,
|
|
88
|
+
q as hasAnyUnsubscribeClass,
|
|
89
|
+
R as hasLegacyUnsubscribeClass
|
|
49
90
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.30.0-beta.
|
|
3
|
+
"version": "3.30.0-beta.2d741af",
|
|
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",
|