@useinsider/guido 3.5.1-beta.ff14e7c → 3.5.1

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,85 +1,36 @@
1
- var x = Object.defineProperty;
2
- var y = (s, t, e) => t in s ? x(s, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : s[t] = e;
3
- var m = (s, t, e) => y(s, typeof t != "symbol" ? t + "" : t, e);
4
- import b from "../../extensions/Blocks/Checkbox/template.js";
5
- class f {
1
+ var h = Object.defineProperty;
2
+ var g = (r, t, e) => t in r ? h(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
+ var l = (r, t, e) => g(r, typeof t != "symbol" ? t + "" : t, e);
4
+ import f from "../../extensions/Blocks/Checkbox/template.js";
5
+ import { extractTextFromElement as m, buildTextBlock as p } from "./textBlockMigration.js";
6
+ class C {
6
7
  constructor() {
7
- m(this, "parser");
8
+ l(this, "parser");
8
9
  this.parser = new DOMParser();
9
10
  }
10
11
  migrate(t) {
11
12
  try {
12
- const e = this.parser.parseFromString(t, "text/html"), i = e.querySelectorAll("td.checkbox-block");
13
- return i.length === 0 ? t : (i.forEach((r) => {
14
- if (r.classList.contains("checkbox-block-v2"))
13
+ const e = this.parser.parseFromString(t, "text/html"), n = e.querySelectorAll("td.checkbox-block");
14
+ if (n.length === 0)
15
+ return t;
16
+ let i = !1;
17
+ return n.forEach((o) => {
18
+ if (o.classList.contains("checkbox-block-v2"))
15
19
  return;
16
- const n = r.getAttribute("id"), l = this.extractTextFromElement(r, "ins-title"), c = this.extractTextFromElement(r, "ins-description"), a = this.buildTextBlock(l), p = this.buildTextBlock(c), g = b.replace("{-{-TITLE-}-}", a).replace("{-{-DESCRIPTION-}-}", p), o = this.parser.parseFromString(
17
- `<table id="tempDoc"><tbody><tr>${g}</tr></tbody></table>`,
20
+ const b = o.getAttribute("id"), s = m(o, "ins-title"), a = m(o, "ins-description"), u = p(s, s.containerClass), x = p(a, a.containerClass), d = f.replace("{-{-TITLE-}-}", u).replace("{-{-DESCRIPTION-}-}", x), c = this.parser.parseFromString(
21
+ `<table id="tempDoc"><tbody><tr>${d}</tr></tbody></table>`,
18
22
  "text/html"
19
23
  ).querySelector(".checkbox-block-v2");
20
- o && r.parentNode && (o.setAttribute("id", n || ""), r.parentNode.replaceChild(o, r));
21
- }), e.documentElement.outerHTML);
24
+ c && o.parentNode && (c.setAttribute("id", b || ""), o.parentNode.replaceChild(c, o), i = !0);
25
+ }), i ? e.documentElement.outerHTML : t;
22
26
  } catch (e) {
23
27
  return console.error("CheckboxMigrator failed:", e), t;
24
28
  }
25
29
  }
26
- extractTextFromElement(t, e) {
27
- var o, d;
28
- const i = t.querySelector(`.${e}`);
29
- if (!i)
30
- return {
31
- text: e === "ins-title" ? "Title" : "Description",
32
- isBold: !1,
33
- isItalic: !1,
34
- align: "left",
35
- styles: ""
36
- };
37
- const r = i.querySelector("p");
38
- if (!r)
39
- return {
40
- text: ((o = i.textContent) == null ? void 0 : o.trim()) || (e === "ins-title" ? "Title" : "Description"),
41
- isBold: !1,
42
- isItalic: !1,
43
- align: i.getAttribute("align") || "left",
44
- styles: ""
45
- };
46
- const n = ((d = r.textContent) == null ? void 0 : d.trim()) || (e === "ins-title" ? "Title" : "Description"), l = r.getAttribute("style") || "", c = i.getAttribute("align") || r.getAttribute("align") || "left", a = /font-weight\s*:\s*bold/i.test(l) || !!r.querySelector("b, strong"), p = /font-style\s*:\s*italic/i.test(l) || !!r.querySelector("i, em"), g = this.removeStyleProperties(l, ["font-weight", "font-style"]), u = this.convertInlineToBlock(g);
47
- return {
48
- text: n,
49
- isBold: a,
50
- isItalic: p,
51
- align: c,
52
- styles: u
53
- };
54
- }
55
- buildTextBlock(t) {
56
- let e = t.text;
57
- t.isBold && t.isItalic ? e = `<strong path="1,0"><em path="1,0,0">${e}</em></strong>` : t.isBold ? e = `<strong path="1,0">${e}</strong>` : t.isItalic && (e = `<em path="1,0">${e}</em>`);
58
- const i = t.align ? ` align="${t.align}"` : "", r = t.styles ? ` style="${t.styles}"` : "";
59
- return `
60
- <td class="esd-block-text" ${i}>
61
- <p path="1" ${r}>
62
- ${e}
63
- </p>
64
- </td>
65
- `;
66
- }
67
- removeStyleProperties(t, e) {
68
- return t ? e.reduce((r, n) => {
69
- const l = new RegExp(`${n}\\s*:\\s*[^;]*;?`, "gi");
70
- return r.replace(l, "");
71
- }, t).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
72
- }
73
- convertInlineToBlock(t) {
74
- if (!t)
75
- return "";
76
- let e = t.replace(/display\s*:\s*inline/gi, "display: block");
77
- return /display\s*:/i.test(e) || (e = e ? `${e}; display: block` : "display: block"), e.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
78
- }
79
30
  }
80
- function k(s) {
81
- return new f().migrate(s);
31
+ function E(r) {
32
+ return new C().migrate(r);
82
33
  }
83
34
  export {
84
- k as migrateCheckbox
35
+ E as migrateCheckbox
85
36
  };
@@ -1,109 +1,54 @@
1
- var x = Object.defineProperty;
2
- var T = (l, e, t) => e in l ? x(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
- var b = (l, e, t) => T(l, typeof e != "symbol" ? e + "" : e, t);
4
- import S from "../../extensions/Blocks/RadioButton/template.js";
5
- class B {
1
+ var q = Object.defineProperty;
2
+ var C = (o, t, e) => t in o ? q(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var g = (o, t, e) => C(o, typeof t != "symbol" ? t + "" : t, e);
4
+ import N from "../../extensions/Blocks/RadioButton/template.js";
5
+ import { extractTextFromElement as b, buildTextBlock as f } from "./textBlockMigration.js";
6
+ class R {
6
7
  constructor() {
7
- b(this, "parser");
8
+ g(this, "parser");
8
9
  this.parser = new DOMParser();
9
10
  }
10
- migrate(e) {
11
+ migrate(t) {
11
12
  try {
12
- const t = this.parser.parseFromString(e, "text/html"), s = t.querySelectorAll("td.radio-button-block"), i = t.querySelectorAll("td.radio-button-v2");
13
- if (s.length === 0 && i.length === 0)
14
- return e;
15
- let o = !1;
16
- return s.forEach((r) => {
13
+ const e = this.parser.parseFromString(t, "text/html"), n = e.querySelectorAll("td.radio-button-block"), a = e.querySelectorAll("td.radio-button-v2");
14
+ if (n.length === 0 && a.length === 0)
15
+ return t;
16
+ let i = !1;
17
+ return n.forEach((r) => {
17
18
  if (r.classList.contains("radio-button-v2"))
18
19
  return;
19
- const n = r.getAttribute("id"), a = this.extractTextFromElement(r, "ins-title"), g = this.extractTextFromElement(r, "ins-description"), c = this.extractTextFromElement(r, "ins-subscribe"), u = this.extractTextFromElement(r, "ins-unsubscribe"), p = this.buildTextBlock(a), d = this.buildTextBlock(g), y = this.buildTextBlock({ ...c, classList: "" }), f = this.buildTextBlock({ ...u, classList: "" }), h = S.replace("{-{-TITLE-}-}", p).replace("{-{-DESCRIPTION-}-}", d).replace("{-{-YES-}-}", y).replace("{-{-NO-}-}", f), m = this.parser.parseFromString(
20
- `<table id="tempDoc"><tbody><tr>${h}</tr></tbody></table>`,
20
+ const s = r.getAttribute("id"), c = b(r, "ins-title"), d = b(r, "ins-description"), u = b(r, "ins-subscribe"), l = b(r, "ins-unsubscribe"), p = f(c, c.containerClass), m = f(d, d.containerClass), h = f(u), S = f(l), T = N.replace("{-{-TITLE-}-}", p).replace("{-{-DESCRIPTION-}-}", m).replace("{-{-YES-}-}", h).replace("{-{-NO-}-}", S), y = this.parser.parseFromString(
21
+ `<table id="tempDoc"><tbody><tr>${T}</tr></tbody></table>`,
21
22
  "text/html"
22
23
  ).querySelector(".radio-button-v2");
23
- m && r.parentNode && (m.setAttribute("id", n || ""), r.parentNode.replaceChild(m, r), o = !0);
24
- }), o = this.healRadioButtonV2(t) || o, o ? t.documentElement.outerHTML : e;
25
- } catch (t) {
26
- return console.error("RadioButtonMigrator failed:", t), e;
24
+ y && r.parentNode && (y.setAttribute("id", s || ""), r.parentNode.replaceChild(y, r), i = !0);
25
+ }), i = this.healRadioButtonV2(e) || i, i ? e.documentElement.outerHTML : t;
26
+ } catch (e) {
27
+ return console.error("RadioButtonMigrator failed:", e), t;
27
28
  }
28
29
  }
29
- healRadioButtonV2(e) {
30
- let t = !1;
31
- return e.querySelectorAll("td.radio-button-v2").forEach((s) => {
32
- var d;
33
- s.classList.contains("radio-button-block") || (s.classList.add("radio-button-block"), t = !0);
34
- const i = s.querySelector("input#radioYes"), o = s.querySelector("input#radioNo");
35
- if (!i || !o)
30
+ healRadioButtonV2(t) {
31
+ let e = !1;
32
+ return t.querySelectorAll("td.radio-button-v2").forEach((n) => {
33
+ var m;
34
+ n.classList.contains("radio-button-block") || (n.classList.add("radio-button-block"), e = !0);
35
+ const a = n.querySelector("input#radioYes"), i = n.querySelector("input#radioNo");
36
+ if (!a || !i)
36
37
  return;
37
- const r = ((d = i.parentElement) == null ? void 0 : d.querySelector(":scope > p")) || null;
38
- if (!r && !i.hasAttribute("align"))
38
+ const r = ((m = a.parentElement) == null ? void 0 : m.querySelector(":scope > p")) || null;
39
+ if (!r && !a.hasAttribute("align"))
39
40
  return;
40
- const n = i.closest("tr"), a = o.closest("tr");
41
- if (!n || !a || n === a || !n.parentNode)
41
+ const s = a.closest("tr"), c = i.closest("tr");
42
+ if (!s || !c || s === c || !s.parentNode)
42
43
  return;
43
- const g = (r == null ? void 0 : r.innerHTML.trim()) || "Yes", c = a.cloneNode(!0), u = c.querySelector("input#radioNo"), p = c.querySelector("p");
44
- u && (u.setAttribute("id", "radioYes"), u.removeAttribute("align")), p && (p.innerHTML = g), n.parentNode.replaceChild(c, n), t = !0;
45
- }), t;
46
- }
47
- extractTextFromElement(e, t) {
48
- var d, y;
49
- const s = e.querySelector(`.${t}`);
50
- if (!s)
51
- return {
52
- text: t === "ins-title" ? "Title" : "Description",
53
- isBold: !1,
54
- isItalic: !1,
55
- align: "left",
56
- styles: "",
57
- classList: ""
58
- };
59
- const i = s.querySelector("p");
60
- if (!i)
61
- return {
62
- text: ((d = s.textContent) == null ? void 0 : d.trim()) || (t === "ins-title" ? "Title" : "Description"),
63
- isBold: !1,
64
- isItalic: !1,
65
- align: s.getAttribute("align") || "left",
66
- styles: "",
67
- classList: ""
68
- };
69
- const o = ((y = i.textContent) == null ? void 0 : y.trim()) || (t === "ins-title" ? "Title" : "Description"), r = i.getAttribute("style") || "", n = s.getAttribute("align") || i.getAttribute("align") || "left", a = /font-weight\s*:\s*bold/i.test(r) || !!i.querySelector("b, strong"), g = /font-style\s*:\s*italic/i.test(r) || !!i.querySelector("i, em"), c = this.removeStyleProperties(r, ["font-weight", "font-style"]), u = this.convertInlineToBlock(c), p = s.getAttribute("class") || "";
70
- return {
71
- text: o,
72
- isBold: a,
73
- isItalic: g,
74
- align: n,
75
- styles: u,
76
- classList: p
77
- };
78
- }
79
- buildTextBlock(e) {
80
- let t = e.text;
81
- e.isBold && e.isItalic ? t = `<strong path="1,0"><em path="1,0,0">${t}</em></strong>` : e.isBold ? t = `<strong path="1,0">${t}</strong>` : e.isItalic && (t = `<em path="1,0">${t}</em>`);
82
- const s = e.align ? ` align="${e.align}"` : "", i = e.styles ? ` style="${e.styles.replaceAll('"', "'")}"` : "";
83
- return `
84
- <td class="esd-block-text ${e.classList}" ${s}>
85
- <p path="1" ${i}>
86
- ${t}
87
- </p>
88
- </td>
89
- `;
90
- }
91
- removeStyleProperties(e, t) {
92
- return e ? t.reduce((i, o) => {
93
- const r = new RegExp(`${o}\\s*:\\s*[^;]*;?`, "gi");
94
- return i.replace(r, "");
95
- }, e).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
96
- }
97
- convertInlineToBlock(e) {
98
- if (!e)
99
- return "";
100
- let t = e.replace(/display\s*:\s*inline/gi, "display: block");
101
- return /display\s*:/i.test(t) || (t = t ? `${t}; display: block` : "display: block"), t.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
44
+ const d = (r == null ? void 0 : r.innerHTML.trim()) || "Yes", u = c.cloneNode(!0), l = u.querySelector("input#radioNo"), p = u.querySelector("p");
45
+ l && (l.setAttribute("id", "radioYes"), l.removeAttribute("align")), p && (p.innerHTML = d), s.parentNode.replaceChild(u, s), e = !0;
46
+ }), e;
102
47
  }
103
48
  }
104
- function L(l) {
105
- return new B().migrate(l);
49
+ function w(o) {
50
+ return new R().migrate(o);
106
51
  }
107
52
  export {
108
- L as migrateRadioButton
53
+ w as migrateRadioButton
109
54
  };
@@ -0,0 +1,65 @@
1
+ const I = {
2
+ "ins-title": "Title",
3
+ "ins-description": "Description",
4
+ "ins-subscribe": "Yes",
5
+ "ins-unsubscribe": "No"
6
+ }, y = /font-weight\s*:\s*[^;]*;?/gi, S = /font-style\s*:\s*[^;]*;?/gi, u = /;\s*;/g, T = /^;|;$/g, d = /display\s*:\s*inline/gi, m = /display\s*:/i, b = /font-weight\s*:\s*bold/i, A = /font-style\s*:\s*italic/i, R = /^<(?:strong|b)\b/i, $ = /^<(?:em|i)\b/i;
7
+ function L(t) {
8
+ return t ? t.replace(y, "").replace(S, "").replace(u, ";").replace(T, "").trim() : "";
9
+ }
10
+ function O(t) {
11
+ if (!t)
12
+ return "";
13
+ let e = t.replace(d, "display: block");
14
+ return m.test(e) || (e = e ? `${e}; display: block` : "display: block"), e.replace(u, ";").replace(T, "").trim();
15
+ }
16
+ function B(t, e) {
17
+ var c, a;
18
+ const o = I[e], l = t.querySelector(`.${e}`);
19
+ if (!l)
20
+ return {
21
+ paragraphs: [{ innerHtml: o, isBold: !1, isItalic: !1, styles: "" }],
22
+ align: "left",
23
+ containerClass: ""
24
+ };
25
+ const n = Array.from(l.querySelectorAll("p")), p = l.getAttribute("align") || ((c = n[0]) == null ? void 0 : c.getAttribute("align")) || "left", i = l.getAttribute("class") || "";
26
+ return n.length === 0 ? {
27
+ paragraphs: [{
28
+ innerHtml: ((a = l.textContent) == null ? void 0 : a.trim()) || o,
29
+ isBold: !1,
30
+ isItalic: !1,
31
+ styles: ""
32
+ }],
33
+ align: p,
34
+ containerClass: ""
35
+ } : { paragraphs: n.map((r) => {
36
+ const _ = r.getAttribute("style") || "", f = b.test(_) || !!r.querySelector("b, strong"), g = A.test(_) || !!r.querySelector("i, em"), E = L(_);
37
+ return {
38
+ // Legacy parity: empty <p> → fallback placeholder; <p><br></p> is not empty.
39
+ innerHtml: r.innerHTML.trim() || o,
40
+ isBold: f,
41
+ isItalic: g,
42
+ styles: O(E)
43
+ };
44
+ }), align: p, containerClass: i };
45
+ }
46
+ function C(t, e = "") {
47
+ const o = t.align ? ` align="${t.align}"` : "", l = t.paragraphs.map((n, p) => {
48
+ const i = p + 1;
49
+ let s = n.innerHtml;
50
+ const c = n.isBold && !R.test(s), a = n.isItalic && !$.test(s);
51
+ c && a ? s = `<strong path="${i},0"><em path="${i},0,0">${s}</em></strong>` : c ? s = `<strong path="${i},0">${s}</strong>` : a && (s = `<em path="${i},0">${s}</em>`);
52
+ const r = n.styles ? ` style="${n.styles.replaceAll('"', "'")}"` : "";
53
+ return `<p path="${i}"${r}>${s}</p>`;
54
+ }).join(`
55
+ `);
56
+ return `
57
+ <td class="esd-block-text ${e}" ${o}>
58
+ ${l}
59
+ </td>
60
+ `;
61
+ }
62
+ export {
63
+ C as buildTextBlock,
64
+ B as extractTextFromElement
65
+ };
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Shared text-block migration helpers used by both `radioButtonMigrator` and
3
+ * `checkboxMigrator`. Extracts a legacy v1 `.ins-title` / `.ins-description`
4
+ * cell into a paragraph descriptor and rebuilds it as a v2 `esd-block-text`
5
+ * cell — preserving every <p>, every inline tag (<u>, <a>, <br>, <strong>,
6
+ * <em>) and re-encoding bold/italic detection as canonical tags.
7
+ */
8
+ export type InsCellClass = 'ins-title' | 'ins-description' | 'ins-subscribe' | 'ins-unsubscribe';
9
+ type ParagraphContent = {
10
+ innerHtml: string;
11
+ isBold: boolean;
12
+ isItalic: boolean;
13
+ styles: string;
14
+ };
15
+ export type TextContent = {
16
+ paragraphs: ParagraphContent[];
17
+ align: string;
18
+ };
19
+ export type ExtractedTextContent = TextContent & {
20
+ containerClass: string;
21
+ };
22
+ export declare function extractTextFromElement(parent: Element, className: InsCellClass): ExtractedTextContent;
23
+ export declare function buildTextBlock(content: TextContent, extraClass?: string): string;
24
+ export {};
@@ -11,6 +11,11 @@ ue-description a {
11
11
  display: none;
12
12
  }
13
13
 
14
+ /* Override the rule above for the Gmail Promotions switcher docs link — remove with DT-28355. */
15
+ ue-lock-container.e2e-promotions-switcher ue-description a {
16
+ display: unset;
17
+ }
18
+
14
19
  .label {
15
20
  font-size: 13px;
16
21
  color: var(--guido-color-gray-800);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.5.1-beta.ff14e7c",
3
+ "version": "3.5.1",
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",