@useinsider/guido 3.7.0-beta.a6317a3 → 3.7.0-beta.b0ed94d
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/useHtmlValidator.js +98 -104
- package/dist/enums/html-validator.js +5 -13
- package/dist/extensions/Blocks/Items/block.js +48 -29
- package/dist/extensions/Blocks/Items/utils/nodeConfigUtils.js +62 -45
- package/dist/src/enums/html-validator.d.ts +0 -3
- package/dist/src/extensions/Blocks/Items/block.d.ts +8 -0
- package/dist/src/extensions/Blocks/Items/utils/nodeConfigUtils.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,172 +1,166 @@
|
|
|
1
|
-
import { useConfig as
|
|
2
|
-
import { TemplateTypes as
|
|
3
|
-
import { DISPLAY_CONDITIONS_REGEX as
|
|
1
|
+
import { useConfig as _ } from "./useConfig.js";
|
|
2
|
+
import { TemplateTypes as H } from "../enums/defaults.js";
|
|
3
|
+
import { DISPLAY_CONDITIONS_REGEX as P, DISPLAY_CONDITIONS_EXCEPTIONS_REGEX as G, CampaignCouldNotBeSavedKey as M, CanNotMakeAnyChangesForRunningKey as $ } from "../enums/html-validator.js";
|
|
4
4
|
import { ToasterTypeOptions as c } from "../enums/toaster.js";
|
|
5
|
-
import { itemsBlockDynamicVariables as
|
|
6
|
-
import { useRecommendationExtensionStore as
|
|
7
|
-
import { RecommendationRequiredFieldsKey as
|
|
8
|
-
import { useRecommendationStore as
|
|
9
|
-
import { base64EncodeWithSpecialChars as
|
|
10
|
-
import { useHttp as
|
|
11
|
-
import { useToaster as
|
|
12
|
-
import { useTranslations as
|
|
13
|
-
const
|
|
14
|
-
function
|
|
15
|
-
return [...
|
|
5
|
+
import { itemsBlockDynamicVariables as q } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
6
|
+
import { useRecommendationExtensionStore as X } from "../extensions/Blocks/Recommendation/store/recommendation.js";
|
|
7
|
+
import { RecommendationRequiredFieldsKey as j } from "../extensions/Blocks/Recommendation/validation/requiredFields.js";
|
|
8
|
+
import { useRecommendationStore as K } from "../stores/recommendation.js";
|
|
9
|
+
import { base64EncodeWithSpecialChars as z } from "../utils/base64.js";
|
|
10
|
+
import { useHttp as U } from "./useHttp.js";
|
|
11
|
+
import { useToaster as Y } from "./useToaster.js";
|
|
12
|
+
import { useTranslations as Z } from "./useTranslations.js";
|
|
13
|
+
const J = /recommendation-id="(\d+)"/g;
|
|
14
|
+
function Q(a) {
|
|
15
|
+
return [...a.matchAll(J)].map((u) => u[1]);
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
return
|
|
17
|
+
function ee(a, u) {
|
|
18
|
+
return u.some((d) => a.startsWith(`${d}_`));
|
|
19
19
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
const ve = () => {
|
|
27
|
-
var h, v;
|
|
28
|
-
const { showToaster: o } = Q(), { post: d } = J(), { config: f } = V(), i = ee(), u = U(), g = j(), y = ((v = (h = f.value) == null ? void 0 : h.partner) == null ? void 0 : v.messageType) === M.transactional, A = async (e) => {
|
|
29
|
-
const t = await d(
|
|
20
|
+
const ge = () => {
|
|
21
|
+
var y, h;
|
|
22
|
+
const { showToaster: a } = Y(), { post: u } = U(), { config: d } = _(), r = Z(), g = K(), S = X(), p = ((h = (y = d.value) == null ? void 0 : y.partner) == null ? void 0 : h.messageType) === H.transactional, b = async (e) => {
|
|
23
|
+
const t = await u(
|
|
30
24
|
"/newsletter/template-library/check-template-html-body",
|
|
31
|
-
{ html:
|
|
25
|
+
{ html: z(e) }
|
|
32
26
|
), { status: n, message: l } = t.data;
|
|
33
|
-
return n ||
|
|
27
|
+
return n || a({
|
|
34
28
|
type: c.Alert,
|
|
35
|
-
message: n === void 0 ? l :
|
|
36
|
-
}),
|
|
29
|
+
message: n === void 0 ? l : r("newsletter.invalid-url-link-for-toaster")
|
|
30
|
+
}), r(M), l === r($) && a({
|
|
37
31
|
type: c.Alert,
|
|
38
|
-
message:
|
|
32
|
+
message: r("newsletter.already-in-progress")
|
|
39
33
|
}), n;
|
|
40
|
-
},
|
|
34
|
+
}, w = (e) => !["if", "endif", "else", "elif", "now"].includes(e.toLowerCase()), E = (e) => ["if", "endif"].includes(e.toLowerCase()), A = (e, s) => {
|
|
41
35
|
const t = e.match(/({%(.*?)%})/g);
|
|
42
36
|
let n = !0;
|
|
43
|
-
return t !== null && !
|
|
44
|
-
const
|
|
45
|
-
if (
|
|
46
|
-
const [
|
|
47
|
-
|
|
37
|
+
return t !== null && !p && t.forEach((l) => {
|
|
38
|
+
const o = l.slice(2, -2).trim().match(/(".*?"|[^"\s]+)(?=\s*|\s*$)/g);
|
|
39
|
+
if (o && o.length > 0) {
|
|
40
|
+
const [i] = o;
|
|
41
|
+
w(i) && !s.includes(i) && (a({
|
|
48
42
|
type: c.Warning,
|
|
49
|
-
message:
|
|
43
|
+
message: r("custom-fields.invalid-custom-fields")
|
|
50
44
|
}), n = !1);
|
|
51
45
|
}
|
|
52
46
|
}), n;
|
|
53
|
-
},
|
|
54
|
-
const n = t ? await
|
|
55
|
-
return
|
|
56
|
-
}, x = (e) => e.length > 0 ? !0 : (
|
|
47
|
+
}, k = async (e, s, t) => {
|
|
48
|
+
const n = t ? await b(e) : !0;
|
|
49
|
+
return A(e, s) && n;
|
|
50
|
+
}, x = (e) => e.length > 0 ? !0 : (a({
|
|
57
51
|
type: c.Warning,
|
|
58
|
-
message:
|
|
59
|
-
}), !1),
|
|
52
|
+
message: r("newsletter.html-content-is-empty")
|
|
53
|
+
}), !1), I = (e) => {
|
|
60
54
|
const s = (e.match(/{/gm) || []).length, t = (e.match(/}/gm) || []).length;
|
|
61
|
-
return s > t &&
|
|
55
|
+
return s > t && a({
|
|
62
56
|
type: c.Warning,
|
|
63
|
-
message:
|
|
64
|
-
}), s < t &&
|
|
57
|
+
message: r("custom-fields.missing-closing-braces")
|
|
58
|
+
}), s < t && a({
|
|
65
59
|
type: c.Warning,
|
|
66
|
-
message:
|
|
60
|
+
message: r("custom-fields.missing-opening-braces")
|
|
67
61
|
}), s === t;
|
|
68
|
-
},
|
|
69
|
-
const s =
|
|
70
|
-
return s ||
|
|
62
|
+
}, F = (e) => {
|
|
63
|
+
const s = e.match(/{{\s*(\w+\s+((\w+\|\w+)|(\w+)))\s*}}/gm) === null;
|
|
64
|
+
return s || a({
|
|
71
65
|
type: c.Warning,
|
|
72
|
-
message:
|
|
66
|
+
message: r("custom-fields.invalid-custom-fields")
|
|
73
67
|
}), s;
|
|
74
|
-
},
|
|
68
|
+
}, T = (e, s) => {
|
|
75
69
|
const t = e.match(/{{([a-zA-Z0-9_\s]*)}}/gm);
|
|
76
|
-
if (t && !
|
|
77
|
-
const n = new Set(s.map((
|
|
78
|
-
if (t.forEach((
|
|
79
|
-
const m =
|
|
80
|
-
(!n.has(m) || m === "") && !
|
|
81
|
-
}),
|
|
82
|
-
const
|
|
70
|
+
if (t && !p) {
|
|
71
|
+
const n = new Set(s.map((i) => i.toLowerCase())), l = Q(e), o = [];
|
|
72
|
+
if (t.forEach((i) => {
|
|
73
|
+
const m = i.slice(2, -2).trim().toLowerCase();
|
|
74
|
+
(!n.has(m) || m === "") && !ee(m, l) && o.push(m);
|
|
75
|
+
}), o.length > 0) {
|
|
76
|
+
const i = `
|
|
83
77
|
<ul>
|
|
84
|
-
${
|
|
78
|
+
${o.map((m) => `<li>${m}</li>`).join("")}
|
|
85
79
|
</ul>
|
|
86
80
|
`;
|
|
87
|
-
return
|
|
81
|
+
return a({
|
|
88
82
|
type: c.Alert,
|
|
89
|
-
message:
|
|
83
|
+
message: r("custom-fields.invalid-custom-fields") + i
|
|
90
84
|
}), !1;
|
|
91
85
|
}
|
|
92
86
|
}
|
|
93
87
|
return !0;
|
|
94
|
-
},
|
|
88
|
+
}, R = (e) => {
|
|
95
89
|
const s = e.match(/{%(.*?)%}/g), t = [];
|
|
96
90
|
let n = !0;
|
|
97
91
|
if (s && s.forEach((l) => {
|
|
98
|
-
const
|
|
99
|
-
(!
|
|
92
|
+
const o = l.match(P), i = l.match(G), m = (o == null ? void 0 : o.join("")) || "";
|
|
93
|
+
(!o || l !== m) && !i && (a({
|
|
100
94
|
type: c.Alert,
|
|
101
|
-
message:
|
|
102
|
-
}), n = !1),
|
|
103
|
-
|
|
95
|
+
message: r("newsletter.display-conditions-invalid-syntax")
|
|
96
|
+
}), n = !1), o && o.forEach((f) => {
|
|
97
|
+
f.trim() === "=" && (a({
|
|
104
98
|
type: c.Alert,
|
|
105
|
-
message:
|
|
99
|
+
message: r("custom-conditions.wrong-equality-operators")
|
|
106
100
|
}), n = !1);
|
|
107
|
-
const
|
|
108
|
-
|
|
109
|
-
|
|
101
|
+
const v = f.match(/^[a-zA-Z]*$/g);
|
|
102
|
+
v && v.forEach((C) => {
|
|
103
|
+
E(C) && t.push(C);
|
|
110
104
|
});
|
|
111
105
|
});
|
|
112
106
|
}), t.length) {
|
|
113
|
-
const l = t.filter((
|
|
114
|
-
l.length !==
|
|
107
|
+
const l = t.filter((i) => i === "if"), o = t.filter((i) => i === "endif");
|
|
108
|
+
l.length !== o.length && (a({
|
|
115
109
|
type: c.Alert,
|
|
116
|
-
message:
|
|
110
|
+
message: r("custom-conditions.missing-if-endif-tag")
|
|
117
111
|
}), n = !1);
|
|
118
112
|
}
|
|
119
113
|
return n;
|
|
120
|
-
},
|
|
114
|
+
}, B = (e) => {
|
|
121
115
|
const s = (e.match(/{% /gm) || []).length, t = (e.match(/ %}/gm) || []).length, n = s === t;
|
|
122
|
-
return n ||
|
|
116
|
+
return n || a({
|
|
123
117
|
type: c.Warning,
|
|
124
|
-
message:
|
|
118
|
+
message: r("custom-conditions.no-space-after-braces")
|
|
125
119
|
}), n;
|
|
126
|
-
},
|
|
120
|
+
}, W = (e) => (e.match(/({%(.*?)%})/g) || []).filter((t) => t.includes("if")).map((t) => (t.match(/{{.*}}/gm) || []).length).reduce((t, n) => t + n, 0) > 0 ? (a({
|
|
127
121
|
type: c.Warning,
|
|
128
|
-
message:
|
|
129
|
-
}), !1) : !0,
|
|
122
|
+
message: r("custom-conditions.no-braces-inside-if-tag")
|
|
123
|
+
}), !1) : !0, N = () => S.hasInvalidBlock() ? (a({
|
|
130
124
|
type: c.Alert,
|
|
131
|
-
message:
|
|
132
|
-
}), !1) : !0, O = () =>
|
|
125
|
+
message: r(j)
|
|
126
|
+
}), !1) : !0, O = () => g.recommendationConfigs && Object.values(g.recommendationConfigs).find((s) => s.filters.find((t) => t.value === "")) !== void 0 ? (a({
|
|
133
127
|
type: c.Alert,
|
|
134
|
-
message:
|
|
135
|
-
}), !1) : !0,
|
|
128
|
+
message: r("newsletter.fill-all-necessary-fields")
|
|
129
|
+
}), !1) : !0, D = (e) => {
|
|
136
130
|
const s = /src="[^"]*\.(svg|pst)"/gm;
|
|
137
|
-
return e.match(s) === null ? !0 : (
|
|
131
|
+
return e.match(s) === null ? !0 : (a({
|
|
138
132
|
type: c.Alert,
|
|
139
|
-
message:
|
|
133
|
+
message: r("newsletter.invalid-image-type")
|
|
140
134
|
}), !1);
|
|
141
135
|
}, L = (e) => {
|
|
142
136
|
const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".checkbox-block-v2");
|
|
143
|
-
return Array.from(n).find((
|
|
144
|
-
var
|
|
145
|
-
return !((
|
|
146
|
-
}) ? (
|
|
137
|
+
return Array.from(n).find((o) => {
|
|
138
|
+
var i;
|
|
139
|
+
return !((i = o.id) != null && i.trim());
|
|
140
|
+
}) ? (a({
|
|
147
141
|
type: c.Alert,
|
|
148
|
-
message:
|
|
142
|
+
message: r("unsubscribe-templates.select-checkbox-groups")
|
|
149
143
|
}), !1) : !0;
|
|
150
|
-
},
|
|
144
|
+
}, V = (e) => {
|
|
151
145
|
const n = new DOMParser().parseFromString(e, "text/html").querySelectorAll(".radio-button-v2");
|
|
152
|
-
return Array.from(n).find((
|
|
153
|
-
var
|
|
154
|
-
return !((
|
|
155
|
-
}) ? (
|
|
146
|
+
return Array.from(n).find((o) => {
|
|
147
|
+
var i;
|
|
148
|
+
return !((i = o.id) != null && i.trim());
|
|
149
|
+
}) ? (a({
|
|
156
150
|
type: c.Alert,
|
|
157
|
-
message:
|
|
151
|
+
message: r("unsubscribe-templates.select-radio-button-groups")
|
|
158
152
|
}), !1) : !0;
|
|
159
153
|
};
|
|
160
154
|
return { validateHtml: async (e, s, t = !1) => {
|
|
161
|
-
var
|
|
155
|
+
var o, i;
|
|
162
156
|
const n = [
|
|
163
157
|
...s.map((m) => m.value),
|
|
164
|
-
...
|
|
165
|
-
...((
|
|
158
|
+
...q,
|
|
159
|
+
...((i = (o = d.value) == null ? void 0 : o.template) == null ? void 0 : i.customFieldAttributes) ?? []
|
|
166
160
|
];
|
|
167
|
-
return await
|
|
161
|
+
return await k(e, n, t) && x(e) && I(e) && F(e) && T(e, n) && R(e) && B(e) && W(e) && N() && O() && D(e) && L(e) && V(e);
|
|
168
162
|
} };
|
|
169
163
|
};
|
|
170
164
|
export {
|
|
171
|
-
|
|
165
|
+
ge as useHtmlValidator
|
|
172
166
|
};
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
const
|
|
2
|
-
"ins-unsubscribe-link",
|
|
3
|
-
"ins-global-unsubscribe-link",
|
|
4
|
-
"ins-preferences-unsubscribe-link",
|
|
5
|
-
"@COUPON_CODE"
|
|
6
|
-
];
|
|
1
|
+
const e = "newsletter.already-in-progress", n = "newsletter.campaign-could-not-be-saved", o = / (==|<=|>=|!=|>|<|in) | (if|elif|endif|else|and|or) |("[\S ]+")|('[\S ]+')|([^”\s\n]+)|(({%)|( %}))/gm, a = /{%( )*now( )(".*")( )*%}/gm;
|
|
7
2
|
export {
|
|
8
|
-
|
|
9
|
-
e as
|
|
10
|
-
|
|
11
|
-
o as
|
|
12
|
-
s as DISPLAY_CONDITIONS_REGEX,
|
|
13
|
-
i as DYNAMIC_CONTENT_TAG_REGEX,
|
|
14
|
-
E as VALID_DYNAMIC_VARIABLE_REGEX
|
|
3
|
+
n as CampaignCouldNotBeSavedKey,
|
|
4
|
+
e as CanNotMakeAnyChangesForRunningKey,
|
|
5
|
+
a as DISPLAY_CONDITIONS_EXCEPTIONS_REGEX,
|
|
6
|
+
o as DISPLAY_CONDITIONS_REGEX
|
|
15
7
|
};
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { BlockId as
|
|
1
|
+
import { BlockId as u } from "../../../enums/block.js";
|
|
2
2
|
import { useOnboardingStore as p } from "../../../stores/onboarding.js";
|
|
3
|
-
import { getMigrationBannerHtml as
|
|
4
|
-
import { Block as
|
|
5
|
-
import { SETTINGS_ENUMS as
|
|
6
|
-
import { getDefaultTemplate as
|
|
7
|
-
import { getItemsBlockContainer as
|
|
8
|
-
const
|
|
9
|
-
class E extends
|
|
3
|
+
import { getMigrationBannerHtml as C } from "../../../utils/migrationBannerHtml.js";
|
|
4
|
+
import { Block as I, BlockCompositionType as y, ModificationDescription as s } from "../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
5
|
+
import { SETTINGS_ENUMS as c, DefaultConfigValues as a } from "./enums/settingsEnums.js";
|
|
6
|
+
import { getDefaultTemplate as h } from "./template.js";
|
|
7
|
+
import { getItemsBlockContainer as l, getItemsBlockConfig as m, getDefaultItemsBlockConfig as b } from "./utils/nodeConfigUtils.js";
|
|
8
|
+
const d = u.Items;
|
|
9
|
+
class E extends I {
|
|
10
10
|
getId() {
|
|
11
|
-
return
|
|
11
|
+
return d;
|
|
12
12
|
}
|
|
13
13
|
getIcon() {
|
|
14
14
|
return "items-icon";
|
|
15
15
|
}
|
|
16
16
|
getBlockCompositionType() {
|
|
17
|
-
return
|
|
17
|
+
return y.CONTAINER;
|
|
18
18
|
}
|
|
19
19
|
getName() {
|
|
20
20
|
return this.api.translate("Items");
|
|
@@ -23,41 +23,60 @@ class E extends u {
|
|
|
23
23
|
return this.api.translate("Items lets you display personalized products based on user behavior.");
|
|
24
24
|
}
|
|
25
25
|
getSettingsPanelTitleHtml() {
|
|
26
|
-
return
|
|
27
|
-
|
|
26
|
+
return C(
|
|
27
|
+
d,
|
|
28
28
|
this.api.translate("Items"),
|
|
29
29
|
this.api.translate("This block is switched from the Old Version to the New Version. We recommend you check the Items block and test your message to ensure it works properly.")
|
|
30
30
|
);
|
|
31
31
|
}
|
|
32
32
|
getTemplate() {
|
|
33
|
-
return
|
|
34
|
-
orientation:
|
|
35
|
-
itemsType:
|
|
33
|
+
return h({
|
|
34
|
+
orientation: c.ORIENTATION.VERTICAL,
|
|
35
|
+
itemsType: c.ITEMS_TYPE.CART_ITEMS,
|
|
36
36
|
itemId: "{{Abandoned Cart Item (1) Url}}",
|
|
37
|
-
currencySymbol:
|
|
38
|
-
currencyLocation:
|
|
39
|
-
formattedPrice:
|
|
37
|
+
currencySymbol: a.productPriceCurrencySymbolControlValue,
|
|
38
|
+
currencyLocation: a.productPriceCurrencyLocationControlValue,
|
|
39
|
+
formattedPrice: a.productPriceFormattedControlValue === "1"
|
|
40
40
|
});
|
|
41
41
|
}
|
|
42
42
|
allowInnerBlocksDND() {
|
|
43
43
|
return !1;
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
canBeSavedAsModule() {
|
|
46
|
+
return !0;
|
|
47
|
+
}
|
|
48
|
+
onCreated(i) {
|
|
49
|
+
const n = this.api.getDocumentModifier(), r = this.api.getDocumentRootCssNode();
|
|
50
|
+
r.querySelector('[product-attr="imageSrc"] img') || n.modifyCss(r).appendRule('[product-attr="imageSrc"] img {object-fit: contain;}');
|
|
51
|
+
const t = l(i);
|
|
52
|
+
if (!t)
|
|
50
53
|
return;
|
|
51
|
-
const
|
|
52
|
-
if (
|
|
53
|
-
|
|
54
|
+
const e = t.getNodeConfig(), g = e && Object.keys(e).length > 0, o = m(i);
|
|
55
|
+
if (o != null && o.initialized)
|
|
56
|
+
g ? o.blockInstanceId || this.api.getDocumentModifier().modifyHtml(t).setNodeConfig({ ...o, blockInstanceId: String(Date.now()) }).apply(new s("Assign block instance ID to block")) : this.api.getDocumentModifier().modifyHtml(t).setNodeConfig(o).apply(new s("Migrate legacy config to nodeConfig"));
|
|
54
57
|
else {
|
|
55
|
-
const
|
|
56
|
-
this.api.getDocumentModifier().modifyHtml(
|
|
58
|
+
const f = b();
|
|
59
|
+
this.api.getDocumentModifier().modifyHtml(t).setNodeConfig(f).apply(new s("Initialize Items block with default configuration")), p().startOnboarding("itemsOnboarding");
|
|
57
60
|
}
|
|
58
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
|
|
64
|
+
* surfaces via document load. Stripo strips esd-ext-config and never restores it
|
|
65
|
+
* into nodeConfig, so without this a reused module would reset to defaults.
|
|
66
|
+
* Guarded to the nodeConfig-empty case so it runs once and never loops.
|
|
67
|
+
*/
|
|
68
|
+
onDocumentChanged(i) {
|
|
69
|
+
const n = l(i);
|
|
70
|
+
if (!n)
|
|
71
|
+
return;
|
|
72
|
+
const r = n.getNodeConfig();
|
|
73
|
+
if (r && Object.keys(r).length > 0)
|
|
74
|
+
return;
|
|
75
|
+
const e = m(i);
|
|
76
|
+
e != null && e.initialized && this.api.getDocumentModifier().modifyHtml(n).setNodeConfig(e).apply(new s("Recover Items block config from saved module"));
|
|
77
|
+
}
|
|
59
78
|
}
|
|
60
79
|
export {
|
|
61
|
-
|
|
80
|
+
d as BLOCK_ID,
|
|
62
81
|
E as ItemsBlock
|
|
63
82
|
};
|
|
@@ -1,36 +1,36 @@
|
|
|
1
1
|
import { ModificationDescription as b } from "../../../../node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js";
|
|
2
|
-
import { DefaultConfigValues as
|
|
2
|
+
import { DefaultConfigValues as i, SETTINGS_ENUMS as n, ItemInCartOptions as g } from "../enums/settingsEnums.js";
|
|
3
3
|
function _() {
|
|
4
4
|
return String(Date.now() + Math.floor(Math.random() * 1e3));
|
|
5
5
|
}
|
|
6
6
|
const E = (r) => r.replace(/\$/g, "$$$$");
|
|
7
|
-
function
|
|
7
|
+
function y() {
|
|
8
8
|
return {
|
|
9
9
|
initialized: !0,
|
|
10
10
|
blockInstanceId: _(),
|
|
11
11
|
source: n.ITEMS_TYPE.CART_ITEMS,
|
|
12
12
|
type: n.ITEMS_TYPE.CART_ITEMS,
|
|
13
|
-
itemsSelectValue:
|
|
13
|
+
itemsSelectValue: i.cartItemsSelectControlValue,
|
|
14
14
|
orientation: n.ORIENTATION.VERTICAL,
|
|
15
|
-
nameTrimming:
|
|
16
|
-
priceHideDiscount:
|
|
17
|
-
priceFormatted:
|
|
15
|
+
nameTrimming: i.productNameTrimmingControlValue === "1",
|
|
16
|
+
priceHideDiscount: i.productPriceHideDiscountControlValue === "1",
|
|
17
|
+
priceFormatted: i.productPriceFormattedControlValue === "1",
|
|
18
18
|
priceSinglePrice: !1,
|
|
19
|
-
priceCurrencySymbol:
|
|
20
|
-
priceCurrencyLocation:
|
|
19
|
+
priceCurrencySymbol: i.productPriceCurrencySymbolControlValue,
|
|
20
|
+
priceCurrencyLocation: i.productPriceCurrencyLocationControlValue,
|
|
21
21
|
priceOrientation: "horizontal",
|
|
22
|
-
quantityControlEnabled:
|
|
23
|
-
buttonLink:
|
|
24
|
-
imageLink:
|
|
22
|
+
quantityControlEnabled: i.productQuantityControlEnabled === "1",
|
|
23
|
+
buttonLink: i.productButtonLinkControlValue,
|
|
24
|
+
imageLink: i.productImageLinkControlValue,
|
|
25
25
|
buttonLabel: "Buy",
|
|
26
26
|
buttonFullWidth: !0,
|
|
27
27
|
// Default to full width (es-fw class)
|
|
28
|
-
imageVisible:
|
|
29
|
-
nameVisible:
|
|
30
|
-
quantityVisible:
|
|
31
|
-
priceVisible:
|
|
32
|
-
originalPriceVisible:
|
|
33
|
-
buttonVisible:
|
|
28
|
+
imageVisible: i.productImageVisible === "1",
|
|
29
|
+
nameVisible: i.productNameVisible === "1",
|
|
30
|
+
quantityVisible: i.productQuantityVisible === "1",
|
|
31
|
+
priceVisible: i.productPriceVisible === "1",
|
|
32
|
+
originalPriceVisible: i.productOriginalPriceVisible === "1",
|
|
33
|
+
buttonVisible: i.productButtonVisible === "1"
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
36
|
function p(r) {
|
|
@@ -50,26 +50,26 @@ function m(r) {
|
|
|
50
50
|
PURCHASED_ITEMS: n.ITEMS_TYPE.PURCHASED_ITEMS
|
|
51
51
|
}[r] || n.ITEMS_TYPE.CART_ITEMS : n.ITEMS_TYPE.CART_ITEMS;
|
|
52
52
|
}
|
|
53
|
-
function
|
|
53
|
+
function f(r, t) {
|
|
54
54
|
if (!r)
|
|
55
|
-
return
|
|
55
|
+
return i.cartItemsSelectControlValue;
|
|
56
56
|
if (r.includes("{{"))
|
|
57
57
|
return r;
|
|
58
58
|
if (/^\d+$/.test(r)) {
|
|
59
|
-
const e = parseInt(r) - 1,
|
|
60
|
-
if (
|
|
61
|
-
return
|
|
59
|
+
const e = parseInt(r) - 1, o = g[t];
|
|
60
|
+
if (o && o[e])
|
|
61
|
+
return o[e].value;
|
|
62
62
|
}
|
|
63
|
-
return
|
|
63
|
+
return i.cartItemsSelectControlValue;
|
|
64
64
|
}
|
|
65
65
|
function C(r) {
|
|
66
66
|
const t = r.querySelector("esd-config-block");
|
|
67
67
|
if (!t)
|
|
68
68
|
return null;
|
|
69
|
-
const e = (
|
|
69
|
+
const e = (u, s) => u == null ? s : u === "1" || u === "true", o = (u, s) => u || s, c = t.getAttribute("data-type"), a = m(c), d = t.getAttribute("data-cart_items_select_control_value"), l = f(d, a);
|
|
70
70
|
return {
|
|
71
71
|
initialized: e(t.getAttribute("data-initialized"), !1),
|
|
72
|
-
blockInstanceId:
|
|
72
|
+
blockInstanceId: o(
|
|
73
73
|
t.getAttribute("data-block-instance-id"),
|
|
74
74
|
_()
|
|
75
75
|
),
|
|
@@ -93,28 +93,28 @@ function C(r) {
|
|
|
93
93
|
t.getAttribute("data-product_price_control_single_price"),
|
|
94
94
|
!1
|
|
95
95
|
),
|
|
96
|
-
priceCurrencySymbol:
|
|
96
|
+
priceCurrencySymbol: o(
|
|
97
97
|
t.getAttribute("data-product_price_control_currency_symbol"),
|
|
98
|
-
|
|
98
|
+
i.productPriceCurrencySymbolControlValue
|
|
99
99
|
),
|
|
100
|
-
priceCurrencyLocation:
|
|
100
|
+
priceCurrencyLocation: o(
|
|
101
101
|
t.getAttribute("data-product_price_currency_location"),
|
|
102
|
-
|
|
102
|
+
i.productPriceCurrencyLocationControlValue
|
|
103
103
|
),
|
|
104
104
|
priceOrientation: t.getAttribute("data-product_original_price_control_orientation") || "horizontal",
|
|
105
105
|
quantityControlEnabled: e(
|
|
106
106
|
t.getAttribute("data-product_quantity_control_enabled"),
|
|
107
107
|
!0
|
|
108
108
|
),
|
|
109
|
-
buttonLink:
|
|
109
|
+
buttonLink: o(
|
|
110
110
|
t.getAttribute("data-product_button_link"),
|
|
111
|
-
|
|
111
|
+
i.productButtonLinkControlValue
|
|
112
112
|
),
|
|
113
|
-
imageLink:
|
|
113
|
+
imageLink: o(
|
|
114
114
|
t.getAttribute("data-product_image_link"),
|
|
115
|
-
|
|
115
|
+
i.productImageLinkControlValue
|
|
116
116
|
),
|
|
117
|
-
buttonLabel:
|
|
117
|
+
buttonLabel: o(
|
|
118
118
|
t.getAttribute("data-product_button_control_label"),
|
|
119
119
|
"Buy"
|
|
120
120
|
),
|
|
@@ -149,28 +149,45 @@ function C(r) {
|
|
|
149
149
|
)
|
|
150
150
|
};
|
|
151
151
|
}
|
|
152
|
-
function
|
|
152
|
+
function I(r) {
|
|
153
|
+
if (typeof r.getAttribute != "function")
|
|
154
|
+
return null;
|
|
155
|
+
const t = r.getAttribute("esd-ext-config");
|
|
156
|
+
if (!t)
|
|
157
|
+
return null;
|
|
158
|
+
try {
|
|
159
|
+
const e = JSON.parse(t);
|
|
160
|
+
if (e && e.initialized)
|
|
161
|
+
return e;
|
|
162
|
+
} catch {
|
|
163
|
+
}
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
function A(r) {
|
|
153
167
|
const t = p(r);
|
|
154
168
|
if (!t)
|
|
155
169
|
return null;
|
|
156
170
|
const e = t.getNodeConfig();
|
|
157
171
|
if (e && e.initialized)
|
|
158
172
|
return e;
|
|
159
|
-
const
|
|
160
|
-
|
|
173
|
+
const o = I(t);
|
|
174
|
+
if (o)
|
|
175
|
+
return o;
|
|
176
|
+
const c = C(t);
|
|
177
|
+
return c || null;
|
|
161
178
|
}
|
|
162
|
-
function
|
|
163
|
-
const
|
|
164
|
-
if (!
|
|
179
|
+
function V(r, t, e, o) {
|
|
180
|
+
const c = p(r);
|
|
181
|
+
if (!c)
|
|
165
182
|
return;
|
|
166
|
-
const d = { ...
|
|
167
|
-
l.modifyHtml(
|
|
183
|
+
const d = { ...c.getNodeConfig() || {}, ...e }, l = o ?? t.getDocumentModifier();
|
|
184
|
+
l.modifyHtml(c).setNodeConfig(d), o || l.apply(new b("Update Items block configuration"));
|
|
168
185
|
}
|
|
169
186
|
export {
|
|
170
187
|
E as escapeReplacement,
|
|
171
188
|
_ as generateBlockInstanceId,
|
|
172
|
-
|
|
173
|
-
|
|
189
|
+
y as getDefaultItemsBlockConfig,
|
|
190
|
+
A as getItemsBlockConfig,
|
|
174
191
|
p as getItemsBlockContainer,
|
|
175
|
-
|
|
192
|
+
V as setItemsBlockConfig
|
|
176
193
|
};
|
|
@@ -4,6 +4,3 @@ export declare const CampaignCouldNotBeSavedKey = "newsletter.campaign-could-not
|
|
|
4
4
|
export declare const DISPLAY_CONDITIONS_REGEX: RegExp;
|
|
5
5
|
export declare const DISPLAY_CONDITIONS_EXCEPTIONS_REGEX: RegExp;
|
|
6
6
|
export declare const REMOVE_CONDITIONS_REGEX: RegExp;
|
|
7
|
-
export declare const DYNAMIC_CONTENT_TAG_REGEX: RegExp;
|
|
8
|
-
export declare const VALID_DYNAMIC_VARIABLE_REGEX: RegExp;
|
|
9
|
-
export declare const ALLOWED_DYNAMIC_SYSTEM_TOKENS: string[];
|
|
@@ -24,5 +24,13 @@ export declare class ItemsBlock extends Block {
|
|
|
24
24
|
getSettingsPanelTitleHtml(): string;
|
|
25
25
|
getTemplate(): string;
|
|
26
26
|
allowInnerBlocksDND(): boolean;
|
|
27
|
+
canBeSavedAsModule(): boolean;
|
|
27
28
|
onCreated(node: ImmutableHtmlNode): void;
|
|
29
|
+
/**
|
|
30
|
+
* Re-seeds nodeConfig from the persisted esd-ext-config when a saved module
|
|
31
|
+
* surfaces via document load. Stripo strips esd-ext-config and never restores it
|
|
32
|
+
* into nodeConfig, so without this a reused module would reset to defaults.
|
|
33
|
+
* Guarded to the nodeConfig-empty case so it runs once and never loops.
|
|
34
|
+
*/
|
|
35
|
+
onDocumentChanged(node: ImmutableHtmlNode): void;
|
|
28
36
|
}
|
|
@@ -55,7 +55,7 @@ export declare function getItemsBlockContainer(currentNode: ImmutableHtmlNode |
|
|
|
55
55
|
/**
|
|
56
56
|
* Gets the node configuration from the Items block.
|
|
57
57
|
* Uses Stripo V2's getNodeConfig() API.
|
|
58
|
-
* Falls back to
|
|
58
|
+
* Falls back to the persisted esd-ext-config (saved modules), then legacy config block.
|
|
59
59
|
* @param currentNode - The current node from the control
|
|
60
60
|
* @returns The ItemsBlockConfig object or null if not found
|
|
61
61
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.7.0-beta.
|
|
3
|
+
"version": "3.7.0-beta.b0ed94d",
|
|
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",
|