@useinsider/guido 2.1.0-beta.f42da92 → 2.1.0-beta.f8696fd
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 +36 -0
- package/dist/@types/config/schemas.js +70 -65
- package/dist/components/Guido.vue.js +1 -1
- package/dist/components/Guido.vue2.js +69 -58
- package/dist/components/organisms/header/EditorActions.vue.js +12 -10
- package/dist/components/organisms/header/EditorActions.vue2.js +41 -31
- package/dist/components/organisms/header/MigrationConfirmModal.vue.js +21 -0
- package/dist/components/organisms/header/MigrationConfirmModal.vue2.js +38 -0
- package/dist/composables/useBlocksConfig.js +26 -16
- package/dist/composables/useStripo.js +25 -23
- package/dist/composables/useVersionHistoryApi.js +1 -1
- package/dist/config/i18n/en/index.js +11 -0
- package/dist/config/i18n/en/labels.json.js +12 -0
- package/dist/config/i18n/en/toasters.json.js +56 -0
- package/dist/config/i18n/en/tooltips.json.js +82 -0
- package/dist/config/i18n/index.js +7 -0
- package/dist/config/migrator/itemsBlockMigrator.js +128 -121
- package/dist/config/migrator/recommendationMigrator.js +42 -40
- package/dist/enums/defaults.js +8 -4
- package/dist/extensions/Blocks/Items/block.js +45 -25
- package/dist/extensions/Blocks/Items/iconsRegistry.js +40 -5
- package/dist/extensions/Blocks/Items/items.css.js +48 -0
- package/dist/extensions/Blocks/Recommendation/block.js +49 -29
- package/dist/extensions/Blocks/Recommendation/iconsRegistry.js +37 -2
- package/dist/extensions/Blocks/Recommendation/recommendation.css.js +48 -0
- package/dist/extensions/Blocks/common-control.js +12 -4
- package/dist/extensions/ModulesTabIcons/extension.js +17 -0
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +204 -136
- package/dist/services/stripoApi.js +20 -17
- package/dist/src/@types/config/schemas.d.ts +8 -0
- package/dist/src/components/Guido.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/EditorActions.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/HeaderWrapper.vue.d.ts +1 -1
- package/dist/src/components/organisms/header/MigrationConfirmModal.vue.d.ts +5 -0
- package/dist/src/components/organisms/header/RightSlot.vue.d.ts +1 -1
- package/dist/src/components/wrappers/WpModal.vue.d.ts +2 -2
- package/dist/src/composables/useConfig.d.ts +4 -0
- package/dist/src/config/i18n/en/index.d.ts +1 -0
- package/dist/src/config/i18n/index.d.ts +16 -0
- package/dist/src/enums/defaults.d.ts +4 -0
- package/dist/src/extensions/Blocks/Items/block.d.ts +1 -0
- package/dist/src/extensions/Blocks/Recommendation/block.d.ts +1 -0
- package/dist/src/extensions/Blocks/common-control.d.ts +5 -0
- package/dist/src/extensions/ModulesTabIcons/extension.d.ts +2 -0
- package/dist/src/stores/config.d.ts +36 -0
- package/dist/src/stores/template.d.ts +3 -0
- package/dist/static/styles/components/notification.css.js +18 -0
- package/dist/static/styles/components/tools.css.js +6 -2
- package/dist/static/styles/variables.css.js +2 -0
- package/dist/static/templates/empty/index.html.js +74 -0
- package/dist/static/templates/empty/style.css.js +779 -0
- package/dist/stores/template.js +9 -0
- package/package.json +1 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
var B = Object.defineProperty;
|
|
2
|
-
var
|
|
3
|
-
var M = (r, t,
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
2
|
+
var v = (r, t, o) => t in r ? B(r, t, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[t] = o;
|
|
3
|
+
var M = (r, t, o) => v(r, typeof t != "symbol" ? t + "" : t, o);
|
|
4
|
+
import { BLOCK_ID as U } from "../../extensions/Blocks/Items/block.js";
|
|
5
|
+
import { productPairs as K } from "../../extensions/Blocks/Items/enums/productEnums.js";
|
|
6
|
+
import { ItemInCartOptions as T, DefaultConfigValues as g, SETTINGS_ENUMS as s } from "../../extensions/Blocks/Items/enums/settingsEnums.js";
|
|
7
|
+
import { getDefaultTemplate as w } from "../../extensions/Blocks/Items/template.js";
|
|
8
|
+
import { useTemplateStore as F } from "../../stores/template.js";
|
|
9
|
+
const q = {
|
|
8
10
|
img: {
|
|
9
11
|
pairsKey: "imageSrc",
|
|
10
12
|
defaultKey: "DEFAULT",
|
|
@@ -71,50 +73,51 @@ const w = {
|
|
|
71
73
|
isArray: !1
|
|
72
74
|
}
|
|
73
75
|
};
|
|
74
|
-
function
|
|
76
|
+
function O() {
|
|
75
77
|
return String(Date.now() + Math.floor(Math.random() * 1e3));
|
|
76
78
|
}
|
|
77
|
-
function
|
|
79
|
+
function $(r) {
|
|
78
80
|
return r ? {
|
|
79
|
-
CartItems:
|
|
80
|
-
BrowsedItems:
|
|
81
|
-
PurchasedItems:
|
|
82
|
-
CART_ITEMS:
|
|
83
|
-
BROWSED_ITEMS:
|
|
84
|
-
PURCHASED_ITEMS:
|
|
85
|
-
}[r] ||
|
|
81
|
+
CartItems: s.ITEMS_TYPE.CART_ITEMS,
|
|
82
|
+
BrowsedItems: s.ITEMS_TYPE.BROWSED_ITEMS,
|
|
83
|
+
PurchasedItems: s.ITEMS_TYPE.PURCHASED_ITEMS,
|
|
84
|
+
CART_ITEMS: s.ITEMS_TYPE.CART_ITEMS,
|
|
85
|
+
BROWSED_ITEMS: s.ITEMS_TYPE.BROWSED_ITEMS,
|
|
86
|
+
PURCHASED_ITEMS: s.ITEMS_TYPE.PURCHASED_ITEMS
|
|
87
|
+
}[r] || s.ITEMS_TYPE.CART_ITEMS : s.ITEMS_TYPE.CART_ITEMS;
|
|
86
88
|
}
|
|
87
89
|
function R(r) {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
var e;
|
|
91
|
+
const t = (i, _) => i == null ? _ : i === "1" || i === "true", o = (i, _) => i || _, c = r["data-type"] || r["data-source"], a = $(c), n = T[a];
|
|
92
|
+
let l = r["data-cart_items_select_control_value"] || ((e = n == null ? void 0 : n[0]) == null ? void 0 : e.value) || g.cartItemsSelectControlValue;
|
|
93
|
+
if (l && !l.includes("{{") && /^\d+$/.test(l)) {
|
|
94
|
+
const i = parseInt(l) - 1, _ = T[a];
|
|
95
|
+
_ && _[i] && (l = _[i].value);
|
|
93
96
|
}
|
|
94
97
|
return {
|
|
95
98
|
initialized: !0,
|
|
96
|
-
blockInstanceId:
|
|
97
|
-
source:
|
|
98
|
-
type:
|
|
99
|
-
itemsSelectValue:
|
|
100
|
-
orientation: r["data-card_orientation_control_value"] ||
|
|
99
|
+
blockInstanceId: o(r["data-block-instance-id"], O()),
|
|
100
|
+
source: a,
|
|
101
|
+
type: a,
|
|
102
|
+
itemsSelectValue: l,
|
|
103
|
+
orientation: r["data-card_orientation_control_value"] || s.ORIENTATION.VERTICAL,
|
|
101
104
|
nameTrimming: t(r["data-product_name_control_trim"], !0),
|
|
102
105
|
priceHideDiscount: t(r["data-product_price_control_nodup"], !0),
|
|
103
106
|
priceFormatted: t(r["data-product_price_control_formated"], !0),
|
|
104
107
|
priceSinglePrice: t(r["data-product_price_control_single_price"], !1),
|
|
105
|
-
priceCurrencySymbol:
|
|
108
|
+
priceCurrencySymbol: o(
|
|
106
109
|
r["data-product_price_control_currency_symbol"],
|
|
107
110
|
g.productPriceCurrencySymbolControlValue
|
|
108
111
|
),
|
|
109
|
-
priceCurrencyLocation:
|
|
112
|
+
priceCurrencyLocation: o(
|
|
110
113
|
r["data-product_price_currency_location"],
|
|
111
114
|
g.productPriceCurrencyLocationControlValue
|
|
112
115
|
),
|
|
113
116
|
priceOrientation: r["data-product_original_price_control_orientation"] || "horizontal",
|
|
114
117
|
quantityControlEnabled: t(r["data-product_quantity_control_enabled"], !0),
|
|
115
|
-
buttonLink:
|
|
116
|
-
imageLink:
|
|
117
|
-
buttonLabel:
|
|
118
|
+
buttonLink: o(r["data-product_button_link"], g.productButtonLinkControlValue),
|
|
119
|
+
imageLink: o(r["data-product_image_link"], g.productImageLinkControlValue),
|
|
120
|
+
buttonLabel: o(r["data-product_button_control_label"], "Buy"),
|
|
118
121
|
buttonFullWidth: t(r["data-product_button_control_atw"], !0),
|
|
119
122
|
imageVisible: t(r["data-product_image_control_enabled"], !0),
|
|
120
123
|
nameVisible: t(r["data-product_name_control_enabled"], !0),
|
|
@@ -124,68 +127,68 @@ function R(r) {
|
|
|
124
127
|
buttonVisible: t(r["data-product_button_control_enabled"], !0)
|
|
125
128
|
};
|
|
126
129
|
}
|
|
127
|
-
const
|
|
130
|
+
const x = {
|
|
128
131
|
ins_apr: "CART_ITEMS",
|
|
129
132
|
browsed_item: "BROWSED_ITEMS",
|
|
130
133
|
purchased_item: "PURCHASED_ITEMS"
|
|
131
134
|
};
|
|
132
|
-
function
|
|
133
|
-
const
|
|
135
|
+
function V(r, t) {
|
|
136
|
+
const o = {
|
|
134
137
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Image}}`,
|
|
135
138
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Image}}`,
|
|
136
139
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Image}}`
|
|
137
140
|
};
|
|
138
|
-
return
|
|
141
|
+
return o[r] || o.CART_ITEMS;
|
|
139
142
|
}
|
|
140
|
-
function
|
|
141
|
-
const
|
|
143
|
+
function N(r, t) {
|
|
144
|
+
const o = {
|
|
142
145
|
CART_ITEMS: `{{Abandoned Cart Item (${t}) Url}}`,
|
|
143
146
|
BROWSED_ITEMS: `{{Browsed Item (${t}) Url}}`,
|
|
144
147
|
PURCHASED_ITEMS: `{{Purchased Item (${t}) Url}}`
|
|
145
148
|
};
|
|
146
|
-
return
|
|
149
|
+
return o[r] || o.CART_ITEMS;
|
|
147
150
|
}
|
|
148
|
-
class
|
|
151
|
+
class z {
|
|
149
152
|
constructor() {
|
|
150
153
|
M(this, "parser");
|
|
151
154
|
this.parser = new DOMParser();
|
|
152
155
|
}
|
|
153
156
|
migrate(t) {
|
|
154
157
|
try {
|
|
155
|
-
let
|
|
156
|
-
|
|
157
|
-
const
|
|
158
|
+
let o = this.removeJinjaConditionals(t);
|
|
159
|
+
o = this.replaceTemplateVariables(o);
|
|
160
|
+
const c = this.parser.parseFromString(o, "text/html"), a = c.querySelectorAll(
|
|
158
161
|
"td.esd-cart-items-block, td.esd-browsed-items-block, td.esd-purchased-items-block"
|
|
159
|
-
);
|
|
160
|
-
return
|
|
161
|
-
const
|
|
162
|
-
orientation:
|
|
163
|
-
itemsType:
|
|
164
|
-
itemId:
|
|
165
|
-
currencySymbol:
|
|
166
|
-
currencyLocation:
|
|
167
|
-
formattedPrice:
|
|
168
|
-
configBlockAttributes:
|
|
162
|
+
), n = F();
|
|
163
|
+
return n.migrations[U] = a.length, a.length === 0 ? (console.warn("ItemsBlockMigrator: No blocks found with items block selectors"), o) : (a.forEach((l) => {
|
|
164
|
+
const e = this.extractConfiguration(l), i = w({
|
|
165
|
+
orientation: e.orientation,
|
|
166
|
+
itemsType: e.itemsType,
|
|
167
|
+
itemId: e.itemId,
|
|
168
|
+
currencySymbol: e.currencySymbol,
|
|
169
|
+
currencyLocation: e.currencyLocation,
|
|
170
|
+
formattedPrice: e.formattedPrice,
|
|
171
|
+
configBlockAttributes: e.configBlockAttributes,
|
|
169
172
|
migrate: !0,
|
|
170
|
-
nameStyles:
|
|
171
|
-
buttonStyles:
|
|
172
|
-
priceStyles:
|
|
173
|
-
originalPriceStyles:
|
|
174
|
-
quantityStyles:
|
|
175
|
-
nodeConfig: R(
|
|
176
|
-
}),
|
|
177
|
-
`<table><tbody><tr>${
|
|
173
|
+
nameStyles: e.nameStyles,
|
|
174
|
+
buttonStyles: e.buttonStyles,
|
|
175
|
+
priceStyles: e.priceStyles,
|
|
176
|
+
originalPriceStyles: e.originalPriceStyles,
|
|
177
|
+
quantityStyles: e.quantityStyles,
|
|
178
|
+
nodeConfig: R(e.configBlockAttributes)
|
|
179
|
+
}), d = this.parser.parseFromString(
|
|
180
|
+
`<table><tbody><tr>${i}</tr></tbody></table>`,
|
|
178
181
|
"text/html"
|
|
179
182
|
).querySelector("td");
|
|
180
|
-
if (
|
|
181
|
-
const
|
|
182
|
-
|
|
183
|
-
const u =
|
|
184
|
-
u && u.remove(),
|
|
183
|
+
if (d && l.parentNode) {
|
|
184
|
+
const p = R(e.configBlockAttributes);
|
|
185
|
+
d.setAttribute("esd-ext-config", JSON.stringify(p));
|
|
186
|
+
const u = d.querySelector("esd-config-block");
|
|
187
|
+
u && u.remove(), l.parentNode.replaceChild(d, l);
|
|
185
188
|
}
|
|
186
|
-
}),
|
|
187
|
-
} catch (
|
|
188
|
-
return console.error("ItemsBlockMigrator failed:",
|
|
189
|
+
}), c.documentElement.outerHTML);
|
|
190
|
+
} catch (o) {
|
|
191
|
+
return console.error("ItemsBlockMigrator failed:", o), t;
|
|
189
192
|
}
|
|
190
193
|
}
|
|
191
194
|
/**
|
|
@@ -196,22 +199,22 @@ class V {
|
|
|
196
199
|
*/
|
|
197
200
|
extractConfiguration(t) {
|
|
198
201
|
var C, D, P;
|
|
199
|
-
const
|
|
200
|
-
let
|
|
201
|
-
|
|
202
|
-
const
|
|
202
|
+
const o = ((C = t.querySelector("[data-type]")) == null ? void 0 : C.getAttribute("data-type")) || "CART_ITEMS", c = ((D = t.querySelector("[data-number]")) == null ? void 0 : D.getAttribute("data-number")) || "1", a = parseInt(c) - 1, n = T[o], l = ((P = n == null ? void 0 : n[a]) == null ? void 0 : P.value) || n[0].value, e = t.querySelector('[product-attr="price"]'), i = (e == null ? void 0 : e.getAttribute("data-currency_symbol")) || "USD", d = ((e == null ? void 0 : e.getAttribute("data-curency")) || "before") === "after" ? "1" : "0", p = (e == null ? void 0 : e.getAttribute("data-formated")) !== "false", u = this.extractConfigBlockAttributes(t, o, c), S = u["data-card_orientation_control_value"];
|
|
203
|
+
let b;
|
|
204
|
+
S ? b = S === "horizontal" ? "horizontal" : "vertical" : b = t.querySelector('[colspan="2"]') !== null ? "vertical" : "horizontal";
|
|
205
|
+
const y = t.querySelector('a[product-attr="name"]'), I = (y == null ? void 0 : y.getAttribute("style")) || void 0, f = t.querySelector('a[product-attr="button"]'), m = (f == null ? void 0 : f.getAttribute("style")) || void 0, h = (e == null ? void 0 : e.getAttribute("style")) || void 0, A = t.querySelector("p.original-price"), k = (A == null ? void 0 : A.getAttribute("style")) || void 0, E = t.querySelector('[product-attr="quantity"]'), L = (E == null ? void 0 : E.getAttribute("style")) || void 0;
|
|
203
206
|
return {
|
|
204
|
-
orientation:
|
|
205
|
-
itemsType:
|
|
206
|
-
itemId:
|
|
207
|
-
currencySymbol:
|
|
208
|
-
currencyLocation:
|
|
209
|
-
formattedPrice:
|
|
210
|
-
configBlockAttributes:
|
|
211
|
-
nameStyles:
|
|
207
|
+
orientation: b,
|
|
208
|
+
itemsType: o,
|
|
209
|
+
itemId: l,
|
|
210
|
+
currencySymbol: i,
|
|
211
|
+
currencyLocation: d,
|
|
212
|
+
formattedPrice: p,
|
|
213
|
+
configBlockAttributes: u,
|
|
214
|
+
nameStyles: I,
|
|
212
215
|
buttonStyles: m,
|
|
213
|
-
priceStyles:
|
|
214
|
-
originalPriceStyles:
|
|
216
|
+
priceStyles: h,
|
|
217
|
+
originalPriceStyles: k,
|
|
215
218
|
quantityStyles: L
|
|
216
219
|
};
|
|
217
220
|
}
|
|
@@ -222,27 +225,27 @@ class V {
|
|
|
222
225
|
* @param itemsType - The type of items (CART_ITEMS, BROWSED_ITEMS, PURCHASED_ITEMS)
|
|
223
226
|
* @param itemNumber - The item number (1-based index)
|
|
224
227
|
*/
|
|
225
|
-
extractConfigBlockAttributes(t,
|
|
226
|
-
const
|
|
227
|
-
if (!
|
|
228
|
+
extractConfigBlockAttributes(t, o, c) {
|
|
229
|
+
const a = t.querySelector("esd-config-block"), n = {};
|
|
230
|
+
if (!a)
|
|
228
231
|
return this.getDefaultConfigBlockAttributes();
|
|
229
|
-
if (Array.from(
|
|
230
|
-
|
|
232
|
+
if (Array.from(a.attributes).forEach((e) => {
|
|
233
|
+
e.name.startsWith("data-") && (n[e.name] = e.value);
|
|
231
234
|
}), n["data-cart_items_select_control_value"]) {
|
|
232
|
-
const
|
|
233
|
-
if (/^\d+$/.test(
|
|
234
|
-
const
|
|
235
|
-
|
|
235
|
+
const e = n["data-cart_items_select_control_value"];
|
|
236
|
+
if (/^\d+$/.test(e)) {
|
|
237
|
+
const i = parseInt(e) - 1, _ = T[o];
|
|
238
|
+
_ && _[i] && (n["data-cart_items_select_control_value"] = _[i].value);
|
|
236
239
|
}
|
|
237
240
|
}
|
|
238
241
|
if (n["data-product_price_control_curency"]) {
|
|
239
|
-
const
|
|
240
|
-
let
|
|
241
|
-
|
|
242
|
+
const e = n["data-product_price_control_curency"];
|
|
243
|
+
let i = e;
|
|
244
|
+
e === "before" ? i = "0" : e === "after" && (i = "1"), n["data-product_price_control_curency"] = i, n["data-product_price_currency_location"] = i;
|
|
242
245
|
}
|
|
243
246
|
(!n["data-product_price_control_currency_symbol"] || n["data-product_price_control_currency_symbol"].trim() === "") && (n["data-product_price_control_currency_symbol"] = "USD");
|
|
244
|
-
const
|
|
245
|
-
return
|
|
247
|
+
const l = { ...this.getDefaultConfigBlockAttributes(), ...n };
|
|
248
|
+
return l["data-type"] = o, l["data-source"] = o, l["data-product_image_link"] = V(o, c), l["data-product_button_link"] = N(o, c), l;
|
|
246
249
|
}
|
|
247
250
|
/**
|
|
248
251
|
* Returns default esd-config-block attributes based on the old template structure
|
|
@@ -297,18 +300,22 @@ class V {
|
|
|
297
300
|
* - Cart Items: ins_apr_total_product_kind, ins_apr_price_N, ins_apr_originalprice_N
|
|
298
301
|
* - Browsed Items: browsed_item_total_product_kind, browsed_item_price_N, browsed_item_originalprice_N
|
|
299
302
|
* - Purchased Items: purchased_item_total_product_kind, purchased_item_price_N, purchased_item_originalprice_N
|
|
303
|
+
*
|
|
304
|
+
* IMPORTANT: Preserves the esd-custom-display-conditions attribute on <body> which
|
|
305
|
+
* contains display condition Jinja scripts that should NOT be removed.
|
|
300
306
|
*/
|
|
301
307
|
removeJinjaConditionals(t) {
|
|
302
|
-
|
|
308
|
+
const o = "__ESD_DISPLAY_CONDITIONS_PLACEHOLDER__", c = t.match(/esd-custom-display-conditions="[^"]*"/);
|
|
309
|
+
let a = c ? t.replace(c[0], o) : t;
|
|
310
|
+
return a = a.replace(
|
|
303
311
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_total_product_kind\s*(>|>)\s*\d+\s*%\}/g,
|
|
304
312
|
""
|
|
305
|
-
)
|
|
306
|
-
return e = e.replace(
|
|
313
|
+
), a = a.replace(
|
|
307
314
|
/\{%\s*if\s+(ins_apr|browsed_item|purchased_item)_price_\d+\s*(!=|!=)\s*\1_originalprice_\d+\s*%\}/g,
|
|
308
315
|
""
|
|
309
|
-
),
|
|
316
|
+
), a = a.replace(/\{%\s*endif\s*%\}/g, ""), c && (a = a.replace(o, c[0])), a = a.replace(/\n\s*\n\s*\n/g, `
|
|
310
317
|
|
|
311
|
-
`),
|
|
318
|
+
`), a;
|
|
312
319
|
}
|
|
313
320
|
/**
|
|
314
321
|
* Replaces template variables with default values from productPairs
|
|
@@ -320,32 +327,32 @@ class V {
|
|
|
320
327
|
* - {{purchased_item_formattedprice_5}} → '1,490.49' (PURCHASED_ITEMS)
|
|
321
328
|
*/
|
|
322
329
|
replaceTemplateVariables(t) {
|
|
323
|
-
const { PAIRS_FOR_EXTENSION:
|
|
324
|
-
return t.replace(/{{([^}]+)}}/g, (
|
|
325
|
-
const n =
|
|
330
|
+
const { PAIRS_FOR_EXTENSION: o } = K;
|
|
331
|
+
return t.replace(/{{([^}]+)}}/g, (c, a) => {
|
|
332
|
+
const n = a.match(/^(ins_apr|browsed_item|purchased_item)_([a-z_]+)_(\d+)$/);
|
|
326
333
|
if (!n)
|
|
327
|
-
return
|
|
328
|
-
const [,
|
|
329
|
-
if (!
|
|
330
|
-
return console.warn(`Unknown variable prefix: ${
|
|
331
|
-
const
|
|
332
|
-
if (!
|
|
333
|
-
return console.warn(`Unknown variable suffix mapping for: ${
|
|
334
|
-
const { pairsKey:
|
|
335
|
-
if (!
|
|
336
|
-
return console.warn(`No data found for: ${
|
|
337
|
-
if (
|
|
338
|
-
const
|
|
339
|
-
return Array.isArray(m) && m[
|
|
334
|
+
return c;
|
|
335
|
+
const [, l, e, i] = n, _ = x[l];
|
|
336
|
+
if (!_)
|
|
337
|
+
return console.warn(`Unknown variable prefix: ${l}`), c;
|
|
338
|
+
const d = q[e];
|
|
339
|
+
if (!d)
|
|
340
|
+
return console.warn(`Unknown variable suffix mapping for: ${e}`), c;
|
|
341
|
+
const { pairsKey: p, defaultKey: u, isArray: S } = d, y = o[p][_];
|
|
342
|
+
if (!y)
|
|
343
|
+
return console.warn(`No data found for: ${p}.${_}`), c;
|
|
344
|
+
if (S) {
|
|
345
|
+
const f = parseInt(i) - 1, m = y[u];
|
|
346
|
+
return Array.isArray(m) && m[f] ? m[f] : (console.warn(`Array value not found: ${p}.${_}.${u}[${f}]`), c);
|
|
340
347
|
}
|
|
341
|
-
const
|
|
342
|
-
return
|
|
348
|
+
const I = y[u];
|
|
349
|
+
return I !== void 0 ? String(I) : (console.warn(`Default value not found: ${p}.${_}.${u}`), c);
|
|
343
350
|
});
|
|
344
351
|
}
|
|
345
352
|
}
|
|
346
|
-
function
|
|
347
|
-
return new
|
|
353
|
+
function Q(r) {
|
|
354
|
+
return new z().migrate(r);
|
|
348
355
|
}
|
|
349
356
|
export {
|
|
350
|
-
|
|
357
|
+
Q as migrateItemsBlock
|
|
351
358
|
};
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
var h = Object.defineProperty;
|
|
2
|
-
var T = (
|
|
3
|
-
var
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
|
|
2
|
+
var T = (d, e, t) => e in d ? h(d, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : d[e] = t;
|
|
3
|
+
var A = (d, e, t) => T(d, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { BLOCK_ID as S } from "../../extensions/Blocks/Recommendation/block.js";
|
|
5
|
+
import P, { prepareProductRows as q } from "../../extensions/Blocks/Recommendation/templates/grid/migration.js";
|
|
6
|
+
import { useTemplateStore as w } from "../../stores/template.js";
|
|
7
|
+
import { getDefaultProducts as B } from "../../extensions/Blocks/Recommendation/templates/utils.js";
|
|
8
|
+
class $ {
|
|
7
9
|
constructor() {
|
|
8
|
-
|
|
10
|
+
A(this, "parser");
|
|
9
11
|
this.parser = new DOMParser();
|
|
10
12
|
}
|
|
11
13
|
migrate(e) {
|
|
12
14
|
try {
|
|
13
15
|
const t = this.parser.parseFromString(e, "text/html"), s = t.querySelectorAll(
|
|
14
16
|
'td.ins-recommendation-v3-block-1, td.product-block[esd-handler-name*="EmailRecommendationV3"]'
|
|
15
|
-
);
|
|
16
|
-
return s.length === 0 ? e : (s.forEach((
|
|
17
|
-
const
|
|
18
|
-
`<table id="tempDoc"><tbody><tr>${
|
|
17
|
+
), o = w();
|
|
18
|
+
return o.migrations[S] = s.length, s.length === 0 ? e : (s.forEach((n) => {
|
|
19
|
+
const r = n.getAttribute("id"), i = this.extractBgColor(n), u = this.extractTitle(n), c = this.extractProductRows(n), l = P.replace("{-{-TITLE-}-}", u).replace("{-{-PRODUCT_ROWS-}-}", c), a = this.parser.parseFromString(
|
|
20
|
+
`<table id="tempDoc"><tbody><tr>${l}</tr></tbody></table>`,
|
|
19
21
|
"text/html"
|
|
20
22
|
).querySelector(".ins-recommendation-v3-block-v2");
|
|
21
|
-
a &&
|
|
23
|
+
a && n.parentNode && (r && a.setAttribute("id", r), i && a.setAttribute("bgcolor", i), n.parentNode.replaceChild(a, n));
|
|
22
24
|
}), t.documentElement.outerHTML);
|
|
23
25
|
} catch (t) {
|
|
24
26
|
return console.error("RecommendationMigrator failed:", t), e;
|
|
@@ -64,7 +66,7 @@ class w {
|
|
|
64
66
|
* @returns HTML string for the title block
|
|
65
67
|
*/
|
|
66
68
|
extractTitle(e) {
|
|
67
|
-
var
|
|
69
|
+
var g, a;
|
|
68
70
|
const t = e.querySelector(".ext-recommendation-title");
|
|
69
71
|
if (!t)
|
|
70
72
|
return this.buildTitleBlock({
|
|
@@ -76,7 +78,7 @@ class w {
|
|
|
76
78
|
});
|
|
77
79
|
const s = t.querySelector("p");
|
|
78
80
|
if (!s) {
|
|
79
|
-
const p = ((
|
|
81
|
+
const p = ((g = t.textContent) == null ? void 0 : g.trim()) || "You May Also Like!", b = t.getAttribute("align") || "center";
|
|
80
82
|
return this.buildTitleBlock({
|
|
81
83
|
text: p,
|
|
82
84
|
isBold: !0,
|
|
@@ -85,13 +87,13 @@ class w {
|
|
|
85
87
|
styles: "font-size: 28px; color: #333333;"
|
|
86
88
|
});
|
|
87
89
|
}
|
|
88
|
-
const o = ((
|
|
90
|
+
const o = ((a = s.textContent) == null ? void 0 : a.trim()) || "You May Also Like!", n = t.getAttribute("align") || s.getAttribute("align") || "center", r = s.getAttribute("style") || "", i = /font-weight\s*:\s*bold/i.test(r) || !!s.querySelector("b, strong"), u = /font-style\s*:\s*italic/i.test(r) || !!s.querySelector("i, em"), c = this.removeStyleProperties(r, ["font-weight", "font-style"]), l = this.convertInlineToBlock(c);
|
|
89
91
|
return this.buildTitleBlock({
|
|
90
92
|
text: o,
|
|
91
93
|
isBold: i,
|
|
92
94
|
isItalic: u,
|
|
93
|
-
align:
|
|
94
|
-
styles:
|
|
95
|
+
align: n,
|
|
96
|
+
styles: l
|
|
95
97
|
});
|
|
96
98
|
}
|
|
97
99
|
/**
|
|
@@ -103,8 +105,8 @@ class w {
|
|
|
103
105
|
const t = this.extractProductConfig(e);
|
|
104
106
|
if (!t)
|
|
105
107
|
return console.warn("[RecommendationMigrator] No product config found, using defaults"), this.generateProductRows(6, 3, {});
|
|
106
|
-
const { totalCount: s, productsPerRow: o } = t,
|
|
107
|
-
return this.generateProductRows(s, o,
|
|
108
|
+
const { totalCount: s, productsPerRow: o } = t, n = this.extractProductStyles(e);
|
|
109
|
+
return this.generateProductRows(s, o, n);
|
|
108
110
|
}
|
|
109
111
|
/**
|
|
110
112
|
* Extracts Stripo padding/margin utility classes from a class string
|
|
@@ -152,12 +154,12 @@ class w {
|
|
|
152
154
|
* @returns HTML string for product rows with applied styles
|
|
153
155
|
*/
|
|
154
156
|
generateProductRows(e, t, s) {
|
|
155
|
-
const o =
|
|
157
|
+
const o = B(), n = [];
|
|
156
158
|
for (let i = 0; i < e; i++) {
|
|
157
159
|
const u = o[i % o.length];
|
|
158
|
-
|
|
160
|
+
n.push({ ...u });
|
|
159
161
|
}
|
|
160
|
-
let r =
|
|
162
|
+
let r = q(n, t);
|
|
161
163
|
return r = this.applyExtractedStyles(r, s), r;
|
|
162
164
|
}
|
|
163
165
|
/**
|
|
@@ -171,30 +173,30 @@ class w {
|
|
|
171
173
|
return console.warn("[RecommendationMigrator] No product card found, using default styles"), t;
|
|
172
174
|
const o = this.extractCardBgColor(s);
|
|
173
175
|
o && (t.cardBgColor = o);
|
|
174
|
-
const
|
|
175
|
-
if (
|
|
176
|
-
const
|
|
177
|
-
t.imageWidth =
|
|
176
|
+
const n = s.querySelector(".ext-product-image");
|
|
177
|
+
if (n) {
|
|
178
|
+
const l = n.querySelector("img"), g = l == null ? void 0 : l.getAttribute("width"), a = n.getAttribute("style") || "", p = n.getAttribute("align") || "center", b = n.getAttribute("class") || "", m = this.extractStripoClasses(b);
|
|
179
|
+
t.imageWidth = g || "120", t.imageAlign = p, t.imageTdStyle = a, t.imageClasses = m;
|
|
178
180
|
}
|
|
179
181
|
const r = s.querySelector(".ext-product-name");
|
|
180
182
|
if (r) {
|
|
181
|
-
const
|
|
182
|
-
t.nameStyle =
|
|
183
|
+
const l = r.querySelector("p"), g = (l == null ? void 0 : l.getAttribute("style")) || "", a = r.getAttribute("align") || "center", p = r.getAttribute("style") || "", b = r.getAttribute("class") || "", m = this.extractStripoClasses(b);
|
|
184
|
+
t.nameStyle = g, t.nameAlign = a, t.nameTdStyle = p, t.nameClasses = m;
|
|
183
185
|
}
|
|
184
186
|
const i = s.querySelector(".ext-product-price");
|
|
185
187
|
if (i) {
|
|
186
|
-
const
|
|
187
|
-
t.priceStyle =
|
|
188
|
+
const l = i.querySelector("p"), g = (l == null ? void 0 : l.getAttribute("style")) || "", a = i.getAttribute("align") || "center", p = i.getAttribute("style") || "", b = i.getAttribute("class") || "", m = this.extractStripoClasses(b);
|
|
189
|
+
t.priceStyle = g, t.priceAlign = a, t.priceTdStyle = p, t.priceClasses = m;
|
|
188
190
|
}
|
|
189
191
|
const u = s.querySelector(".ext-product-original-price");
|
|
190
192
|
if (u) {
|
|
191
|
-
const
|
|
192
|
-
t.oldPriceStyle =
|
|
193
|
+
const l = u.querySelector("p"), g = (l == null ? void 0 : l.getAttribute("style")) || "", a = u.getAttribute("align") || "center", p = u.getAttribute("style") || "", b = u.getAttribute("class") || "", m = this.extractStripoClasses(b);
|
|
194
|
+
t.oldPriceStyle = g, t.oldPriceAlign = a, t.oldPriceTdStyle = p, t.oldPriceClasses = m;
|
|
193
195
|
}
|
|
194
196
|
const c = s.querySelector(".ext-product-button");
|
|
195
197
|
if (c) {
|
|
196
|
-
const
|
|
197
|
-
t.buttonBorderStyle =
|
|
198
|
+
const l = c.querySelector(".es-button-border"), g = c.querySelector("a.es-button"), a = (l == null ? void 0 : l.getAttribute("style")) || "", p = (g == null ? void 0 : g.getAttribute("style")) || "", b = c.getAttribute("align") || "center", m = c.getAttribute("style") || "", f = c.getAttribute("class") || "", C = this.extractStripoClasses(f), y = ((c == null ? void 0 : c.textContent) || "").trim();
|
|
199
|
+
t.buttonBorderStyle = a, t.buttonLinkStyle = p, t.buttonAlign = b, t.buttonTdStyle = m, t.buttonClasses = C, t.buttonText = y;
|
|
198
200
|
}
|
|
199
201
|
return t;
|
|
200
202
|
}
|
|
@@ -240,8 +242,8 @@ class w {
|
|
|
240
242
|
i && t.oldPriceStyle && i.setAttribute("style", t.oldPriceStyle);
|
|
241
243
|
}), (t.buttonBorderStyle || t.buttonLinkStyle || t.buttonAlign || t.buttonTdStyle || t.buttonClasses) && s.querySelectorAll(".product-button").forEach((r) => {
|
|
242
244
|
if (t.buttonAlign && r.setAttribute("align", t.buttonAlign), t.buttonTdStyle && r.setAttribute("style", t.buttonTdStyle), t.buttonClasses) {
|
|
243
|
-
const
|
|
244
|
-
r.setAttribute("class",
|
|
245
|
+
const l = `${r.getAttribute("class") || ""} ${t.buttonClasses}`.trim();
|
|
246
|
+
r.setAttribute("class", l);
|
|
245
247
|
}
|
|
246
248
|
const i = r.querySelector(".es-button-border");
|
|
247
249
|
i && t.buttonBorderStyle && i.setAttribute("style", t.buttonBorderStyle);
|
|
@@ -270,8 +272,8 @@ class w {
|
|
|
270
272
|
* Removes specified style properties from a style string
|
|
271
273
|
*/
|
|
272
274
|
removeStyleProperties(e, t) {
|
|
273
|
-
return e ? t.reduce((o,
|
|
274
|
-
const r = new RegExp(`${
|
|
275
|
+
return e ? t.reduce((o, n) => {
|
|
276
|
+
const r = new RegExp(`${n}\\s*:\\s*[^;]*;?`, "gi");
|
|
275
277
|
return o.replace(r, "");
|
|
276
278
|
}, e).replace(/;\s*;/g, ";").replace(/^;|;$/g, "").trim() : "";
|
|
277
279
|
}
|
|
@@ -285,9 +287,9 @@ class w {
|
|
|
285
287
|
return /display\s*:/i.test(t) || (t = t ? `${t}; display: block` : "display: block"), t.replace(/;\s*;/g, ";").replace(/^;|;$/g, "").replace(/"/g, "'").trim();
|
|
286
288
|
}
|
|
287
289
|
}
|
|
288
|
-
function
|
|
289
|
-
return new
|
|
290
|
+
function v(d) {
|
|
291
|
+
return new $().migrate(d);
|
|
290
292
|
}
|
|
291
293
|
export {
|
|
292
|
-
|
|
294
|
+
v as migrateRecommendation
|
|
293
295
|
};
|
package/dist/enums/defaults.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
const
|
|
1
|
+
const e = {
|
|
2
2
|
transactional: 2
|
|
3
|
-
}, o = 2,
|
|
3
|
+
}, o = 2, t = 13, s = {
|
|
4
|
+
SAVED_MODULES: "savedModules",
|
|
5
|
+
DEFAULT_MODULES: "defaultModules"
|
|
6
|
+
};
|
|
4
7
|
export {
|
|
5
8
|
o as EditorType,
|
|
6
|
-
|
|
7
|
-
|
|
9
|
+
t as MAX_DEFAULT_TEMPLATE_ID,
|
|
10
|
+
s as ModuleFolderDefaults,
|
|
11
|
+
e as TemplateTypes
|
|
8
12
|
};
|