@useinsider/guido 3.13.1-beta.695671e → 3.13.1-beta.77f8a06
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.
- package/dist/config/compiler/itemsCompilerRules.js +25 -4
- package/dist/config/compiler/utils/itemsCompilerUtils.js +28 -0
- package/dist/config/migrator/itemsBlockMigrator.js +47 -45
- package/dist/extensions/Blocks/Items/block.js +30 -30
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +16 -16
- package/dist/extensions/Blocks/Items/controls/price/hideDiscount.js +26 -22
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +35 -36
- package/dist/extensions/Blocks/Items/template.js +263 -228
- package/dist/src/config/compiler/utils/itemsCompilerUtils.d.ts +12 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +1 -1
- package/dist/utils/pairProductVariables.js +64 -67
- package/package.json +1 -1
- package/dist/extensions/Blocks/Items/utils/nameNode.js +0 -4
- package/dist/src/extensions/Blocks/Items/utils/nameNode.d.ts +0 -9
- package/dist/src/utils/unwrapProductNameLink.d.ts +0 -15
- package/dist/utils/unwrapProductNameLink.js +0 -37
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const MSO_ITEMS_HIDE_START = "MSO_ITEMS_HIDE_START";
|
|
2
|
+
export declare const MSO_ITEMS_HIDE_END = "MSO_ITEMS_HIDE_END";
|
|
3
|
+
/**
|
|
4
|
+
* SD-147597: the horizontal Items layout ships a second copy of price +
|
|
5
|
+
* original price in a `td.vertical-price` fallback hidden only by inline
|
|
6
|
+
* `display:none` (and vice versa for the vertical price orientation). Outlook's
|
|
7
|
+
* Word engine ignores `display:none` on `<td>`, so it paints BOTH copies —
|
|
8
|
+
* duplicate price. Wrap whichever price td(s) are hidden at export time in safe
|
|
9
|
+
* placeholder comments (swapped into `<!--[if !mso]>` by the priority-101 rule)
|
|
10
|
+
* and collapse them inline for web-engine Outlook.
|
|
11
|
+
*/
|
|
12
|
+
export declare function wrapHiddenPriceTdsForOutlook(html: string): string;
|
|
@@ -34,7 +34,7 @@ export declare class ItemsBlock extends Block {
|
|
|
34
34
|
*/
|
|
35
35
|
onDocumentChanged(node: ImmutableHtmlNode): void;
|
|
36
36
|
/**
|
|
37
|
-
* Bakes the compiler-read DOM attributes (`data-type`, `data-number`) onto the
|
|
37
|
+
* Bakes the compiler-read DOM attributes (`data-type`, `data-number`, `data-nodup`) onto the
|
|
38
38
|
* `.ins-product-td` container from the recovered config. Required for saved modules:
|
|
39
39
|
* `migrate()` (which backfills these) only runs at template load — never when a module
|
|
40
40
|
* is dropped into a live editor — so this is the one place the namespace + index get
|
|
@@ -1,88 +1,85 @@
|
|
|
1
|
-
import { productPairs as
|
|
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
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
T.querySelectorAll(".ins-product-td").forEach((c) => {
|
|
11
|
-
const A = c.getAttribute("data-number") || "1", m = c.getAttribute("data-type") || "CART_ITEMS";
|
|
12
|
-
c.querySelectorAll(`[product-attr="${r}"]`).forEach((t) => {
|
|
3
|
+
import { preserveTextStyles as R } from "./preserveTextStyles.js";
|
|
4
|
+
function v(L) {
|
|
5
|
+
const H = L.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), y = new DOMParser().parseFromString(H, "text/html"), m = N.PAIRS_FOR_EXTENSION;
|
|
6
|
+
Object.entries(m).forEach(([r, f]) => {
|
|
7
|
+
y.querySelectorAll(".ins-product-td").forEach((l) => {
|
|
8
|
+
const h = l.getAttribute("data-number") || "1", $ = l.getAttribute("data-type") || "CART_ITEMS";
|
|
9
|
+
l.querySelectorAll(`[product-attr="${r}"]`).forEach((t) => {
|
|
13
10
|
var F, I, w;
|
|
14
|
-
const
|
|
11
|
+
const T = t.getAttribute("data-type") || $, u = t.getAttribute("data-number") || h, d = f[T];
|
|
15
12
|
if (d)
|
|
16
13
|
switch (r) {
|
|
17
14
|
case "imageSrc": {
|
|
18
|
-
let e = null,
|
|
19
|
-
if (t.tagName === "IMG" ? (e = t,
|
|
15
|
+
let e = null, c = null;
|
|
16
|
+
if (t.tagName === "IMG" ? (e = t, c = e.closest("a")) : (e = t.querySelector("img"), c = t.querySelector("a") || t.closest("a")), !e)
|
|
20
17
|
break;
|
|
21
|
-
const
|
|
22
|
-
if (
|
|
18
|
+
const i = d.DEFAULT, s = d.ATTR;
|
|
19
|
+
if (i && e.src) {
|
|
23
20
|
const o = e.src;
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
return o.includes(
|
|
21
|
+
i.some((E) => {
|
|
22
|
+
const a = E.split("/").pop() || "", b = o.split("/").pop() || "";
|
|
23
|
+
return o.includes(E) || o.includes(a) || b === a;
|
|
27
24
|
}) && (e.src = `{{${s}_${u}}}`);
|
|
28
25
|
}
|
|
29
|
-
const n = (I = (F =
|
|
30
|
-
if (n && e.setAttribute("alt", `{{${n}_${u}}}`),
|
|
31
|
-
const o = (w =
|
|
26
|
+
const n = (I = (F = m.name) == null ? void 0 : F[T]) == null ? void 0 : I.ATTR;
|
|
27
|
+
if (n && e.setAttribute("alt", `{{${n}_${u}}}`), c) {
|
|
28
|
+
const o = (w = m.itemLink) == null ? void 0 : w[T];
|
|
32
29
|
if (o) {
|
|
33
|
-
const
|
|
34
|
-
(
|
|
30
|
+
const A = o.HREF, E = o.DEFAULT_HREF || "#!", a = c.href;
|
|
31
|
+
(a === "#" || a === "" || a.endsWith("#!") || a.endsWith(E) || a === `${window.location.href}${E}` || !a || a === window.location.href) && (c.href = `{{${A}_${u}}}`);
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
34
|
break;
|
|
38
35
|
}
|
|
39
36
|
case "name": {
|
|
40
|
-
const e = d,
|
|
41
|
-
t.textContent && (t.innerHTML =
|
|
37
|
+
const e = d, c = e.ATTR, i = e.DEFAULT_HREF || "#!", s = e.HREF;
|
|
38
|
+
t.textContent && (t.innerHTML = R(t, `{{${c}_${u}}}`));
|
|
42
39
|
const n = t.closest("a") || (t.tagName === "A" ? t : null);
|
|
43
40
|
if (n && s) {
|
|
44
|
-
const o = n.href,
|
|
45
|
-
(o ===
|
|
41
|
+
const o = n.href, A = `${window.location.href}${i}`;
|
|
42
|
+
(o === A || o.endsWith(i)) && (n.href = `{{${s}_${u}}}`);
|
|
46
43
|
}
|
|
47
44
|
break;
|
|
48
45
|
}
|
|
49
46
|
case "price":
|
|
50
47
|
case "originalPrice": {
|
|
51
|
-
const e = d,
|
|
52
|
-
let
|
|
53
|
-
n ?
|
|
54
|
-
const
|
|
55
|
-
let
|
|
56
|
-
const b = (t.getAttribute("data-currency_symbol") || "").trim(),
|
|
48
|
+
const e = d, c = t.getAttribute("data-formated"), i = t.getAttribute("data-single_price"), s = c === "true", n = i === "true", o = t.getAttribute("data-curency") || "before";
|
|
49
|
+
let A;
|
|
50
|
+
n ? A = s ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : A = s ? e.PRICE_FORMATTED : e.PRICE;
|
|
51
|
+
const E = e.CURRENCY;
|
|
52
|
+
let a = `{{${A}_${u}}}`;
|
|
53
|
+
const b = (t.getAttribute("data-currency_symbol") || "").trim(), q = b !== "" && b !== O.productPriceCurrencySymbolControlValue;
|
|
57
54
|
let g = "";
|
|
58
|
-
|
|
55
|
+
q ? g = b : E && (g = `{{${E}_${u}}}`), g && (a = o === "after" ? `${a} ${g}` : `${g} ${a}`), t.innerHTML = R(t, a);
|
|
59
56
|
break;
|
|
60
57
|
}
|
|
61
58
|
case "quantity": {
|
|
62
|
-
const e = d,
|
|
63
|
-
t.textContent && t.textContent.trim() ===
|
|
59
|
+
const e = d, c = e.ATTR, i = e.DEFAULT;
|
|
60
|
+
t.textContent && t.textContent.trim() === i && (t.innerHTML = R(t, `{{${c}_${u}}}`));
|
|
64
61
|
break;
|
|
65
62
|
}
|
|
66
63
|
case "button": {
|
|
67
|
-
const e = d,
|
|
64
|
+
const e = d, c = e.HREF, i = e.DEFAULT_HREF || "#!", s = t.tagName === "A" ? t : t.querySelector("a");
|
|
68
65
|
if (s) {
|
|
69
|
-
const n = s.href || "", o = `${window.location.href}${
|
|
70
|
-
(n === "" || n === "#" || n === o || n.endsWith(
|
|
66
|
+
const n = s.href || "", o = `${window.location.href}${i}`;
|
|
67
|
+
(n === "" || n === "#" || n === o || n.endsWith(i) || n.endsWith("#!") || n === window.location.href) && (s.href = `{{${c}_${u}}}`);
|
|
71
68
|
}
|
|
72
69
|
break;
|
|
73
70
|
}
|
|
74
71
|
case "itemLink": {
|
|
75
|
-
const e = d,
|
|
72
|
+
const e = d, c = e.HREF, i = e.DEFAULT_HREF || "#!", s = t;
|
|
76
73
|
if (s.href) {
|
|
77
|
-
const n = s.href, o = `${window.location.href}${
|
|
78
|
-
(n === o || n.endsWith(
|
|
74
|
+
const n = s.href, o = `${window.location.href}${i}`;
|
|
75
|
+
(n === o || n.endsWith(i)) && (s.href = `{{${c}_${u}}}`);
|
|
79
76
|
}
|
|
80
77
|
break;
|
|
81
78
|
}
|
|
82
79
|
default: {
|
|
83
80
|
if ("ATTR" in d) {
|
|
84
81
|
const e = d.ATTR;
|
|
85
|
-
t.textContent && (t.innerHTML =
|
|
82
|
+
t.textContent && (t.innerHTML = R(t, `{{${e}_${u}}}`));
|
|
86
83
|
}
|
|
87
84
|
break;
|
|
88
85
|
}
|
|
@@ -91,54 +88,54 @@ function Y(L) {
|
|
|
91
88
|
});
|
|
92
89
|
});
|
|
93
90
|
const k = H.match(/<!DOCTYPE[^>]*>/i), P = k ? `${k[0]}
|
|
94
|
-
` : "", D =
|
|
91
|
+
` : "", D = y.querySelectorAll(".ins-product-td"), M = [];
|
|
95
92
|
D.forEach((r) => {
|
|
96
|
-
const f = r.getAttribute("data-type") || "CART_ITEMS", p = r.getAttribute("data-number") || "1",
|
|
93
|
+
const f = r.getAttribute("data-type") || "CART_ITEMS", p = r.getAttribute("data-number") || "1", l = r.outerHTML;
|
|
97
94
|
M.push({
|
|
98
95
|
element: r,
|
|
99
|
-
outerHtml:
|
|
96
|
+
outerHtml: l,
|
|
100
97
|
type: f,
|
|
101
|
-
number: p
|
|
102
|
-
nodup: c || void 0
|
|
98
|
+
number: p
|
|
103
99
|
});
|
|
104
100
|
});
|
|
105
|
-
let _ = P +
|
|
101
|
+
let _ = P + y.documentElement.outerHTML;
|
|
106
102
|
M.reverse().forEach(({ outerHtml: r, type: f, number: p }) => {
|
|
107
|
-
let
|
|
103
|
+
let l = "";
|
|
108
104
|
switch (f) {
|
|
109
105
|
case "CART_ITEMS":
|
|
110
|
-
|
|
106
|
+
l = "ins_apr_total_product_kind";
|
|
111
107
|
break;
|
|
112
108
|
case "BROWSED_ITEMS":
|
|
113
|
-
|
|
109
|
+
l = "browsed_item_total_product_kind";
|
|
114
110
|
break;
|
|
115
111
|
case "PURCHASED_ITEMS":
|
|
116
|
-
|
|
112
|
+
l = "purchased_item_total_product_kind";
|
|
117
113
|
break;
|
|
118
114
|
}
|
|
119
|
-
if (
|
|
120
|
-
const
|
|
121
|
-
_ = _.replace(r,
|
|
115
|
+
if (l) {
|
|
116
|
+
const $ = parseInt(p) - 1, T = `${`{% if ${l} > ${$} %}`}${r}{% endif %}`;
|
|
117
|
+
_ = _.replace(r, T);
|
|
122
118
|
}
|
|
123
119
|
});
|
|
124
|
-
const x =
|
|
120
|
+
const x = y.querySelectorAll('[product-attr="originalPrice"][data-type="CART_ITEMS"]'), S = [];
|
|
125
121
|
return x.forEach((r) => {
|
|
122
|
+
var $;
|
|
126
123
|
const f = r.getAttribute("data-number"), p = r.getAttribute("data-type");
|
|
127
|
-
if (!f || p !== "CART_ITEMS")
|
|
124
|
+
if (!f || p !== "CART_ITEMS" || (($ = r.closest(".ins-product-td")) == null ? void 0 : $.getAttribute("data-nodup")) === "false")
|
|
128
125
|
return;
|
|
129
|
-
const
|
|
130
|
-
if (
|
|
131
|
-
const
|
|
132
|
-
|
|
126
|
+
const h = r.closest(".product-original-price-class");
|
|
127
|
+
if (h) {
|
|
128
|
+
const C = h.outerHTML;
|
|
129
|
+
S.some((T) => T.tdOuterHtml === C) || S.push({ tdOuterHtml: C, number: f });
|
|
133
130
|
}
|
|
134
|
-
}),
|
|
131
|
+
}), S.reverse().forEach(({ tdOuterHtml: r, number: f }) => {
|
|
135
132
|
const p = `{% if ins_apr_price_${f} != ins_apr_originalprice_${f} %}`;
|
|
136
133
|
if (!_.includes(p) && !r.includes("{% if")) {
|
|
137
|
-
const
|
|
138
|
-
_ = _.replace(r,
|
|
134
|
+
const h = `${p}${r}{% endif %}`;
|
|
135
|
+
_ = _.replace(r, h);
|
|
139
136
|
}
|
|
140
137
|
}), _.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
141
138
|
}
|
|
142
139
|
export {
|
|
143
|
-
|
|
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.
|
|
3
|
+
"version": "3.13.1-beta.77f8a06",
|
|
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,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
|
-
};
|