@chaibuilder/sdk 3.1.15 → 3.1.17
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/{apply-binding-DXR0sMuX.js → apply-binding-DCno1xQL.js} +215 -209
- package/dist/apply-binding-DvHNFLQD.cjs +1 -0
- package/dist/{code-editor-BeFF_6gp.js → code-editor-BWhFfK_2.js} +1 -1
- package/dist/{code-editor-DrQr2iOn.cjs → code-editor-DKoUFePM.cjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +5 -4
- package/dist/core.js +2 -2
- package/dist/index-ByCJl7aR.cjs +153 -0
- package/dist/{index-BUT6PpvB.js → index-seEzvADJ.js} +1103 -1057
- package/dist/render.cjs +1 -1
- package/dist/render.js +2 -2
- package/dist/{rte-widget-modal-CmcQewRS.js → rte-widget-modal-6srLi8vj.js} +1 -1
- package/dist/{rte-widget-modal-BAXArDDD.cjs → rte-widget-modal-Dv8E1sGo.cjs} +1 -1
- package/package.json +1 -1
- package/dist/apply-binding-DCZAw7M-.cjs +0 -1
- package/dist/index-BAxhgbfL.cjs +0 -153
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { g as
|
|
2
|
-
import { isEmpty as f, flatten as
|
|
3
|
-
import { parse as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { g as ot, c as R } from "./common-functions-BGzDsf1z.js";
|
|
2
|
+
import { isEmpty as f, flatten as ct, flatMapDeep as lt, get as d, set as E, startsWith as _, find as m, startCase as pt, forEach as $, camelCase as ut, includes as v, has as A, filter as G, some as dt, map as tt, compact as ht, trim as gt, capitalize as mt, memoize as et, cloneDeep as M, keys as P, isString as B, isArray as C, last as yt } from "lodash-es";
|
|
3
|
+
import { parse as bt, stringify as N } from "himalaya";
|
|
4
|
+
import { unset as H } from "lodash";
|
|
5
|
+
import { getRegisteredChaiBlock as ft } from "@chaibuilder/runtime";
|
|
6
|
+
import { twMerge as xt } from "tailwind-merge";
|
|
7
|
+
const x = "#styles:", qt = "__ADD_BLOCK_INTERNAL_ROOT", Mt = "@", _t = "#", st = (e) => {
|
|
7
8
|
if (e = e.replace(x, ""), !e) return { baseClasses: "", classes: "" };
|
|
8
|
-
const
|
|
9
|
-
if (
|
|
10
|
-
return { baseClasses: "", classes:
|
|
11
|
-
const [t, ...
|
|
9
|
+
const a = e.split(/,(?![^\[]*\])/);
|
|
10
|
+
if (a.length === 1)
|
|
11
|
+
return { baseClasses: "", classes: a[0].trim() };
|
|
12
|
+
const [t, ...s] = a;
|
|
12
13
|
return {
|
|
13
14
|
baseClasses: t.trim(),
|
|
14
|
-
classes:
|
|
15
|
+
classes: s.join(",").trim().replace(/ +(?= )/g, "")
|
|
15
16
|
};
|
|
16
17
|
};
|
|
17
18
|
import.meta.vitest && describe("getSplitChaiClasses", () => {
|
|
@@ -40,20 +41,20 @@ import.meta.vitest && describe("getSplitChaiClasses", () => {
|
|
|
40
41
|
classes: "bg-[linear-gradient(-10deg,black,transparent_100%)]"
|
|
41
42
|
}
|
|
42
43
|
};
|
|
43
|
-
for (let
|
|
44
|
-
const t =
|
|
45
|
-
expect(t).toEqual(e[
|
|
44
|
+
for (let a in e) {
|
|
45
|
+
const t = st(`${x}${a}`);
|
|
46
|
+
expect(t).toEqual(e[a]);
|
|
46
47
|
}
|
|
47
48
|
});
|
|
48
49
|
});
|
|
49
|
-
const
|
|
50
|
-
const
|
|
51
|
-
return
|
|
52
|
-
},
|
|
50
|
+
const kt = (e) => {
|
|
51
|
+
const a = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, t = /(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;
|
|
52
|
+
return a.test(e) || t.test(e);
|
|
53
|
+
}, vt = (e) => {
|
|
53
54
|
if (f(e)) return e;
|
|
54
|
-
const
|
|
55
|
-
return r && (o.test(r) ||
|
|
56
|
-
}, at = ["chai-name", "data-chai-name"],
|
|
55
|
+
const a = /<video[^>]+src=['"]([^'">]+)['"]/, t = /<iframe[^>]+src=['"]([^'">]+)['"]/, s = e.match(a), n = e.match(t), r = s ? s[1] : n ? n[1] : null, o = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, l = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
|
|
56
|
+
return r && (o.test(r) || l.test(r)) ? r : e;
|
|
57
|
+
}, at = ["chai-name", "data-chai-name"], wt = {
|
|
57
58
|
img: { alt: "alt", width: "width", height: "height", src: "image" },
|
|
58
59
|
video: {
|
|
59
60
|
src: "url",
|
|
@@ -89,51 +90,51 @@ const _t = (e) => {
|
|
|
89
90
|
form: {
|
|
90
91
|
action: "action"
|
|
91
92
|
}
|
|
92
|
-
},
|
|
93
|
+
}, Tt = (e, a) => e.children.length === 1 && v(
|
|
93
94
|
["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
|
|
94
|
-
|
|
95
|
-
),
|
|
96
|
-
const
|
|
97
|
-
if (!
|
|
98
|
-
const n = (
|
|
99
|
-
if (!
|
|
100
|
-
const g =
|
|
95
|
+
a._type
|
|
96
|
+
), j = (e) => e.map((a) => a.type === "text" ? d(a, "content", "") : f(a.children) ? "" : j(a.children)).join(""), S = (e) => e === null ? "" : e, nt = (e) => {
|
|
97
|
+
const a = ht(tt(e.split(/\s+/), gt)), t = m(a, (l) => /^w-/.test(l)), s = m(a, (l) => /^h-/.test(l));
|
|
98
|
+
if (!s || !t) return { height: "", width: "" };
|
|
99
|
+
const n = (l) => {
|
|
100
|
+
if (!l) return;
|
|
101
|
+
const g = l.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);
|
|
101
102
|
if (!g) return;
|
|
102
103
|
if (g[1]) return g[1];
|
|
103
104
|
const i = g[2];
|
|
104
105
|
return /^\d+(\.\d+)?$/.test(i) ? `${Number(i) * 4}px` : i === "auto" || v(i, "%") ? i : "16px";
|
|
105
|
-
}, r = n(t), o = n(
|
|
106
|
+
}, r = n(t), o = n(s);
|
|
106
107
|
return {
|
|
107
108
|
width: v(r, "px") ? r : "16px",
|
|
108
109
|
height: v(o, "px") ? o : "16px"
|
|
109
110
|
};
|
|
110
|
-
},
|
|
111
|
+
}, Q = (e) => {
|
|
111
112
|
if (e.tagName === "svg") return {};
|
|
112
|
-
const
|
|
113
|
-
return $(
|
|
113
|
+
const a = {}, t = wt[e.tagName] || {}, s = e.attributes;
|
|
114
|
+
return $(s, ({ key: n, value: r }) => {
|
|
114
115
|
if (!v(at, n))
|
|
115
|
-
if (t[n]) {
|
|
116
|
+
if (n === "bid" && (a._bid = S(r)), t[n]) {
|
|
116
117
|
if (e.tagName === "img" && n === "src" && !r.startsWith("http")) {
|
|
117
|
-
const o = m(e.attributes, { key: "width" }),
|
|
118
|
-
o &&
|
|
118
|
+
const o = m(e.attributes, { key: "width" }), l = m(e.attributes, { key: "height" });
|
|
119
|
+
o && l ? r = `https://picsum.photos/${o == null ? void 0 : o.value}x${l == null ? void 0 : l.value}` : r = "https://picsum.photos/150x150";
|
|
119
120
|
}
|
|
120
|
-
E(
|
|
121
|
-
} else v(["style", "class", "srcset"], n) || (A(
|
|
122
|
-
}), delete
|
|
123
|
-
},
|
|
124
|
-
if (!e.attributes) return { [
|
|
121
|
+
E(a, t[n], S(r));
|
|
122
|
+
} else v(["style", "class", "srcset", "bid"], n) || (A(a, "styles_attrs") || (a.styles_attrs = {}), _(n, "@") && (n = n.replace("@", "x-on:")), a.styles_attrs[`${n}`] = S(r));
|
|
123
|
+
}), delete a.class, a;
|
|
124
|
+
}, Et = (e, a = "styles") => {
|
|
125
|
+
if (!e.attributes) return { [a]: `${x},` };
|
|
125
126
|
const t = m(e.attributes, { key: "class" });
|
|
126
127
|
if (t) {
|
|
127
|
-
const
|
|
128
|
-
return { [
|
|
128
|
+
const s = t.value;
|
|
129
|
+
return { [a]: `${x},${s}` };
|
|
129
130
|
}
|
|
130
|
-
return { [
|
|
131
|
-
},
|
|
132
|
-
const
|
|
131
|
+
return { [a]: `${x},` };
|
|
132
|
+
}, $t = (e) => {
|
|
133
|
+
const a = d(e, "attributes", []), t = a.find((i) => i.key === "data-chai-richtext" || i.key === "chai-richtext"), s = a.find((i) => i.key === "data-chai-lightbox" || i.key === "chai-lightbox"), n = a.find((i) => i.key === "data-chai-dropdown" || i.key === "chai-dropdown"), r = a.find(
|
|
133
134
|
(i) => i.key === "data-chai-dropdown-button" || i.key === "chai-dropdown-button"
|
|
134
|
-
), o =
|
|
135
|
+
), o = a.find(
|
|
135
136
|
(i) => i.key === "data-chai-dropdown-content" || i.key === "chai-dropdown-content"
|
|
136
|
-
),
|
|
137
|
+
), l = a.find((i) => i.key === "class"), g = l && l.value.split(/\s+/).includes("rte");
|
|
137
138
|
if (n)
|
|
138
139
|
return { _type: "Dropdown" };
|
|
139
140
|
if (r)
|
|
@@ -142,7 +143,7 @@ const _t = (e) => {
|
|
|
142
143
|
return { _type: "DropdownContent" };
|
|
143
144
|
if (t || g)
|
|
144
145
|
return { _type: "Paragraph" };
|
|
145
|
-
if (
|
|
146
|
+
if (s)
|
|
146
147
|
return { _type: "LightBoxLink" };
|
|
147
148
|
switch (e.tagName) {
|
|
148
149
|
// self closing tags
|
|
@@ -226,55 +227,55 @@ const _t = (e) => {
|
|
|
226
227
|
return {
|
|
227
228
|
_type: i,
|
|
228
229
|
tag: e.tagName,
|
|
229
|
-
_name: i == "EmptyBox" || e.tagName === "div" ? i :
|
|
230
|
+
_name: i == "EmptyBox" || e.tagName === "div" ? i : mt(e.tagName)
|
|
230
231
|
};
|
|
231
232
|
}
|
|
232
233
|
}
|
|
233
|
-
},
|
|
234
|
-
var
|
|
234
|
+
}, q = (e, a = null) => lt(e, (t) => {
|
|
235
|
+
var J, O, z, V, W, F, U, Y, K, X;
|
|
235
236
|
if (t.type === "comment") return [];
|
|
236
|
-
let
|
|
237
|
-
if (
|
|
238
|
-
return f(d(t, "content", "")) ? [] :
|
|
237
|
+
let s = { _id: ot() };
|
|
238
|
+
if (a && (s._parent = a.block._id), t.type === "text")
|
|
239
|
+
return f(d(t, "content", "")) ? [] : a && Tt(a.node, a.block) ? (E(a, "block.content", d(t, "content", "")), []) : { ...s, _type: "Text", content: d(t, "content", "") };
|
|
239
240
|
if (_(t.tagName, "chai-")) {
|
|
240
|
-
const
|
|
241
|
-
|
|
241
|
+
const c = t.attributes, p = m(c, { key: "chai-type" }), u = (p == null ? void 0 : p.value) || pt(t.tagName.replace("chai-", "")).replace(/\s+/g, "");
|
|
242
|
+
s._type = u, $(c, ({ key: y, value: Z }) => {
|
|
242
243
|
if (y === "about-this-component" || y === "chai-type" || y === "can-move" || y === "can-delete") return;
|
|
243
244
|
if (y === "id") {
|
|
244
|
-
|
|
245
|
+
s._id = Z;
|
|
245
246
|
return;
|
|
246
247
|
}
|
|
247
|
-
const
|
|
248
|
-
let I =
|
|
249
|
-
typeof I == "string" && _(I, "#styles:") && (I = I.replace("#styles:", "#styles:,")),
|
|
248
|
+
const rt = _(y, "_") ? y : ut(y);
|
|
249
|
+
let I = S(Z);
|
|
250
|
+
typeof I == "string" && _(I, "#styles:") && (I = I.replace("#styles:", "#styles:,")), s[rt] = I;
|
|
250
251
|
});
|
|
251
|
-
const h =
|
|
252
|
-
return [
|
|
252
|
+
const h = q(t.children, { block: s, node: t });
|
|
253
|
+
return [s, ...h];
|
|
253
254
|
}
|
|
254
255
|
const n = d(t, "attributes", []), r = n.find(
|
|
255
|
-
(
|
|
256
|
-
), o = n.find((
|
|
257
|
-
(
|
|
256
|
+
(c) => c.key === "data-chai-richtext" || c.key === "chai-richtext"
|
|
257
|
+
), o = n.find((c) => c.key === "class"), l = o && o.value.split(/\s+/).includes("rte"), g = n.find(
|
|
258
|
+
(c) => c.key === "data-chai-lightbox" || c.key === "chai-lightbox"
|
|
258
259
|
), i = n.find(
|
|
259
|
-
(
|
|
260
|
+
(c) => c.key === "data-chai-dropdown" || c.key === "chai-dropdown"
|
|
260
261
|
), w = n.find(
|
|
261
|
-
(
|
|
262
|
+
(c) => c.key === "data-chai-dropdown-button" || c.key === "chai-dropdown-button"
|
|
262
263
|
), D = n.find(
|
|
263
|
-
(
|
|
264
|
+
(c) => c.key === "data-chai-dropdown-content" || c.key === "chai-dropdown-content"
|
|
264
265
|
);
|
|
265
|
-
if (
|
|
266
|
-
...
|
|
267
|
-
|
|
268
|
-
...
|
|
269
|
-
...
|
|
266
|
+
if (s = {
|
|
267
|
+
...s,
|
|
268
|
+
...$t(t),
|
|
269
|
+
...Q(t),
|
|
270
|
+
...Et(t)
|
|
270
271
|
}, t.attributes) {
|
|
271
|
-
const
|
|
272
|
-
|
|
272
|
+
const c = t.attributes.find((p) => v(at, p.key));
|
|
273
|
+
c && (s._name = c.value);
|
|
273
274
|
}
|
|
274
|
-
if (r ||
|
|
275
|
-
return
|
|
275
|
+
if (r || l)
|
|
276
|
+
return s.content = N(t.children), A(s, "styles_attrs.data-chai-richtext") && delete s.styles_attrs["data-chai-richtext"], A(s, "styles_attrs.chai-richtext") && delete s.styles_attrs["chai-richtext"], [s];
|
|
276
277
|
if (g) {
|
|
277
|
-
const
|
|
278
|
+
const c = [
|
|
278
279
|
"data-chai-lightbox",
|
|
279
280
|
"chai-lightbox",
|
|
280
281
|
"data-vbtype",
|
|
@@ -284,202 +285,207 @@ const _t = (e) => {
|
|
|
284
285
|
"data-gall",
|
|
285
286
|
"href"
|
|
286
287
|
];
|
|
287
|
-
|
|
288
|
-
...
|
|
289
|
-
href: ((
|
|
290
|
-
hrefType: ((
|
|
291
|
-
autoplay: ((
|
|
292
|
-
maxWidth: ((
|
|
293
|
-
backdropColor: ((
|
|
294
|
-
galleryName: ((
|
|
295
|
-
}, $(
|
|
296
|
-
A(
|
|
288
|
+
s = {
|
|
289
|
+
...s,
|
|
290
|
+
href: ((J = n.find((p) => p.key === "href")) == null ? void 0 : J.value) || "",
|
|
291
|
+
hrefType: ((O = n.find((p) => p.key === "data-vbtype")) == null ? void 0 : O.value) || "video",
|
|
292
|
+
autoplay: ((z = n.find((p) => p.key === "data-autoplay")) == null ? void 0 : z.value) === "true" ? "true" : "false",
|
|
293
|
+
maxWidth: ((W = (V = n.find((p) => p.key === "data-maxwidth")) == null ? void 0 : V.value) == null ? void 0 : W.replace("px", "")) || "",
|
|
294
|
+
backdropColor: ((F = n.find((p) => p.key === "data-overlay")) == null ? void 0 : F.value) || "",
|
|
295
|
+
galleryName: ((U = n.find((p) => p.key === "data-gall")) == null ? void 0 : U.value) || ""
|
|
296
|
+
}, $(c, (p) => {
|
|
297
|
+
A(s, `styles_attrs.${p}`) && delete s.styles_attrs[p];
|
|
297
298
|
});
|
|
298
299
|
}
|
|
299
|
-
if (i && (delete
|
|
300
|
-
delete
|
|
301
|
-
const
|
|
302
|
-
|
|
300
|
+
if (i && (delete s.styles_attrs, s.showDropdown = !1), D && delete s.styles_attrs, w) {
|
|
301
|
+
delete s.styles_attrs;
|
|
302
|
+
const c = G(t.children || [], (u) => (u == null ? void 0 : u.tagName) !== "span");
|
|
303
|
+
s.content = j(c);
|
|
303
304
|
const p = m(
|
|
304
305
|
t.children || [],
|
|
305
|
-
(u) => (u == null ? void 0 : u.tagName) === "span" &&
|
|
306
|
+
(u) => (u == null ? void 0 : u.tagName) === "span" && dt(u.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg")
|
|
306
307
|
);
|
|
307
308
|
if (p) {
|
|
308
309
|
const u = m(p.children || [], (h) => (h == null ? void 0 : h.tagName) === "svg");
|
|
309
310
|
if (u) {
|
|
310
|
-
|
|
311
|
-
const { height: h, width: y } =
|
|
312
|
-
|
|
311
|
+
s.icon = N([u]);
|
|
312
|
+
const { height: h, width: y } = Bt(u, "16px", "16px");
|
|
313
|
+
s.iconHeight = h, s.iconWidth = y;
|
|
313
314
|
}
|
|
314
315
|
}
|
|
315
|
-
return [
|
|
316
|
+
return [s];
|
|
316
317
|
}
|
|
317
|
-
if (
|
|
318
|
-
const
|
|
319
|
-
|
|
318
|
+
if (s._type === "Input") {
|
|
319
|
+
const c = s.inputType || "text";
|
|
320
|
+
c === "checkbox" ? E(s, "_type", "Checkbox") : c === "radio" && E(s, "_type", "Radio");
|
|
320
321
|
} else if (t.tagName === "video" || t.tagName === "iframe") {
|
|
321
|
-
const
|
|
322
|
-
return
|
|
322
|
+
const c = N([t]);
|
|
323
|
+
return kt(c) && (E(s, "_type", "Video"), E(s, "url", vt(c)), E(s, "styles", `${x},`), E(s, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), s.content = c, [s];
|
|
323
324
|
} else if (t.tagName === "svg") {
|
|
324
|
-
const
|
|
325
|
+
const c = d(m(t.attributes, { key: "class" }), "value", ""), { height: p, width: u } = nt(c);
|
|
325
326
|
if (p && u)
|
|
326
|
-
|
|
327
|
+
s.styles = `${x}, ${R(`w-${u} h-${p}`, c)}`.trim(), s.height = p == null ? void 0 : p.replace("px", ""), s.width = u == null ? void 0 : u.replace("px", "");
|
|
327
328
|
else {
|
|
328
|
-
const h = (
|
|
329
|
-
h && y ? (
|
|
329
|
+
const h = (Y = m(t.attributes, { key: "height" })) == null ? void 0 : Y.value, y = (K = m(t.attributes, { key: "width" })) == null ? void 0 : K.value;
|
|
330
|
+
h && y ? (s.styles = `${x}, ${R(`w-[${y}px] h-[${h}px]`, c)}`.trim(), s.height = h, s.width = y) : s.styles = `${x}, ${R("w-full h-full", c)}`.trim();
|
|
330
331
|
}
|
|
331
|
-
return t.attributes =
|
|
332
|
-
} else if (t.tagName == "option" &&
|
|
333
|
-
return
|
|
334
|
-
label:
|
|
335
|
-
...
|
|
332
|
+
return t.attributes = G(t.attributes, (h) => !v(["style", "width", "height", "class"], h.key)), s.icon = N([t]), [s];
|
|
333
|
+
} else if (t.tagName == "option" && a && ((X = a.block) == null ? void 0 : X._type) === "Select")
|
|
334
|
+
return a.block.options.push({
|
|
335
|
+
label: j(t.children),
|
|
336
|
+
...Q(t)
|
|
336
337
|
}), [];
|
|
337
|
-
const T =
|
|
338
|
-
return [
|
|
339
|
-
}),
|
|
338
|
+
const T = q(t.children, { block: s, node: t });
|
|
339
|
+
return [s, ...T];
|
|
340
|
+
}), Bt = (e, a, t) => {
|
|
340
341
|
var g, i;
|
|
341
|
-
const
|
|
342
|
-
d(m(
|
|
342
|
+
const s = d(e, "attributes", []), { height: n, width: r } = nt(
|
|
343
|
+
d(m(s, { key: "class" }), "value", "")
|
|
343
344
|
);
|
|
344
345
|
if (n && r)
|
|
345
346
|
return {
|
|
346
347
|
height: `[${n}px]`,
|
|
347
348
|
width: `[${r}px]`
|
|
348
349
|
};
|
|
349
|
-
const o = (g = m(
|
|
350
|
+
const o = (g = m(s, { key: "height" })) == null ? void 0 : g.value, l = (i = m(s, { key: "width" })) == null ? void 0 : i.value;
|
|
350
351
|
return {
|
|
351
352
|
height: o ? `[${o}px]` : t,
|
|
352
|
-
width:
|
|
353
|
+
width: l ? `[${l}px]` : a
|
|
353
354
|
};
|
|
354
|
-
},
|
|
355
|
-
e = e.replace(/(\w+)=\\?"(.*?)\\?"/g, (
|
|
355
|
+
}, It = (e) => {
|
|
356
|
+
e = e.replace(/(\w+)=\\?"(.*?)\\?"/g, (s, n, r) => {
|
|
356
357
|
let o = r.replace(/\\"/g, '"');
|
|
357
|
-
return o = o.replace(/{([^}]+)}/g, (
|
|
358
|
+
return o = o.replace(/{([^}]+)}/g, (l) => l.replace(/"/g, '\\"')), `${n}="${o.replace(/\\"/g, '"')}"`;
|
|
358
359
|
}), e = e.replace(/\\n/g, "").replace(/\\\\/g, "").replace(/\\([/<>])/g, "$1").replace(/\\./g, "").replace(/[\n\r\t\f\v]/g, ""), e = e.replace(/\$name="[^"]*"/g, "");
|
|
359
|
-
const
|
|
360
|
-
return (
|
|
361
|
-
},
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
360
|
+
const a = e.match(/<body[^>]*>[\s\S]*?<\/body>/);
|
|
361
|
+
return (a && a.length > 0 ? a[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : e).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
|
|
362
|
+
}, Ct = (e, a) => m(e, { _id: a }), Pt = (e, a) => f(a) ? e.map((t) => (H(t, "_bid"), t)) : tt(e, (t) => {
|
|
363
|
+
const s = f(t._bid) ? void 0 : Ct(a, t._bid);
|
|
364
|
+
if (s) {
|
|
365
|
+
s._type === "Icon" && d(t, "icon", "").match(/chai-default-svg/) && delete t.icon;
|
|
366
|
+
const n = { ...s, ...t };
|
|
367
|
+
return H(n, "_bid"), n;
|
|
368
|
+
}
|
|
369
|
+
return H(t, "_bid"), t;
|
|
370
|
+
}), Jt = (e) => {
|
|
371
|
+
const a = bt(It(e));
|
|
372
|
+
return f(e) ? [] : ct(q(a));
|
|
367
373
|
};
|
|
368
|
-
function
|
|
369
|
-
const
|
|
370
|
-
if (f(
|
|
371
|
-
const n =
|
|
372
|
-
return $(
|
|
373
|
-
if (v(
|
|
374
|
-
const o = d(n, r),
|
|
375
|
-
B(o) ? n[r] = B(
|
|
374
|
+
function Ot(e, a, t) {
|
|
375
|
+
const s = d(t, "i18nProps", []);
|
|
376
|
+
if (f(a) || f(s)) return e;
|
|
377
|
+
const n = M(e);
|
|
378
|
+
return $(P(n), (r) => {
|
|
379
|
+
if (v(s, r) && !f(a)) {
|
|
380
|
+
const o = d(n, r), l = d(n, `${r}-${a}`, "");
|
|
381
|
+
B(o) ? n[r] = B(l) && !f(l.trim()) && l.trimStart() || o : n[r] = f(l) ? o : l;
|
|
376
382
|
}
|
|
377
383
|
}), n;
|
|
378
384
|
}
|
|
379
|
-
const
|
|
380
|
-
const { baseClasses:
|
|
381
|
-
return
|
|
385
|
+
const Dt = et((e) => {
|
|
386
|
+
const { baseClasses: a, classes: t } = st(e);
|
|
387
|
+
return xt(a, t);
|
|
382
388
|
});
|
|
383
|
-
function
|
|
384
|
-
return d(e, `${
|
|
389
|
+
function Nt(e, a) {
|
|
390
|
+
return d(e, `${a}_attrs`, {});
|
|
385
391
|
}
|
|
386
|
-
function
|
|
392
|
+
function zt(e, a = !0) {
|
|
387
393
|
const t = {};
|
|
388
|
-
return Object.keys(e).forEach((
|
|
389
|
-
if (B(e[
|
|
390
|
-
const n =
|
|
391
|
-
t[
|
|
394
|
+
return Object.keys(e).forEach((s) => {
|
|
395
|
+
if (B(e[s]) && e[s].startsWith(x)) {
|
|
396
|
+
const n = Dt(e[s]), r = Nt(e, s);
|
|
397
|
+
t[s] = {
|
|
392
398
|
...!f(n) && { className: n },
|
|
393
399
|
...r,
|
|
394
|
-
...
|
|
395
|
-
"data-style-prop":
|
|
400
|
+
...a ? {
|
|
401
|
+
"data-style-prop": s,
|
|
396
402
|
"data-block-parent": e._id,
|
|
397
|
-
"data-style-id": `${
|
|
403
|
+
"data-style-id": `${s}-${e._id}`
|
|
398
404
|
} : {}
|
|
399
405
|
};
|
|
400
406
|
}
|
|
401
407
|
}), t;
|
|
402
408
|
}
|
|
403
|
-
const
|
|
404
|
-
const
|
|
405
|
-
return Object.fromEntries(Object.entries(t).filter(([,
|
|
406
|
-
}),
|
|
409
|
+
const Vt = et((e) => {
|
|
410
|
+
const a = ft(e), t = d(a, "schema.properties", {});
|
|
411
|
+
return Object.fromEntries(Object.entries(t).filter(([, s]) => d(s, "runtime", !1)));
|
|
412
|
+
}), Wt = (e, a) => {
|
|
407
413
|
if (!C(e)) return e;
|
|
408
|
-
let t = e,
|
|
409
|
-
return typeof
|
|
410
|
-
},
|
|
411
|
-
const t =
|
|
412
|
-
return $(
|
|
413
|
-
if (B(t[
|
|
414
|
-
let n = t[
|
|
415
|
-
|
|
414
|
+
let t = e, s;
|
|
415
|
+
return typeof a.limit == "number" && a.limit > 0 && (s = a.limit), s !== void 0 && (t = t.slice(0, s)), t;
|
|
416
|
+
}, Ft = (e, a) => {
|
|
417
|
+
const t = M(e);
|
|
418
|
+
return $(P(t), (s) => {
|
|
419
|
+
if (B(t[s]) && !_(s, "_")) {
|
|
420
|
+
let n = t[s];
|
|
421
|
+
s === "repeaterItems" && (t.repeaterItemsBinding = n);
|
|
416
422
|
const r = /\{\{(.*?)\}\}/g, o = n.match(r);
|
|
417
|
-
o && o.forEach((
|
|
418
|
-
let g =
|
|
419
|
-
const i = d(
|
|
420
|
-
n = C(i) ? i : n.replace(
|
|
421
|
-
}), t[
|
|
423
|
+
o && o.forEach((l) => {
|
|
424
|
+
let g = l.slice(2, -2);
|
|
425
|
+
const i = d(a, g, l);
|
|
426
|
+
n = C(i) ? i : n.replace(l, i);
|
|
427
|
+
}), t[s] = n;
|
|
422
428
|
}
|
|
423
429
|
}), t;
|
|
424
430
|
}, k = (e) => {
|
|
425
|
-
const
|
|
431
|
+
const a = yt(e);
|
|
426
432
|
return e.map((t) => {
|
|
427
|
-
const
|
|
428
|
-
for (let n = 0; n <
|
|
429
|
-
if (B(t[
|
|
430
|
-
const r = t ===
|
|
431
|
-
t[
|
|
433
|
+
const s = Object.keys(t);
|
|
434
|
+
for (let n = 0; n < s.length; n++)
|
|
435
|
+
if (B(t[s[n]]) && _(s[n], "content")) {
|
|
436
|
+
const r = t === a ? "" : " ";
|
|
437
|
+
t[s[n]] = `${t[s[n]].trim()}${r}`;
|
|
432
438
|
}
|
|
433
439
|
return t;
|
|
434
440
|
});
|
|
435
441
|
};
|
|
436
442
|
if (import.meta.vitest) {
|
|
437
|
-
const { describe: e, it:
|
|
443
|
+
const { describe: e, it: a, expect: t } = import.meta.vitest;
|
|
438
444
|
e("adjustSpacingInContentBlocks", () => {
|
|
439
|
-
|
|
445
|
+
a("should add space after content fields except for the last block", () => {
|
|
440
446
|
const n = k([
|
|
441
447
|
{ _id: "1", _type: "Text", content: "First" },
|
|
442
448
|
{ _id: "2", _type: "Text", content: "Second" },
|
|
443
449
|
{ _id: "3", _type: "Text", content: "Third" }
|
|
444
450
|
]);
|
|
445
451
|
t(n[0].content).toBe("First "), t(n[1].content).toBe("Second "), t(n[2].content).toBe("Third");
|
|
446
|
-
}),
|
|
452
|
+
}), a("should trim whitespace from content before adding space", () => {
|
|
447
453
|
const n = k([
|
|
448
454
|
{ _id: "1", _type: "Text", content: " First " },
|
|
449
455
|
{ _id: "2", _type: "Text", content: " Second " }
|
|
450
456
|
]);
|
|
451
457
|
t(n[0].content).toBe("First "), t(n[1].content).toBe("Second");
|
|
452
|
-
}),
|
|
458
|
+
}), a("should handle multiple content fields in a single block", () => {
|
|
453
459
|
const n = k([
|
|
454
460
|
{ _id: "1", _type: "Text", content: "Main", contentAlt: "Alt" },
|
|
455
461
|
{ _id: "2", _type: "Text", content: "Last", contentSecondary: "Secondary" }
|
|
456
462
|
]);
|
|
457
463
|
t(n[0].content).toBe("Main "), t(n[0].contentAlt).toBe("Alt "), t(n[1].content).toBe("Last"), t(n[1].contentSecondary).toBe("Secondary");
|
|
458
|
-
}),
|
|
464
|
+
}), a("should only process fields that start with 'content'", () => {
|
|
459
465
|
const n = k([
|
|
460
466
|
{ _id: "1", _type: "Text", content: "Text", title: "Title", text: "Text" },
|
|
461
467
|
{ _id: "2", _type: "Text", content: "Last" }
|
|
462
468
|
]);
|
|
463
469
|
t(n[0].content).toBe("Text "), t(n[0].title).toBe("Title"), t(n[0].text).toBe("Text"), t(n[1].content).toBe("Last");
|
|
464
|
-
}),
|
|
470
|
+
}), a("should handle empty array", () => {
|
|
465
471
|
const n = k([]);
|
|
466
472
|
t(n).toEqual([]);
|
|
467
|
-
}),
|
|
473
|
+
}), a("should handle single block", () => {
|
|
468
474
|
const n = k([{ _id: "1", _type: "Text", content: "Only" }]);
|
|
469
475
|
t(n[0].content).toBe("Only");
|
|
470
|
-
}),
|
|
476
|
+
}), a("should handle blocks without content fields", () => {
|
|
471
477
|
const n = k([
|
|
472
478
|
{ _id: "1", _type: "Container", title: "Title" },
|
|
473
479
|
{ _id: "2", _type: "Container", name: "Name" }
|
|
474
480
|
]);
|
|
475
481
|
t(n[0].title).toBe("Title"), t(n[1].name).toBe("Name");
|
|
476
|
-
}),
|
|
482
|
+
}), a("should handle blocks with non-string content fields", () => {
|
|
477
483
|
const n = k([
|
|
478
484
|
{ _id: "1", _type: "Text", content: "Text", contentNum: 123 },
|
|
479
485
|
{ _id: "2", _type: "Text", content: "Last", contentBool: !0 }
|
|
480
486
|
]);
|
|
481
487
|
t(n[0].content).toBe("Text "), t(n[0].contentNum).toBe(123), t(n[1].content).toBe("Last"), t(n[1].contentBool).toBe(!0);
|
|
482
|
-
}),
|
|
488
|
+
}), a("should handle empty string content", () => {
|
|
483
489
|
const n = k([
|
|
484
490
|
{ _id: "1", _type: "Text", content: "" },
|
|
485
491
|
{ _id: "2", _type: "Text", content: "Last" }
|
|
@@ -488,33 +494,33 @@ if (import.meta.vitest) {
|
|
|
488
494
|
});
|
|
489
495
|
});
|
|
490
496
|
}
|
|
491
|
-
const b = (e,
|
|
497
|
+
const b = (e, a, { index: t, key: s }, n) => {
|
|
492
498
|
if (B(e)) {
|
|
493
499
|
let r = e;
|
|
494
|
-
const o = /\{\{(.*?)\}\}/g,
|
|
495
|
-
if (
|
|
500
|
+
const o = /\{\{(.*?)\}\}/g, l = e.match(o);
|
|
501
|
+
if (l) {
|
|
496
502
|
const g = n === "image" || n === "mobileImage";
|
|
497
|
-
|
|
498
|
-
let w = i.slice(2, -2).trim(), D =
|
|
503
|
+
l.forEach((i) => {
|
|
504
|
+
let w = i.slice(2, -2).trim(), D = s.slice(2, -2).trim();
|
|
499
505
|
t !== -1 && _(w, "$index.") ? w = `${D}.${t}.${w.slice(7)}` : t !== -1 && _(w, "$index") && (w = `${D}.${t}`);
|
|
500
|
-
const T = d(
|
|
506
|
+
const T = d(a, w);
|
|
501
507
|
T === void 0 ? r = r.replace(i, "") : g && !C(T) ? r = T : r = C(T) ? T : r.replace(i, T);
|
|
502
508
|
});
|
|
503
509
|
}
|
|
504
510
|
return r;
|
|
505
511
|
}
|
|
506
512
|
if (C(e))
|
|
507
|
-
return e.map((r) => b(r,
|
|
513
|
+
return e.map((r) => b(r, a, { index: t, key: s }, n));
|
|
508
514
|
if (e && typeof e == "object") {
|
|
509
515
|
const r = {};
|
|
510
|
-
return $(
|
|
511
|
-
!_(o, "_") && o !== "$repeaterItemsKey" ? r[o] = b(e[o],
|
|
516
|
+
return $(P(e), (o) => {
|
|
517
|
+
!_(o, "_") && o !== "$repeaterItemsKey" ? r[o] = b(e[o], a, { index: t, key: s }, o) : r[o] = e[o];
|
|
512
518
|
}), r;
|
|
513
519
|
}
|
|
514
520
|
return e;
|
|
515
|
-
}, L = (e,
|
|
516
|
-
let n =
|
|
517
|
-
return n.repeaterItems && (n.$repeaterItemsKey = n.repeaterItems, _(n.repeaterItems, `{{${
|
|
521
|
+
}, L = (e, a, { index: t, key: s }) => {
|
|
522
|
+
let n = M(e);
|
|
523
|
+
return n.repeaterItems && (n.$repeaterItemsKey = n.repeaterItems, _(n.repeaterItems, `{{${_t}`) && (n.$repeaterItemsKey = n.repeaterItems = `${n.repeaterItems.replace("}}", `/${n._id}}}`)}`), !f(n.repeaterItems) && n.pagination && (n.repeaterTotalItems = `${n.repeaterItems.replace("}}", `/${n._id}/totalItems}}`)}`)), b(n, a, { index: t, key: s });
|
|
518
524
|
};
|
|
519
525
|
import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
520
526
|
it("should handle string values with bindings", () => {
|
|
@@ -548,11 +554,11 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
|
548
554
|
const t = b("Hello {{user.nonexistent}}", { user: { name: "John" } }, { index: -1, key: "" });
|
|
549
555
|
expect(t).toBe("Hello ");
|
|
550
556
|
}), it("should preserve private properties starting with _", () => {
|
|
551
|
-
const
|
|
557
|
+
const a = b({
|
|
552
558
|
name: "John",
|
|
553
559
|
_private: "secret"
|
|
554
560
|
}, {}, { index: -1, key: "" });
|
|
555
|
-
expect(
|
|
561
|
+
expect(a).toEqual({
|
|
556
562
|
name: "John",
|
|
557
563
|
_private: "secret"
|
|
558
564
|
});
|
|
@@ -688,18 +694,18 @@ import.meta.vitest && (describe("applyBindingToValue", () => {
|
|
|
688
694
|
});
|
|
689
695
|
}));
|
|
690
696
|
export {
|
|
691
|
-
|
|
692
|
-
|
|
697
|
+
_t as C,
|
|
698
|
+
Mt as R,
|
|
693
699
|
x as S,
|
|
694
700
|
L as a,
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
701
|
+
Ot as b,
|
|
702
|
+
Vt as c,
|
|
703
|
+
Wt as d,
|
|
698
704
|
k as e,
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
+
Ft as f,
|
|
706
|
+
zt as g,
|
|
707
|
+
Jt as h,
|
|
708
|
+
st as i,
|
|
709
|
+
qt as j,
|
|
710
|
+
Pt as m
|
|
705
711
|
};
|