@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
|
|
2
|
-
var
|
|
3
|
-
var y = (
|
|
4
|
-
import
|
|
5
|
-
class
|
|
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
|
-
|
|
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
|
|
17
|
-
`<table id="tempDoc"><tbody><tr>${
|
|
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",
|
|
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
|
|
23
|
-
const
|
|
24
|
-
if (!
|
|
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
|
|
28
|
-
|
|
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,
|
|
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
|
|
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:
|
|
59
|
-
isBold:
|
|
61
|
+
text: n,
|
|
62
|
+
isBold: o,
|
|
60
63
|
isItalic: a,
|
|
61
|
-
align:
|
|
62
|
-
styles:
|
|
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,
|
|
80
|
-
const
|
|
81
|
-
return i.replace(
|
|
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
|
|
92
|
-
return new
|
|
94
|
+
function k(l) {
|
|
95
|
+
return new B().migrate(l);
|
|
93
96
|
}
|
|
94
97
|
export {
|
|
95
|
-
|
|
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.
|
|
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",
|