@useinsider/guido 3.30.0-beta.a1f329f → 3.30.0-beta.b189780
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 +0 -1
- package/dist/@types/config/schemas.js +11 -13
- package/dist/components/organisms/header/EditorActions.vue.js +2 -2
- package/dist/components/organisms/header/EditorActionsMenu.vue.js +4 -4
- package/dist/components/organisms/header/EditorActionsMenu.vue2.js +28 -28
- package/dist/composables/useAutoSave.js +13 -13
- package/dist/composables/useSave.js +78 -76
- package/dist/composables/useStripo.js +45 -41
- package/dist/config/migrator/itemsBlockMigrator.js +164 -161
- package/dist/guido.css +1 -1
- package/dist/package.json.js +1 -1
- package/dist/services/stripoApi.js +21 -18
- package/dist/src/@types/config/schemas.d.ts +0 -4
- package/dist/src/composables/useConfig.d.ts +0 -2
- package/dist/src/stores/config.d.ts +0 -21
- package/dist/src/stores/editor.d.ts +6 -0
- package/dist/stores/editor.js +15 -14
- package/dist/utils/pairProductVariables.js +98 -108
- package/package.json +1 -1
|
@@ -2,19 +2,22 @@ import { useHttp as m } from "../composables/useHttp.js";
|
|
|
2
2
|
import { useToaster as y } from "../composables/useToaster.js";
|
|
3
3
|
import { MAX_DEFAULT_TEMPLATE_ID as f } from "../enums/defaults.js";
|
|
4
4
|
import { useBlankTemplate as g } from "./blankTemplate.js";
|
|
5
|
-
const
|
|
5
|
+
const p = () => ({
|
|
6
6
|
id: 0,
|
|
7
7
|
stripoId: 0,
|
|
8
8
|
unsubscriptionPreferencePages: []
|
|
9
|
-
}),
|
|
10
|
-
const { get: s, post:
|
|
9
|
+
}), E = () => {
|
|
10
|
+
const { get: s, post: i } = m(), { handleError: r } = y(), { getBlankTemplate: a } = g();
|
|
11
11
|
return {
|
|
12
12
|
getToken: async () => {
|
|
13
|
+
var t;
|
|
13
14
|
try {
|
|
14
|
-
const { data:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return
|
|
15
|
+
const { data: e } = await s("/stripo/get-user-token"), n = (t = e == null ? void 0 : e.body) == null ? void 0 : t.token;
|
|
16
|
+
if (!n)
|
|
17
|
+
throw new Error("Response carries no token");
|
|
18
|
+
return n;
|
|
19
|
+
} catch (e) {
|
|
20
|
+
return r(e, "Failed to fetch token"), "";
|
|
18
21
|
}
|
|
19
22
|
},
|
|
20
23
|
getCustomFonts: async () => {
|
|
@@ -30,13 +33,13 @@ const l = () => ({
|
|
|
30
33
|
},
|
|
31
34
|
getDefaultTemplate: async () => {
|
|
32
35
|
try {
|
|
33
|
-
const t = new URLSearchParams(window.location.search), e = t.get("default-template"),
|
|
34
|
-
if (!
|
|
35
|
-
return await
|
|
36
|
-
const d = `/stripo/default-template/${
|
|
37
|
-
return !
|
|
36
|
+
const t = new URLSearchParams(window.location.search), e = t.get("default-template"), n = t.get("master"), c = e ? parseInt(e) : 0, l = c >= 1 && c <= f ? c : 0;
|
|
37
|
+
if (!l && !n)
|
|
38
|
+
return await a();
|
|
39
|
+
const d = `/stripo/default-template/${l}`, { data: u } = await s(d), o = typeof u == "string" ? JSON.parse(u) : u;
|
|
40
|
+
return !o || typeof o != "object" || !("html" in o) || !("css" in o) ? await a() : o;
|
|
38
41
|
} catch (t) {
|
|
39
|
-
return r(t, "Failed to fetch default template"),
|
|
42
|
+
return r(t, "Failed to fetch default template"), a();
|
|
40
43
|
}
|
|
41
44
|
},
|
|
42
45
|
getSyncModulesStatus: async () => {
|
|
@@ -49,7 +52,7 @@ const l = () => ({
|
|
|
49
52
|
},
|
|
50
53
|
updateSyncModule: async (t) => {
|
|
51
54
|
try {
|
|
52
|
-
return await
|
|
55
|
+
return await i(`/stripo/stripo-modules/${t.moduleId}/update`), !0;
|
|
53
56
|
} catch (e) {
|
|
54
57
|
return r(e, "Failed to update sync module"), !1;
|
|
55
58
|
}
|
|
@@ -57,16 +60,16 @@ const l = () => ({
|
|
|
57
60
|
getSyncModule: async (t) => {
|
|
58
61
|
try {
|
|
59
62
|
const { data: e } = await s(`/stripo/stripo-modules/${t}/get`);
|
|
60
|
-
return Array.isArray(e == null ? void 0 : e.unsubscriptionPreferencePages) ? e :
|
|
63
|
+
return Array.isArray(e == null ? void 0 : e.unsubscriptionPreferencePages) ? e : p();
|
|
61
64
|
} catch (e) {
|
|
62
|
-
return r(e, "Failed to get sync module"),
|
|
65
|
+
return r(e, "Failed to get sync module"), p();
|
|
63
66
|
}
|
|
64
67
|
},
|
|
65
68
|
setSyncModuleUnsubscriptionPages: async (t) => {
|
|
66
69
|
if (t.length === 0)
|
|
67
70
|
return !0;
|
|
68
71
|
try {
|
|
69
|
-
return await
|
|
72
|
+
return await i("/stripo/stripo-modules/set-unsubscription-preference-pages", t), !0;
|
|
70
73
|
} catch (e) {
|
|
71
74
|
return r(e, "Failed to set unsubscription preference pages"), !1;
|
|
72
75
|
}
|
|
@@ -74,5 +77,5 @@ const l = () => ({
|
|
|
74
77
|
};
|
|
75
78
|
};
|
|
76
79
|
export {
|
|
77
|
-
|
|
80
|
+
E as useStripoApi
|
|
78
81
|
};
|
|
@@ -419,8 +419,6 @@ export declare const FeaturesSchema: v.ObjectSchema<{
|
|
|
419
419
|
readonly reusableRecommendationStrategy: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
420
420
|
/** Convert linkless legacy unsubscribe blocks into text blocks and warn with a modal (opt-in) */
|
|
421
421
|
readonly legacyUnsubscribeConversion: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
422
|
-
/** Disable every save path and the unsaved-changes signal; read at mount only. */
|
|
423
|
-
readonly readonly: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
424
422
|
/** Items block: Recommendation-style price formatting (root currency-* attrs, raw price tags). Released dark. */
|
|
425
423
|
readonly itemsPriceFormatting: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
426
424
|
/** Warn on save when the design carries an Insider unsubscribe link or code (host sets true for SFMC accounts) */
|
|
@@ -848,8 +846,6 @@ export declare const GuidoConfigSchema: v.ObjectSchema<{
|
|
|
848
846
|
readonly reusableRecommendationStrategy: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
849
847
|
/** Convert linkless legacy unsubscribe blocks into text blocks and warn with a modal (opt-in) */
|
|
850
848
|
readonly legacyUnsubscribeConversion: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
851
|
-
/** Disable every save path and the unsaved-changes signal; read at mount only. */
|
|
852
|
-
readonly readonly: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
853
849
|
/** Items block: Recommendation-style price formatting (root currency-* attrs, raw price tags). Released dark. */
|
|
854
850
|
readonly itemsPriceFormatting: v.OptionalSchema<v.BooleanSchema<undefined>, false>;
|
|
855
851
|
/** Warn on save when the design carries an Insider unsubscribe link or code (host sets true for SFMC accounts) */
|
|
@@ -107,7 +107,6 @@ export declare const useConfig: () => {
|
|
|
107
107
|
allowSaveWithErrors: boolean;
|
|
108
108
|
reusableRecommendationStrategy: boolean;
|
|
109
109
|
legacyUnsubscribeConversion: boolean;
|
|
110
|
-
readonly: boolean;
|
|
111
110
|
itemsPriceFormatting: boolean;
|
|
112
111
|
blockUnsubscribeLinks: boolean;
|
|
113
112
|
};
|
|
@@ -252,7 +251,6 @@ export declare const useConfig: () => {
|
|
|
252
251
|
allowSaveWithErrors: boolean;
|
|
253
252
|
reusableRecommendationStrategy: boolean;
|
|
254
253
|
legacyUnsubscribeConversion: boolean;
|
|
255
|
-
readonly: boolean;
|
|
256
254
|
itemsPriceFormatting: boolean;
|
|
257
255
|
blockUnsubscribeLinks: boolean;
|
|
258
256
|
} | null>;
|
|
@@ -112,7 +112,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
112
112
|
allowSaveWithErrors: boolean;
|
|
113
113
|
reusableRecommendationStrategy: boolean;
|
|
114
114
|
legacyUnsubscribeConversion: boolean;
|
|
115
|
-
readonly: boolean;
|
|
116
115
|
itemsPriceFormatting: boolean;
|
|
117
116
|
blockUnsubscribeLinks: boolean;
|
|
118
117
|
};
|
|
@@ -263,7 +262,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
263
262
|
allowSaveWithErrors: boolean;
|
|
264
263
|
reusableRecommendationStrategy: boolean;
|
|
265
264
|
legacyUnsubscribeConversion: boolean;
|
|
266
|
-
readonly: boolean;
|
|
267
265
|
itemsPriceFormatting: boolean;
|
|
268
266
|
blockUnsubscribeLinks: boolean;
|
|
269
267
|
};
|
|
@@ -414,7 +412,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
414
412
|
allowSaveWithErrors: boolean;
|
|
415
413
|
reusableRecommendationStrategy: boolean;
|
|
416
414
|
legacyUnsubscribeConversion: boolean;
|
|
417
|
-
readonly: boolean;
|
|
418
415
|
itemsPriceFormatting: boolean;
|
|
419
416
|
blockUnsubscribeLinks: boolean;
|
|
420
417
|
};
|
|
@@ -565,7 +562,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
565
562
|
allowSaveWithErrors: boolean;
|
|
566
563
|
reusableRecommendationStrategy: boolean;
|
|
567
564
|
legacyUnsubscribeConversion: boolean;
|
|
568
|
-
readonly: boolean;
|
|
569
565
|
itemsPriceFormatting: boolean;
|
|
570
566
|
blockUnsubscribeLinks: boolean;
|
|
571
567
|
};
|
|
@@ -716,7 +712,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
716
712
|
allowSaveWithErrors: boolean;
|
|
717
713
|
reusableRecommendationStrategy: boolean;
|
|
718
714
|
legacyUnsubscribeConversion: boolean;
|
|
719
|
-
readonly: boolean;
|
|
720
715
|
itemsPriceFormatting: boolean;
|
|
721
716
|
blockUnsubscribeLinks: boolean;
|
|
722
717
|
};
|
|
@@ -867,7 +862,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
867
862
|
allowSaveWithErrors: boolean;
|
|
868
863
|
reusableRecommendationStrategy: boolean;
|
|
869
864
|
legacyUnsubscribeConversion: boolean;
|
|
870
|
-
readonly: boolean;
|
|
871
865
|
itemsPriceFormatting: boolean;
|
|
872
866
|
blockUnsubscribeLinks: boolean;
|
|
873
867
|
};
|
|
@@ -1018,7 +1012,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
1018
1012
|
allowSaveWithErrors: boolean;
|
|
1019
1013
|
reusableRecommendationStrategy: boolean;
|
|
1020
1014
|
legacyUnsubscribeConversion: boolean;
|
|
1021
|
-
readonly: boolean;
|
|
1022
1015
|
itemsPriceFormatting: boolean;
|
|
1023
1016
|
blockUnsubscribeLinks: boolean;
|
|
1024
1017
|
};
|
|
@@ -1169,7 +1162,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
1169
1162
|
allowSaveWithErrors: boolean;
|
|
1170
1163
|
reusableRecommendationStrategy: boolean;
|
|
1171
1164
|
legacyUnsubscribeConversion: boolean;
|
|
1172
|
-
readonly: boolean;
|
|
1173
1165
|
itemsPriceFormatting: boolean;
|
|
1174
1166
|
blockUnsubscribeLinks: boolean;
|
|
1175
1167
|
};
|
|
@@ -1320,7 +1312,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
1320
1312
|
allowSaveWithErrors: boolean;
|
|
1321
1313
|
reusableRecommendationStrategy: boolean;
|
|
1322
1314
|
legacyUnsubscribeConversion: boolean;
|
|
1323
|
-
readonly: boolean;
|
|
1324
1315
|
itemsPriceFormatting: boolean;
|
|
1325
1316
|
blockUnsubscribeLinks: boolean;
|
|
1326
1317
|
};
|
|
@@ -1471,7 +1462,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
1471
1462
|
allowSaveWithErrors: boolean;
|
|
1472
1463
|
reusableRecommendationStrategy: boolean;
|
|
1473
1464
|
legacyUnsubscribeConversion: boolean;
|
|
1474
|
-
readonly: boolean;
|
|
1475
1465
|
itemsPriceFormatting: boolean;
|
|
1476
1466
|
blockUnsubscribeLinks: boolean;
|
|
1477
1467
|
};
|
|
@@ -1622,7 +1612,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
1622
1612
|
allowSaveWithErrors: boolean;
|
|
1623
1613
|
reusableRecommendationStrategy: boolean;
|
|
1624
1614
|
legacyUnsubscribeConversion: boolean;
|
|
1625
|
-
readonly: boolean;
|
|
1626
1615
|
itemsPriceFormatting: boolean;
|
|
1627
1616
|
blockUnsubscribeLinks: boolean;
|
|
1628
1617
|
};
|
|
@@ -1773,7 +1762,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
1773
1762
|
allowSaveWithErrors: boolean;
|
|
1774
1763
|
reusableRecommendationStrategy: boolean;
|
|
1775
1764
|
legacyUnsubscribeConversion: boolean;
|
|
1776
|
-
readonly: boolean;
|
|
1777
1765
|
itemsPriceFormatting: boolean;
|
|
1778
1766
|
blockUnsubscribeLinks: boolean;
|
|
1779
1767
|
};
|
|
@@ -1924,7 +1912,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
1924
1912
|
allowSaveWithErrors: boolean;
|
|
1925
1913
|
reusableRecommendationStrategy: boolean;
|
|
1926
1914
|
legacyUnsubscribeConversion: boolean;
|
|
1927
|
-
readonly: boolean;
|
|
1928
1915
|
itemsPriceFormatting: boolean;
|
|
1929
1916
|
blockUnsubscribeLinks: boolean;
|
|
1930
1917
|
};
|
|
@@ -2075,7 +2062,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
2075
2062
|
allowSaveWithErrors: boolean;
|
|
2076
2063
|
reusableRecommendationStrategy: boolean;
|
|
2077
2064
|
legacyUnsubscribeConversion: boolean;
|
|
2078
|
-
readonly: boolean;
|
|
2079
2065
|
itemsPriceFormatting: boolean;
|
|
2080
2066
|
blockUnsubscribeLinks: boolean;
|
|
2081
2067
|
};
|
|
@@ -2226,7 +2212,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
2226
2212
|
allowSaveWithErrors: boolean;
|
|
2227
2213
|
reusableRecommendationStrategy: boolean;
|
|
2228
2214
|
legacyUnsubscribeConversion: boolean;
|
|
2229
|
-
readonly: boolean;
|
|
2230
2215
|
itemsPriceFormatting: boolean;
|
|
2231
2216
|
blockUnsubscribeLinks: boolean;
|
|
2232
2217
|
};
|
|
@@ -2377,7 +2362,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
2377
2362
|
allowSaveWithErrors: boolean;
|
|
2378
2363
|
reusableRecommendationStrategy: boolean;
|
|
2379
2364
|
legacyUnsubscribeConversion: boolean;
|
|
2380
|
-
readonly: boolean;
|
|
2381
2365
|
itemsPriceFormatting: boolean;
|
|
2382
2366
|
blockUnsubscribeLinks: boolean;
|
|
2383
2367
|
};
|
|
@@ -2528,7 +2512,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
2528
2512
|
allowSaveWithErrors: boolean;
|
|
2529
2513
|
reusableRecommendationStrategy: boolean;
|
|
2530
2514
|
legacyUnsubscribeConversion: boolean;
|
|
2531
|
-
readonly: boolean;
|
|
2532
2515
|
itemsPriceFormatting: boolean;
|
|
2533
2516
|
blockUnsubscribeLinks: boolean;
|
|
2534
2517
|
};
|
|
@@ -2691,7 +2674,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
2691
2674
|
allowSaveWithErrors: boolean;
|
|
2692
2675
|
reusableRecommendationStrategy: boolean;
|
|
2693
2676
|
legacyUnsubscribeConversion: boolean;
|
|
2694
|
-
readonly: boolean;
|
|
2695
2677
|
itemsPriceFormatting: boolean;
|
|
2696
2678
|
blockUnsubscribeLinks: boolean;
|
|
2697
2679
|
};
|
|
@@ -2842,7 +2824,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
2842
2824
|
allowSaveWithErrors: boolean;
|
|
2843
2825
|
reusableRecommendationStrategy: boolean;
|
|
2844
2826
|
legacyUnsubscribeConversion: boolean;
|
|
2845
|
-
readonly: boolean;
|
|
2846
2827
|
itemsPriceFormatting: boolean;
|
|
2847
2828
|
blockUnsubscribeLinks: boolean;
|
|
2848
2829
|
};
|
|
@@ -2993,7 +2974,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
2993
2974
|
allowSaveWithErrors: boolean;
|
|
2994
2975
|
reusableRecommendationStrategy: boolean;
|
|
2995
2976
|
legacyUnsubscribeConversion: boolean;
|
|
2996
|
-
readonly: boolean;
|
|
2997
2977
|
itemsPriceFormatting: boolean;
|
|
2998
2978
|
blockUnsubscribeLinks: boolean;
|
|
2999
2979
|
};
|
|
@@ -3146,7 +3126,6 @@ export declare const useConfigStore: import("pinia").StoreDefinition<"guido-conf
|
|
|
3146
3126
|
allowSaveWithErrors: boolean;
|
|
3147
3127
|
reusableRecommendationStrategy: boolean;
|
|
3148
3128
|
legacyUnsubscribeConversion: boolean;
|
|
3149
|
-
readonly: boolean;
|
|
3150
3129
|
itemsPriceFormatting: boolean;
|
|
3151
3130
|
blockUnsubscribeLinks: boolean;
|
|
3152
3131
|
};
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { ColorVisionDeficiency } from '@@/Types/api/accessibility-api';
|
|
2
|
+
type EditorReadiness = {
|
|
3
|
+
loadingStatus: boolean;
|
|
4
|
+
isStripoInitialized: boolean;
|
|
5
|
+
};
|
|
2
6
|
export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEditor", {
|
|
3
7
|
loadingStatus: boolean;
|
|
4
8
|
isCodeEditorOpen: boolean;
|
|
@@ -17,6 +21,7 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
|
|
|
17
21
|
syncModulesEnabled: boolean;
|
|
18
22
|
trackIdSessionFloor: number;
|
|
19
23
|
}, {
|
|
24
|
+
isEditorUnavailable: (state: EditorReadiness) => boolean;
|
|
20
25
|
isEditorToolbarVisible: (state: {
|
|
21
26
|
loadingStatus: boolean;
|
|
22
27
|
isCodeEditorOpen: boolean;
|
|
@@ -473,3 +478,4 @@ export declare const useEditorStore: import("pinia").StoreDefinition<"guidoEdito
|
|
|
473
478
|
trackIdSessionFloor: number;
|
|
474
479
|
}>) => boolean;
|
|
475
480
|
}, {}>;
|
|
481
|
+
export {};
|
package/dist/stores/editor.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineStore as
|
|
2
|
-
const
|
|
1
|
+
import { defineStore as s } from "pinia";
|
|
2
|
+
const e = (i) => i.loadingStatus || !i.isStripoInitialized, n = s("guidoEditor", {
|
|
3
3
|
state: () => ({
|
|
4
4
|
loadingStatus: !0,
|
|
5
5
|
isCodeEditorOpen: !1,
|
|
@@ -24,25 +24,26 @@ const o = e("guidoEditor", {
|
|
|
24
24
|
trackIdSessionFloor: 0
|
|
25
25
|
}),
|
|
26
26
|
getters: {
|
|
27
|
+
isEditorUnavailable: e,
|
|
27
28
|
// Middle Slot
|
|
28
29
|
isEditorToolbarVisible: (i) => !i.isVersionHistoryOpen && !i.isPreviewModeOpen && !i.isAccessibilityTestingOpen,
|
|
29
|
-
isUndoButtonDisabled: (i) => i
|
|
30
|
-
isRedoButtonDisabled: (i) => i
|
|
31
|
-
isCodeEditorButtonDisabled: (i) => i
|
|
32
|
-
isPreviewButtonDisabled: (i) => i
|
|
33
|
-
isViewOptionsDisabled: (i) => i
|
|
30
|
+
isUndoButtonDisabled: (i) => e(i) || i.isPreviewModeOpen,
|
|
31
|
+
isRedoButtonDisabled: (i) => e(i) || i.isPreviewModeOpen,
|
|
32
|
+
isCodeEditorButtonDisabled: (i) => e(i) || i.isPreviewModeOpen,
|
|
33
|
+
isPreviewButtonDisabled: (i) => e(i),
|
|
34
|
+
isViewOptionsDisabled: (i) => e(i) || i.isPreviewModeOpen,
|
|
34
35
|
// Right Slot
|
|
35
36
|
isNormalMode: (i) => !i.isVersionHistoryOpen && !i.isAccessibilityTestingOpen,
|
|
36
|
-
isVersionHistoryButtonDisabled: (i) => i
|
|
37
|
-
isExportButtonDisabled: (i) => i
|
|
38
|
-
isSaveAsButtonDisabled: (i) => i
|
|
39
|
-
isTestButtonDisabled: (i) => i
|
|
40
|
-
isSaveButtonDisabled: (i) => i
|
|
37
|
+
isVersionHistoryButtonDisabled: (i) => e(i) || i.isPreviewModeOpen,
|
|
38
|
+
isExportButtonDisabled: (i) => e(i) || i.isVersionHistoryOpen,
|
|
39
|
+
isSaveAsButtonDisabled: (i) => e(i) || i.isVersionHistoryOpen,
|
|
40
|
+
isTestButtonDisabled: (i) => e(i) || i.isVersionHistoryOpen,
|
|
41
|
+
isSaveButtonDisabled: (i) => e(i) || i.isVersionHistoryOpen || i.isPreviewModeOpen || i.isAccessibilityTestingOpen,
|
|
41
42
|
// Accessibility Test is absent on purpose: it only simulates, but its Apply / Auto-tune
|
|
42
43
|
// edit the document, so pausing autosave there would lose those fixes.
|
|
43
|
-
isInSaveableState: (i) => !i
|
|
44
|
+
isInSaveableState: (i) => !e(i) && !i.isVersionHistoryOpen && !i.isPreviewModeOpen && !i.isCodeEditorOpen
|
|
44
45
|
}
|
|
45
46
|
});
|
|
46
47
|
export {
|
|
47
|
-
|
|
48
|
+
n as useEditorStore
|
|
48
49
|
};
|
|
@@ -1,129 +1,128 @@
|
|
|
1
|
-
import { isNewPriceFormatRoot as
|
|
2
|
-
import { productPairs as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
const q = {
|
|
1
|
+
import { isNewPriceFormatRoot as W, ITEMS_PRICE_FORMAT_ATTR as w, currencyPositionFromLocation as V, ITEMS_CURRENCY_ATTR as x, isCustomCurrencySymbol as G } from "../extensions/Blocks/Items/constants/currency.js";
|
|
2
|
+
import { productPairs as N } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
3
|
+
import { preserveTextStyles as H } from "./preserveTextStyles.js";
|
|
4
|
+
import { protectTableText as Y, restoreTableText as B } from "./protectTableText.js";
|
|
5
|
+
import { unwrapProductNameLinks as X } from "./unwrapProductNameLink.js";
|
|
6
|
+
const D = {
|
|
8
7
|
CART_ITEMS: "ins_apr",
|
|
9
8
|
BROWSED_ITEMS: "browsed_item",
|
|
10
9
|
PURCHASED_ITEMS: "purchased_item"
|
|
11
|
-
},
|
|
12
|
-
function
|
|
13
|
-
let
|
|
14
|
-
for (;
|
|
15
|
-
|
|
16
|
-
return
|
|
10
|
+
}, U = (r) => r.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
|
|
11
|
+
function v(r, _, u) {
|
|
12
|
+
let l = _;
|
|
13
|
+
for (; l > 0 && /\s/.test(r[l - 1]); )
|
|
14
|
+
l -= 1;
|
|
15
|
+
return u.some((p) => r.endsWith(p, l));
|
|
17
16
|
}
|
|
18
|
-
const
|
|
19
|
-
function
|
|
20
|
-
var
|
|
21
|
-
const
|
|
22
|
-
for (let
|
|
23
|
-
(
|
|
17
|
+
const j = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
|
|
18
|
+
function Q(r, _) {
|
|
19
|
+
var l;
|
|
20
|
+
const u = r.ownerDocument.createTreeWalker(r, NodeFilter.SHOW_COMMENT);
|
|
21
|
+
for (let p = u.nextNode(); p; p = u.nextNode())
|
|
22
|
+
(l = p.nodeValue) != null && l.includes("[if mso]") && (p.nodeValue = p.nodeValue.replace(j, (I, E) => `${E}href="${_}"`));
|
|
24
23
|
}
|
|
25
|
-
function
|
|
24
|
+
function z(r) {
|
|
26
25
|
return {
|
|
27
26
|
isFormatted: r.getAttribute("data-formated") === "true",
|
|
28
27
|
isSinglePrice: r.getAttribute("data-single_price") === "true",
|
|
29
|
-
currencyPosition: r.getAttribute(
|
|
30
|
-
configuredSymbol: (r.getAttribute(
|
|
28
|
+
currencyPosition: r.getAttribute(x.POSITION) || "before",
|
|
29
|
+
configuredSymbol: (r.getAttribute(x.SYMBOL) || "").trim()
|
|
31
30
|
};
|
|
32
31
|
}
|
|
33
|
-
function
|
|
32
|
+
function J(r) {
|
|
34
33
|
return {
|
|
35
34
|
isFormatted: !1,
|
|
36
|
-
isSinglePrice: r.getAttribute(
|
|
37
|
-
currencyPosition:
|
|
38
|
-
r.getAttribute(
|
|
35
|
+
isSinglePrice: r.getAttribute(w.SINGLE_PRICE) === "true",
|
|
36
|
+
currencyPosition: V(
|
|
37
|
+
r.getAttribute(w.ALIGNMENT) ?? void 0
|
|
39
38
|
),
|
|
40
|
-
configuredSymbol: (r.getAttribute(
|
|
39
|
+
configuredSymbol: (r.getAttribute(w.SYMBOL) || "").trim()
|
|
41
40
|
};
|
|
42
41
|
}
|
|
43
|
-
function
|
|
44
|
-
const { isFormatted:
|
|
42
|
+
function K(r, _, u) {
|
|
43
|
+
const { isFormatted: l, isSinglePrice: p, currencyPosition: I, configuredSymbol: E } = u;
|
|
45
44
|
let y;
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
let
|
|
49
|
-
return
|
|
45
|
+
p ? y = l ? r.SINGLE_PRICE_FORMATTED : r.SINGLE_PRICE : y = l ? r.PRICE_FORMATTED : r.PRICE;
|
|
46
|
+
const b = r.CURRENCY;
|
|
47
|
+
let S = `{{${y}_${_}}}`, o = "";
|
|
48
|
+
return G(E) ? o = E : b && (o = `{{${b}_${_}}}`), o && (S = I === "after" ? `${S} ${o}` : `${o} ${S}`), S;
|
|
50
49
|
}
|
|
51
|
-
function
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
Object.entries(
|
|
56
|
-
|
|
57
|
-
const
|
|
50
|
+
function nt(r) {
|
|
51
|
+
const _ = U(Y(r)), u = new DOMParser().parseFromString(_, "text/html");
|
|
52
|
+
X(u);
|
|
53
|
+
const l = N.PAIRS_FOR_EXTENSION;
|
|
54
|
+
Object.entries(l).forEach(([o, R]) => {
|
|
55
|
+
u.querySelectorAll(".ins-product-td").forEach((n) => {
|
|
56
|
+
const m = n.getAttribute("data-number") || "1", C = n.getAttribute("data-type") || "CART_ITEMS";
|
|
58
57
|
n.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
|
|
59
|
-
var
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
58
|
+
var h, L, k, O;
|
|
59
|
+
const P = t.getAttribute("data-type") || C, c = t.getAttribute("data-number") || m, d = R[P];
|
|
60
|
+
if (d)
|
|
62
61
|
switch (o) {
|
|
63
62
|
case "imageSrc": {
|
|
64
63
|
let e = null, i = null;
|
|
65
64
|
if (t.tagName === "IMG" ? (e = t, i = e.closest("a")) : (e = t.querySelector("img"), i = t.querySelector("a") || t.closest("a")), !e)
|
|
66
65
|
break;
|
|
67
|
-
const
|
|
68
|
-
if (
|
|
69
|
-
const
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
return
|
|
66
|
+
const A = d.DEFAULT, a = d.ATTR;
|
|
67
|
+
if (A && e.src) {
|
|
68
|
+
const f = e.src;
|
|
69
|
+
A.some((F) => {
|
|
70
|
+
const T = F.split("/").pop() || "", q = f.split("/").pop() || "";
|
|
71
|
+
return f.includes(F) || f.includes(T) || q === T;
|
|
73
72
|
}) && (e.src = `{{${a}_${c}}}`);
|
|
74
73
|
}
|
|
75
|
-
const s = (
|
|
74
|
+
const s = (L = (h = l.name) == null ? void 0 : h[P]) == null ? void 0 : L.ATTR;
|
|
76
75
|
if (s && e.setAttribute("alt", `{{${s}_${c}}}`), i) {
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
79
|
-
const
|
|
80
|
-
(
|
|
76
|
+
const f = (k = l.itemLink) == null ? void 0 : k[P];
|
|
77
|
+
if (f) {
|
|
78
|
+
const M = f.HREF, F = f.DEFAULT_HREF || "#!", T = i.href;
|
|
79
|
+
(T === "#" || T === "" || T.endsWith("#!") || T.endsWith(F) || T === `${window.location.href}${F}` || !T || T === window.location.href) && (i.href = `{{${M}_${c}}}`);
|
|
81
80
|
}
|
|
82
81
|
}
|
|
83
82
|
break;
|
|
84
83
|
}
|
|
85
84
|
case "name": {
|
|
86
|
-
const e =
|
|
87
|
-
t.textContent && (t.innerHTML =
|
|
85
|
+
const e = d, i = e.ATTR, A = e.DEFAULT_HREF || "#!", a = e.HREF;
|
|
86
|
+
t.textContent && (t.innerHTML = H(t, `{{${i}_${c}}}`));
|
|
88
87
|
const s = t.closest("a") || (t.tagName === "A" ? t : null);
|
|
89
88
|
if (s && a) {
|
|
90
|
-
const
|
|
91
|
-
(
|
|
89
|
+
const f = s.href, M = `${window.location.href}${A}`;
|
|
90
|
+
(f === M || f.endsWith(A)) && (s.href = `{{${a}_${c}}}`);
|
|
92
91
|
}
|
|
93
92
|
break;
|
|
94
93
|
}
|
|
95
94
|
case "price":
|
|
96
95
|
case "originalPrice": {
|
|
97
|
-
const e =
|
|
98
|
-
t.innerHTML =
|
|
96
|
+
const e = d, i = W(n) ? J(n) : z(t);
|
|
97
|
+
t.innerHTML = H(t, K(e, c, i));
|
|
99
98
|
break;
|
|
100
99
|
}
|
|
101
100
|
case "quantity": {
|
|
102
|
-
const e =
|
|
103
|
-
a &&
|
|
101
|
+
const e = d, i = e.ATTR, A = [e.DEFAULT, ...e.LEGACY_DEFAULTS], a = (O = t.textContent) == null ? void 0 : O.trim();
|
|
102
|
+
a && A.includes(a) && (t.innerHTML = H(t, `{{${i}_${c}}}`));
|
|
104
103
|
break;
|
|
105
104
|
}
|
|
106
105
|
case "button": {
|
|
107
|
-
const e =
|
|
106
|
+
const e = d, i = e.HREF, A = e.DEFAULT_HREF || "#!", a = t.tagName === "A" ? t : t.querySelector("a");
|
|
108
107
|
if (a) {
|
|
109
|
-
const s = a.href || "",
|
|
110
|
-
(s === "" || s === "#" || s ===
|
|
108
|
+
const s = a.href || "", f = `${window.location.href}${A}`;
|
|
109
|
+
(s === "" || s === "#" || s === f || s.endsWith(A) || s.endsWith("#!") || s === window.location.href) && (a.href = `{{${i}_${c}}}`);
|
|
111
110
|
}
|
|
112
|
-
|
|
111
|
+
Q(t, `{{${i}_${c}}}`);
|
|
113
112
|
break;
|
|
114
113
|
}
|
|
115
114
|
case "itemLink": {
|
|
116
|
-
const e =
|
|
115
|
+
const e = d, i = e.HREF, A = e.DEFAULT_HREF || "#!", a = t;
|
|
117
116
|
if (a.href) {
|
|
118
|
-
const s = a.href,
|
|
119
|
-
(s ===
|
|
117
|
+
const s = a.href, f = `${window.location.href}${A}`;
|
|
118
|
+
(s === f || s.endsWith(A)) && (a.href = `{{${i}_${c}}}`);
|
|
120
119
|
}
|
|
121
120
|
break;
|
|
122
121
|
}
|
|
123
122
|
default: {
|
|
124
|
-
if ("ATTR" in
|
|
125
|
-
const e =
|
|
126
|
-
t.textContent && (t.innerHTML =
|
|
123
|
+
if ("ATTR" in d) {
|
|
124
|
+
const e = d.ATTR;
|
|
125
|
+
t.textContent && (t.innerHTML = H(t, `{{${e}_${c}}}`));
|
|
127
126
|
}
|
|
128
127
|
break;
|
|
129
128
|
}
|
|
@@ -131,49 +130,40 @@ function at(r) {
|
|
|
131
130
|
});
|
|
132
131
|
});
|
|
133
132
|
});
|
|
134
|
-
const
|
|
135
|
-
` : ""
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
number: _
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
let E = L + p.documentElement.outerHTML;
|
|
146
|
-
y.reverse().forEach(({ outerHtml: o, type: T, number: _ }) => {
|
|
147
|
-
const n = q[T], S = n ? `${n}_total_product_kind` : "";
|
|
148
|
-
if (S) {
|
|
149
|
-
const b = parseInt(_) - 1, c = `${`{% if ${S} > ${b} %}`}${o}{% endif %}`;
|
|
150
|
-
E = E.replace(o, v(c));
|
|
151
|
-
}
|
|
133
|
+
const p = _.match(/<!DOCTYPE[^>]*>/i), I = p ? `${p[0]}
|
|
134
|
+
` : "";
|
|
135
|
+
u.querySelectorAll(".ins-product-td").forEach((o) => {
|
|
136
|
+
const R = o.getAttribute("data-type") || "CART_ITEMS", $ = D[R];
|
|
137
|
+
if (!$)
|
|
138
|
+
return;
|
|
139
|
+
const n = parseInt(o.getAttribute("data-number") || "1") - 1;
|
|
140
|
+
o.before(u.createComment(`{% if ${$}_total_product_kind > ${n} %}`)), o.after(u.createComment("{% endif %}"));
|
|
152
141
|
});
|
|
153
|
-
|
|
154
|
-
|
|
142
|
+
let E = I + u.documentElement.outerHTML;
|
|
143
|
+
const y = u.querySelectorAll('[product-attr="originalPrice"][data-type]'), b = /* @__PURE__ */ new Map(), S = /* @__PURE__ */ new Set();
|
|
144
|
+
return y.forEach((o) => {
|
|
155
145
|
var t;
|
|
156
|
-
const
|
|
157
|
-
if (!
|
|
146
|
+
const R = o.getAttribute("data-number"), $ = o.getAttribute("data-type");
|
|
147
|
+
if (!R || !D[$])
|
|
158
148
|
return;
|
|
159
149
|
const n = o.closest(".product-original-price-class");
|
|
160
|
-
if (!n ||
|
|
150
|
+
if (!n || S.has(n))
|
|
161
151
|
return;
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
}),
|
|
166
|
-
if (n.includes("{% if") ||
|
|
152
|
+
S.add(n);
|
|
153
|
+
const m = n.outerHTML, C = (t = o.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), g = b.get(m) ?? { number: R, type: $, wrap: [] };
|
|
154
|
+
g.wrap.push(C !== "false"), b.set(m, g);
|
|
155
|
+
}), b.forEach(({ number: o, type: R, wrap: $ }, n) => {
|
|
156
|
+
if (n.includes("{% if") || !$.some(Boolean))
|
|
167
157
|
return;
|
|
168
|
-
const
|
|
169
|
-
let
|
|
170
|
-
for (;
|
|
171
|
-
const
|
|
172
|
-
|
|
158
|
+
const m = N.PAIRS_FOR_EXTENSION.price[R].PRICE, C = N.PAIRS_FOR_EXTENSION.originalPrice[R].PRICE, g = `{% if ${m}_${o} != ${C}_${o} %}`, t = [g, U(g)];
|
|
159
|
+
let P = "", c = 0, d = 0, h = E.indexOf(n);
|
|
160
|
+
for (; h !== -1; ) {
|
|
161
|
+
const L = $[d] === !0 && !v(E, h, t);
|
|
162
|
+
P += E.slice(c, h) + (L ? `${g}${n}{% endif %}` : n), c = h + n.length, d += 1, h = E.indexOf(n, c);
|
|
173
163
|
}
|
|
174
|
-
E =
|
|
175
|
-
}),
|
|
164
|
+
E = P + E.slice(c);
|
|
165
|
+
}), B(E.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}"));
|
|
176
166
|
}
|
|
177
167
|
export {
|
|
178
|
-
|
|
168
|
+
nt as pairProductVariables
|
|
179
169
|
};
|