@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 x = Object.defineProperty;
2
- var f = (r, t, e) => t in r ? x(r, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : r[t] = e;
3
- var b = (r, t, e) => f(r, typeof t != "symbol" ? t + "" : t, e);
4
- import h from "../../extensions/Blocks/RadioButton/template.js";
5
- class T {
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
- b(this, "parser");
7
+ y(this, "parser");
8
8
  this.parser = new DOMParser();
9
9
  }
10
- migrate(t) {
10
+ migrate(e) {
11
11
  try {
12
- const e = this.parser.parseFromString(t, "text/html"), i = e.querySelectorAll("td.radio-button-block");
13
- return i.length === 0 ? t : (i.forEach((s) => {
14
- if (s.classList.contains("radio-button-v2"))
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 n = s.getAttribute("id"), l = this.extractTextFromElement(s, "ins-title"), a = this.extractTextFromElement(s, "ins-description"), p = this.extractTextFromElement(s, "ins-subscribe"), u = this.extractTextFromElement(s, "ins-unsubscribe"), d = this.buildTextBlock(l), g = this.buildTextBlock(a), m = this.buildTextBlock({ ...p, classList: "" }), o = this.buildTextBlock({ ...u, classList: "" }), c = h.replace("{-{-TITLE-}-}", d).replace("{-{-DESCRIPTION-}-}", g).replace("{-{-YES-}-}", m).replace("{-{-NO-}-}", o), y = this.parser.parseFromString(
17
- `<table id="tempDoc"><tbody><tr>${c}</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
- y && s.parentNode && (y.setAttribute("id", n || ""), s.parentNode.replaceChild(y, s));
21
- }), e.documentElement.outerHTML);
22
- } catch (e) {
23
- return console.error("RadioButtonMigrator failed:", e), t;
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(t, e) {
27
- var o, c;
28
- const i = t.querySelector(`.${e}`);
29
- if (!i)
37
+ extractTextFromElement(e, t) {
38
+ var d, g;
39
+ const s = e.querySelector(`.${t}`);
40
+ if (!s)
30
41
  return {
31
- text: e === "ins-title" ? "Title" : "Description",
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 s = i.querySelector("p");
39
- if (!s)
49
+ const i = s.querySelector("p");
50
+ if (!i)
40
51
  return {
41
- text: ((o = i.textContent) == null ? void 0 : o.trim()) || (e === "ins-title" ? "Title" : "Description"),
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: i.getAttribute("align") || "left",
55
+ align: s.getAttribute("align") || "left",
45
56
  styles: "",
46
57
  classList: ""
47
58
  };
48
- const n = ((c = s.textContent) == null ? void 0 : c.trim()) || (e === "ins-title" ? "Title" : "Description"), l = s.getAttribute("style") || "", a = i.getAttribute("align") || s.getAttribute("align") || "left", p = /font-weight\s*:\s*bold/i.test(l) || !!s.querySelector("b, strong"), u = /font-style\s*:\s*italic/i.test(l) || !!s.querySelector("i, em"), d = this.removeStyleProperties(l, ["font-weight", "font-style"]), g = this.convertInlineToBlock(d), m = i.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") || "";
49
60
  return {
50
61
  text: n,
51
- isBold: p,
52
- isItalic: u,
53
- align: a,
54
- styles: g,
62
+ isBold: o,
63
+ isItalic: a,
64
+ align: c,
65
+ styles: u,
55
66
  classList: m
56
67
  };
57
68
  }
58
- buildTextBlock(t) {
59
- let e = t.text;
60
- 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>`);
61
- const i = t.align ? ` align="${t.align}"` : "", s = t.styles ? ` style="${t.styles.replaceAll('"', "'")}"` : "";
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 ${t.classList}" ${i}>
64
- <p path="1" ${s}>
65
- ${e}
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(t, e) {
71
- return t ? e.reduce((s, n) => {
72
- const l = new RegExp(`${n}\\s*:\\s*[^;]*;?`, "gi");
73
- return s.replace(l, "");
74
- }, t).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
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(t) {
77
- if (!t)
87
+ convertInlineToBlock(e) {
88
+ if (!e)
78
89
  return "";
79
- let e = t.replace(/display\s*:\s*inline/gi, "display: block");
80
- return /display\s*:/i.test(e) || (e = e ? `${e}; display: block` : "display: block"), e.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim();
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 A(r) {
84
- return new T().migrate(r);
94
+ function k(l) {
95
+ return new B().migrate(l);
85
96
  }
86
97
  export {
87
- A as migrateRadioButton
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, BlockType as L, ModificationDescription as b } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
7
- import { getDefaultTemplate as v } from "./template.js";
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 g = "unsubscribe-block", T = 'a[data-unsubscribe-link="true"]', f = ".unsubscribe-block-v2", B = "{{ins-unsubscribe-link}}", C = {
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 I extends _ {
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 g;
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 v();
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).replaceWith(`<${L.EMPTY_CONTAINER}/>`).apply(new b("Removed unsubscribe block due to cancel"));
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(T);
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 C[e] ?? B;
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
- g as UNSUBSCRIBE_BLOCK_ID,
134
- I as UnsubscribeBlock
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.2a61d0e",
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",