@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.
Files changed (38) hide show
  1. package/README.md +12 -18
  2. package/dist/@types/config/schemas.js +5 -7
  3. package/dist/components/Guido.vue.js +5 -5
  4. package/dist/components/Guido.vue2.js +110 -105
  5. package/dist/components/organisms/unsubscribe/SfmcUnsubscribeConvertedModal.vue.js +17 -0
  6. package/dist/components/organisms/unsubscribe/SfmcUnsubscribeConvertedModal.vue2.js +30 -0
  7. package/dist/composables/useHtmlCompiler.js +13 -15
  8. package/dist/composables/useModuleRepair.js +56 -50
  9. package/dist/composables/useStripo.js +85 -79
  10. package/dist/config/compiler/liquidCompilerRules.js +5 -13
  11. package/dist/config/migrator/index.js +10 -9
  12. package/dist/config/migrator/sfmcUnsubscribeTextMigrator.js +20 -0
  13. package/dist/enums/academy.js +2 -1
  14. package/dist/extensions/DynamicContent/dynamic-content.js +33 -56
  15. package/dist/guido.css +1 -1
  16. package/dist/package.json.js +1 -1
  17. package/dist/src/@types/config/schemas.d.ts +0 -4
  18. package/dist/src/@types/generic.d.ts +0 -10
  19. package/dist/src/components/organisms/unsubscribe/SfmcUnsubscribeConvertedModal.vue.d.ts +2 -0
  20. package/dist/src/composables/useConfig.d.ts +0 -2
  21. package/dist/src/composables/useModuleRepair.d.ts +1 -1
  22. package/dist/src/config/migrator/sfmcUnsubscribeTextMigrator.d.ts +1 -0
  23. package/dist/src/enums/academy.d.ts +1 -0
  24. package/dist/src/extensions/DynamicContent/dynamic-content.d.ts +0 -11
  25. package/dist/src/stores/config.d.ts +0 -21
  26. package/dist/src/stores/editor.d.ts +54 -0
  27. package/dist/src/utils/genericUtil.d.ts +1 -6
  28. package/dist/src/utils/legacyUnsubscribeConversion.d.ts +3 -0
  29. package/dist/stores/editor.js +2 -0
  30. package/dist/utils/genericUtil.js +45 -55
  31. package/dist/utils/legacyUnsubscribeConversion.js +69 -28
  32. package/package.json +1 -1
  33. package/dist/src/utils/clipboardText.d.ts +0 -1
  34. package/dist/src/utils/linkTokenPaste.d.ts +0 -3
  35. package/dist/src/utils/liquidLinkQuotes.d.ts +0 -4
  36. package/dist/utils/clipboardText.js +0 -31
  37. package/dist/utils/linkTokenPaste.js +0 -28
  38. package/dist/utils/liquidLinkQuotes.js +0 -10
@@ -1,88 +1,78 @@
1
- import { formatToLiquidFilter as g, liquidFilterToFormat as p, quoteArgument as y } from "./liquidDynamicContent.js";
2
- const m = (t) => {
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 [a, e] = t.split("=");
6
- return { key: a.trim(), value: e.trim() };
7
- }, u = "default:", b = (t) => {
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 a = t.slice(u.length).trim(), e = (r) => a.length >= 2 && a.startsWith(r) && a.endsWith(r);
11
- return e('"') || e("'") ? a.slice(1, -1) : a;
12
- }, A = (t) => {
13
- const e = t.value.match(/\{\{([^}]+)\}\}/)[1].split("|").map((n) => n.trim()), [r] = e, l = {
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: r || ""
15
+ value: n || ""
16
16
  };
