@useinsider/guido 3.21.2-beta.e1315e9 → 3.21.2-beta.e89b843
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 +1 -0
- package/dist/@types/config/schemas.js +41 -39
- package/dist/@types/display-condition.js +25 -0
- package/dist/components/Guido.vue.js +6 -6
- package/dist/components/Guido.vue2.js +81 -79
- package/dist/components/organisms/display-conditions/CodeEditorField.vue.js +20 -0
- package/dist/components/organisms/display-conditions/CodeEditorField.vue2.js +30 -0
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.js +30 -0
- package/dist/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue2.js +71 -0
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.js +34 -0
- package/dist/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue2.js +57 -0
- package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue.js +17 -0
- package/dist/components/organisms/display-conditions/DisplayConditionsHost.vue2.js +22 -0
- package/dist/composables/useBlocksConfig.js +32 -24
- package/dist/composables/useDisplayConditions.js +102 -0
- package/dist/enums/academy.js +1 -0
- package/dist/enums/display-condition.js +12 -0
- package/dist/extensions/DisplayConditions/bridge.js +17 -0
- package/dist/extensions/DisplayConditions/constants.js +17 -0
- package/dist/extensions/DisplayConditions/control.js +178 -0
- package/dist/extensions/DisplayConditions/display-conditions.css.js +201 -0
- package/dist/extensions/DisplayConditions/extension.js +28 -0
- package/dist/extensions/DisplayConditions/iconsRegistry.js +20 -0
- package/dist/extensions/DisplayConditions/library.js +27 -0
- package/dist/extensions/DisplayConditions/settingsPanel.js +17 -0
- package/dist/guido.css +1 -1
- package/dist/node_modules/@stripoinc/ui-editor-extensions/dist/esm/index.js +93 -92
- package/dist/node_modules/valibot/dist/index.js +297 -261
- package/dist/services/displayConditionApi.js +39 -0
- package/dist/src/@types/config/schemas.d.ts +4 -0
- package/dist/src/@types/display-condition.d.ts +59 -0
- package/dist/src/components/organisms/display-conditions/CodeEditorField.vue.d.ts +43 -0
- package/dist/src/components/organisms/display-conditions/DisplayConditionCreateDrawer.vue.d.ts +2 -0
- package/dist/src/components/organisms/display-conditions/DisplayConditionSelectDrawer.vue.d.ts +2 -0
- package/dist/src/components/organisms/display-conditions/DisplayConditionsHost.vue.d.ts +2 -0
- package/dist/src/composables/useConfig.d.ts +2 -0
- package/dist/src/composables/useDisplayConditions.d.ts +16 -0
- package/dist/src/enums/academy.d.ts +1 -0
- package/dist/src/enums/display-condition.d.ts +15 -0
- package/dist/src/extensions/DisplayConditions/bridge.d.ts +6 -0
- package/dist/src/extensions/DisplayConditions/constants.d.ts +14 -0
- package/dist/src/extensions/DisplayConditions/control.d.ts +23 -0
- package/dist/src/extensions/DisplayConditions/extension.d.ts +2 -0
- package/dist/src/extensions/DisplayConditions/iconsRegistry.d.ts +4 -0
- package/dist/src/extensions/DisplayConditions/library.d.ts +8 -0
- package/dist/src/extensions/DisplayConditions/settingsPanel.d.ts +5 -0
- package/dist/src/mock/api/display-conditions.d.ts +2 -0
- package/dist/src/services/displayConditionApi.d.ts +8 -0
- package/dist/src/stores/config.d.ts +166 -0
- package/dist/src/stores/display-condition.d.ts +81 -0
- package/dist/src/utils/displayCondition.d.ts +10 -0
- package/dist/src/utils/protectTableText.d.ts +2 -0
- package/dist/stores/config.js +13 -6
- package/dist/stores/display-condition.js +28 -0
- package/dist/utils/displayCondition.js +26 -0
- package/dist/utils/pairProductVariables.js +30 -29
- package/dist/utils/protectTableText.js +22 -0
- package/package.json +1 -1
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import type { AppliedDisplayCondition, SavedDisplayCondition } from '@@/Types/display-condition';
|
|
2
|
+
export type DisplayConditionView = 'none' | 'create' | 'select';
|
|
3
|
+
export type DisplayConditionListStatus = 'idle' | 'loading' | 'loaded' | 'error';
|
|
4
|
+
interface DisplayConditionState {
|
|
5
|
+
view: DisplayConditionView;
|
|
6
|
+
editing: AppliedDisplayCondition | null;
|
|
7
|
+
list: SavedDisplayCondition[];
|
|
8
|
+
listStatus: DisplayConditionListStatus;
|
|
9
|
+
pendingDelete: SavedDisplayCondition | null;
|
|
10
|
+
}
|
|
11
|
+
export declare const useDisplayConditionStore: import("pinia").StoreDefinition<"guidoDisplayCondition", DisplayConditionState, {
|
|
12
|
+
isCreateOpen: (state: {
|
|
13
|
+
view: DisplayConditionView;
|
|
14
|
+
editing: {
|
|
15
|
+
id: number;
|
|
16
|
+
name: string;
|
|
17
|
+
description: string;
|
|
18
|
+
beforeScript: string;
|
|
19
|
+
afterScript: string;
|
|
20
|
+
extraData?: string | undefined;
|
|
21
|
+
} | null;
|
|
22
|
+
list: {
|
|
23
|
+
id: number;
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
syntax: "liquid" | "pongo";
|
|
27
|
+
method: "codeOnly" | "logicBuilder";
|
|
28
|
+
codeBefore: string;
|
|
29
|
+
codeAfter: string;
|
|
30
|
+
createdAt?: string | undefined;
|
|
31
|
+
}[];
|
|
32
|
+
listStatus: DisplayConditionListStatus;
|
|
33
|
+
pendingDelete: {
|
|
34
|
+
id: number;
|
|
35
|
+
name: string;
|
|
36
|
+
description: string;
|
|
37
|
+
syntax: "liquid" | "pongo";
|
|
38
|
+
method: "codeOnly" | "logicBuilder";
|
|
39
|
+
codeBefore: string;
|
|
40
|
+
codeAfter: string;
|
|
41
|
+
createdAt?: string | undefined;
|
|
42
|
+
} | null;
|
|
43
|
+
} & import("pinia").PiniaCustomStateProperties<DisplayConditionState>) => boolean;
|
|
44
|
+
isSelectOpen: (state: {
|
|
45
|
+
view: DisplayConditionView;
|
|
46
|
+
editing: {
|
|
47
|
+
id: number;
|
|
48
|
+
name: string;
|
|
49
|
+
description: string;
|
|
50
|
+
beforeScript: string;
|
|
51
|
+
afterScript: string;
|
|
52
|
+
extraData?: string | undefined;
|
|
53
|
+
} | null;
|
|
54
|
+
list: {
|
|
55
|
+
id: number;
|
|
56
|
+
name: string;
|
|
57
|
+
description: string;
|
|
58
|
+
syntax: "liquid" | "pongo";
|
|
59
|
+
method: "codeOnly" | "logicBuilder";
|
|
60
|
+
codeBefore: string;
|
|
61
|
+
codeAfter: string;
|
|
62
|
+
createdAt?: string | undefined;
|
|
63
|
+
}[];
|
|
64
|
+
listStatus: DisplayConditionListStatus;
|
|
65
|
+
pendingDelete: {
|
|
66
|
+
id: number;
|
|
67
|
+
name: string;
|
|
68
|
+
description: string;
|
|
69
|
+
syntax: "liquid" | "pongo";
|
|
70
|
+
method: "codeOnly" | "logicBuilder";
|
|
71
|
+
codeBefore: string;
|
|
72
|
+
codeAfter: string;
|
|
73
|
+
createdAt?: string | undefined;
|
|
74
|
+
} | null;
|
|
75
|
+
} & import("pinia").PiniaCustomStateProperties<DisplayConditionState>) => boolean;
|
|
76
|
+
}, {
|
|
77
|
+
openCreate(editing?: AppliedDisplayCondition | null): void;
|
|
78
|
+
openSelect(): void;
|
|
79
|
+
close(): void;
|
|
80
|
+
}>;
|
|
81
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AppliedDisplayCondition, DisplayConditionSource } from '@@/Types/display-condition';
|
|
2
|
+
export declare const parseSource: (condition: AppliedDisplayCondition | null | undefined) => DisplayConditionSource | null;
|
|
3
|
+
type ConditionLike = Omit<AppliedDisplayCondition, 'description'> & {
|
|
4
|
+
description?: string | null;
|
|
5
|
+
};
|
|
6
|
+
export declare const toAppliedCondition: (condition: ConditionLike | null | undefined) => AppliedDisplayCondition | null;
|
|
7
|
+
export declare const nextConditionId: () => number;
|
|
8
|
+
export type CodeField = 'codeBefore' | 'codeAfter';
|
|
9
|
+
export declare const findInvalidCodeFields: (codeBefore: string, codeAfter: string) => CodeField[];
|
|
10
|
+
export {};
|
package/dist/stores/config.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { MessageType as
|
|
1
|
+
import { MessageType as a } from "../@types/config/schemas.js";
|
|
2
2
|
import "../@types/config/defaults.js";
|
|
3
|
-
import { parseConfig as
|
|
4
|
-
import { defineStore as
|
|
5
|
-
const g =
|
|
3
|
+
import { parseConfig as o } from "../@types/config/validator.js";
|
|
4
|
+
import { defineStore as l } from "pinia";
|
|
5
|
+
const g = l("guido-config", {
|
|
6
6
|
state: () => ({
|
|
7
7
|
initialized: !1,
|
|
8
8
|
config: null
|
|
@@ -132,7 +132,7 @@ const g = o("guido-config", {
|
|
|
132
132
|
* consumers stay safe in setup where a raw config read snapshots null (SD-147945).
|
|
133
133
|
*/
|
|
134
134
|
isTransactional() {
|
|
135
|
-
return this.messageType ===
|
|
135
|
+
return this.messageType === a.TRANSACTIONAL;
|
|
136
136
|
},
|
|
137
137
|
/**
|
|
138
138
|
* Soft-save policy: may the editor persist a template with validation errors?
|
|
@@ -158,6 +158,13 @@ const g = o("guido-config", {
|
|
|
158
158
|
var e, t;
|
|
159
159
|
return ((t = (e = i.config) == null ? void 0 : e.ui) == null ? void 0 : t.showHeader) ?? !0;
|
|
160
160
|
},
|
|
161
|
+
/**
|
|
162
|
+
* Check if the Insider display-condition UI replaces Stripo's
|
|
163
|
+
*/
|
|
164
|
+
externalDisplayConditions: (i) => {
|
|
165
|
+
var e, t, n, r;
|
|
166
|
+
return (((t = (e = i.config) == null ? void 0 : e.ui) == null ? void 0 : t.externalDisplayConditions) ?? !1) && (((r = (n = i.config) == null ? void 0 : n.features) == null ? void 0 : r.displayConditions) ?? !0);
|
|
167
|
+
},
|
|
161
168
|
/**
|
|
162
169
|
* Check if a specific feature is enabled.
|
|
163
170
|
* Returns false before init (config null) so header controls don't
|
|
@@ -174,7 +181,7 @@ const g = o("guido-config", {
|
|
|
174
181
|
* Initialize the config store with validated configuration
|
|
175
182
|
*/
|
|
176
183
|
init(i) {
|
|
177
|
-
const e =
|
|
184
|
+
const e = o(i);
|
|
178
185
|
this.config = e, this.initialized = !0;
|
|
179
186
|
},
|
|
180
187
|
/**
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineStore as i } from "pinia";
|
|
2
|
+
const n = i("guidoDisplayCondition", {
|
|
3
|
+
state: () => ({
|
|
4
|
+
view: "none",
|
|
5
|
+
editing: null,
|
|
6
|
+
list: [],
|
|
7
|
+
listStatus: "idle",
|
|
8
|
+
pendingDelete: null
|
|
9
|
+
}),
|
|
10
|
+
getters: {
|
|
11
|
+
isCreateOpen: (e) => e.view === "create",
|
|
12
|
+
isSelectOpen: (e) => e.view === "select"
|
|
13
|
+
},
|
|
14
|
+
actions: {
|
|
15
|
+
openCreate(e = null) {
|
|
16
|
+
this.editing = e, this.view = "create";
|
|
17
|
+
},
|
|
18
|
+
openSelect() {
|
|
19
|
+
this.editing = null, this.view = "select";
|
|
20
|
+
},
|
|
21
|
+
close() {
|
|
22
|
+
this.view = "none", this.pendingDelete = null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
export {
|
|
27
|
+
n as useDisplayConditionStore
|
|
28
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DisplayConditionSourceType as d } from "../enums/display-condition.js";
|
|
2
|
+
const m = (e) => {
|
|
3
|
+
if (!e)
|
|
4
|
+
return null;
|
|
5
|
+
try {
|
|
6
|
+
return JSON.parse(e.extraData ?? "{}").source === d.INLINE ? "inline" : "saved";
|
|
7
|
+
} catch {
|
|
8
|
+
return "saved";
|
|
9
|
+
}
|
|
10
|
+
}, E = (e) => !e || !(e.name || e.beforeScript || e.afterScript) ? null : { ...e, description: e.description ?? "" };
|
|
11
|
+
let o = 0;
|
|
12
|
+
const w = () => (o = Math.max(Date.now(), o + 1), o), f = /{%-?\s*(\w+)[\s\S]*?-?%}/g, p = /{%[\s\S]*?%}|{{[\s\S]*?}}/g, u = /{%-?\s*(comment|raw)\s*-?%}[\s\S]*?{%-?\s*end\1\s*-?%}/g, l = /* @__PURE__ */ new Set(["if", "unless", "for", "case", "capture", "tablerow", "comment"]), h = /* @__PURE__ */ new Set(["else", "elsif", "elif", "when"]), S = (e) => /{%|%}|{{|}}/.test(e.replace(p, "")), C = (e, c) => {
|
|
13
|
+
const t = /* @__PURE__ */ new Set(), r = [];
|
|
14
|
+
return [["codeBefore", e], ["codeAfter", c]].forEach(([n, i]) => {
|
|
15
|
+
const a = i.replace(u, "");
|
|
16
|
+
S(a) && t.add(n), Array.from(a.matchAll(f), (s) => s[1]).forEach((s) => {
|
|
17
|
+
l.has(s) ? r.push(s) : s.startsWith("end") && l.has(s.slice(3)) ? r.pop() !== s.slice(3) && t.add(n) : h.has(s) && !r.length && t.add(n);
|
|
18
|
+
});
|
|
19
|
+
}), r.length && t.add("codeAfter"), [...t];
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
C as findInvalidCodeFields,
|
|
23
|
+
w as nextConditionId,
|
|
24
|
+
m as parseSource,
|
|
25
|
+
E as toAppliedCondition
|
|
26
|
+
};
|
|
@@ -2,34 +2,35 @@ import { ITEMS_CURRENCY_ATTR as U, isCustomCurrencySymbol as Y } from "../extens
|
|
|
2
2
|
import { productPairs as M } from "../extensions/Blocks/Items/enums/productEnums.js";
|
|
3
3
|
import { escapeReplacement as B } from "../extensions/Blocks/Items/utils/nodeConfigUtils.js";
|
|
4
4
|
import { preserveTextStyles as L } from "./preserveTextStyles.js";
|
|
5
|
-
import {
|
|
5
|
+
import { protectTableText as X, restoreTableText as v } from "./protectTableText.js";
|
|
6
|
+
import { unwrapProductNameLinks as j } from "./unwrapProductNameLink.js";
|
|
6
7
|
const q = {
|
|
7
8
|
CART_ITEMS: "ins_apr",
|
|
8
9
|
BROWSED_ITEMS: "browsed_item",
|
|
9
10
|
PURCHASED_ITEMS: "purchased_item"
|
|
10
11
|
}, W = ($) => $.replaceAll("{%", "<!--{%").replaceAll("%}", "%}-->");
|
|
11
|
-
function
|
|
12
|
+
function Q($, C, A) {
|
|
12
13
|
let d = C;
|
|
13
14
|
for (; d > 0 && /\s/.test($[d - 1]); )
|
|
14
15
|
d -= 1;
|
|
15
16
|
return A.some((E) => $.endsWith(E, d));
|
|
16
17
|
}
|
|
17
|
-
const
|
|
18
|
-
function
|
|
18
|
+
const z = /(\s)href=(["'])(?:[^"']*#!|#)?\2/gi;
|
|
19
|
+
function J($, C) {
|
|
19
20
|
var d;
|
|
20
21
|
const A = $.ownerDocument.createTreeWalker($, NodeFilter.SHOW_COMMENT);
|
|
21
22
|
for (let E = A.nextNode(); E; E = A.nextNode())
|
|
22
|
-
(d = E.nodeValue) != null && d.includes("[if mso]") && (E.nodeValue = E.nodeValue.replace(
|
|
23
|
+
(d = E.nodeValue) != null && d.includes("[if mso]") && (E.nodeValue = E.nodeValue.replace(z, (k, P) => `${P}href="${C}"`));
|
|
23
24
|
}
|
|
24
|
-
function
|
|
25
|
-
const C = W($), A = new DOMParser().parseFromString(C, "text/html");
|
|
26
|
-
|
|
25
|
+
function ot($) {
|
|
26
|
+
const C = W(X($)), A = new DOMParser().parseFromString(C, "text/html");
|
|
27
|
+
j(A);
|
|
27
28
|
const d = M.PAIRS_FOR_EXTENSION;
|
|
28
29
|
Object.entries(d).forEach(([o, p]) => {
|
|
29
30
|
A.querySelectorAll(".ins-product-td").forEach((r) => {
|
|
30
31
|
const _ = r.getAttribute("data-number") || "1", y = r.getAttribute("data-type") || "CART_ITEMS";
|
|
31
32
|
r.querySelectorAll(`[product-attr="${o}"]`).forEach((t) => {
|
|
32
|
-
var
|
|
33
|
+
var b, I, D, O;
|
|
33
34
|
const m = t.getAttribute("data-type") || y, n = t.getAttribute("data-number") || _, f = p[m];
|
|
34
35
|
if (f)
|
|
35
36
|
switch (o) {
|
|
@@ -45,12 +46,12 @@ function et($) {
|
|
|
45
46
|
return a.includes(g) || a.includes(u) || H === u;
|
|
46
47
|
}) && (e.src = `{{${c}_${n}}}`);
|
|
47
48
|
}
|
|
48
|
-
const i = (I = (
|
|
49
|
+
const i = (I = (b = d.name) == null ? void 0 : b[m]) == null ? void 0 : I.ATTR;
|
|
49
50
|
if (i && e.setAttribute("alt", `{{${i}_${n}}}`), s) {
|
|
50
|
-
const a = (
|
|
51
|
+
const a = (D = d.itemLink) == null ? void 0 : D[m];
|
|
51
52
|
if (a) {
|
|
52
|
-
const
|
|
53
|
-
(u === "#" || u === "" || u.endsWith("#!") || u.endsWith(g) || u === `${window.location.href}${g}` || !u || u === window.location.href) && (s.href = `{{${
|
|
53
|
+
const S = a.HREF, g = a.DEFAULT_HREF || "#!", u = s.href;
|
|
54
|
+
(u === "#" || u === "" || u.endsWith("#!") || u.endsWith(g) || u === `${window.location.href}${g}` || !u || u === window.location.href) && (s.href = `{{${S}_${n}}}`);
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
break;
|
|
@@ -60,25 +61,25 @@ function et($) {
|
|
|
60
61
|
t.textContent && (t.innerHTML = L(t, `{{${s}_${n}}}`));
|
|
61
62
|
const i = t.closest("a") || (t.tagName === "A" ? t : null);
|
|
62
63
|
if (i && c) {
|
|
63
|
-
const a = i.href,
|
|
64
|
-
(a ===
|
|
64
|
+
const a = i.href, S = `${window.location.href}${l}`;
|
|
65
|
+
(a === S || a.endsWith(l)) && (i.href = `{{${c}_${n}}}`);
|
|
65
66
|
}
|
|
66
67
|
break;
|
|
67
68
|
}
|
|
68
69
|
case "price":
|
|
69
70
|
case "originalPrice": {
|
|
70
71
|
const e = f, s = t.getAttribute("data-formated"), l = t.getAttribute("data-single_price"), c = s === "true", i = l === "true", a = t.getAttribute(U.POSITION) || "before";
|
|
71
|
-
let
|
|
72
|
-
i ?
|
|
72
|
+
let S;
|
|
73
|
+
i ? S = c ? e.SINGLE_PRICE_FORMATTED : e.SINGLE_PRICE : S = c ? e.PRICE_FORMATTED : e.PRICE;
|
|
73
74
|
const g = e.CURRENCY;
|
|
74
|
-
let u = `{{${
|
|
75
|
+
let u = `{{${S}_${n}}}`;
|
|
75
76
|
const H = (t.getAttribute(U.SYMBOL) || "").trim(), G = Y(H);
|
|
76
77
|
let F = "";
|
|
77
78
|
G ? F = H : g && (F = `{{${g}_${n}}}`), F && (u = a === "after" ? `${u} ${F}` : `${F} ${u}`), t.innerHTML = L(t, u);
|
|
78
79
|
break;
|
|
79
80
|
}
|
|
80
81
|
case "quantity": {
|
|
81
|
-
const e = f, s = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (
|
|
82
|
+
const e = f, s = e.ATTR, l = [e.DEFAULT, ...e.LEGACY_DEFAULTS], c = (O = t.textContent) == null ? void 0 : O.trim();
|
|
82
83
|
c && l.includes(c) && (t.innerHTML = L(t, `{{${s}_${n}}}`));
|
|
83
84
|
break;
|
|
84
85
|
}
|
|
@@ -88,7 +89,7 @@ function et($) {
|
|
|
88
89
|
const i = c.href || "", a = `${window.location.href}${l}`;
|
|
89
90
|
(i === "" || i === "#" || i === a || i.endsWith(l) || i.endsWith("#!") || i === window.location.href) && (c.href = `{{${s}_${n}}}`);
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
+
J(t, `{{${s}_${n}}}`);
|
|
92
93
|
break;
|
|
93
94
|
}
|
|
94
95
|
case "itemLink": {
|
|
@@ -129,30 +130,30 @@ function et($) {
|
|
|
129
130
|
h = h.replace(o, B(n));
|
|
130
131
|
}
|
|
131
132
|
});
|
|
132
|
-
const V = A.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(),
|
|
133
|
+
const V = A.querySelectorAll('[product-attr="originalPrice"][data-type]'), w = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Set();
|
|
133
134
|
return V.forEach((o) => {
|
|
134
135
|
var t;
|
|
135
136
|
const p = o.getAttribute("data-number"), T = o.getAttribute("data-type");
|
|
136
137
|
if (!p || !q[T])
|
|
137
138
|
return;
|
|
138
139
|
const r = o.closest(".product-original-price-class");
|
|
139
|
-
if (!r ||
|
|
140
|
+
if (!r || x.has(r))
|
|
140
141
|
return;
|
|
141
|
-
|
|
142
|
+
x.add(r);
|
|
142
143
|
const _ = r.outerHTML, y = (t = o.closest(".ins-product-td")) == null ? void 0 : t.getAttribute("data-nodup"), R = w.get(_) ?? { number: p, type: T, wrap: [] };
|
|
143
144
|
R.wrap.push(y !== "false"), w.set(_, R);
|
|
144
145
|
}), w.forEach(({ number: o, type: p, wrap: T }, r) => {
|
|
145
146
|
if (r.includes("{% if") || !T.some(Boolean))
|
|
146
147
|
return;
|
|
147
148
|
const _ = M.PAIRS_FOR_EXTENSION.price[p].PRICE, y = M.PAIRS_FOR_EXTENSION.originalPrice[p].PRICE, R = `{% if ${_}_${o} != ${y}_${o} %}`, t = [R, W(R)];
|
|
148
|
-
let m = "", n = 0, f = 0,
|
|
149
|
-
for (;
|
|
150
|
-
const I = T[f] === !0 && !
|
|
151
|
-
m += h.slice(n,
|
|
149
|
+
let m = "", n = 0, f = 0, b = h.indexOf(r);
|
|
150
|
+
for (; b !== -1; ) {
|
|
151
|
+
const I = T[f] === !0 && !Q(h, b, t);
|
|
152
|
+
m += h.slice(n, b) + (I ? `${R}${r}{% endif %}` : r), n = b + r.length, f += 1, b = h.indexOf(r, n);
|
|
152
153
|
}
|
|
153
154
|
h = m + h.slice(n);
|
|
154
|
-
}), h.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}");
|
|
155
|
+
}), v(h.replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}").replaceAll("<!--{%", "{%").replaceAll("%}-->", "%}"));
|
|
155
156
|
}
|
|
156
157
|
export {
|
|
157
|
-
|
|
158
|
+
ot as pairProductVariables
|
|
158
159
|
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
const c = "guido-table-text:", l = new RegExp(`<!--${c}([A-Za-z0-9+/=]*)-->`, "g"), i = /<!--[\s\S]*?-->|\{%[\s\S]*?%\}|<[a-zA-Z/!?](?:[^>"']|"[^"]*"|'[^']*')*>|[^<{]+|[<{]/g, o = /* @__PURE__ */ new Set(["table", "tbody", "thead", "tfoot", "tr"]), T = /* @__PURE__ */ new Set([...o, "td", "th", "caption"]), d = (s) => btoa(unescape(encodeURIComponent(s))), f = (s) => decodeURIComponent(escape(atob(s))), p = (s) => {
|
|
2
|
+
const e = /^<(\/?)([a-zA-Z][\w-]*)/.exec(s);
|
|
3
|
+
return { name: e ? e[2].toLowerCase() : "", closing: e ? e[1] === "/" : !1 };
|
|
4
|
+
};
|
|
5
|
+
function u(s) {
|
|
6
|
+
const e = [];
|
|
7
|
+
let a = !1;
|
|
8
|
+
return s.replace(i, (t) => {
|
|
9
|
+
if (t.startsWith("<!--") || t.startsWith("{%"))
|
|
10
|
+
return t;
|
|
11
|
+
if (t.length > 1 && t.startsWith("<")) {
|
|
12
|
+
const { name: n, closing: r } = p(t);
|
|
13
|
+
return a = T.has(n), a && (r ? e.includes(n) && e.splice(e.lastIndexOf(n)) : e.push(n)), t;
|
|
14
|
+
}
|
|
15
|
+
return a && o.has(e[e.length - 1] ?? "") && t.trim() ? `<!--${c}${d(t)}-->` : t;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
const E = (s) => s.replace(l, (e, a) => f(a));
|
|
19
|
+
export {
|
|
20
|
+
u as protectTableText,
|
|
21
|
+
E as restoreTableText
|
|
22
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@useinsider/guido",
|
|
3
|
-
"version": "3.21.2-beta.
|
|
3
|
+
"version": "3.21.2-beta.e89b843",
|
|
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",
|