@useinsider/guido 3.30.0-beta.23d415d → 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 -18
- package/dist/@types/config/schemas.js +5 -7
- package/dist/components/Guido.vue.js +5 -5
- package/dist/components/Guido.vue2.js +110 -105
- package/dist/components/organisms/unsubscribe/SfmcUnsubscribeConvertedModal.vue.js +17 -0
- package/dist/components/organisms/unsubscribe/SfmcUnsubscribeConvertedModal.vue2.js +30 -0
- package/dist/composables/useHtmlCompiler.js +13 -15
- package/dist/composables/useModuleRepair.js +56 -50
- package/dist/composables/useStripo.js +85 -79
- package/dist/config/compiler/liquidCompilerRules.js +5 -13
- 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/extensions/DynamicContent/dynamic-content.js +33 -56
- package/dist/guido.css +1 -1
- package/dist/package.json.js +1 -1
- package/dist/src/@types/config/schemas.d.ts +0 -4
- package/dist/src/@types/generic.d.ts +0 -10
- package/dist/src/components/organisms/unsubscribe/SfmcUnsubscribeConvertedModal.vue.d.ts +2 -0
- package/dist/src/composables/useConfig.d.ts +0 -2
- 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/extensions/DynamicContent/dynamic-content.d.ts +0 -11
- package/dist/src/stores/config.d.ts +0 -21
- package/dist/src/stores/editor.d.ts +54 -0
- package/dist/src/utils/genericUtil.d.ts +1 -6
- package/dist/src/utils/legacyUnsubscribeConversion.d.ts +3 -0
- package/dist/stores/editor.js +2 -0
- package/dist/utils/genericUtil.js +45 -55
- package/dist/utils/legacyUnsubscribeConversion.js +69 -28
- package/package.json +1 -1
- package/dist/src/utils/clipboardText.d.ts +0 -1
- package/dist/src/utils/linkTokenPaste.d.ts +0 -3
- package/dist/src/utils/liquidLinkQuotes.d.ts +0 -4
- package/dist/utils/clipboardText.js +0 -31
- package/dist/utils/linkTokenPaste.js +0 -28
- package/dist/utils/liquidLinkQuotes.js +0 -10
|
@@ -1,88 +1,78 @@
|
|
|
1
|
-
import { formatToLiquidFilter as
|
|
2
|
-
const
|
|
1
|
+
import { formatToLiquidFilter as y, liquidFilterToFormat as g, quoteArgument as m } from "./liquidDynamicContent.js";
|
|
2
|
+
const v = (t) => {
|
|
3
3
|
if (!t.includes("="))
|
|
4
4
|
return null;
|
|
5
|
-
const [
|
|
6
|
-
return { key:
|
|
7
|
-
}, u = "default:",
|
|
5
|
+
const [r, e] = t.split("=");
|
|
6
|
+
return { key: r.trim(), value: e.trim() };
|
|
7
|
+
}, u = "default:", i = (t) => {
|
|
8
8
|
if (!t.startsWith(u))
|
|
9
9
|
return t;
|
|
10
|
-
const
|
|
11
|
-
return e('"') || e("'") ?
|
|
12
|
-
},
|
|
13
|
-
const e = t.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((
|
|
10
|
+
const r = t.slice(u.length).trim(), e = (n) => r.length >= 2 && r.startsWith(n) && r.endsWith(n);
|
|
11
|
+
return e('"') || e("'") ? r.slice(1, -1) : r;
|
|
12
|
+
}, $ = (t) => {
|
|
13
|
+
const e = t.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((a) => a.trim()), [n] = e, s = {
|
|
14
14
|
text: t.label,
|
|
15
|
-
value:
|
|
15
|
+
value: n || ""
|
|
16
16
|
};
|
|
17
17
|
if (e.length >= 2) {
|
|
18
|
-
const [,
|
|
19
|
-
if (
|
|
20
|
-
|
|
18
|
+
const [, a, o] = e;
|
|
19
|
+
if (a.startsWith(u))
|
|
20
|
+
s.fallback = i(a);
|
|
21
21
|
else {
|
|
22
|
-
const
|
|
23
|
-
|
|
22
|
+
const l = g(a) ?? v(a);
|
|
23
|
+
l ? s.format = l : o || (s.fallback = a), o && (s.fallback = i(o));
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
return
|
|
27
|
-
},
|
|
28
|
-
const e = !Number.isNaN(Number(t)) && t.trim() !== "" ? t :
|
|
26
|
+
return s;
|
|
27
|
+
}, h = (t) => {
|
|
28
|
+
const e = !Number.isNaN(Number(t)) && t.trim() !== "" ? t : m(t);
|
|
29
29
|
return e === null ? null : `${u} ${e}`;
|
|
30
|
-
},
|
|
31
|
-
const
|
|
30
|
+
}, p = (t) => {
|
|
31
|
+
const r = t.format ? y(t.format) : null, e = t.fallback ? h(t.fallback) : null, n = [t.value, r, e].filter(Boolean);
|
|
32
32
|
return {
|
|
33
|
-
label: [t.text,
|
|
34
|
-
value: `{{ ${
|
|
33
|
+
label: [t.text, r, e && t.fallback].filter(Boolean).join(" | "),
|
|
34
|
+
value: `{{ ${n.join(" | ")} }}`
|
|
35
35
|
};
|
|
36
|
-
},
|
|
36
|
+
}, b = (t, r = !1) => t.map((e) => r ? p(e) : e.format ? {
|
|
37
37
|
label: `${e.text} | ${e.format.key}=${e.format.value}`,
|
|
38
38
|
value: `{{${e.value}|${e.format.key}=${e.format.value}}}`
|
|
39
39
|
} : {
|
|
40
40
|
label: e.fallback ? `${e.text} | ${e.fallback}` : e.text,
|
|
41
41
|
value: e.fallback ? `{{${e.value}|${e.fallback}}}` : `{{${e.value}}}`
|
|
42
|
-
}),
|
|
43
|
-
const
|
|
44
|
-
Array.isArray(
|
|
45
|
-
const f = [...
|
|
42
|
+
}), k = (t) => {
|
|
43
|
+
const r = [], e = /* @__PURE__ */ new Set(), n = (a, o) => {
|
|
44
|
+
Array.isArray(a) && a.forEach((l) => {
|
|
45
|
+
const f = [...l.children ?? [], ...l.select_items ?? []], c = l.text || l.tag_text;
|
|
46
46
|
if (f.length > 0) {
|
|
47
|
-
|
|
47
|
+
n(f, c ? [...o, c] : o);
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
c && l.value && !e.has(l.value) && (e.add(l.value), r.push({ value: l.value, text: c, tagText: l.tag_text || c, path: o }));
|
|
51
51
|
});
|
|
52
|
-
}, [
|
|
53
|
-
return
|
|
54
|
-
},
|
|
55
|
-
const
|
|
52
|
+
}, [s] = Object.values(t ?? {});
|
|
53
|
+
return n(s, []), r;
|
|
54
|
+
}, x = (t) => k(t).map(({ text: r, value: e }) => ({ text: r, value: e })), T = (t, r, e = !1) => {
|
|
55
|
+
const n = new Set(t.map((a) => a.value)), s = r.filter((a) => n.has(a.value) ? !1 : (n.add(a.value), !0));
|
|
56
56
|
return [
|
|
57
|
-
...
|
|
58
|
-
...
|
|
57
|
+
...b(t, e),
|
|
58
|
+
...b(s, e)
|
|
59
59
|
];
|
|
60
|
-
}, k = /url(_\d+)?$/i, _ = /^call_an_api_response_/, $ = (t) => k.test(t) || _.test(t), P = (t, a = !1) => {
|
|
61
|
-
const [e] = Object.values(t ?? {});
|
|
62
|
-
return (e ?? []).map((r) => {
|
|
63
|
-
const l = h({ node: [r] }).filter((n) => $(n.value));
|
|
64
|
-
return {
|
|
65
|
-
category: r.text || r.tag_text || "",
|
|
66
|
-
entries: i(l, a).map(({ label: n, value: c }) => ({ label: n, value: c }))
|
|
67
|
-
};
|
|
68
|
-
}).filter((r) => r.category && r.entries.length > 0);
|
|
69
60
|
}, F = () => {
|
|
70
61
|
var t;
|
|
71
62
|
return ((t = document.head.querySelector('meta[name="csrf-token"]')) == null ? void 0 : t.getAttribute("content")) ?? "";
|
|
72
|
-
},
|
|
63
|
+
}, P = (t) => typeof t == "string" ? t : typeof t == "number" ? String(t) : "", j = (t) => {
|
|
73
64
|
if (t === null || typeof t != "object" || Array.isArray(t))
|
|
74
65
|
return !1;
|
|
75
|
-
const
|
|
76
|
-
return
|
|
66
|
+
const r = Object.getPrototypeOf(t);
|
|
67
|
+
return r === Object.prototype || r === null;
|
|
77
68
|
};
|
|
78
69
|
export {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
h as flattenDynamicContentList,
|
|
70
|
+
P as asText,
|
|
71
|
+
T as buildMergeTagEntries,
|
|
72
|
+
b as dynamicContentToMergeTags,
|
|
73
|
+
k as flattenDynamicContentCandidates,
|
|
74
|
+
x as flattenDynamicContentList,
|
|
85
75
|
F as getCsrfToken,
|
|
86
|
-
|
|
87
|
-
|
|
76
|
+
j as isPlainObject,
|
|
77
|
+
$ as mergeTagToDynamicContent
|
|
88
78
|
};
|
|
@@ -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",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const clipboardHtmlToPlainText: (html: string) => string | null;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const i = "p, div, li, h1, h2, h3, h4, h5, h6, td", d = "style, script", l = /\u200B/g, o = (e) => {
|
|
2
|
-
const n = e.replace(/[ \t]+$/, "");
|
|
3
|
-
return n && !n.endsWith(`
|
|
4
|
-
`) ? `${n}
|
|
5
|
-
` : n;
|
|
6
|
-
}, E = (e, n) => {
|
|
7
|
-
const r = n.replace(l, "").replace(/[ \t]*[\r\n]\s*/g, " ");
|
|
8
|
-
return e + (e === "" || e.endsWith(`
|
|
9
|
-
`) ? r.replace(/^[ \t]+/, "") : r);
|
|
10
|
-
}, s = (e, n) => {
|
|
11
|
-
if (n.nodeType === Node.TEXT_NODE)
|
|
12
|
-
return E(e, n.textContent ?? "");
|
|
13
|
-
if (n.nodeType !== Node.ELEMENT_NODE)
|
|
14
|
-
return e;
|
|
15
|
-
const r = n;
|
|
16
|
-
if (r.matches(d))
|
|
17
|
-
return e;
|
|
18
|
-
if (r.matches("br"))
|
|
19
|
-
return `${e}
|
|
20
|
-
`;
|
|
21
|
-
const t = r.matches(i), c = Array.from(r.childNodes).reduce(s, t ? o(e) : e);
|
|
22
|
-
return t ? o(c) : c;
|
|
23
|
-
}, N = (e) => {
|
|
24
|
-
if (!e.includes("{{"))
|
|
25
|
-
return null;
|
|
26
|
-
const { body: n } = new DOMParser().parseFromString(e, "text/html"), r = Array.from(n.childNodes).reduce(s, "").trim();
|
|
27
|
-
return r.includes("{{") ? r : null;
|
|
28
|
-
};
|
|
29
|
-
export {
|
|
30
|
-
N as clipboardHtmlToPlainText
|
|
31
|
-
};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { findEditorShadowRoot as a } from "./editorShadowRoot.js";
|
|
2
|
-
const l = ".e2e-link-input .contenteditable-input", c = "https://", p = /^\{\{[^{}]+\}\}$/;
|
|
3
|
-
let e = null;
|
|
4
|
-
const d = (t) => p.test(t), u = (t) => {
|
|
5
|
-
var i;
|
|
6
|
-
const n = t instanceof Element ? t.closest(l) : null;
|
|
7
|
-
return ((i = n == null ? void 0 : n.textContent) == null ? void 0 : i.trim()) === c ? n : null;
|
|
8
|
-
}, r = (t) => {
|
|
9
|
-
var o, s;
|
|
10
|
-
const n = ((o = t.clipboardData) == null ? void 0 : o.getData("text/plain").trim()) ?? "", i = d(n) ? u(t.target) : null;
|
|
11
|
-
if (!i)
|
|
12
|
-
return;
|
|
13
|
-
(s = window.getSelection()) == null || s.selectAllChildren(i), !i.dispatchEvent(new InputEvent("beforeinput", {
|
|
14
|
-
inputType: "insertFromPaste",
|
|
15
|
-
data: n,
|
|
16
|
-
bubbles: !0,
|
|
17
|
-
cancelable: !0
|
|
18
|
-
})) && (t.preventDefault(), t.stopImmediatePropagation());
|
|
19
|
-
}, E = () => {
|
|
20
|
-
e == null || e.removeEventListener("paste", r, !0), e = null;
|
|
21
|
-
}, m = () => {
|
|
22
|
-
E(), e = a(), e == null || e.addEventListener("paste", r, !0);
|
|
23
|
-
};
|
|
24
|
-
export {
|
|
25
|
-
E as disposeLinkTokenPaste,
|
|
26
|
-
d as isBareToken,
|
|
27
|
-
m as listenForLinkTokenPaste
|
|
28
|
-
};
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const o = /\s([\w:-]+)\s*=\s*(?:"[^"]*"|'[^']*')/g, E = /^(?:href|src)$/i, e = /\{\{[^{}]*\}\}/g, c = /'[^']*'|'.*?'|"(.*?)"/gs, i = /'|'|'|'|"|"/i, T = (t) => t.replace(
|
|
2
|
-
c,
|
|
3
|
-
(n, s) => s === void 0 || i.test(s) || s.startsWith("//") ? n : `'${s}'`
|
|
4
|
-
);
|
|
5
|
-
function r(t) {
|
|
6
|
-
return t.includes(""") ? t.replace(o, (n, s) => E.test(s) && n.endsWith('"') ? n.replace(e, T) : n) : t;
|
|
7
|
-
}
|
|
8
|
-
export {
|
|
9
|
-
r as singleQuoteLiquidLinks
|
|
10
|
-
};
|