@useinsider/guido 3.2.0-beta.250b0a1 → 3.2.0-beta.2e5aafb

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,8 +1,8 @@
1
- var f = Object.defineProperty;
2
- var h = (o, e, t) => e in o ? f(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
3
- var y = (o, e, t) => h(o, typeof e != "symbol" ? e + "" : e, t);
4
- import T from "../../extensions/Blocks/RadioButton/template.js";
5
- class S {
1
+ var h = Object.defineProperty;
2
+ var T = (l, e, t) => e in l ? h(l, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[e] = t;
3
+ var y = (l, e, t) => T(l, typeof e != "symbol" ? e + "" : e, t);
4
+ import S from "../../extensions/Blocks/RadioButton/template.js";
5
+ class B {
6
6
  constructor() {
7
7
  y(this, "parser");
8
8
  this.parser = new DOMParser();
@@ -10,29 +10,32 @@ class S {
10
10
  migrate(e) {
11
11
  try {
12
12
  const t = this.parser.parseFromString(e, "text/html"), s = t.querySelectorAll("td.radio-button-block"), i = t.querySelectorAll("td.radio-button-v2");
13
- return s.length === 0 && i.length === 0 ? e : (s.forEach((r) => {
13
+ if (s.length === 0 && i.length === 0)
14
+ return e;
15
+ let n = !1;
16
+ return s.forEach((r) => {
14
17
  if (r.classList.contains("radio-button-v2"))
15
18
  return;
16
- const l = r.getAttribute("id"), n = this.extractTextFromElement(r, "ins-title"), c = this.extractTextFromElement(r, "ins-description"), a = this.extractTextFromElement(r, "ins-subscribe"), p = this.extractTextFromElement(r, "ins-unsubscribe"), g = this.buildTextBlock(n), m = this.buildTextBlock(c), d = this.buildTextBlock({ ...a, classList: "" }), u = this.buildTextBlock({ ...p, classList: "" }), x = T.replace("{-{-TITLE-}-}", g).replace("{-{-DESCRIPTION-}-}", m).replace("{-{-YES-}-}", d).replace("{-{-NO-}-}", u), b = this.parser.parseFromString(
17
- `<table id="tempDoc"><tbody><tr>${x}</tr></tbody></table>`,
19
+ const c = r.getAttribute("id"), o = this.extractTextFromElement(r, "ins-title"), a = this.extractTextFromElement(r, "ins-description"), p = this.extractTextFromElement(r, "ins-subscribe"), u = this.extractTextFromElement(r, "ins-unsubscribe"), m = this.buildTextBlock(o), d = this.buildTextBlock(a), g = this.buildTextBlock({ ...p, classList: "" }), x = this.buildTextBlock({ ...u, classList: "" }), f = S.replace("{-{-TITLE-}-}", m).replace("{-{-DESCRIPTION-}-}", d).replace("{-{-YES-}-}", g).replace("{-{-NO-}-}", x), b = this.parser.parseFromString(
20
+ `<table id="tempDoc"><tbody><tr>${f}</tr></tbody></table>`,
18
21
  "text/html"
19
22
  ).querySelector(".radio-button-v2");
20
- b && r.parentNode && (b.setAttribute("id", l || ""), r.parentNode.replaceChild(b, r));
23
+ b && r.parentNode && (b.setAttribute("id", c || ""), r.parentNode.replaceChild(b, r), n = !0);
21
24
  }), t.querySelectorAll("td.radio-button-v2 input#radioYes").forEach((r) => {
22
- var a, p;
23
- const l = (a = r.parentElement) == null ? void 0 : a.querySelector(":scope > p"), n = (p = r.parentElement) == null ? void 0 : p.parentElement;
24
- if (!l || (n == null ? void 0 : n.tagName) !== "TR")
25
+ var p, u;
26
+ const c = (p = r.parentElement) == null ? void 0 : p.querySelector(":scope > p"), o = (u = r.parentElement) == null ? void 0 : u.parentElement;
27
+ if (!c || (o == null ? void 0 : o.tagName) !== "TR")
25
28
  return;
26
29
  r.removeAttribute("esd-block-text");
27
- const c = t.createElement("td");
28
- c.className = "esd-block-text", c.appendChild(l), n.appendChild(c);
29
- }), t.documentElement.outerHTML);
30
+ const a = t.createElement("td");
31
+ a.className = "esd-block-text", a.appendChild(c), o.appendChild(a), n = !0;
32
+ }), n ? t.documentElement.outerHTML : e;
30
33
  } catch (t) {
31
34
  return console.error("RadioButtonMigrator failed:", t), e;
32
35
  }
33
36
  }
34
37
  extractTextFromElement(e, t) {
35
- var d, u;
38
+ var d, g;
36
39
  const s = e.querySelector(`.${t}`);
37
40
  if (!s)
38
41
  return {
@@ -53,13 +56,13 @@ class S {
53
56
  styles: "",
54
57
  classList: ""
55
58
  };
56
- const r = ((u = i.textContent) == null ? void 0 : u.trim()) || (t === "ins-title" ? "Title" : "Description"), l = i.getAttribute("style") || "", n = s.getAttribute("align") || i.getAttribute("align") || "left", c = /font-weight\s*:\s*bold/i.test(l) || !!i.querySelector("b, strong"), a = /font-style\s*:\s*italic/i.test(l) || !!i.querySelector("i, em"), p = this.removeStyleProperties(l, ["font-weight", "font-style"]), g = this.convertInlineToBlock(p), m = s.getAttribute("class") || "";
59
+ const n = ((g = i.textContent) == null ? void 0 : g.trim()) || (t === "ins-title" ? "Title" : "Description"), r = i.getAttribute("style") || "", c = s.getAttribute("align") || i.getAttribute("align") || "left", o = /font-weight\s*:\s*bold/i.test(r) || !!i.querySelector("b, strong"), a = /font-style\s*:\s*italic/i.test(r) || !!i.querySelector("i, em"), p = this.removeStyleProperties(r, ["font-weight", "font-style"]), u = this.convertInlineToBlock(p), m = s.getAttribute("class") || "";
57
60
  return {
58
- text: r,
59
- isBold: c,
61
+ text: n,
62
+ isBold: o,
60
63
  isItalic: a,
61
- align: n,
62
- styles: g,
64
+ align: c,
65
+ styles: u,
63
66
  classList: m
64
67
  };
65
68
  }
@@ -76,9 +79,9 @@ class S {
76
79
  `;
77
80
  }
78
81
  removeStyleProperties(e, t) {
79
- return e ? t.reduce((i, r) => {
80
- const l = new RegExp(`${r}\\s*:\\s*[^;]*;?`, "gi");
81
- return i.replace(l, "");
82
+ return e ? t.reduce((i, n) => {
83
+ const r = new RegExp(`${n}\\s*:\\s*[^;]*;?`, "gi");
84
+ return i.replace(r, "");
82
85
  }, e).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
83
86
  }
84
87
  convertInlineToBlock(e) {
@@ -88,9 +91,9 @@ class S {
88
91
  return /display\s*:/i.test(t) || (t = t ? `${t}; display: block` : "display: block"), t.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
89
92
  }
90
93
  }
91
- function A(o) {
92
- return new S().migrate(o);
94
+ function k(l) {
95
+ return new B().migrate(l);
93
96
  }
94
97
  export {
95
- A as migrateRadioButton
98
+ k as migrateRadioButton
96
99
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.2.0-beta.250b0a1",
3
+ "version": "3.2.0-beta.2e5aafb",
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",