@useinsider/guido 3.2.0-beta.6d12eec → 3.2.0-beta.6f6a5ed
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/composables/useActionsApi.js +4 -4
- package/dist/composables/useFullStoryBridge.js +9 -29
- package/dist/composables/useSave.js +1 -1
- package/dist/composables/useStripo.js +23 -22
- package/dist/config/compiler/recommendationCompilerRules.js +72 -67
- package/dist/config/compiler/utils/recommendationCompilerUtils.js +33 -30
- package/dist/config/migrator/recommendationMigrator.js +1 -1
- package/dist/extensions/Blocks/Items/controls/price/singlePrice.js +38 -38
- package/dist/extensions/Blocks/Items/enums/productEnums.js +19 -7
- package/dist/extensions/Blocks/Recommendation/constants/controlIds.js +1 -1
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/index.js +21 -18
- package/dist/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.js +99 -0
- package/dist/extensions/Blocks/Recommendation/controls/main/algorithm.js +6 -6
- package/dist/extensions/Blocks/Recommendation/controls/main/index.js +3 -1
- package/dist/extensions/Blocks/Recommendation/controls/name/textTrim.js +27 -57
- package/dist/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.js +14 -0
- package/dist/extensions/Blocks/Recommendation/settingsPanel.js +18 -17
- package/dist/extensions/Blocks/Recommendation/store/recommendation.js +29 -25
- package/dist/extensions/Blocks/Recommendation/templates/list/template.js +11 -11
- package/dist/extensions/Blocks/Recommendation/utils/filterUtil.js +17 -14
- package/dist/extensions/Blocks/Unsubscribe/block.js +11 -11
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +393 -264
- package/dist/package.json.js +1 -1
- package/dist/src/composables/useActionsApi.d.ts +1 -1
- package/dist/src/composables/useFullStoryBridge.d.ts +6 -6
- package/dist/src/extensions/Blocks/Recommendation/constants/controlIds.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/index.d.ts +3 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/customAttribute/textTrim.d.ts +35 -0
- package/dist/src/extensions/Blocks/Recommendation/controls/name/textTrim.d.ts +3 -20
- package/dist/src/extensions/Blocks/Recommendation/controls/shared/textTrimCssRules.d.ts +29 -0
- package/dist/static/styles/components/button.css.js +16 -9
- package/dist/static/styles/components/loader.css.js +4 -0
- package/dist/static/styles/components/narrow-panel.css.js +52 -0
- package/dist/static/templates/empty/style.css.js +0 -1
- package/package.json +3 -3
|
@@ -89,11 +89,11 @@ const v = () => {
|
|
|
89
89
|
updateHtmlAndCss: (t, e) => {
|
|
90
90
|
window.StripoEditorApi.actionsApi.updateHtmlAndCss(t, e);
|
|
91
91
|
},
|
|
92
|
-
editorSave: () => {
|
|
93
|
-
window.StripoEditorApi.actionsApi.save((
|
|
94
|
-
|
|
92
|
+
editorSave: () => new Promise((t) => {
|
|
93
|
+
window.StripoEditorApi.actionsApi.save((e) => {
|
|
94
|
+
e && n(e, "Failed to save template"), t();
|
|
95
95
|
});
|
|
96
|
-
}
|
|
96
|
+
})
|
|
97
97
|
};
|
|
98
98
|
};
|
|
99
99
|
export {
|
|
@@ -1,34 +1,14 @@
|
|
|
1
|
-
const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const t = ((e, s, n) => {
|
|
6
|
-
if (t.q) {
|
|
7
|
-
t.q.push([e, s, n]);
|
|
8
|
-
return;
|
|
9
|
-
}
|
|
10
|
-
t._api(e, s, n);
|
|
11
|
-
});
|
|
12
|
-
return t.q = [], t.identify = (e, s, n) => {
|
|
13
|
-
t("user", { uid: e }, n), s && t("user", s, n);
|
|
14
|
-
}, t.setUserVars = (e, s) => t("user", e, s), t.event = (e, s, n) => t("event", { n: e, p: s }, n), t.anonymize = () => t.identify(!1), t.shutdown = () => t("rec", !1), t.restart = () => t("rec", !0), t.log = (e, s) => t("log", [e, s]), t.consent = (e) => t("consent", e ?? !0), t.identifyAccount = (e, s) => t("account", { ...s ?? {}, acctId: e }), t.clearUserCookie = () => {
|
|
15
|
-
}, t.setVars = (e, s) => t("setVars", [e, s]), t._w = { XMLHttpRequest: r.XMLHttpRequest, fetch: r.fetch }, t._v = "1.3.0", t;
|
|
16
|
-
}, F = () => ({ injectFullStory: async () => {
|
|
17
|
-
var d;
|
|
18
|
-
const t = f("_fs_org", "");
|
|
19
|
-
if (!t)
|
|
1
|
+
const c = "https://email-static.useinsider.com/guido/guido-fs.js", u = () => ({ injectFullStory: () => {
|
|
2
|
+
var n;
|
|
3
|
+
const s = window;
|
|
4
|
+
if (typeof s._fs_org != "string" || !s._fs_org)
|
|
20
5
|
return;
|
|
21
|
-
const
|
|
22
|
-
if (!
|
|
6
|
+
const r = document.querySelector("ui-editor"), o = (n = r == null ? void 0 : r.shadowRoot) == null ? void 0 : n.querySelector("iframe"), e = o == null ? void 0 : o.contentDocument;
|
|
7
|
+
if (!e || e.querySelector('script[data-fullstory-bridge="true"]'))
|
|
23
8
|
return;
|
|
24
|
-
const
|
|
25
|
-
|
|
26
|
-
return;
|
|
27
|
-
const a = window.fetch.bind(window), y = typeof n.fetch == "function" ? n.fetch.bind(n) : a, w = (o, p) => (typeof o == "string" || o instanceof URL ? String(o) : o.url).includes("fullstory.com") ? a(o, p) : y(o, p);
|
|
28
|
-
n.fetch = w, n._fs_run_in_iframe = !0, n._fs_host = h, n._fs_script = l, n._fs_org = t, n._fs_namespace = u, n[u] = m(n);
|
|
29
|
-
const g = await (await a(`https://${l}`)).text(), _ = URL.createObjectURL(new Blob([g], { type: "text/javascript" })), c = i.createElement("script");
|
|
30
|
-
c.src = _, c.crossOrigin = "anonymous", c.onload = () => URL.revokeObjectURL(_), i.head.appendChild(c);
|
|
9
|
+
const t = e.createElement("script");
|
|
10
|
+
t.src = c, t.async = !0, t.crossOrigin = "anonymous", t.dataset.fullstoryBridge = "true", e.head.appendChild(t);
|
|
31
11
|
} });
|
|
32
12
|
export {
|
|
33
|
-
|
|
13
|
+
u as useFullStoryBridge
|
|
34
14
|
};
|
|
@@ -19,7 +19,7 @@ const F = () => {
|
|
|
19
19
|
return;
|
|
20
20
|
if ((i = a.value) != null && i.externalValidation && !await a.value.externalValidation(t))
|
|
21
21
|
return;
|
|
22
|
-
c();
|
|
22
|
+
await c();
|
|
23
23
|
const { unsubscribePayload: f, stripoModules: v } = d(t.rawHtml);
|
|
24
24
|
return await u(f), t.modules = v, m || s(t), t;
|
|
25
25
|
} };
|
|
@@ -12,17 +12,17 @@ import L from "../static/styles/customEditorStyle.css.js";
|
|
|
12
12
|
import { useEditorStore as C } from "../stores/editor.js";
|
|
13
13
|
import { dynamicContentToMergeTags as $ } from "../utils/genericUtil.js";
|
|
14
14
|
import z from "../package.json.js";
|
|
15
|
-
const
|
|
16
|
-
const { features: c, template: h, isFeatureEnabled: u } = P(), { handleError: m } = x(), { getToken:
|
|
17
|
-
var g,
|
|
18
|
-
const e = C(), { html: p, css: a } = i, { baseBlocks: o, extensions: d } = await T(), f = ((g = c.value) == null ? void 0 : g.displayConditions) ?? !0,
|
|
15
|
+
const ae = (E, l) => {
|
|
16
|
+
const { features: c, template: h, isFeatureEnabled: u } = P(), { handleError: m } = x(), { getToken: w, getCustomFonts: b, getSyncModulesStatus: k } = j(), { handleEvent: B } = q(), { getStripoBlocksConfig: T } = I(), V = async (i, r = [], s = !1) => {
|
|
17
|
+
var g, S, y;
|
|
18
|
+
const e = C(), { html: p, css: a } = i, { baseBlocks: o, extensions: d } = await T(), f = ((g = c.value) == null ? void 0 : g.displayConditions) ?? !0, F = ((S = c.value) == null ? void 0 : S.modulesDisabled) ?? !1, v = ((y = h.value) == null ? void 0 : y.forceRecreate) ?? !1;
|
|
19
19
|
window.UIEditor.initEditor(
|
|
20
20
|
document.querySelector("#guido-editor"),
|
|
21
21
|
{
|
|
22
22
|
metadata: E,
|
|
23
23
|
html: p,
|
|
24
24
|
css: a,
|
|
25
|
-
forceRecreate:
|
|
25
|
+
forceRecreate: v,
|
|
26
26
|
locale: "en",
|
|
27
27
|
undoButtonSelector: "#guido__undo-button",
|
|
28
28
|
redoButtonSelector: "#guido__redo-button",
|
|
@@ -37,19 +37,20 @@ const se = (E, l) => {
|
|
|
37
37
|
customConditionsEnabled: f,
|
|
38
38
|
conditionCategories: O,
|
|
39
39
|
enableXSSSecurity: !0,
|
|
40
|
-
modulesDisabled:
|
|
41
|
-
syncModulesEnabled:
|
|
40
|
+
modulesDisabled: F,
|
|
41
|
+
syncModulesEnabled: s,
|
|
42
42
|
messageSettingsEnabled: !0,
|
|
43
43
|
displayGmailAnnotations: !0,
|
|
44
44
|
displayHiddenPreheader: !1,
|
|
45
45
|
displayTitle: !1,
|
|
46
46
|
displayUTM: !1,
|
|
47
47
|
selectElementAfterDrop: !0,
|
|
48
|
+
allowedScriptSourceDomains: "https://email-static.useinsider.com https://edge.fullstory.com https://rs.fullstory.com",
|
|
48
49
|
...o ? { baseBlocks: o } : {},
|
|
49
50
|
editorFonts: {
|
|
50
51
|
showDefaultStandardFonts: !0,
|
|
51
52
|
showDefaultNotStandardFonts: !0,
|
|
52
|
-
customFonts:
|
|
53
|
+
customFonts: r
|
|
53
54
|
},
|
|
54
55
|
mergeTags: [
|
|
55
56
|
{
|
|
@@ -61,16 +62,16 @@ const se = (E, l) => {
|
|
|
61
62
|
],
|
|
62
63
|
async onTokenRefreshRequest(t) {
|
|
63
64
|
try {
|
|
64
|
-
const
|
|
65
|
-
t(
|
|
66
|
-
} catch (
|
|
67
|
-
m(
|
|
65
|
+
const n = await w();
|
|
66
|
+
t(n);
|
|
67
|
+
} catch (n) {
|
|
68
|
+
m(n, "Failed to refresh token");
|
|
68
69
|
}
|
|
69
70
|
},
|
|
70
71
|
onTemplateLoaded() {
|
|
71
72
|
try {
|
|
72
|
-
const { importCss: t } = U(), { activateCustomViewStyles:
|
|
73
|
-
t(),
|
|
73
|
+
const { importCss: t } = U(), { activateCustomViewStyles: n, updateTimerInClonedTemplate: M } = D(), { injectFullStory: A } = R();
|
|
74
|
+
t(), n(), A(), M(), l.onReady(), e.isStripoInitialized = !0, e.loadingStatus = !1, setTimeout(() => {
|
|
74
75
|
e.hasChanges = !1;
|
|
75
76
|
}, 1e3);
|
|
76
77
|
} catch (t) {
|
|
@@ -99,29 +100,29 @@ const se = (E, l) => {
|
|
|
99
100
|
localePatch: H
|
|
100
101
|
}
|
|
101
102
|
);
|
|
102
|
-
}, _ = (i) => new Promise((
|
|
103
|
+
}, _ = (i) => new Promise((r, s) => {
|
|
103
104
|
var d;
|
|
104
105
|
if (document.getElementById("UiEditorScript")) {
|
|
105
|
-
i(),
|
|
106
|
+
i(), r();
|
|
106
107
|
return;
|
|
107
108
|
}
|
|
108
109
|
const e = z.guido, a = `https://email-static.useinsider.com/guido/${(d = e == null ? void 0 : e.stripo) == null ? void 0 : d.version}/UIEditor.js`, o = document.createElement("script");
|
|
109
110
|
o.id = "UiEditorScript", o.type = "module", o.src = a, o.onload = () => {
|
|
110
|
-
i(),
|
|
111
|
+
i(), r();
|
|
111
112
|
}, o.onerror = () => {
|
|
112
|
-
|
|
113
|
+
s(new Error(`Failed to load Stripo UIEditor script from S3: ${a}`));
|
|
113
114
|
}, document.body.appendChild(o);
|
|
114
115
|
});
|
|
115
116
|
return { initPlugin: async (i) => {
|
|
116
117
|
await _(async () => {
|
|
117
|
-
const
|
|
118
|
-
|
|
118
|
+
const r = C(), [s, e] = await Promise.all([
|
|
119
|
+
b(),
|
|
119
120
|
k()
|
|
120
121
|
]);
|
|
121
|
-
|
|
122
|
+
r.syncModulesEnabled = e, await V(i, s, e);
|
|
122
123
|
});
|
|
123
124
|
} };
|
|
124
125
|
};
|
|
125
126
|
export {
|
|
126
|
-
|
|
127
|
+
ae as useStripo
|
|
127
128
|
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { useRecommendation as
|
|
2
|
-
import { DUMMY_IMAGE_MAPPINGS as
|
|
1
|
+
import { useRecommendation as C } from "../../composables/useRecommendation.js";
|
|
2
|
+
import { DUMMY_IMAGE_MAPPINGS as h, REGEX as T, VerticalOrientation as M, CSS as E, ATTRIBUTES as A, CONDITIONS as g, HTML as N } from "../../enums/recommendation.js";
|
|
3
3
|
import { prepareRecommendationBlocks as x } from "./utils/recommendationCompilerUtils.js";
|
|
4
4
|
const w = [
|
|
5
5
|
{
|
|
6
6
|
id: "replace-images-with-variable-names",
|
|
7
7
|
description: "Replacing dummy images with variable names in recommendation module",
|
|
8
8
|
type: "custom",
|
|
9
|
-
processor: (
|
|
10
|
-
let e =
|
|
11
|
-
return Object.entries(
|
|
12
|
-
Object.entries(
|
|
13
|
-
e = e.replaceAll(
|
|
9
|
+
processor: (c) => {
|
|
10
|
+
let e = c;
|
|
11
|
+
return Object.entries(h).forEach(([, l]) => {
|
|
12
|
+
Object.entries(l).forEach(([n, s]) => {
|
|
13
|
+
e = e.replaceAll(s, `{{${n}}}`);
|
|
14
14
|
});
|
|
15
15
|
}), e;
|
|
16
16
|
},
|
|
@@ -29,21 +29,21 @@ const w = [
|
|
|
29
29
|
id: "add-recommendation-unresponsive-css",
|
|
30
30
|
description: "Adding recommendation unresponsive css",
|
|
31
31
|
type: "custom",
|
|
32
|
-
processor: (
|
|
33
|
-
const { calculateCardWidth: e, getRecommendationCampaignData:
|
|
34
|
-
let
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
32
|
+
processor: (c) => {
|
|
33
|
+
const { calculateCardWidth: e, getRecommendationCampaignData: l } = C();
|
|
34
|
+
let n = c;
|
|
35
|
+
const s = n.match(T.ID);
|
|
36
|
+
if (s) {
|
|
37
37
|
const a = [];
|
|
38
|
-
if (
|
|
39
|
-
const d = /recommendation-id="(.*?)"/i.exec(
|
|
40
|
-
|
|
38
|
+
if (s.forEach((i) => {
|
|
39
|
+
const d = /recommendation-id="(.*?)"/i.exec(i), _ = d ? d[1].trim() : "", R = l(_);
|
|
40
|
+
R.textTrimming && R.orientation === M && a.push(e(R));
|
|
41
41
|
}), a.length) {
|
|
42
|
-
const
|
|
43
|
-
|
|
42
|
+
const i = `width:${Math.min(...a)}px!important;`;
|
|
43
|
+
n = n.replace(E.REGULAR_NAME_HEIGHT, `${E.TRIMMED_NAME_HEIGHT} ${i} ${E.ELLIPSIS}`).replace(E.REGULAR_NAME_CONTAINER_HEIGHT, E.TRIMMED_NAME_CONTAINER_CSS).replace(E.RESPONSIVE_NAME_SIZE, `${E.RESPONSIVE_NAME_HEIGHT} ${i} ${E.ELLIPSIS}`).replace(E.RESPONSIVE_NAME_CONTAINER_HEIGHT, E.TRIMMED_RESPONSIVE_NAME_CONTAINER_CSS);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
return
|
|
46
|
+
return n;
|
|
47
47
|
},
|
|
48
48
|
priority: 52
|
|
49
49
|
},
|
|
@@ -51,34 +51,34 @@ const w = [
|
|
|
51
51
|
id: "prepare-recommendations",
|
|
52
52
|
description: "Replacing product data with template variables in recommendation blocks",
|
|
53
53
|
type: "custom",
|
|
54
|
-
processor: (
|
|
54
|
+
processor: (c) => x(c),
|
|
55
55
|
priority: 48
|
|
56
56
|
},
|
|
57
57
|
{
|
|
58
58
|
id: "add-discount-conditions",
|
|
59
59
|
description: "Adding discount conditions to the recommendation block",
|
|
60
60
|
type: "custom",
|
|
61
|
-
processor: (
|
|
62
|
-
let e =
|
|
63
|
-
const
|
|
64
|
-
return
|
|
65
|
-
const a =
|
|
61
|
+
processor: (c) => {
|
|
62
|
+
let e = c;
|
|
63
|
+
const l = e.match(T.ATTRIBUTE_PARAGRAPH), { getRecommendationCampaignData: n } = C();
|
|
64
|
+
return l !== null && l.forEach((s) => {
|
|
65
|
+
const a = s.match(T.CUSTOM_FIELD);
|
|
66
66
|
if (!a)
|
|
67
67
|
return;
|
|
68
|
-
const [
|
|
69
|
-
if (!d || !_ || !
|
|
68
|
+
const [i] = a, d = i.match(T.CUSTOM_FIELD_INDEXES_PART), _ = i.match(T.CUSTOM_FIELD_NAME_PART), R = s.match(T.ATTRIBUTE_PARAGRAPH_START_TAG);
|
|
69
|
+
if (!d || !_ || !R)
|
|
70
70
|
return;
|
|
71
|
-
const [
|
|
72
|
-
let t =
|
|
71
|
+
const [S] = d, [b] = _, [m] = R, o = b.substring(1, b.length - 2), r = m.match(T.COMPOSITION) !== null;
|
|
72
|
+
let t = i;
|
|
73
73
|
if (r) {
|
|
74
|
-
const
|
|
75
|
-
o ===
|
|
74
|
+
const I = S.substring(2, S.length - 3), p = n(I);
|
|
75
|
+
o === A.OMNIBUS_PRICE && (p.priceBeforeTextValue && (t = `${p.priceBeforeTextValue}${t}`), p.priceAfterTextValue && (t = `${t}${p.priceAfterTextValue}`)), o === A.OMNIBUS_DISCOUNT && (p.discountBeforeTextValue && (t = `${p.discountBeforeTextValue}${t}`), p.discountAfterTextValue && (t = `${t}${p.discountAfterTextValue}`));
|
|
76
76
|
}
|
|
77
|
-
const u =
|
|
77
|
+
const u = S.substring(2);
|
|
78
78
|
let f = "";
|
|
79
|
-
o in
|
|
80
|
-
const
|
|
81
|
-
e = e.replace(
|
|
79
|
+
o in g.IF && (f = g.IF[o].replaceAll(`{${A.DISCOUNT}}`, `${u}${A.DISCOUNT}`).replaceAll(`{${A.OMNIBUS_DISCOUNT}}`, `${u}${A.OMNIBUS_DISCOUNT}`).replaceAll(`{${A.OMNIBUS_PRICE}}`, `${u}${A.OMNIBUS_PRICE}`));
|
|
80
|
+
const $ = `${m}${t}${N.PARAGRAPH_END_TAG}`, y = `${f}${r ? $ : s}${g.ELSE}${m}${N.PARAGRAPH_END_TAG}${g.END_IF}`;
|
|
81
|
+
e = e.replace(s, y);
|
|
82
82
|
}), e;
|
|
83
83
|
},
|
|
84
84
|
priority: 53
|
|
@@ -95,19 +95,24 @@ const w = [
|
|
|
95
95
|
{
|
|
96
96
|
id: "strip-recommendation-editor-attributes",
|
|
97
97
|
description: "Strip editor-only attributes from compiled recommendation output",
|
|
98
|
-
type: "
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
98
|
+
type: "custom",
|
|
99
|
+
// Scoped to REC_START/REC_END markers so it cannot strip `product-attr`
|
|
100
|
+
// from Items block elements, which the items compiler rule depends on.
|
|
101
|
+
processor: (c) => {
|
|
102
|
+
const e = /\s+(?:esd-extension-block-id|data-attribute-type|data-visibility|data-text-before|data-text-after|product-attr|composition)="[^"]*"/g;
|
|
103
|
+
return c.replace(
|
|
104
|
+
/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
|
|
105
|
+
(l, n) => `<!--REC_START-->${n.replace(e, "")}<!--REC_END-->`
|
|
106
|
+
);
|
|
107
|
+
},
|
|
103
108
|
priority: 55
|
|
104
109
|
},
|
|
105
110
|
{
|
|
106
111
|
id: "strip-unused-recommendation-classes",
|
|
107
112
|
description: "Remove CSS classes not referenced by any style rule from recommendation elements",
|
|
108
113
|
type: "custom",
|
|
109
|
-
processor: (
|
|
110
|
-
let e =
|
|
114
|
+
processor: (c) => {
|
|
115
|
+
let e = c.replace(
|
|
111
116
|
/ class="(?:product-card-segment|attribute-cell|recommendation-attribute-row|product-image|product-name|product-price|product-old-price|product-omnibus-price|product-omnibus-discount|product-button|recommendation-product-row|product-card-wrapper)"/g,
|
|
112
117
|
""
|
|
113
118
|
);
|
|
@@ -119,8 +124,8 @@ const w = [
|
|
|
119
124
|
id: "remove-empty-mobile-layout-artifacts",
|
|
120
125
|
description: "Remove empty mobile container rows and unused mobile layout CSS",
|
|
121
126
|
type: "custom",
|
|
122
|
-
processor: (
|
|
123
|
-
let e =
|
|
127
|
+
processor: (c) => {
|
|
128
|
+
let e = c;
|
|
124
129
|
return e = e.replace(
|
|
125
130
|
/<tr[^>]*class="ins-recommendation-mobile-row"[^>]*><\/tr>/g,
|
|
126
131
|
""
|
|
@@ -129,9 +134,9 @@ const w = [
|
|
|
129
134
|
""
|
|
130
135
|
), e = e.replace(
|
|
131
136
|
/@media[^{]*max-width\s*:\s*480px[^{]*\{((?:[^{}]*\{[^{}]*\})*[^{}]*)\}/g,
|
|
132
|
-
(
|
|
133
|
-
const
|
|
134
|
-
return
|
|
137
|
+
(l, n) => {
|
|
138
|
+
const s = n.match(/[^{}]+\{[^{}]*\}/g) || [], a = /ins-recommendation|product-image-cell|button-cell|product-info-cell/;
|
|
139
|
+
return s.every((d) => a.test(d)) ? "" : l;
|
|
135
140
|
}
|
|
136
141
|
)), e;
|
|
137
142
|
},
|
|
@@ -141,38 +146,38 @@ const w = [
|
|
|
141
146
|
id: "deduplicate-inline-styles",
|
|
142
147
|
description: "Replace repeated inline styles with CSS class references within recommendation blocks",
|
|
143
148
|
type: "custom",
|
|
144
|
-
processor: (
|
|
145
|
-
const e =
|
|
149
|
+
processor: (c) => {
|
|
150
|
+
const e = c.replace(
|
|
146
151
|
/<a\b[^>]*\bes-button\b[^>]*>/g,
|
|
147
152
|
(o) => o.replace(
|
|
148
153
|
/([;"]color:)([^;"]+)/g,
|
|
149
154
|
(r, t, u) => u.includes("!important") ? r : `${t}${u} !important`
|
|
150
155
|
)
|
|
151
|
-
),
|
|
152
|
-
let a =
|
|
156
|
+
), l = /<!--REC_START-->([\s\S]*?)<!--REC_END-->/g, n = / style="([^"]*)"/g, s = /* @__PURE__ */ new Map();
|
|
157
|
+
let a = l.exec(e);
|
|
153
158
|
for (; a !== null; ) {
|
|
154
|
-
let o =
|
|
159
|
+
let o = n.exec(a[1]);
|
|
155
160
|
for (; o !== null; ) {
|
|
156
161
|
const [, r] = o;
|
|
157
|
-
|
|
162
|
+
s.set(r, (s.get(r) || 0) + 1), o = n.exec(a[1]);
|
|
158
163
|
}
|
|
159
|
-
|
|
164
|
+
n.lastIndex = 0, a = l.exec(e);
|
|
160
165
|
}
|
|
161
|
-
const
|
|
166
|
+
const i = /* @__PURE__ */ new Map(), d = [];
|
|
162
167
|
let _ = 0;
|
|
163
|
-
if (
|
|
168
|
+
if (s.forEach((o, r) => {
|
|
164
169
|
if (o >= 6) {
|
|
165
170
|
const t = `rc${_++}`;
|
|
166
|
-
|
|
171
|
+
i.set(r, t), d.push(`.${t}{${r}}`);
|
|
167
172
|
}
|
|
168
|
-
}),
|
|
173
|
+
}), i.size === 0) {
|
|
169
174
|
let o = e;
|
|
170
175
|
return o = o.replaceAll("<!--REC_START-->", ""), o = o.replaceAll("<!--REC_END-->", ""), o;
|
|
171
176
|
}
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
const t =
|
|
175
|
-
|
|
177
|
+
const R = (o) => o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), S = (o, r) => `${o.slice(0, -1)} ${r}"`, b = /* @__PURE__ */ new Map();
|
|
178
|
+
i.forEach((o, r) => {
|
|
179
|
+
const t = R(r);
|
|
180
|
+
b.set(r, {
|
|
176
181
|
caseA: new RegExp(`(class="[^"]*")((?:[^>]*?)) style="${t}"`, "g"),
|
|
177
182
|
caseB: new RegExp(` style="${t}"((?:[^>]*?))(class="[^"]*")`, "g")
|
|
178
183
|
});
|
|
@@ -182,14 +187,14 @@ const w = [
|
|
|
182
187
|
/<!--REC_START-->([\s\S]*?)<!--REC_END-->/g,
|
|
183
188
|
(o, r) => {
|
|
184
189
|
let t = r;
|
|
185
|
-
return
|
|
186
|
-
const
|
|
190
|
+
return i.forEach((u, f) => {
|
|
191
|
+
const $ = b.get(f);
|
|
187
192
|
t = t.replace(
|
|
188
|
-
|
|
189
|
-
(y,
|
|
193
|
+
$.caseA,
|
|
194
|
+
(y, I, p) => S(I, u) + p
|
|
190
195
|
), t = t.replace(
|
|
191
|
-
|
|
192
|
-
(y,
|
|
196
|
+
$.caseB,
|
|
197
|
+
(y, I, p) => I + S(p, u)
|
|
193
198
|
), t = t.replaceAll(` style="${f}"`, ` class="${u}"`);
|
|
194
199
|
}), t;
|
|
195
200
|
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { useConfig as S } from "../../../composables/useConfig.js";
|
|
2
2
|
import { useRecommendation as _ } from "../../../composables/useRecommendation.js";
|
|
3
|
+
import { useRecommendationExtensionStore as d } from "../../../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
3
4
|
function y(e, u, r, o, s = "") {
|
|
4
5
|
const n = `{{${s}${e}_${u}_${r}}}`, t = `{{${s}${e}_${u}_currency}}`;
|
|
5
6
|
return o === "before" ? `${t} ${n}` : `${n} ${t}`;
|
|
6
7
|
}
|
|
7
|
-
function
|
|
8
|
+
function m(e, u, r, o, s, n) {
|
|
8
9
|
switch (u) {
|
|
9
10
|
case "productImage": {
|
|
10
11
|
const t = e.querySelector("img");
|
|
@@ -69,67 +70,69 @@ function p(e, u, r, o, s, n) {
|
|
|
69
70
|
default: {
|
|
70
71
|
const t = e.getAttribute("product-attr") ? e : e.querySelector("[product-attr]");
|
|
71
72
|
if (t) {
|
|
72
|
-
const c = t.getAttribute("product-attr"),
|
|
73
|
-
if (
|
|
74
|
-
const
|
|
75
|
-
|
|
73
|
+
const c = t.getAttribute("product-attr"), a = t.querySelector("p");
|
|
74
|
+
if (a) {
|
|
75
|
+
const i = a.querySelector("strong") || a;
|
|
76
|
+
i.textContent = `{{${n}${r}_${o}_${c}}}`;
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
break;
|
|
79
80
|
}
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
|
-
function
|
|
83
|
+
function q(e, u, r, o) {
|
|
83
84
|
e.querySelectorAll(".recommendation-product-row").forEach((n, t) => {
|
|
84
|
-
n.querySelectorAll("[data-attribute-type]").forEach((
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
p
|
|
88
|
-
}) :
|
|
85
|
+
n.querySelectorAll("[data-attribute-type]").forEach((a) => {
|
|
86
|
+
const i = a.getAttribute("data-attribute-type") || "", l = a.querySelectorAll(".attribute-cell");
|
|
87
|
+
l.length > 0 ? l.forEach((p) => {
|
|
88
|
+
m(p, i, u, t, r, o);
|
|
89
|
+
}) : m(a, i, u, t, r, o);
|
|
89
90
|
});
|
|
90
91
|
});
|
|
91
92
|
}
|
|
92
|
-
function
|
|
93
|
+
function g(e, u, r, o) {
|
|
93
94
|
const s = e.querySelectorAll(".recommendation-product-row");
|
|
94
95
|
if (!s.length)
|
|
95
96
|
return;
|
|
96
97
|
const [n] = s, t = n.querySelector("[data-attribute-type]"), c = t ? t.querySelectorAll(".attribute-cell").length : 1;
|
|
97
|
-
s.forEach((
|
|
98
|
-
|
|
99
|
-
const
|
|
100
|
-
|
|
101
|
-
const A =
|
|
102
|
-
|
|
98
|
+
s.forEach((a, i) => {
|
|
99
|
+
a.querySelectorAll("[data-attribute-type]").forEach((p) => {
|
|
100
|
+
const b = p.getAttribute("data-attribute-type") || "";
|
|
101
|
+
p.querySelectorAll(".attribute-cell").forEach((f, $) => {
|
|
102
|
+
const A = i * c + $;
|
|
103
|
+
m(f, b, u, A, r, o);
|
|
103
104
|
});
|
|
104
105
|
});
|
|
105
106
|
});
|
|
106
107
|
}
|
|
107
|
-
function
|
|
108
|
+
function h(e, u, r, o) {
|
|
108
109
|
e.querySelectorAll(".ins-recommendation-product-container").forEach((n) => {
|
|
109
|
-
|
|
110
|
+
g(n, u, r, o);
|
|
110
111
|
});
|
|
111
112
|
}
|
|
112
|
-
function
|
|
113
|
+
function C(e, u, r) {
|
|
113
114
|
const o = e.getAttribute("data-layout") || "grid", s = e.getAttribute("currency-alignment") || "after";
|
|
114
|
-
o === "list" ?
|
|
115
|
+
o === "list" ? q(e, u, s, r) : h(e, u, s, r);
|
|
115
116
|
}
|
|
116
|
-
function
|
|
117
|
+
function E(e, u) {
|
|
117
118
|
const r = e.match(/<!DOCTYPE[^>]*>/i);
|
|
118
119
|
return (r ? `${r[0]}
|
|
119
120
|
` : "") + u.documentElement.outerHTML;
|
|
120
121
|
}
|
|
121
|
-
function
|
|
122
|
+
function T(e) {
|
|
122
123
|
const u = e.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->"), r = new DOMParser().parseFromString(u, "text/html"), o = r.querySelectorAll(".recommendation-block-v2");
|
|
123
124
|
if (!o.length)
|
|
124
125
|
return e;
|
|
125
|
-
const { buildCampaignUrl: s } = _(),
|
|
126
|
+
const { buildCampaignUrl: s } = _(), n = d();
|
|
127
|
+
n.recommendationCampaignUrls = {};
|
|
128
|
+
const { isFeatureEnabled: t } = S(), c = t("liquidSyntax") ? "reco_" : "";
|
|
126
129
|
return o.forEach((i) => {
|
|
127
|
-
var
|
|
128
|
-
const
|
|
129
|
-
|
|
130
|
-
}),
|
|
130
|
+
var p, b;
|
|
131
|
+
const l = i.getAttribute("recommendation-id");
|
|
132
|
+
l && ((p = i.parentNode) == null || p.insertBefore(r.createComment("REC_START"), i), (b = i.parentNode) == null || b.insertBefore(r.createComment("REC_END"), i.nextSibling), s(l), C(i, l, c));
|
|
133
|
+
}), E(u, r).replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
131
134
|
}
|
|
132
135
|
export {
|
|
133
136
|
y as formatPriceVariable,
|
|
134
|
-
|
|
137
|
+
T as prepareRecommendationBlocks
|
|
135
138
|
};
|
|
@@ -13,7 +13,7 @@ class B {
|
|
|
13
13
|
migrate(e) {
|
|
14
14
|
try {
|
|
15
15
|
const t = this.parser.parseFromString(e, "text/html"), s = t.querySelectorAll(
|
|
16
|
-
'td.ins-recommendation-v3-block-1, td.product-block[esd-handler-name*="EmailRecommendationV3"]'
|
|
16
|
+
'td.ins-recommendation-v3-block-1:not(.recommendation-block-v2), td.product-block[esd-handler-name*="EmailRecommendationV3"]:not(.recommendation-block-v2)'
|
|
17
17
|
);
|
|
18
18
|
return w().$patch((i) => {
|
|
19
19
|
i.migrations = { ...i.migrations, [S]: s.length };
|