@useinsider/guido 3.13.1-beta.a1e3c5f → 3.13.1-beta.de07673
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/@types/config/schemas.js +13 -15
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +66 -67
- package/dist/config/migrator/index.js +7 -7
- package/dist/config/migrator/productNameLinkMigrator.js +27 -0
- 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/guido.css +1 -1
- package/dist/library.js +9 -14
- package/dist/src/@types/config/schemas.d.ts +0 -4
- package/dist/src/composables/useConfig.d.ts +0 -2
- package/dist/src/config/migrator/index.d.ts +1 -4
- package/dist/src/config/migrator/productNameLinkMigrator.d.ts +1 -0
- package/dist/src/extensions/Blocks/Items/utils/nameNode.d.ts +9 -0
- package/dist/src/library.d.ts +0 -2
- package/dist/src/stores/config.d.ts +0 -18
- package/dist/src/stores/editor.d.ts +0 -25
- package/dist/src/utils/unwrapProductNameLink.d.ts +15 -0
- package/dist/stores/editor.js +1 -4
- package/dist/utils/pairProductVariables.js +27 -24
- package/dist/utils/templatePreparation.js +59 -70
- package/dist/utils/unwrapProductNameLink.js +37 -0
- package/package.json +1 -1
- package/dist/config/migrator/trackIdMigrator.js +0 -11
- package/dist/src/config/migrator/trackIdMigrator.d.ts +0 -6
- package/dist/src/utils/linkTrackingIds.d.ts +0 -25
- package/dist/utils/linkTrackingIds.js +0 -44
|
@@ -1,65 +1,62 @@
|
|
|
1
|
-
import { useActionsApi as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return n.forEach((a) => {
|
|
16
|
-
const r = a.getAttribute(C.PAGE_LIST);
|
|
17
|
-
r && t.push(...R(r));
|
|
1
|
+
import { useActionsApi as P } from "../composables/useActionsApi.js";
|
|
2
|
+
import { useHtmlCompiler as w } from "../composables/useHtmlCompiler.js";
|
|
3
|
+
import { DEFAULT_CURRENCY as l, DEFAULT_NODE_CONFIG as i } from "../extensions/Blocks/Recommendation/constants/defaultConfig.js";
|
|
4
|
+
import { useRecommendationExtensionStore as b } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
5
|
+
import { mapLegacyStrategy as E } from "../extensions/Blocks/Recommendation/utils/legacyStrategyMap.js";
|
|
6
|
+
import { DATA_ATTRIBUTES as h } from "../extensions/Blocks/Unsubscribe/utils/constants.js";
|
|
7
|
+
import { parsePageList as H } from "../extensions/Blocks/Unsubscribe/utils/utils.js";
|
|
8
|
+
import { useDynamicContentStore as U } from "../stores/dynamic-content.js";
|
|
9
|
+
import { useUnsubscribeStore as F } from "../stores/unsubscribe.js";
|
|
10
|
+
function L(s) {
|
|
11
|
+
const o = new DOMParser().parseFromString(s, "text/html").querySelectorAll(`[${h.PAGE_LIST}]`), t = [];
|
|
12
|
+
return o.forEach((a) => {
|
|
13
|
+
const n = a.getAttribute(h.PAGE_LIST);
|
|
14
|
+
n && t.push(...H(n));
|
|
18
15
|
}), [...new Set(t)];
|
|
19
16
|
}
|
|
20
|
-
async function
|
|
21
|
-
const m = new DOMParser().parseFromString(
|
|
17
|
+
async function R(s) {
|
|
18
|
+
const m = new DOMParser().parseFromString(s, "text/html").querySelectorAll(".recommendation-block-v2");
|
|
22
19
|
if (m.length === 0)
|
|
23
20
|
return;
|
|
24
|
-
const
|
|
21
|
+
const o = b();
|
|
25
22
|
m.forEach((t) => {
|
|
26
|
-
var
|
|
27
|
-
const a = t.getAttribute("recommendation-id"),
|
|
28
|
-
if (!Number.isFinite(
|
|
23
|
+
var c, p, g, f, r;
|
|
24
|
+
const a = t.getAttribute("recommendation-id"), n = a ? Number(a) : NaN;
|
|
25
|
+
if (!Number.isFinite(n))
|
|
29
26
|
return;
|
|
30
|
-
const
|
|
31
|
-
if (!
|
|
27
|
+
const d = t.getAttribute("esd-ext-config");
|
|
28
|
+
if (!d)
|
|
32
29
|
return;
|
|
33
30
|
let e;
|
|
34
31
|
try {
|
|
35
|
-
e = JSON.parse(
|
|
32
|
+
e = JSON.parse(d);
|
|
36
33
|
} catch {
|
|
37
34
|
return;
|
|
38
35
|
}
|
|
39
36
|
if (!e || typeof e != "object" || Array.isArray(e))
|
|
40
37
|
return;
|
|
41
|
-
const
|
|
38
|
+
const y = {
|
|
42
39
|
// Normalize legacy strategy keys (e.g. `mostViewed` → `mostPopular`) so
|
|
43
40
|
// already-saved blocks that never re-run the migrator don't emit a
|
|
44
41
|
// strategy-less campaign URL. `||` also catches '' / undefined (SD-144882).
|
|
45
|
-
strategy:
|
|
46
|
-
language: e.language ??
|
|
47
|
-
size: e.size ??
|
|
42
|
+
strategy: E(e.strategy) || i.strategy,
|
|
43
|
+
language: e.language ?? i.language,
|
|
44
|
+
size: e.size ?? i.size,
|
|
48
45
|
// Spread the default arrays so each block gets a fresh reference
|
|
49
46
|
// instead of sharing the singleton in DEFAULT_NODE_CONFIG.
|
|
50
|
-
productIds: e.productIds ?? [...
|
|
51
|
-
filters: e.filters ?? [...
|
|
52
|
-
shuffleProducts: e.shuffleProducts ??
|
|
53
|
-
currencyCode: ((
|
|
54
|
-
currencyAlignment: ((
|
|
55
|
-
currencyDecimalCount: ((
|
|
56
|
-
currencyDecimalSeparator: ((
|
|
57
|
-
currencyThousandSeparator: ((
|
|
47
|
+
productIds: e.productIds ?? [...i.productIds],
|
|
48
|
+
filters: e.filters ?? [...i.filters],
|
|
49
|
+
shuffleProducts: e.shuffleProducts ?? i.shuffleProducts,
|
|
50
|
+
currencyCode: ((c = e.currency) == null ? void 0 : c.code) ?? l.code,
|
|
51
|
+
currencyAlignment: ((p = e.currency) == null ? void 0 : p.alignment) ?? l.alignment,
|
|
52
|
+
currencyDecimalCount: ((g = e.currency) == null ? void 0 : g.decimalCount) ?? l.decimalCount,
|
|
53
|
+
currencyDecimalSeparator: ((f = e.currency) == null ? void 0 : f.decimalSeparator) ?? l.decimalSeparator,
|
|
54
|
+
currencyThousandSeparator: ((r = e.currency) == null ? void 0 : r.thousandSeparator) ?? l.thousandSeparator
|
|
58
55
|
};
|
|
59
|
-
|
|
56
|
+
o.seedBlockUrlConfig(n, y);
|
|
60
57
|
});
|
|
61
58
|
try {
|
|
62
|
-
await
|
|
59
|
+
await o.fetchRecommendationCreateData();
|
|
63
60
|
} catch (t) {
|
|
64
61
|
console.warn(
|
|
65
62
|
"Recommendation reference data pre-load failed; validator will skip the availability check.",
|
|
@@ -67,51 +64,43 @@ async function M(c) {
|
|
|
67
64
|
);
|
|
68
65
|
}
|
|
69
66
|
}
|
|
70
|
-
const
|
|
71
|
-
const
|
|
67
|
+
const G = () => {
|
|
68
|
+
const s = U(), u = F(), { getCompiledEmail: m, getTemplateData: o } = P(), { compileHtml: t, compileAmpHtml: a } = w();
|
|
72
69
|
return {
|
|
73
70
|
prepareTemplateDetails: async () => {
|
|
74
|
-
|
|
75
|
-
if (p("linkTrackingIds"))
|
|
76
|
-
try {
|
|
77
|
-
const h = z(), { html: A, changed: H, nextSeq: I } = v(o, h.trackIdSessionFloor);
|
|
78
|
-
H && (t(A, l), o = A), h.trackIdSessionFloor = I;
|
|
79
|
-
} catch (h) {
|
|
80
|
-
console.error("Tracking-id assignment failed, saving without new ids:", h);
|
|
81
|
-
}
|
|
82
|
-
const { html: f, ampHtml: i = "", ampErrors: S = [] } = await m({
|
|
71
|
+
const { html: d, ampHtml: e = "", ampErrors: y = [] } = await m({
|
|
83
72
|
minimize: !0,
|
|
84
73
|
resetDataSavedFlag: !1
|
|
85
|
-
});
|
|
86
|
-
u.selectedUnsubscribePages.length && await u.fetchTemplates(), await
|
|
87
|
-
const { compiledHtml:
|
|
74
|
+
}), { html: c, css: p, syncModulesIds: g = [] } = await o();
|
|
75
|
+
u.selectedUnsubscribePages.length && await u.fetchTemplates(), await R(c);
|
|
76
|
+
const { compiledHtml: f, stats: r, appliedRules: A } = t(d), C = e && a(e).compiledHtml, T = s.getSelectedDynamicContentList, D = b(), S = L(c);
|
|
88
77
|
return console.debug("HTML Compilation Stats:", {
|
|
89
|
-
originalSize:
|
|
90
|
-
compiledSize:
|
|
91
|
-
reduction: `${
|
|
92
|
-
appliedRules:
|
|
93
|
-
executionTime: `${
|
|
78
|
+
originalSize: r.originalSize,
|
|
79
|
+
compiledSize: r.compiledSize,
|
|
80
|
+
reduction: `${r.reductionPercentage.toFixed(2)}%`,
|
|
81
|
+
appliedRules: A,
|
|
82
|
+
executionTime: `${r.executionTime.toFixed(2)}ms`
|
|
94
83
|
}), {
|
|
95
|
-
dynamicContentList:
|
|
96
|
-
compiledHtml:
|
|
97
|
-
rawHtml:
|
|
98
|
-
css:
|
|
99
|
-
ampHtml:
|
|
100
|
-
ampErrors:
|
|
84
|
+
dynamicContentList: T,
|
|
85
|
+
compiledHtml: f,
|
|
86
|
+
rawHtml: c,
|
|
87
|
+
css: p,
|
|
88
|
+
ampHtml: C,
|
|
89
|
+
ampErrors: y,
|
|
101
90
|
modules: g.map(Number),
|
|
102
91
|
recommendation: {
|
|
103
|
-
campaignUrls:
|
|
92
|
+
campaignUrls: D.recommendationCampaignUrls,
|
|
104
93
|
configs: {}
|
|
105
94
|
},
|
|
106
95
|
unsubscribe: {
|
|
107
|
-
status:
|
|
108
|
-
config:
|
|
96
|
+
status: S.length > 0,
|
|
97
|
+
config: S
|
|
109
98
|
}
|
|
110
99
|
};
|
|
111
100
|
}
|
|
112
101
|
};
|
|
113
102
|
};
|
|
114
103
|
export {
|
|
115
|
-
|
|
116
|
-
|
|
104
|
+
L as getHtmlReferencedUnsubscribePages,
|
|
105
|
+
G as useTemplatePreparation
|
|
117
106
|
};
|
|
@@ -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.1-beta.
|
|
3
|
+
"version": "3.13.1-beta.de07673",
|
|
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,6 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Backfills persistent link tracking ids (SD-141414) at load so legacy
|
|
3
|
-
* templates, library imports and externally edited HTML enter the editor
|
|
4
|
-
* already tagged — before Stripo sees the document (no dirty flag, no undo).
|
|
5
|
-
*/
|
|
6
|
-
export declare function migrateTrackIds(html: string): string;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Persistent link tracking ids for the click heatmap (SD-141414).
|
|
3
|
-
* Pure string transforms — no DOM parse/serialize round-trip, safe for both
|
|
4
|
-
* Stripo raw HTML and hand-authored HTML-editor documents. Shared with email-fe.
|
|
5
|
-
*/
|
|
6
|
-
export declare const TRACK_ID_ATTRIBUTE = "data-ins-track-id";
|
|
7
|
-
export declare const TRACK_SEQ_ATTRIBUTE = "data-ins-track-seq";
|
|
8
|
-
export interface TrackingIdResult {
|
|
9
|
-
html: string;
|
|
10
|
-
changed: boolean;
|
|
11
|
-
nextSeq: number;
|
|
12
|
-
}
|
|
13
|
-
/**
|
|
14
|
-
* Reads the persisted id high-water mark: <body> attr, then <html> attr,
|
|
15
|
-
* then the leading comment fallback. Returns 0 when absent.
|
|
16
|
-
*/
|
|
17
|
-
export declare function readTrackSeq(html: string): number;
|
|
18
|
-
/**
|
|
19
|
-
* Ensures every <a> opening tag carries a unique positive-integer id and the
|
|
20
|
-
* document records the id high-water mark. Ids are minted above
|
|
21
|
-
* max(persisted seq, max id in document, floor) so deleted ids are never
|
|
22
|
-
* reused — even after a version restore or paste-over (floor = session floor).
|
|
23
|
-
* Idempotent: a document already normalized returns changed=false.
|
|
24
|
-
*/
|
|
25
|
-
export declare function assignTrackingIds(html: string, floor?: number): TrackingIdResult;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
const E = "data-ins-track-id", g = "data-ins-track-seq", N = /<a\b[^>]*>/gi, $ = /\bdata-ins-track-id\s*=\s*(?:"([^"]*)"|'([^']*)'|([^\s>]+))/i, R = /\bdata-ins-track-seq\s*=\s*(?:"(\d+)"|'(\d+)'|(\d+))/i, f = /<body\b[^>]*>/i, b = /<html\b[^>]*>/i, A = /<!--\s*ins-track-seq:(\d+)\s*-->/i, k = /^[1-9][0-9]{0,14}$/;
|
|
2
|
-
function S(e) {
|
|
3
|
-
const s = Number(e);
|
|
4
|
-
return Number.isSafeInteger(s) && s > 0 ? s : 0;
|
|
5
|
-
}
|
|
6
|
-
function x(e) {
|
|
7
|
-
var i, a, c;
|
|
8
|
-
const n = [(i = f.exec(e)) == null ? void 0 : i[0], (a = b.exec(e)) == null ? void 0 : a[0]].reduce(
|
|
9
|
-
(T, o) => T ?? (o ? R.exec(o) : null),
|
|
10
|
-
null
|
|
11
|
-
), t = (n == null ? void 0 : n[1]) ?? (n == null ? void 0 : n[2]) ?? (n == null ? void 0 : n[3]) ?? ((c = A.exec(e)) == null ? void 0 : c[1]) ?? "";
|
|
12
|
-
return S(t);
|
|
13
|
-
}
|
|
14
|
-
function I(e, s) {
|
|
15
|
-
const n = `${g}="${s}"`, t = f.exec(e) ?? b.exec(e);
|
|
16
|
-
if (t) {
|
|
17
|
-
const [i] = t, a = R.exec(i), c = a ? i.replace(a[0], n) : i.replace(/\/?>$/, (T) => ` ${n}${T}`);
|
|
18
|
-
return e.slice(0, t.index) + c + e.slice(t.index + i.length);
|
|
19
|
-
}
|
|
20
|
-
return A.test(e) ? e.replace(A, `<!--ins-track-seq:${s}-->`) : `<!--ins-track-seq:${s}-->${e}`;
|
|
21
|
-
}
|
|
22
|
-
function p(e, s, n) {
|
|
23
|
-
const t = `${E}="${n}"`;
|
|
24
|
-
return s ? e.replace(s[0], t) : e.replace(/^<a\b/i, (i) => `${i} ${t}`);
|
|
25
|
-
}
|
|
26
|
-
function q(e, s = 0) {
|
|
27
|
-
const n = /* @__PURE__ */ new Set();
|
|
28
|
-
let t = 0;
|
|
29
|
-
const i = [...e.matchAll(N)].map((r) => {
|
|
30
|
-
const [_] = r, u = $.exec(_), l = u ? u[1] ?? u[2] ?? u[3] ?? "" : "";
|
|
31
|
-
let d = null;
|
|
32
|
-
return k.test(l) && !n.has(Number(l)) && (d = Number(l), n.add(d), t = Math.max(t, d)), { index: r.index, tag: _, attrMatch: u, id: d };
|
|
33
|
-
});
|
|
34
|
-
let a = Math.max(x(e), t, s), c = "", T = 0, o = !1;
|
|
35
|
-
return i.forEach((r) => {
|
|
36
|
-
c += e.slice(T, r.index), r.id === null ? (a += 1, c += p(r.tag, r.attrMatch, a), o = !0) : c += r.tag, T = r.index + r.tag.length;
|
|
37
|
-
}), c += e.slice(T), a > 0 && x(c) !== a && (c = I(c, a), o = !0), { html: c, changed: o, nextSeq: a };
|
|
38
|
-
}
|
|
39
|
-
export {
|
|
40
|
-
E as TRACK_ID_ATTRIBUTE,
|
|
41
|
-
g as TRACK_SEQ_ATTRIBUTE,
|
|
42
|
-
q as assignTrackingIds,
|
|
43
|
-
x as readTrackSeq
|
|
44
|
-
};
|