@useinsider/guido 3.13.0 → 3.13.1-beta.695671e
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/README.md +1 -1
- package/dist/@types/config/defaults.js +6 -2
- package/dist/composables/useTranslations.js +7 -5
- package/dist/config/compiler/outlookCompilerRules.js +21 -8
- package/dist/extensions/Blocks/Items/controls/name/trimming.js +16 -16
- package/dist/extensions/Blocks/Items/controls/settingsControl.js +36 -35
- package/dist/extensions/Blocks/Items/template.js +228 -263
- package/dist/extensions/Blocks/Items/utils/nameNode.js +4 -0
- package/dist/src/composables/useModuleDynamicContentRepair.d.ts +0 -5
- package/dist/src/extensions/Blocks/Items/utils/nameNode.d.ts +9 -0
- package/dist/src/utils/unwrapProductNameLink.d.ts +15 -0
- package/dist/utils/pairProductVariables.js +27 -24
- package/dist/utils/unwrapProductNameLink.js +37 -0
- package/package.json +1 -1
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import type { ModuleAddData, ModuleModifier } from '@@/Types/stripo';
|
|
2
|
-
/**
|
|
3
|
-
* Host-registered translation key for the "some attributes could not be
|
|
4
|
-
* converted" toaster. Guido resolves it against the host's `window.trans.en`;
|
|
5
|
-
* the copy is registered host-side.
|
|
6
|
-
*/
|
|
7
2
|
export declare const UNRESOLVED_DYNAMIC_CONTENT_ON_DROP_KEY = "dynamic-content.unresolved-attributes-on-drop";
|
|
8
3
|
/**
|
|
9
4
|
* Repairs label-form dynamic-content tokens in saved modules as they are dropped
|
|
@@ -0,0 +1,9 @@
|
|
|
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;
|
|
@@ -0,0 +1,15 @@
|
|
|
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,14 +1,17 @@
|
|
|
1
|
-
import { productPairs as
|
|
1
|
+
import { productPairs as q } 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
|
-
|
|
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";
|
|
9
12
|
c.querySelectorAll(`[product-attr="${r}"]`).forEach((t) => {
|
|
10
13
|
var F, I, w;
|
|
11
|
-
const
|
|
14
|
+
const $ = t.getAttribute("data-type") || m, u = t.getAttribute("data-number") || A, d = f[$];
|
|
12
15
|
if (d)
|
|
13
16
|
switch (r) {
|
|
14
17
|
case "imageSrc": {
|
|
@@ -19,13 +22,13 @@ function V(L) {
|
|
|
19
22
|
if (a && e.src) {
|
|
20
23
|
const o = e.src;
|
|
21
24
|
a.some((h) => {
|
|
22
|
-
const l = h.split("/").pop() || "",
|
|
23
|
-
return o.includes(h) || o.includes(l) ||
|
|
25
|
+
const l = h.split("/").pop() || "", b = o.split("/").pop() || "";
|
|
26
|
+
return o.includes(h) || o.includes(l) || b === l;
|
|
24
27
|
}) && (e.src = `{{${s}_${u}}}`);
|
|
25
28
|
}
|
|
26
|
-
const n = (I = (F =
|
|
29
|
+
const n = (I = (F = C.name) == null ? void 0 : F[$]) == null ? void 0 : I.ATTR;
|
|
27
30
|
if (n && e.setAttribute("alt", `{{${n}_${u}}}`), i) {
|
|
28
|
-
const o = (w =
|
|
31
|
+
const o = (w = C.itemLink) == null ? void 0 : w[$];
|
|
29
32
|
if (o) {
|
|
30
33
|
const E = o.HREF, h = o.DEFAULT_HREF || "#!", l = i.href;
|
|
31
34
|
(l === "#" || l === "" || l.endsWith("#!") || l.endsWith(h) || l === `${window.location.href}${h}` || !l || l === window.location.href) && (i.href = `{{${E}_${u}}}`);
|
|
@@ -35,7 +38,7 @@ function V(L) {
|
|
|
35
38
|
}
|
|
36
39
|
case "name": {
|
|
37
40
|
const e = d, i = e.ATTR, a = e.DEFAULT_HREF || "#!", s = e.HREF;
|
|
38
|
-
t.textContent && (t.innerHTML =
|
|
41
|
+
t.textContent && (t.innerHTML = y(t, `{{${i}_${u}}}`));
|
|
39
42
|
const n = t.closest("a") || (t.tagName === "A" ? t : null);
|
|
40
43
|
if (n && s) {
|
|
41
44
|
const o = n.href, E = `${window.location.href}${a}`;
|
|
@@ -50,14 +53,14 @@ function V(L) {
|
|
|
50
53
|
n ? E = s ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : E = s ? e.PRICE_FORMATTED : e.PRICE;
|
|
51
54
|
const h = e.CURRENCY;
|
|
52
55
|
let l = `{{${E}_${u}}}`;
|
|
53
|
-
const
|
|
54
|
-
let
|
|
55
|
-
|
|
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);
|
|
56
59
|
break;
|
|
57
60
|
}
|
|
58
61
|
case "quantity": {
|
|
59
62
|
const e = d, i = e.ATTR, a = e.DEFAULT;
|
|
60
|
-
t.textContent && t.textContent.trim() === a && (t.innerHTML =
|
|
63
|
+
t.textContent && t.textContent.trim() === a && (t.innerHTML = y(t, `{{${i}_${u}}}`));
|
|
61
64
|
break;
|
|
62
65
|
}
|
|
63
66
|
case "button": {
|
|
@@ -79,7 +82,7 @@ function V(L) {
|
|
|
79
82
|
default: {
|
|
80
83
|
if ("ATTR" in d) {
|
|
81
84
|
const e = d.ATTR;
|
|
82
|
-
t.textContent && (t.innerHTML =
|
|
85
|
+
t.textContent && (t.innerHTML = y(t, `{{${e}_${u}}}`));
|
|
83
86
|
}
|
|
84
87
|
break;
|
|
85
88
|
}
|
|
@@ -88,7 +91,7 @@ function V(L) {
|
|
|
88
91
|
});
|
|
89
92
|
});
|
|
90
93
|
const k = H.match(/<!DOCTYPE[^>]*>/i), P = k ? `${k[0]}
|
|
91
|
-
` : "", D =
|
|
94
|
+
` : "", D = T.querySelectorAll(".ins-product-td"), M = [];
|
|
92
95
|
D.forEach((r) => {
|
|
93
96
|
const f = r.getAttribute("data-type") || "CART_ITEMS", p = r.getAttribute("data-number") || "1", c = r.getAttribute("data-nodup"), A = r.outerHTML;
|
|
94
97
|
M.push({
|
|
@@ -99,7 +102,7 @@ function V(L) {
|
|
|
99
102
|
nodup: c || void 0
|
|
100
103
|
});
|
|
101
104
|
});
|
|
102
|
-
let _ = P +
|
|
105
|
+
let _ = P + T.documentElement.outerHTML;
|
|
103
106
|
M.reverse().forEach(({ outerHtml: r, type: f, number: p }) => {
|
|
104
107
|
let c = "";
|
|
105
108
|
switch (f) {
|
|
@@ -114,11 +117,11 @@ function V(L) {
|
|
|
114
117
|
break;
|
|
115
118
|
}
|
|
116
119
|
if (c) {
|
|
117
|
-
const
|
|
118
|
-
_ = _.replace(r,
|
|
120
|
+
const m = parseInt(p) - 1, $ = `${`{% if ${c} > ${m} %}`}${r}{% endif %}`;
|
|
121
|
+
_ = _.replace(r, $);
|
|
119
122
|
}
|
|
120
123
|
});
|
|
121
|
-
const x =
|
|
124
|
+
const x = T.querySelectorAll('[product-attr="originalPrice"][data-type="CART_ITEMS"]'), R = [];
|
|
122
125
|
return x.forEach((r) => {
|
|
123
126
|
const f = r.getAttribute("data-number"), p = r.getAttribute("data-type");
|
|
124
127
|
if (!f || p !== "CART_ITEMS")
|
|
@@ -137,5 +140,5 @@ function V(L) {
|
|
|
137
140
|
}), _.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
138
141
|
}
|
|
139
142
|
export {
|
|
140
|
-
|
|
143
|
+
Y as pairProductVariables
|
|
141
144
|
};
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.13.
|
|
3
|
+
"version": "3.13.1-beta.695671e",
|
|
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",
|