@useinsider/guido 3.13.1-beta.695671e → 3.13.1-beta.98d403f

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,17 +1,14 @@
1
- import { productPairs as q } from "../extensions/Blocks/Items/enums/productEnums.js";
1
+ import { productPairs as N } from "../extensions/Blocks/Items/enums/productEnums.js";
2
2
  import { DefaultConfigValues as O } from "../extensions/Blocks/Items/enums/settingsEnums.js";
3
- import { preserveTextStyles as y } from "./preserveTextStyles.js";
4
- import { unwrapProductNameLinks as U } from "./unwrapProductNameLink.js";
5
- function Y(L) {
6
- const H = L.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), T = new DOMParser().parseFromString(H, "text/html");
7
- U(T);
8
- const C = q.PAIRS_FOR_EXTENSION;
9
- Object.entries(C).forEach(([r, f]) => {
10
- T.querySelectorAll(".ins-product-td").forEach((c) => {
11
- const A = c.getAttribute("data-number") || "1", m = c.getAttribute("data-type") || "CART_ITEMS";
3
+ import { preserveTextStyles as C } from "./preserveTextStyles.js";
4
+ function V(L) {
5
+ const H = L.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), g = new DOMParser().parseFromString(H, "text/html"), m = N.PAIRS_FOR_EXTENSION;
6
+ Object.entries(m).forEach(([r, f]) => {
7
+ g.querySelectorAll(".ins-product-td").forEach((c) => {
8
+ const A = c.getAttribute("data-number") || "1", y = c.getAttribute("data-type") || "CART_ITEMS";
12
9
  c.querySelectorAll(`[product-attr="${r}"]`).forEach((t) => {
13
10
  var F, I, w;
14
- const $ = t.getAttribute("data-type") || m, u = t.getAttribute("data-number") || A, d = f[$];
11
+ const T = t.getAttribute("data-type") || y, u = t.getAttribute("data-number") || A, d = f[T];
15
12
  if (d)
16
13
  switch (r) {
17
14
  case "imageSrc": {
@@ -22,13 +19,13 @@ function Y(L) {
22
19
  if (a && e.src) {
23
20
  const o = e.src;
24
21
  a.some((h) => {
25
- const l = h.split("/").pop() || "", b = o.split("/").pop() || "";
26
- return o.includes(h) || o.includes(l) || b === l;
22
+ const l = h.split("/").pop() || "", $ = o.split("/").pop() || "";
23
+ return o.includes(h) || o.includes(l) || $ === l;
27
24
  }) && (e.src = `{{${s}_${u}}}`);
28
25
  }
29
- const n = (I = (F = C.name) == null ? void 0 : F[$]) == null ? void 0 : I.ATTR;
26
+ const n = (I = (F = m.name) == null ? void 0 : F[T]) == null ? void 0 : I.ATTR;
30
27
  if (n && e.setAttribute("alt", `{{${n}_${u}}}`), i) {
31
- const o = (w = C.itemLink) == null ? void 0 : w[$];
28
+ const o = (w = m.itemLink) == null ? void 0 : w[T];
32
29
  if (o) {
33
30
  const E = o.HREF, h = o.DEFAULT_HREF || "#!", l = i.href;
34
31
  (l === "#" || l === "" || l.endsWith("#!") || l.endsWith(h) || l === `${window.location.href}${h}` || !l || l === window.location.href) && (i.href = `{{${E}_${u}}}`);
@@ -38,7 +35,7 @@ function Y(L) {
38
35
  }
39
36
  case "name": {
40
37
  const e = d, i = e.ATTR, a = e.DEFAULT_HREF || "#!", s = e.HREF;
41
- t.textContent && (t.innerHTML = y(t, `{{${i}_${u}}}`));
38
+ t.textContent && (t.innerHTML = C(t, `{{${i}_${u}}}`));
42
39
  const n = t.closest("a") || (t.tagName === "A" ? t : null);
43
40
  if (n && s) {
44
41
  const o = n.href, E = `${window.location.href}${a}`;
@@ -53,14 +50,14 @@ function Y(L) {
53
50
  n ? E = s ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : E = s ? e.PRICE_FORMATTED : e.PRICE;
54
51
  const h = e.CURRENCY;
55
52
  let l = `{{${E}_${u}}}`;
56
- const b = (t.getAttribute("data-currency_symbol") || "").trim(), N = b !== "" && b !== O.productPriceCurrencySymbolControlValue;
57
- let g = "";
58
- N ? g = b : h && (g = `{{${h}_${u}}}`), g && (l = o === "after" ? `${l} ${g}` : `${g} ${l}`), t.innerHTML = y(t, l);
53
+ const $ = (t.getAttribute("data-currency_symbol") || "").trim(), q = $ !== "" && $ !== O.productPriceCurrencySymbolControlValue;
54
+ let b = "";
55
+ q ? b = $ : h && (b = `{{${h}_${u}}}`), b && (l = o === "after" ? `${l} ${b}` : `${b} ${l}`), t.innerHTML = C(t, l);
59
56
  break;
60
57
  }
61
58
  case "quantity": {
62
59
  const e = d, i = e.ATTR, a = e.DEFAULT;
63
- t.textContent && t.textContent.trim() === a && (t.innerHTML = y(t, `{{${i}_${u}}}`));
60
+ t.textContent && t.textContent.trim() === a && (t.innerHTML = C(t, `{{${i}_${u}}}`));
64
61
  break;
65
62
  }
66
63
  case "button": {
@@ -82,7 +79,7 @@ function Y(L) {
82
79
  default: {
83
80
  if ("ATTR" in d) {
84
81
  const e = d.ATTR;
85
- t.textContent && (t.innerHTML = y(t, `{{${e}_${u}}}`));
82
+ t.textContent && (t.innerHTML = C(t, `{{${e}_${u}}}`));
86
83
  }
87
84
  break;
88
85
  }
@@ -91,7 +88,7 @@ function Y(L) {
91
88
  });
92
89
  });
93
90
  const k = H.match(/<!DOCTYPE[^>]*>/i), P = k ? `${k[0]}
94
- ` : "", D = T.querySelectorAll(".ins-product-td"), M = [];
91
+ ` : "", D = g.querySelectorAll(".ins-product-td"), M = [];
95
92
  D.forEach((r) => {
96
93
  const f = r.getAttribute("data-type") || "CART_ITEMS", p = r.getAttribute("data-number") || "1", c = r.getAttribute("data-nodup"), A = r.outerHTML;
97
94
  M.push({
@@ -102,7 +99,7 @@ function Y(L) {
102
99
  nodup: c || void 0
103
100
  });
104
101
  });
105
- let _ = P + T.documentElement.outerHTML;
102
+ let _ = P + g.documentElement.outerHTML;
106
103
  M.reverse().forEach(({ outerHtml: r, type: f, number: p }) => {
107
104
  let c = "";
108
105
  switch (f) {
@@ -117,11 +114,11 @@ function Y(L) {
117
114
  break;
118
115
  }
119
116
  if (c) {
120
- const m = parseInt(p) - 1, $ = `${`{% if ${c} > ${m} %}`}${r}{% endif %}`;
121
- _ = _.replace(r, $);
117
+ const y = parseInt(p) - 1, T = `${`{% if ${c} > ${y} %}`}${r}{% endif %}`;
118
+ _ = _.replace(r, T);
122
119
  }
123
120
  });
124
- const x = T.querySelectorAll('[product-attr="originalPrice"][data-type="CART_ITEMS"]'), R = [];
121
+ const x = g.querySelectorAll('[product-attr="originalPrice"][data-type="CART_ITEMS"]'), R = [];
125
122
  return x.forEach((r) => {
126
123
  const f = r.getAttribute("data-number"), p = r.getAttribute("data-type");
127
124
  if (!f || p !== "CART_ITEMS")
@@ -140,5 +137,5 @@ function Y(L) {
140
137
  }), _.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("&lt;!--{%", "{%").replaceAll("%}--&gt;", "%}");
141
138
  }
142
139
  export {
143
- Y as pairProductVariables
140
+ V as pairProductVariables
144
141
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@useinsider/guido",
3
- "version": "3.13.1-beta.695671e",
3
+ "version": "3.13.1-beta.98d403f",
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",
@@ -1,4 +0,0 @@
1
- const e = (t) => t ? t.querySelector('[product-attr="name"]') ?? t.querySelector("p > a") : void 0;
2
- export {
3
- e as findNameTextNode
4
- };
@@ -1,9 +0,0 @@
1
- import type { ImmutableHtmlElementNode, ImmutableHtmlNode } from '@stripoinc/ui-editor-extensions';
2
- /**
3
- * Resolves the element carrying the product name text.
4
- *
5
- * New blocks put `product-attr="name"` on the `<p>`; blocks saved before SD-147616 still
6
- * carry it on the inner `<a>`, and the oldest ones have no attribute at all — hence the
7
- * `p > a` fallback. Without it, trimming silently no-ops on legacy blocks.
8
- */
9
- export declare const findNameTextNode: (container?: ImmutableHtmlNode) => ImmutableHtmlElementNode | undefined;
@@ -1,15 +0,0 @@
1
- /**
2
- * Unwraps the `<a>` around an Items-block product name so the name compiles as plain text.
3
- *
4
- * Outlook's Word engine ignores `color: inherit` on an `<a>` and paints its own blue link
5
- * color (SD-147616). New blocks no longer emit the anchor, but templates saved before the
6
- * fix still carry it in their stored HTML — this heals them at compile time.
7
- */
8
- /**
9
- * Removes the product-name link from every `.ins-product-td` in the document, in place.
10
- *
11
- * Scoped like `pairProductVariables` so partner or legacy recommendation markup outside a
12
- * product cell is never touched. Idempotent.
13
- * @param doc - Parsed template document, mutated in place
14
- */
15
- export declare function unwrapProductNameLinks(doc: Document): void;
@@ -1,37 +0,0 @@
1
- const f = "text-decoration", A = /(?:[^;"'()]|"[^"]*"|'[^']*'|\([^)]*\))+/g, c = (e) => (e.match(A) || []).map((r) => r.trim()).filter(Boolean), l = (e) => e.slice(0, e.indexOf(":")).trim().toLowerCase(), m = (e) => e.slice(e.indexOf(":") + 1).trim().toLowerCase(), u = (e, r) => {
2
- const s = e.getAttribute("style");
3
- if (!s)
4
- return;
5
- const t = c(r.getAttribute("style") || ""), i = new Set(t.map(l)), o = c(s).filter((n) => {
6
- const a = l(n);
7
- return !a || i.has(a) ? !1 : !a.startsWith(f) && m(n) !== "inherit";
8
- });
9
- o.length && r.setAttribute("style", [...t, ...o].join("; "));
10
- }, y = ["product-attr", "data-type", "data-number", "data-slot-2"], p = (e, r) => {
11
- y.forEach((s) => {
12
- const t = e.getAttribute(s);
13
- t !== null && !r.hasAttribute(s) && r.setAttribute(s, t);
14
- });
15
- };
16
- function E(e) {
17
- e.querySelectorAll(".ins-product-td").forEach((r) => {
18
- const s = /* @__PURE__ */ new Set();
19
- r.querySelectorAll('[product-attr="name"]').forEach((t) => {
20
- const i = t.closest("a");
21
- i && r.contains(i) && s.add(i);
22
- }), s.forEach((t) => {
23
- if (t.querySelector("img") || Array.from(t.querySelectorAll("[product-attr]")).some((a) => a.getAttribute("product-attr") !== "name"))
24
- return;
25
- const o = t.closest("p");
26
- if (o && r.contains(o)) {
27
- p(t, o), u(t, o), t.replaceWith(...Array.from(t.childNodes));
28
- return;
29
- }
30
- const n = e.createElement("span");
31
- p(t, n), u(t, n), n.append(...Array.from(t.childNodes)), t.replaceWith(n);
32
- });
33
- });
34
- }
35
- export {
36
- E as unwrapProductNameLinks
37
- };