@useinsider/guido 3.2.0-beta.2a61d0e → 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,88 +1,99 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
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();
|
|
9
9
|
}
|
|
10
|
-
migrate(
|
|
10
|
+
migrate(e) {
|
|
11
11
|
try {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
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 n = !1;
|
|
16
|
+
return s.forEach((r) => {
|
|
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
|
-
|
|
21
|
-
}),
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
b && r.parentNode && (b.setAttribute("id", c || ""), r.parentNode.replaceChild(b, r), n = !0);
|
|
24
|
+
}), t.querySelectorAll("td.radio-button-v2 input#radioYes").forEach((r) => {
|
|
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")
|
|
28
|
+
return;
|
|
29
|
+
r.removeAttribute("esd-block-text");
|
|
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;
|
|
33
|
+
} catch (t) {
|
|
34
|
+
return console.error("RadioButtonMigrator failed:", t), e;
|
|
24
35
|
}
|
|
25
36
|
}
|
|
26
|
-
extractTextFromElement(
|
|
27
|
-
var
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
37
|
+
extractTextFromElement(e, t) {
|
|
38
|
+
var d, g;
|
|
39
|
+
const s = e.querySelector(`.${t}`);
|
|
40
|
+
if (!s)
|
|
30
41
|
return {
|
|
31
|
-
text:
|
|
42
|
+
text: t === "ins-title" ? "Title" : "Description",
|
|
32
43
|
isBold: !1,
|
|
33
44
|
isItalic: !1,
|
|
34
45
|
align: "left",
|
|
35
46
|
styles: "",
|
|
36
47
|
classList: ""
|
|
37
48
|
};
|
|
38
|
-
const
|
|
39
|
-
if (!
|
|
49
|
+
const i = s.querySelector("p");
|
|
50
|
+
if (!i)
|
|
40
51
|
return {
|
|
41
|
-
text: ((
|
|
52
|
+
text: ((d = s.textContent) == null ? void 0 : d.trim()) || (t === "ins-title" ? "Title" : "Description"),
|
|
42
53
|
isBold: !1,
|
|
43
54
|
isItalic: !1,
|
|
44
|
-
align:
|
|
55
|
+
align: s.getAttribute("align") || "left",
|
|
45
56
|
styles: "",
|
|
46
57
|
classList: ""
|
|
47
58
|
};
|
|
48
|
-
const n = ((
|
|
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") || "";
|
|
49
60
|
return {
|
|
50
61
|
text: n,
|
|
51
|
-
isBold:
|
|
52
|
-
isItalic:
|
|
53
|
-
align:
|
|
54
|
-
styles:
|
|
62
|
+
isBold: o,
|
|
63
|
+
isItalic: a,
|
|
64
|
+
align: c,
|
|
65
|
+
styles: u,
|
|
55
66
|
classList: m
|
|
56
67
|
};
|
|
57
68
|
}
|
|
58
|
-
buildTextBlock(
|
|
59
|
-
let
|
|
60
|
-
|
|
61
|
-
const
|
|
69
|
+
buildTextBlock(e) {
|
|
70
|
+
let t = e.text;
|
|
71
|
+
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>`);
|
|
72
|
+
const s = e.align ? ` align="${e.align}"` : "", i = e.styles ? ` style="${e.styles.replaceAll('"', "'")}"` : "";
|
|
62
73
|
return `
|
|
63
|
-
<td class="esd-block-text ${
|
|
64
|
-
<p path="1" ${
|
|
65
|
-
${
|
|
74
|
+
<td class="esd-block-text ${e.classList}" ${s}>
|
|
75
|
+
<p path="1" ${i}>
|
|
76
|
+
${t}
|
|
66
77
|
</p>
|
|
67
78
|
</td>
|
|
68
79
|
`;
|
|
69
80
|
}
|
|
70
|
-
removeStyleProperties(
|
|
71
|
-
return
|
|
72
|
-
const
|
|
73
|
-
return
|
|
74
|
-
},
|
|
81
|
+
removeStyleProperties(e, t) {
|
|
82
|
+
return e ? t.reduce((i, n) => {
|
|
83
|
+
const r = new RegExp(`${n}\\s*:\\s*[^;]*;?`, "gi");
|
|
84
|
+
return i.replace(r, "");
|
|
85
|
+
}, e).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
|
|
75
86
|
}
|
|
76
|
-
convertInlineToBlock(
|
|
77
|
-
if (!
|
|
87
|
+
convertInlineToBlock(e) {
|
|
88
|
+
if (!e)
|
|
78
89
|
return "";
|
|
79
|
-
let
|
|
80
|
-
return /display\s*:/i.test(
|
|
90
|
+
let t = e.replace(/display\s*:\s*inline/gi, "display: block");
|
|
91
|
+
return /display\s*:/i.test(t) || (t = t ? `${t}; display: block` : "display: block"), t.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
|
|
81
92
|
}
|
|
82
93
|
}
|
|
83
|
-
function
|
|
84
|
-
return new
|
|
94
|
+
function k(l) {
|
|
95
|
+
return new B().migrate(l);
|
|
85
96
|
}
|
|
86
97
|
export {
|
|
87
|
-
|
|
98
|
+
k as migrateRadioButton
|
|
88
99
|
};
|
|
@@ -3,15 +3,15 @@ var h = (n, i, e) => i in n ? d(n, i, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var u = (n, i, e) => h(n, typeof i != "symbol" ? i + "" : i, e);
|
|
4
4
|
import { PAGE_TYPES as E } from "../../../enums/unsubscribe.js";
|
|
5
5
|
import { useUnsubscribeStore as c } from "../../../stores/unsubscribe.js";
|
|
6
|
-
import { Block as _, BlockCompositionType as S,
|
|
7
|
-
import { getDefaultTemplate as
|
|
6
|
+
import { Block as _, BlockCompositionType as S, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
7
|
+
import { getDefaultTemplate as L } from "./template.js";
|
|
8
8
|
import { UNSUBSCRIBE_EVENTS as a, DATA_ATTRIBUTES as o } from "./utils/constants.js";
|
|
9
9
|
import { parsePageList as p } from "./utils/utils.js";
|
|
10
|
-
const
|
|
10
|
+
const v = "unsubscribe-block", g = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", T = "{{ins-unsubscribe-link}}", B = {
|
|
11
11
|
[E.GLOBAL_UNSUBSCRIBE]: "{{ins-global-unsubscribe-link}}",
|
|
12
12
|
[E.SUBSCRIPTION_PREFERENCE_CENTER]: "{{ins-preferences-unsubscribe-link}}"
|
|
13
13
|
};
|
|
14
|
-
class
|
|
14
|
+
class R extends _ {
|
|
15
15
|
constructor() {
|
|
16
16
|
super();
|
|
17
17
|
u(this, "selectEventListener", null);
|
|
@@ -19,7 +19,7 @@ class I extends _ {
|
|
|
19
19
|
u(this, "currentNode");
|
|
20
20
|
}
|
|
21
21
|
getId() {
|
|
22
|
-
return
|
|
22
|
+
return v;
|
|
23
23
|
}
|
|
24
24
|
getIcon() {
|
|
25
25
|
return "unsubscribe-icon";
|
|
@@ -34,7 +34,7 @@ class I extends _ {
|
|
|
34
34
|
return this.api.translate("Unsubscribe Block Description");
|
|
35
35
|
}
|
|
36
36
|
getTemplate() {
|
|
37
|
-
return
|
|
37
|
+
return L();
|
|
38
38
|
}
|
|
39
39
|
onSelect(e) {
|
|
40
40
|
this.currentNode = e, !("getAttribute" in e && e.getAttribute("data-migration")) && (this._resetStoreState(), this._loadBlockState(e), this._setupSelectEventListener(), this._setupCancelEventListener(), this._checkExistingBlocks(), this._openDrawer());
|
|
@@ -66,7 +66,7 @@ class I extends _ {
|
|
|
66
66
|
try {
|
|
67
67
|
if (!this.currentNode)
|
|
68
68
|
return;
|
|
69
|
-
this.api.getDocumentModifier().modifyHtml(this.currentNode).
|
|
69
|
+
this.api.getDocumentModifier().modifyHtml(this.currentNode).delete().apply(new b("Removed unsubscribe block due to cancel"));
|
|
70
70
|
} catch (e) {
|
|
71
71
|
console.warn("[UnsubscribeBlock] Failed to remove unsubscribe block:", e);
|
|
72
72
|
}
|
|
@@ -77,14 +77,14 @@ class I extends _ {
|
|
|
77
77
|
_updateBlock(e, r) {
|
|
78
78
|
if (!this.currentNode || !("querySelector" in this.currentNode))
|
|
79
79
|
return;
|
|
80
|
-
const s = this.currentNode.querySelector(
|
|
80
|
+
const s = this.currentNode.querySelector(g);
|
|
81
81
|
if (!s)
|
|
82
82
|
return;
|
|
83
83
|
const t = this._getMergeTag(e);
|
|
84
84
|
this.api.getDocumentModifier().modifyHtml(s).setAttribute("href", t).apply(new b(`Updated unsubscribe link to ${t}`)), this.api.getDocumentModifier().modifyHtml(this.currentNode).setAttribute(o.PAGE_TYPE, e.toString()).setAttribute(o.PAGE_LIST, r).apply(new b("Updated unsubscribe block metadata"));
|
|
85
85
|
}
|
|
86
86
|
_getMergeTag(e) {
|
|
87
|
-
return
|
|
87
|
+
return B[e] ?? T;
|
|
88
88
|
}
|
|
89
89
|
_openDrawer() {
|
|
90
90
|
if (!(this.currentNode && this.currentNode.getAttribute("data-unsubscribe-page-type")))
|
|
@@ -130,6 +130,6 @@ class I extends _ {
|
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
132
|
export {
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
v as UNSUBSCRIBE_BLOCK_ID,
|
|
134
|
+
R as UnsubscribeBlock
|
|
135
135
|
};
|
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",
|