17
17
  if (e.length >= 2) {
18
- const [, n, c] = e;
19
- if (n.startsWith(u))
20
- l.fallback = b(n);
18
+ const [, a, o] = e;
19
+ if (a.startsWith(u))
20
+ s.fallback = i(a);
21
21
  else {
22
- const s = p(n) ?? m(n);
23
- s ? l.format = s : c || (l.fallback = n), c && (l.fallback = b(c));
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 l;
27
- }, d = (t) => {
28
- const e = !Number.isNaN(Number(t)) && t.trim() !== "" ? t : y(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
- }, v = (t) => {
31
- const a = t.format ? g(t.format) : null, e = t.fallback ? d(t.fallback) : null, r = [t.value, a, e].filter(Boolean);
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, a, e && t.fallback].filter(Boolean).join(" | "),
34
- value: `{{ ${r.join(" | ")} }}`
33
+ label: [t.text, r, e && t.fallback].filter(Boolean).join(" | "),
34
+ value: `{{ ${n.join(" | ")} }}`
35
35
  };
36
- }, i = (t, a = !1) => t.map((e) => a ? v(e) : e.format ? {
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
- }), T = (t) => {
43
- const a = [], e = /* @__PURE__ */ new Set(), r = (n, c) => {
44
- Array.isArray(n) && n.forEach((s) => {
45
- const f = [...s.children ?? [], ...s.select_items ?? []], o = s.text || s.tag_text;
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
- r(f, o ? [...c, o] : c);
47
+ n(f, c ? [...o, c] : o);
48
48
  return;
49
49
  }
50
- o && s.value && !e.has(s.value) && (e.add(s.value), a.push({ value: s.value, text: o, tagText: s.tag_text || o, path: c }));
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
- }, [l] = Object.values(t ?? {});
53
- return r(l, []), a;
54
- }, h = (t) => T(t).map(({ text: a, value: e }) => ({ text: a, value: e })), L = (t, a, e = !1) => {
55
- const r = new Set(t.map((n) => n.value)), l = a.filter((n) => r.has(n.value) ? !1 : (r.add(n.value), !0));
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
- ...i(t, e),
58
- ...i(l, e)
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
- }, N = (t) => typeof t == "string" ? t : typeof t == "number" ? String(t) : "", C = (t) => {
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 a = Object.getPrototypeOf(t);
76
- return a === Object.prototype || a === null;
66
+ const r = Object.getPrototypeOf(t);
67
+ return r === Object.prototype || r === null;
77
68
  };
78
69
  export {
79
- N as asText,
80
- L as buildMergeTagEntries,
81
- P as buildSpecialLinkGroups,
82
- i as dynamicContentToMergeTags,
83
- T as flattenDynamicContentCandidates,
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
- C as isPlainObject,
87
- A as mergeTagToDynamicContent
76
+ j as isPlainObject,
77
+ $ as mergeTagToDynamicContent
88
78
  };
@@ -1,49 +1,90 @@
1
- import { protectLiquid as a, restoreLiquid as u } from "./liquidProtection.js";
2
- const b = "td.unsubscribe-block", l = ["a.unsubscribe-link", 'a[href*="unsubscribe"]'], d = "esd-block-text", m = [
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
- ], L = "esd-extension-block-id", S = "data-unsubscribe-", E = "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", f = new RegExp(`class\\s*=\\s*(?:["'][^"']*)?(?<![\\w-])unsubscribe-block(?![\\w-])`, "i"), p = (e) => typeof e == "string" && f.test(e), y = (e) => l.some((t) => e.querySelector(t) !== null), g = (e) => {
9
- e.classList.remove(...m), e.classList.add(d), e.removeAttribute(L), Array.from(e.attributes).filter(({ name: t }) => t.startsWith(S)).forEach(({ name: t }) => e.removeAttribute(t)), e.querySelector(E) || (e.innerHTML = `<p path="1">${e.innerHTML}</p>`);
10
- }, h = (e) => {
11
- const t = Array.from(e.querySelectorAll(b)).filter((r) => !y(r));
12
- return t.forEach(g), t.length;
13
- }, v = (e) => {
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
- }, c = (e) => {
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
- }, i = (e, t, r, s) => {
20
- if (!p(e))
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 = a(e), n = t(o);
24
- return !n || h(n) === 0 ? { html: e, converted: !1 } : { html: u(r(n, o)), converted: !0 };
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
- }, C = (e) => i(
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
- v,
31
- (t) => t.innerHTML,
59
+ a,
60
+ m,
32
61
  "module"
33
- ), _ = (e) => i(
62
+ ), G = (e) => n(
34
63
  e,
35
- (t) => new DOMParser().parseFromString(c(t).root, "text/html"),
36
- (t, r) => {
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
- l as LEGACY_UNSUBSCRIBE_LINK_SELECTORS,
44
- b as LEGACY_UNSUBSCRIBE_SELECTOR,
45
- _ as convertLegacyUnsubscribeInDocumentHtml,
46
- C as convertLegacyUnsubscribeInModuleHtml,
47
- h as convertLinklessLegacyUnsubscribeBlocks,
48
- p as hasLegacyUnsubscribeClass
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.23d415d",
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,3 +0,0 @@
1
- export declare const isBareToken: (text: string) => boolean;
2
- export declare const disposeLinkTokenPaste: () => void;
3
- export declare const listenForLinkTokenPaste: () => void;
@@ -1,4 +0,0 @@
1
- /**
2
- * The Liquid engine reads the raw HTML, where a link's `"` is the `&quot;` it cannot parse.
3
- */
4
- export declare function singleQuoteLiquidLinks(html: string): string;
@@ -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 = /'[^']*'|&#39;.*?&#39;|&quot;(.*?)&quot;/gs, i = /'|&#39;|&#x27;|&apos;|&#34;|&#x22;/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("&quot;") ? t.replace(o, (n, s) => E.test(s) && n.endsWith('"') ? n.replace(e, T) : n) : t;
7
- }
8
- export {
9
- r as singleQuoteLiquidLinks
10
- };