@chaibuilder/sdk 2.0.0-beta.57 → 2.0.0-beta.58
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/core.cjs +4 -4
- package/dist/core.js +423 -423
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -105,7 +105,7 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
105
105
|
] = o, d = (B) => {
|
|
106
106
|
let A = n(B);
|
|
107
107
|
return A || (A = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, r(B, A), i == null || i(B, I)), A;
|
|
108
|
-
}, p = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Set(),
|
|
108
|
+
}, p = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new Map(), x = /* @__PURE__ */ new Set(), g = /* @__PURE__ */ new Set(), m = () => {
|
|
109
109
|
var B;
|
|
110
110
|
const A = [], N = (T) => {
|
|
111
111
|
try {
|
|
@@ -118,18 +118,18 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
118
118
|
(B = I[INTERNAL_flushStoreHook]) == null || B.call(I);
|
|
119
119
|
const T = /* @__PURE__ */ new Set(), S = T.add.bind(T);
|
|
120
120
|
u.forEach((L) => {
|
|
121
|
-
var
|
|
122
|
-
return (
|
|
123
|
-
}), u.clear(), x.forEach(S), x.clear(),
|
|
124
|
-
} while (u.size || x.size ||
|
|
121
|
+
var D;
|
|
122
|
+
return (D = L.m) == null ? void 0 : D.l.forEach(S);
|
|
123
|
+
}), u.clear(), x.forEach(S), x.clear(), g.forEach(S), g.clear(), T.forEach(N), u.size && w();
|
|
124
|
+
} while (u.size || x.size || g.size);
|
|
125
125
|
if (A.length)
|
|
126
126
|
throw A[0];
|
|
127
127
|
}, f = (B, A, N) => {
|
|
128
128
|
const T = "v" in A, S = A.v, L = isPendingPromise(A.v) ? A.v : null;
|
|
129
129
|
if (isPromiseLike$2(N)) {
|
|
130
130
|
patchPromiseForCancelability(N);
|
|
131
|
-
for (const
|
|
132
|
-
addPendingPromiseToDependency(B, N, d(
|
|
131
|
+
for (const D of A.d.keys())
|
|
132
|
+
addPendingPromiseToDependency(B, N, d(D));
|
|
133
133
|
A.v = N;
|
|
134
134
|
} else
|
|
135
135
|
A.v = N;
|
|
@@ -148,7 +148,7 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
148
148
|
N.d.clear();
|
|
149
149
|
let T = !0;
|
|
150
150
|
const S = () => {
|
|
151
|
-
N.m && (k(B, N), w(),
|
|
151
|
+
N.m && (k(B, N), w(), m());
|
|
152
152
|
}, L = (M) => {
|
|
153
153
|
if (isSelfAtom(B, M)) {
|
|
154
154
|
const U = d(M);
|
|
@@ -166,21 +166,21 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
166
166
|
addDependency(B, N, M, H), T || S();
|
|
167
167
|
}
|
|
168
168
|
};
|
|
169
|
-
let
|
|
169
|
+
let D, $;
|
|
170
170
|
const O = {
|
|
171
171
|
get signal() {
|
|
172
|
-
return
|
|
172
|
+
return D || (D = new AbortController()), D.signal;
|
|
173
173
|
},
|
|
174
174
|
get setSelf() {
|
|
175
175
|
return !$ && isActuallyWritableAtom(B) && ($ = (...M) => {
|
|
176
176
|
if (!T)
|
|
177
|
-
return
|
|
177
|
+
return E(B, ...M);
|
|
178
178
|
}), $;
|
|
179
179
|
}
|
|
180
180
|
};
|
|
181
181
|
try {
|
|
182
182
|
const M = a(B, L, O);
|
|
183
|
-
return f(B, N, M), isPromiseLike$2(M) && ((A = M.onCancel) == null || A.call(M, () =>
|
|
183
|
+
return f(B, N, M), isPromiseLike$2(M) && ((A = M.onCancel) == null || A.call(M, () => D == null ? void 0 : D.abort()), M.then(S, S)), N;
|
|
184
184
|
} catch (M) {
|
|
185
185
|
return delete N.v, N.e = M, ++N.n, N;
|
|
186
186
|
} finally {
|
|
@@ -210,45 +210,45 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
210
210
|
var B;
|
|
211
211
|
const A = [], N = /* @__PURE__ */ new WeakSet(), T = /* @__PURE__ */ new WeakSet(), S = Array.from(u);
|
|
212
212
|
for (; S.length; ) {
|
|
213
|
-
const [L,
|
|
213
|
+
const [L, D] = S[S.length - 1];
|
|
214
214
|
if (T.has(L)) {
|
|
215
215
|
S.pop();
|
|
216
216
|
continue;
|
|
217
217
|
}
|
|
218
218
|
if (N.has(L)) {
|
|
219
|
-
p.get(L) ===
|
|
219
|
+
p.get(L) === D.n ? A.push([L, D, D.n]) : (p.delete(L), u.set(L, D)), T.add(L), S.pop();
|
|
220
220
|
continue;
|
|
221
221
|
}
|
|
222
222
|
N.add(L);
|
|
223
|
-
for (const [$, O] of y(
|
|
223
|
+
for (const [$, O] of y(D))
|
|
224
224
|
N.has($) || S.push([$, O]);
|
|
225
225
|
}
|
|
226
226
|
for (let L = A.length - 1; L >= 0; --L) {
|
|
227
|
-
const [
|
|
227
|
+
const [D, $, O] = A[L];
|
|
228
228
|
let M = !1;
|
|
229
229
|
for (const H of $.d.keys())
|
|
230
|
-
if (H !==
|
|
230
|
+
if (H !== D && u.has(H)) {
|
|
231
231
|
M = !0;
|
|
232
232
|
break;
|
|
233
233
|
}
|
|
234
|
-
M && (h(
|
|
234
|
+
M && (h(D), k(D, $), O !== $.n && (u.set(D, $), (B = $.u) == null || B.call($))), p.delete(D);
|
|
235
235
|
}
|
|
236
|
-
},
|
|
236
|
+
}, j = (B, ...A) => {
|
|
237
237
|
let N = !0;
|
|
238
|
-
const T = (L) => returnAtomValue(h(L)), S = (L, ...
|
|
238
|
+
const T = (L) => returnAtomValue(h(L)), S = (L, ...D) => {
|
|
239
239
|
var $;
|
|
240
240
|
const O = d(L);
|
|
241
241
|
try {
|
|
242
242
|
if (isSelfAtom(B, L)) {
|
|
243
243
|
if (!hasInitialValue(L))
|
|
244
244
|
throw new Error("atom not writable");
|
|
245
|
-
const M = O.n, H =
|
|
245
|
+
const M = O.n, H = D[0];
|
|
246
246
|
f(L, O, H), k(L, O), M !== O.n && (u.set(L, O), ($ = O.u) == null || $.call(O), R(O));
|
|
247
247
|
return;
|
|
248
248
|
} else
|
|
249
|
-
return
|
|
249
|
+
return j(L, ...D);
|
|
250
250
|
} finally {
|
|
251
|
-
N || (w(),
|
|
251
|
+
N || (w(), m());
|
|
252
252
|
}
|
|
253
253
|
};
|
|
254
254
|
try {
|
|
@@ -256,11 +256,11 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
256
256
|
} finally {
|
|
257
257
|
N = !1;
|
|
258
258
|
}
|
|
259
|
-
},
|
|
259
|
+
}, E = (B, ...A) => {
|
|
260
260
|
try {
|
|
261
|
-
return
|
|
261
|
+
return j(B, ...A);
|
|
262
262
|
} finally {
|
|
263
|
-
w(),
|
|
263
|
+
w(), m();
|
|
264
264
|
}
|
|
265
265
|
}, k = (B, A) => {
|
|
266
266
|
var N;
|
|
@@ -290,15 +290,15 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
290
290
|
}, (N = A.h) == null || N.call(A), isActuallyWritableAtom(B)) {
|
|
291
291
|
const T = A.m, S = () => {
|
|
292
292
|
let L = !0;
|
|
293
|
-
const
|
|
293
|
+
const D = (...$) => {
|
|
294
294
|
try {
|
|
295
|
-
return
|
|
295
|
+
return j(B, ...$);
|
|
296
296
|
} finally {
|
|
297
|
-
L || (w(),
|
|
297
|
+
L || (w(), m());
|
|
298
298
|
}
|
|
299
299
|
};
|
|
300
300
|
try {
|
|
301
|
-
const $ = c(B,
|
|
301
|
+
const $ = c(B, D);
|
|
302
302
|
$ && (T.u = () => {
|
|
303
303
|
L = !0;
|
|
304
304
|
try {
|
|
@@ -311,7 +311,7 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
311
311
|
L = !1;
|
|
312
312
|
}
|
|
313
313
|
};
|
|
314
|
-
|
|
314
|
+
g.add(S);
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
317
|
return A.m;
|
|
@@ -332,11 +332,11 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
332
332
|
return A.m;
|
|
333
333
|
}, I = {
|
|
334
334
|
get: b,
|
|
335
|
-
set:
|
|
335
|
+
set: E,
|
|
336
336
|
sub: (B, A) => {
|
|
337
337
|
const N = d(B), S = C(B, N).l;
|
|
338
|
-
return S.add(A),
|
|
339
|
-
S.delete(A), _(B, N),
|
|
338
|
+
return S.add(A), m(), () => {
|
|
339
|
+
S.delete(A), _(B, N), m();
|
|
340
340
|
};
|
|
341
341
|
},
|
|
342
342
|
unstable_derive: (B) => buildStore(...B(...o))
|
|
@@ -373,37 +373,37 @@ function splitAtom(o, n) {
|
|
|
373
373
|
let p = r.get(c);
|
|
374
374
|
if (p)
|
|
375
375
|
return p;
|
|
376
|
-
const u = d && r.get(d), x = [],
|
|
377
|
-
return c.forEach((
|
|
376
|
+
const u = d && r.get(d), x = [], g = [];
|
|
377
|
+
return c.forEach((m, f) => {
|
|
378
378
|
const h = f;
|
|
379
|
-
|
|
379
|
+
g[f] = h;
|
|
380
380
|
const b = u && u.atomList[u.keyList.indexOf(h)];
|
|
381
381
|
if (b) {
|
|
382
382
|
x[f] = b;
|
|
383
383
|
return;
|
|
384
384
|
}
|
|
385
385
|
const y = (w) => {
|
|
386
|
-
const
|
|
387
|
-
if (C < 0 || C >=
|
|
386
|
+
const j = w(l), E = w(o), C = a(E, j == null ? void 0 : j.arr).keyList.indexOf(h);
|
|
387
|
+
if (C < 0 || C >= E.length) {
|
|
388
388
|
const _ = c[a(c).keyList.indexOf(h)];
|
|
389
389
|
if (_)
|
|
390
390
|
return _;
|
|
391
391
|
throw new Error("splitAtom: index out of bounds for read");
|
|
392
392
|
}
|
|
393
|
-
return
|
|
394
|
-
}, R = (w,
|
|
395
|
-
const k = w(l), C = w(o),
|
|
396
|
-
if (
|
|
393
|
+
return E[C];
|
|
394
|
+
}, R = (w, j, E) => {
|
|
395
|
+
const k = w(l), C = w(o), P = a(C, k == null ? void 0 : k.arr).keyList.indexOf(h);
|
|
396
|
+
if (P < 0 || P >= C.length)
|
|
397
397
|
throw new Error("splitAtom: index out of bounds for write");
|
|
398
|
-
const v = isFunction(
|
|
399
|
-
Object.is(C[
|
|
400
|
-
...C.slice(0,
|
|
398
|
+
const v = isFunction(E) ? E(C[P]) : E;
|
|
399
|
+
Object.is(C[P], v) || j(o, [
|
|
400
|
+
...C.slice(0, P),
|
|
401
401
|
v,
|
|
402
|
-
...C.slice(
|
|
402
|
+
...C.slice(P + 1)
|
|
403
403
|
]);
|
|
404
404
|
};
|
|
405
405
|
x[f] = isWritable(o) ? atom(y, R) : atom(y);
|
|
406
|
-
}), u && u.keyList.length ===
|
|
406
|
+
}), u && u.keyList.length === g.length && u.keyList.every((m, f) => m === g[f]) ? p = u : p = { arr: c, atomList: x, keyList: g }, r.set(c, p), p;
|
|
407
407
|
}, l = atom((c) => {
|
|
408
408
|
const d = c(l), p = c(o);
|
|
409
409
|
return a(p, d == null ? void 0 : d.arr);
|
|
@@ -439,17 +439,17 @@ function splitAtom(o, n) {
|
|
|
439
439
|
case "move": {
|
|
440
440
|
const u = c(i).indexOf(p.atom), x = p.before ? c(i).indexOf(p.before) : c(i).length;
|
|
441
441
|
if (u >= 0 && x >= 0) {
|
|
442
|
-
const
|
|
442
|
+
const g = c(o);
|
|
443
443
|
u < x ? d(o, [
|
|
444
|
-
...
|
|
445
|
-
...
|
|
446
|
-
|
|
447
|
-
...
|
|
444
|
+
...g.slice(0, u),
|
|
445
|
+
...g.slice(u + 1, x),
|
|
446
|
+
g[u],
|
|
447
|
+
...g.slice(x)
|
|
448
448
|
]) : d(o, [
|
|
449
|
-
...
|
|
450
|
-
|
|
451
|
-
...
|
|
452
|
-
...
|
|
449
|
+
...g.slice(0, x),
|
|
450
|
+
g[u],
|
|
451
|
+
...g.slice(x, u),
|
|
452
|
+
...g.slice(u + 1)
|
|
453
453
|
]);
|
|
454
454
|
}
|
|
455
455
|
break;
|
|
@@ -475,8 +475,8 @@ function createJSONStorage(o = () => {
|
|
|
475
475
|
let a, l;
|
|
476
476
|
const i = {
|
|
477
477
|
getItem: (p, u) => {
|
|
478
|
-
var x,
|
|
479
|
-
const
|
|
478
|
+
var x, g;
|
|
479
|
+
const m = (h) => {
|
|
480
480
|
if (h = h || "", a !== h) {
|
|
481
481
|
try {
|
|
482
482
|
l = JSON.parse(h, n == null ? void 0 : n.reviver);
|
|
@@ -486,8 +486,8 @@ function createJSONStorage(o = () => {
|
|
|
486
486
|
a = h;
|
|
487
487
|
}
|
|
488
488
|
return l;
|
|
489
|
-
}, f = (
|
|
490
|
-
return isPromiseLike$1(f) ? f.then(
|
|
489
|
+
}, f = (g = (x = o()) == null ? void 0 : x.getItem(p)) != null ? g : null;
|
|
490
|
+
return isPromiseLike$1(f) ? f.then(m) : m(f);
|
|
491
491
|
},
|
|
492
492
|
setItem: (p, u) => {
|
|
493
493
|
var x;
|
|
@@ -500,12 +500,12 @@ function createJSONStorage(o = () => {
|
|
|
500
500
|
var u;
|
|
501
501
|
return (u = o()) == null ? void 0 : u.removeItem(p);
|
|
502
502
|
}
|
|
503
|
-
}, c = (p) => (u, x,
|
|
503
|
+
}, c = (p) => (u, x, g) => p(u, (m) => {
|
|
504
504
|
let f;
|
|
505
505
|
try {
|
|
506
|
-
f = JSON.parse(
|
|
506
|
+
f = JSON.parse(m || "");
|
|
507
507
|
} catch {
|
|
508
|
-
f =
|
|
508
|
+
f = g;
|
|
509
509
|
}
|
|
510
510
|
x(f);
|
|
511
511
|
});
|
|
@@ -518,8 +518,8 @@ function createJSONStorage(o = () => {
|
|
|
518
518
|
if (!(o() instanceof window.Storage))
|
|
519
519
|
return () => {
|
|
520
520
|
};
|
|
521
|
-
const x = (
|
|
522
|
-
|
|
521
|
+
const x = (g) => {
|
|
522
|
+
g.storageArea === o() && g.key === p && u(g.newValue);
|
|
523
523
|
};
|
|
524
524
|
return window.addEventListener("storage", x), () => {
|
|
525
525
|
window.removeEventListener("storage", x);
|
|
@@ -1306,13 +1306,13 @@ const useBlocksStoreManager = () => {
|
|
|
1306
1306
|
} = useBlocksStoreManager();
|
|
1307
1307
|
return {
|
|
1308
1308
|
moveBlocks: (h, b, y) => {
|
|
1309
|
-
const R = map(h, (
|
|
1310
|
-
const k = n.find((
|
|
1311
|
-
return { _id:
|
|
1312
|
-
}), w = R.find(({ _id:
|
|
1309
|
+
const R = map(h, (j) => {
|
|
1310
|
+
const k = n.find((P) => P._id === j)._parent || null, _ = n.filter((P) => k ? P._parent === k : !P._parent).map((P) => P._id).indexOf(j);
|
|
1311
|
+
return { _id: j, oldParent: k, oldPosition: _ };
|
|
1312
|
+
}), w = R.find(({ _id: j }) => j === h[0]);
|
|
1313
1313
|
w && w.oldParent === b && w.oldPosition === y || (i(h, b, y), o({
|
|
1314
|
-
undo: () => each(R, ({ _id:
|
|
1315
|
-
i([
|
|
1314
|
+
undo: () => each(R, ({ _id: j, oldParent: E, oldPosition: k }) => {
|
|
1315
|
+
i([j], E, k);
|
|
1316
1316
|
}),
|
|
1317
1317
|
redo: () => i(h, b, y)
|
|
1318
1318
|
}));
|
|
@@ -1325,7 +1325,7 @@ const useBlocksStoreManager = () => {
|
|
|
1325
1325
|
},
|
|
1326
1326
|
removeBlocks: (h) => {
|
|
1327
1327
|
var w;
|
|
1328
|
-
const b = (w = first(h)) == null ? void 0 : w._parent, R = n.filter((
|
|
1328
|
+
const b = (w = first(h)) == null ? void 0 : w._parent, R = n.filter((j) => b ? j._parent === b : !j._parent).indexOf(first(h));
|
|
1329
1329
|
l(map(h, "_id")), o({
|
|
1330
1330
|
undo: () => a(h, b, R),
|
|
1331
1331
|
redo: () => l(map(h, "_id"))
|
|
@@ -1337,9 +1337,9 @@ const useBlocksStoreManager = () => {
|
|
|
1337
1337
|
R = map(h, (w) => ({ _id: w, ...y }));
|
|
1338
1338
|
else {
|
|
1339
1339
|
const w = keys(b);
|
|
1340
|
-
R = map(h, (
|
|
1341
|
-
const
|
|
1342
|
-
return each(w, (C) => k[C] =
|
|
1340
|
+
R = map(h, (j) => {
|
|
1341
|
+
const E = n.find((C) => C._id === j), k = { _id: j };
|
|
1342
|
+
return each(w, (C) => k[C] = E[C]), k;
|
|
1343
1343
|
});
|
|
1344
1344
|
}
|
|
1345
1345
|
c(map(h, (w) => ({ _id: w, ...b }))), o({
|
|
@@ -1359,8 +1359,8 @@ const useBlocksStoreManager = () => {
|
|
|
1359
1359
|
updateMultipleBlocksProps: (h) => {
|
|
1360
1360
|
let b = [];
|
|
1361
1361
|
b = map(h, (y) => {
|
|
1362
|
-
const R = keys(y), w = n.find((
|
|
1363
|
-
return each(R, (
|
|
1362
|
+
const R = keys(y), w = n.find((E) => E._id === y._id), j = {};
|
|
1363
|
+
return each(R, (E) => j[E] = w[E]), j;
|
|
1364
1364
|
}), c(h), o({
|
|
1365
1365
|
undo: () => c(b),
|
|
1366
1366
|
redo: () => c(h)
|
|
@@ -1370,7 +1370,7 @@ const useBlocksStoreManager = () => {
|
|
|
1370
1370
|
}, useAddBlock = () => {
|
|
1371
1371
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
1372
1372
|
(i, c, d) => {
|
|
1373
|
-
var
|
|
1373
|
+
var m;
|
|
1374
1374
|
for (let f = 0; f < i.length; f++) {
|
|
1375
1375
|
const { _id: h } = i[f];
|
|
1376
1376
|
i[f]._id = generateUUID();
|
|
@@ -1380,7 +1380,7 @@ const useBlocksStoreManager = () => {
|
|
|
1380
1380
|
}
|
|
1381
1381
|
const p = first(i);
|
|
1382
1382
|
let u, x;
|
|
1383
|
-
return c && (u = find(o, { _id: c }), i[0]._parent = c, x = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, x = u._parent), r(i, x, d), n([(
|
|
1383
|
+
return c && (u = find(o, { _id: c }), i[0]._parent = c, x = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, x = u._parent), r(i, x, d), n([(m = first(i)) == null ? void 0 : m._id]), first(i);
|
|
1384
1384
|
},
|
|
1385
1385
|
[r, o, n]
|
|
1386
1386
|
);
|
|
@@ -1395,8 +1395,8 @@ const useBlocksStoreManager = () => {
|
|
|
1395
1395
|
_id: p,
|
|
1396
1396
|
...u
|
|
1397
1397
|
};
|
|
1398
|
-
let
|
|
1399
|
-
return c && (
|
|
1398
|
+
let g, m;
|
|
1399
|
+
return c && (g = find(o, { _id: c }), x._parent = c, m = c), !canAcceptChildBlock(g == null ? void 0 : g._type, x._type) && g && (x._parent = g._parent, m = g._parent), r([x], m, d), n([x._id]), x;
|
|
1400
1400
|
},
|
|
1401
1401
|
[r, a, o, n]
|
|
1402
1402
|
), addPredefinedBlock: a };
|
|
@@ -2603,13 +2603,13 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), get
|
|
|
2603
2603
|
(a, l = null) => {
|
|
2604
2604
|
const i = [];
|
|
2605
2605
|
each(a, (c) => {
|
|
2606
|
-
const d = o.find((
|
|
2606
|
+
const d = o.find((m) => m._id === c);
|
|
2607
2607
|
l ? l === "root" && (l = null) : l = d._parent;
|
|
2608
2608
|
const x = filter(
|
|
2609
2609
|
o,
|
|
2610
|
-
(
|
|
2611
|
-
).indexOf(d) + 1,
|
|
2612
|
-
r(
|
|
2610
|
+
(m) => isString(l) ? m._parent === l : !m._parent
|
|
2611
|
+
).indexOf(d) + 1, g = getDuplicatedBlocks(o, c, l);
|
|
2612
|
+
r(g, l, x), i.push(get(g, "0._id", ""));
|
|
2613
2613
|
}), n(i);
|
|
2614
2614
|
},
|
|
2615
2615
|
[o, n]
|
|
@@ -2705,13 +2705,13 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), get
|
|
|
2705
2705
|
return map(i, (c) => {
|
|
2706
2706
|
const d = o(c), p = a;
|
|
2707
2707
|
let { classes: u, baseClasses: x } = getSplitClasses(get(d, l.prop, "styles:,"));
|
|
2708
|
-
return each(p, (
|
|
2709
|
-
const
|
|
2708
|
+
return each(p, (g) => {
|
|
2709
|
+
const m = g.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
|
|
2710
2710
|
u = u.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
2711
|
-
const h = first(
|
|
2712
|
-
includes(["2xl", "xl", "lg", "md", "sm"], h) && p.push(
|
|
2713
|
-
}), each(p, (
|
|
2714
|
-
const
|
|
2711
|
+
const h = first(g.split(":"));
|
|
2712
|
+
includes(["2xl", "xl", "lg", "md", "sm"], h) && p.push(g.split(":").pop().trim());
|
|
2713
|
+
}), each(p, (g) => {
|
|
2714
|
+
const m = g.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
|
|
2715
2715
|
x = x.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
2716
2716
|
}), {
|
|
2717
2717
|
ids: [d._id],
|
|
@@ -3125,8 +3125,8 @@ const getBlockWithChildren = (o, n) => {
|
|
|
3125
3125
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
3126
3126
|
})
|
|
3127
3127
|
), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
|
|
3128
|
-
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), x = p.length ? p : u,
|
|
3129
|
-
const h = cloneDeep(f.find((b) => b._id ===
|
|
3128
|
+
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), x = p.length ? p : u, g = (m, f) => {
|
|
3129
|
+
const h = cloneDeep(f.find((b) => b._id === m));
|
|
3130
3130
|
for (const b in h) {
|
|
3131
3131
|
const y = h[b];
|
|
3132
3132
|
typeof y == "string" && startsWith(y, STYLES_KEY) ? h[b] = compact(flattenDeep(y.replace(STYLES_KEY, "").split(","))).join(" ") : b !== "_id" && delete h[b];
|
|
@@ -3135,24 +3135,24 @@ const getBlockWithChildren = (o, n) => {
|
|
|
3135
3135
|
};
|
|
3136
3136
|
return {
|
|
3137
3137
|
askAi: useCallback(
|
|
3138
|
-
async (
|
|
3138
|
+
async (m, f, h, b) => {
|
|
3139
3139
|
if (l) {
|
|
3140
3140
|
n(!0), a(null);
|
|
3141
3141
|
try {
|
|
3142
|
-
const y = p === u ? "" : p, R =
|
|
3143
|
-
if (
|
|
3144
|
-
a(
|
|
3142
|
+
const y = p === u ? "" : p, R = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [g(f, d)], w = await l(m, addLangToPrompt(h, x, m), R, y), { blocks: j, error: E } = w;
|
|
3143
|
+
if (E) {
|
|
3144
|
+
a(E);
|
|
3145
3145
|
return;
|
|
3146
3146
|
}
|
|
3147
|
-
if (
|
|
3148
|
-
const k =
|
|
3147
|
+
if (m === "styles") {
|
|
3148
|
+
const k = j.map((C) => {
|
|
3149
3149
|
for (const _ in C)
|
|
3150
3150
|
_ !== "_id" && (C[_] = `${STYLES_KEY},${C[_]}`);
|
|
3151
3151
|
return C;
|
|
3152
3152
|
});
|
|
3153
3153
|
c(k);
|
|
3154
3154
|
} else
|
|
3155
|
-
i(
|
|
3155
|
+
i(j);
|
|
3156
3156
|
b && b(w);
|
|
3157
3157
|
} catch (y) {
|
|
3158
3158
|
a(y);
|
|
@@ -3250,7 +3250,7 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3250
3250
|
}
|
|
3251
3251
|
});
|
|
3252
3252
|
useResizeObserver(o, () => x(), o !== null);
|
|
3253
|
-
const
|
|
3253
|
+
const g = get(n, "_parent", null), m = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
|
|
3254
3254
|
return !o || !n || d ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
3255
3255
|
"div",
|
|
3256
3256
|
{
|
|
@@ -3267,16 +3267,16 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3267
3267
|
onKeyDown: (f) => f.stopPropagation(),
|
|
3268
3268
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3269
3269
|
children: [
|
|
3270
|
-
|
|
3270
|
+
g && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3271
3271
|
ArrowUpIcon,
|
|
3272
3272
|
{
|
|
3273
3273
|
className: "hover:scale-105",
|
|
3274
3274
|
onClick: () => {
|
|
3275
|
-
c([]), l([
|
|
3275
|
+
c([]), l([g]);
|
|
3276
3276
|
}
|
|
3277
3277
|
}
|
|
3278
3278
|
),
|
|
3279
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(BlockActionLabel, { label:
|
|
3279
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(BlockActionLabel, { label: m, block: n }),
|
|
3280
3280
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2 px-1", children: [
|
|
3281
3281
|
canAddChildBlock(get(n, "_type", "")) && /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3282
3282
|
PlusIcon,
|
|
@@ -3348,15 +3348,15 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3348
3348
|
<script src="https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.js"><\/script>
|
|
3349
3349
|
</body>
|
|
3350
3350
|
</html>`, useKeyEventWatcher = (o) => {
|
|
3351
|
-
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: x, pasteBlocks:
|
|
3351
|
+
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: x, pasteBlocks: g } = usePasteBlocks(), m = o ? { document: o } : {};
|
|
3352
3352
|
useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys("ctrl+c,command+c", () => u(n), {}, [n, u]), useHotkeys(
|
|
3353
3353
|
"ctrl+v,command+v",
|
|
3354
3354
|
() => {
|
|
3355
|
-
x(n[0]) &&
|
|
3355
|
+
x(n[0]) && g(n);
|
|
3356
3356
|
},
|
|
3357
|
-
{ ...
|
|
3358
|
-
[n, x,
|
|
3359
|
-
), useHotkeys("esc", () => r([]),
|
|
3357
|
+
{ ...m, preventDefault: !0 },
|
|
3358
|
+
[n, x, g]
|
|
3359
|
+
), useHotkeys("esc", () => r([]), m, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...m, preventDefault: !0 }, [
|
|
3360
3360
|
n,
|
|
3361
3361
|
i
|
|
3362
3362
|
]), useHotkeys(
|
|
@@ -3364,7 +3364,7 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3364
3364
|
(f) => {
|
|
3365
3365
|
f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
|
|
3366
3366
|
},
|
|
3367
|
-
|
|
3367
|
+
m,
|
|
3368
3368
|
[n, l]
|
|
3369
3369
|
);
|
|
3370
3370
|
}, KeyboardHandler = () => {
|
|
@@ -3450,38 +3450,38 @@ function removeDataDrop() {
|
|
|
3450
3450
|
const useDnd = () => {
|
|
3451
3451
|
const { document: o } = useFrame(), [n, r] = useAtom$1(draggingFlagAtom), { addCoreBlock: a } = useAddBlock(), [, l] = useHighlightBlockId(), [, i] = useSelectedBlockIds(), { moveBlocks: c } = useBlocksStoreUndoableActions(), [d, p] = useAtom$1(draggedBlockAtom), [, u] = useAtom$1(dropTargetBlockIdAtom);
|
|
3452
3452
|
if (!useFeature("dnd")) return {};
|
|
3453
|
-
const
|
|
3453
|
+
const g = () => {
|
|
3454
3454
|
removePlaceholder(), r(!1), p(null), u(null), possiblePositions = [];
|
|
3455
3455
|
};
|
|
3456
3456
|
return iframeDocument = o, {
|
|
3457
3457
|
isDragging: n,
|
|
3458
|
-
onDragOver: (
|
|
3459
|
-
|
|
3458
|
+
onDragOver: (m) => {
|
|
3459
|
+
m.preventDefault(), m.stopPropagation(), throttledDragOver(m);
|
|
3460
3460
|
},
|
|
3461
|
-
onDrop: (
|
|
3462
|
-
var
|
|
3463
|
-
const f = dropTarget, b = getOrientation(f) === "vertical" ?
|
|
3461
|
+
onDrop: (m) => {
|
|
3462
|
+
var E;
|
|
3463
|
+
const f = dropTarget, b = getOrientation(f) === "vertical" ? m.clientY + ((E = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : E.scrollY) : m.clientX;
|
|
3464
3464
|
dropIndex = calculateDropIndex(b, possiblePositions);
|
|
3465
3465
|
const y = d, R = f.getAttribute("data-block-id"), w = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
|
|
3466
3466
|
if ((y == null ? void 0 : y._id) === R || !w) {
|
|
3467
|
-
|
|
3467
|
+
g();
|
|
3468
3468
|
return;
|
|
3469
3469
|
}
|
|
3470
3470
|
if (!has(y, "_id")) {
|
|
3471
|
-
a(y, R === "canvas" ? null : R, dropIndex), setTimeout(
|
|
3471
|
+
a(y, R === "canvas" ? null : R, dropIndex), setTimeout(g, 300);
|
|
3472
3472
|
return;
|
|
3473
3473
|
}
|
|
3474
|
-
let
|
|
3475
|
-
|
|
3474
|
+
let j = f.getAttribute("data-block-id");
|
|
3475
|
+
j === null && (j = m.target.parentElement.getAttribute("data-block-id")), c([y._id], j === "canvas" ? null : j, dropIndex), g(), setTimeout(removePlaceholder, 300);
|
|
3476
3476
|
},
|
|
3477
|
-
onDragEnter: (
|
|
3478
|
-
const f =
|
|
3477
|
+
onDragEnter: (m) => {
|
|
3478
|
+
const f = m, h = f.target;
|
|
3479
3479
|
dropTarget = h;
|
|
3480
3480
|
const b = h.getAttribute("data-block-id"), y = h.getAttribute("data-dnd-dragged") !== "yes";
|
|
3481
3481
|
u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(h), r(!0), l(""), i([]);
|
|
3482
3482
|
},
|
|
3483
|
-
onDragLeave: (
|
|
3484
|
-
|
|
3483
|
+
onDragLeave: (m) => {
|
|
3484
|
+
m.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
|
|
3485
3485
|
}
|
|
3486
3486
|
};
|
|
3487
3487
|
};
|
|
@@ -3501,25 +3501,25 @@ function destroyQuill(o) {
|
|
|
3501
3501
|
const useHandleCanvasDblClick = () => {
|
|
3502
3502
|
const o = ["Heading", "Paragraph", "Text", "Link", "Span", "Button"], n = useUpdateBlocksProps(), [r, a] = useAtom$1(inlineEditingActiveAtom), { clearHighlight: l } = useBlockHighlight();
|
|
3503
3503
|
return (i) => {
|
|
3504
|
-
var
|
|
3504
|
+
var g;
|
|
3505
3505
|
if (r) return;
|
|
3506
3506
|
const c = getTargetedBlock(i.target), d = c.getAttribute("data-block-type");
|
|
3507
3507
|
if (!d || !o.includes(d))
|
|
3508
3508
|
return;
|
|
3509
3509
|
const p = c.cloneNode(!0);
|
|
3510
|
-
c.style.display = "none", Array.from(p.attributes).forEach((
|
|
3511
|
-
|
|
3510
|
+
c.style.display = "none", Array.from(p.attributes).forEach((m) => {
|
|
3511
|
+
m.name !== "class" && p.removeAttribute(m.name);
|
|
3512
3512
|
}), d === "Text" && (p.style.display = "inline-block"), c.parentNode.insertBefore(p, c.nextSibling);
|
|
3513
3513
|
const u = new Quill(p, { placeholder: "Type here..." });
|
|
3514
3514
|
function x() {
|
|
3515
|
-
const
|
|
3516
|
-
n([c.getAttribute("data-block-id")], { content:
|
|
3515
|
+
const m = u.getText(0, u.getLength());
|
|
3516
|
+
n([c.getAttribute("data-block-id")], { content: m }), c.removeAttribute("style"), p.removeEventListener("blur", x, !0), destroyQuill(u), a(""), l(), p.remove();
|
|
3517
3517
|
}
|
|
3518
|
-
p.addEventListener("blur", x, !0), p.addEventListener("click", (
|
|
3519
|
-
|
|
3520
|
-
}), p.addEventListener("keydown", (
|
|
3521
|
-
(
|
|
3522
|
-
}), u.focus(), (
|
|
3518
|
+
p.addEventListener("blur", x, !0), p.addEventListener("click", (m) => {
|
|
3519
|
+
m.stopPropagation();
|
|
3520
|
+
}), p.addEventListener("keydown", (m) => {
|
|
3521
|
+
(m.key === "Enter" || m.key === "Escape") && x();
|
|
3522
|
+
}), u.focus(), (g = p.querySelector(".ql-clipboard")) == null || g.remove(), a(c.getAttribute("data-block-id"));
|
|
3523
3523
|
};
|
|
3524
3524
|
}, useHandleCanvasClick = () => {
|
|
3525
3525
|
const [, o] = useSelectedStylingBlocks(), [n, r] = useSelectedBlockIds(), [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(treeRefAtom), { clearHighlight: i } = useBlockHighlight();
|
|
@@ -3556,12 +3556,12 @@ const useHandleCanvasDblClick = () => {
|
|
|
3556
3556
|
setTimeout(() => {
|
|
3557
3557
|
if (!isEmpty(a))
|
|
3558
3558
|
return;
|
|
3559
|
-
const
|
|
3560
|
-
if (
|
|
3561
|
-
const
|
|
3562
|
-
if (
|
|
3563
|
-
const f =
|
|
3564
|
-
l([{ id: f, prop:
|
|
3559
|
+
const g = getElementByDataBlockId(n, first(r));
|
|
3560
|
+
if (g) {
|
|
3561
|
+
const m = g.getAttribute("data-style-prop");
|
|
3562
|
+
if (m) {
|
|
3563
|
+
const f = g.getAttribute("data-style-id"), h = g.getAttribute("data-block-parent");
|
|
3564
|
+
l([{ id: f, prop: m, blockId: h }]);
|
|
3565
3565
|
}
|
|
3566
3566
|
}
|
|
3567
3567
|
}, 100);
|
|
@@ -3584,9 +3584,9 @@ const useHandleCanvasDblClick = () => {
|
|
|
3584
3584
|
}, getElementByDataBlockId = (o, n) => o.querySelector(`[data-block-id="${n}"]`), HeadTags = () => {
|
|
3585
3585
|
const [o] = useTheme(), n = useThemeOptions(), [r] = useSelectedBlockIds(), [a] = useDarkMode(), [l] = useSelectedStylingBlocks(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), { document: d, window: p } = useFrame(), [u] = useState(d == null ? void 0 : d.getElementById("highlighted-block")), [x] = useState(
|
|
3586
3586
|
d == null ? void 0 : d.getElementById("selected-block")
|
|
3587
|
-
), [m] = useState(
|
|
3588
|
-
d == null ? void 0 : d.getElementById("selected-styling-block")
|
|
3589
3587
|
), [g] = useState(
|
|
3588
|
+
d == null ? void 0 : d.getElementById("selected-styling-block")
|
|
3589
|
+
), [m] = useState(
|
|
3590
3590
|
d == null ? void 0 : d.getElementById("dragged-block")
|
|
3591
3591
|
);
|
|
3592
3592
|
useEffect(() => {
|
|
@@ -3630,14 +3630,14 @@ const useHandleCanvasDblClick = () => {
|
|
|
3630
3630
|
outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
|
|
3631
3631
|
}`);
|
|
3632
3632
|
}, [r, x]), useEffect(() => {
|
|
3633
|
-
|
|
3634
|
-
}, [i,
|
|
3633
|
+
m.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
|
|
3634
|
+
}, [i, m]), useEffect(() => {
|
|
3635
3635
|
u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
|
|
3636
3636
|
}, [u]), useEffect(() => {
|
|
3637
|
-
|
|
3637
|
+
g && (g.textContent = `${map(l, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
|
|
3638
3638
|
outline: 1px solid orange !important; outline-offset: -1px;
|
|
3639
3639
|
}`);
|
|
3640
|
-
}, [l,
|
|
3640
|
+
}, [l, g]), useEffect(() => {
|
|
3641
3641
|
d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
|
|
3642
3642
|
}, [c, d]);
|
|
3643
3643
|
const f = useMemo(
|
|
@@ -3723,60 +3723,60 @@ function applyLanguage(o, n, r) {
|
|
|
3723
3723
|
}), a;
|
|
3724
3724
|
}
|
|
3725
3725
|
function BlocksRendererStatic({ blocks: o, allBlocks: n }) {
|
|
3726
|
-
const { selectedLang: r } = useLanguages(), [
|
|
3726
|
+
const { selectedLang: r, fallbackLang: a } = useLanguages(), [l] = useCutBlockIds(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), [d] = useHiddenBlockIds(), { getGlobalBlocks: p } = useGlobalBlocksStore(), u = useCallback((m) => getStyleAttrs(m), []), [x] = useChaiExternalData(), [g] = useAtom$1(inlineEditingActiveAtom);
|
|
3727
3727
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: React__default.Children.toArray(
|
|
3728
|
-
o.map((m,
|
|
3729
|
-
if (
|
|
3730
|
-
const
|
|
3731
|
-
if (
|
|
3732
|
-
const
|
|
3733
|
-
|
|
3728
|
+
o.map((m, f) => {
|
|
3729
|
+
if (g === m._id || d.includes(m._id)) return null;
|
|
3730
|
+
const h = {}, b = filter(n, { _parent: m._id });
|
|
3731
|
+
if (h.children = b.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(BlocksRendererStatic, { allBlocks: n, blocks: b }) : null, m._type === "GlobalBlock") {
|
|
3732
|
+
const _ = p(m);
|
|
3733
|
+
h.children = /* @__PURE__ */ jsxRuntimeExports.jsx(RenderGlobalBlock, { blocks: filter(_, (P) => !P._parent), allBlocks: _ });
|
|
3734
3734
|
}
|
|
3735
|
-
const
|
|
3736
|
-
if (isNull(
|
|
3737
|
-
const
|
|
3735
|
+
const y = getRegisteredChaiBlock(m._type), R = get(y, "component", null);
|
|
3736
|
+
if (isNull(R)) return /* @__PURE__ */ jsxRuntimeExports.jsx("noscript", { children: `<!-- ${m == null ? void 0 : m._type} not registered -->` });
|
|
3737
|
+
const w = u(m), j = i && isDescendant(i._id, m._id, n), k = {
|
|
3738
3738
|
blockProps: {
|
|
3739
3739
|
"data-block-id": m._id,
|
|
3740
3740
|
"data-block-type": m._type,
|
|
3741
|
-
...
|
|
3741
|
+
...i ? (
|
|
3742
3742
|
// @ts-ignore
|
|
3743
3743
|
{
|
|
3744
|
-
"data-dnd": canAcceptChildBlock(m._type,
|
|
3745
|
-
"data-dnd-dragged":
|
|
3744
|
+
"data-dnd": canAcceptChildBlock(m._type, i == null ? void 0 : i._type) ? "yes" : "no",
|
|
3745
|
+
"data-dnd-dragged": i._id === m._id || j ? "yes" : "no"
|
|
3746
3746
|
}
|
|
3747
3747
|
) : {},
|
|
3748
|
-
...
|
|
3749
|
-
...includes(
|
|
3748
|
+
...c === m._id && !j ? { "data-drop": "yes" } : {},
|
|
3749
|
+
...includes(l, m._id) ? { "data-cut-block": "yes" } : {}
|
|
3750
3750
|
},
|
|
3751
|
-
index:
|
|
3752
|
-
...applyBindings(applyLanguage(m, r,
|
|
3753
|
-
...
|
|
3754
|
-
...
|
|
3751
|
+
index: f,
|
|
3752
|
+
...applyBindings(applyLanguage(m, r, y), x),
|
|
3753
|
+
...w,
|
|
3754
|
+
...h,
|
|
3755
3755
|
inBuilder: !0,
|
|
3756
|
-
lang: r
|
|
3756
|
+
lang: r || a
|
|
3757
3757
|
};
|
|
3758
|
-
if (has(
|
|
3758
|
+
if (has(y, "dataProvider"))
|
|
3759
3759
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3760
3760
|
AsyncPropsBlock,
|
|
3761
3761
|
{
|
|
3762
|
-
lang: r,
|
|
3763
|
-
dataProvider:
|
|
3762
|
+
lang: r || a,
|
|
3763
|
+
dataProvider: y.dataProvider,
|
|
3764
3764
|
block: m,
|
|
3765
|
-
component:
|
|
3766
|
-
props:
|
|
3765
|
+
component: R,
|
|
3766
|
+
props: k
|
|
3767
3767
|
}
|
|
3768
3768
|
) });
|
|
3769
|
-
const
|
|
3770
|
-
return
|
|
3769
|
+
const C = getRuntimeProps(m._type);
|
|
3770
|
+
return C ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
3771
3771
|
RuntimePropsBlock,
|
|
3772
3772
|
{
|
|
3773
|
-
runtimeProps:
|
|
3773
|
+
runtimeProps: C,
|
|
3774
3774
|
block: m,
|
|
3775
|
-
component:
|
|
3776
|
-
props:
|
|
3775
|
+
component: R,
|
|
3776
|
+
props: k
|
|
3777
3777
|
},
|
|
3778
3778
|
m._id
|
|
3779
|
-
) : /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: React__default.createElement(
|
|
3779
|
+
) : /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: React__default.createElement(R, k) });
|
|
3780
3780
|
})
|
|
3781
3781
|
) });
|
|
3782
3782
|
}
|
|
@@ -3789,11 +3789,11 @@ const StaticBlocksRenderer = () => {
|
|
|
3789
3789
|
if (d < n) {
|
|
3790
3790
|
const u = parseFloat((d / n).toFixed(2).toString());
|
|
3791
3791
|
let x = {};
|
|
3792
|
-
const
|
|
3792
|
+
const g = p * u, m = d * u;
|
|
3793
3793
|
p && (x = {
|
|
3794
3794
|
// Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
|
|
3795
|
-
height: 100 + (p -
|
|
3796
|
-
width: 100 + (d -
|
|
3795
|
+
height: 100 + (p - g) / g * 100 + "%",
|
|
3796
|
+
width: 100 + (d - m) / m * 100 + "%"
|
|
3797
3797
|
}), i({
|
|
3798
3798
|
position: "relative",
|
|
3799
3799
|
top: 0,
|
|
@@ -3810,7 +3810,7 @@ const StaticBlocksRenderer = () => {
|
|
|
3810
3810
|
c();
|
|
3811
3811
|
}, [n, o, r, c]), l;
|
|
3812
3812
|
}, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
|
|
3813
|
-
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [x,
|
|
3813
|
+
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [x, g] = useState([]), [, m] = useState([]), [, f] = useAtom$1(canvasIframeAtom), [h, b] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), R = useBuilderProp("htmlDir", "ltr"), w = (k) => {
|
|
3814
3814
|
p((C) => ({ ...C, width: k }));
|
|
3815
3815
|
};
|
|
3816
3816
|
useEffect(() => {
|
|
@@ -3818,7 +3818,7 @@ const StaticBlocksRenderer = () => {
|
|
|
3818
3818
|
const { clientWidth: k, clientHeight: C } = c.current;
|
|
3819
3819
|
p({ width: k, height: C });
|
|
3820
3820
|
}, [c, n]);
|
|
3821
|
-
const
|
|
3821
|
+
const j = (k, C = 0) => {
|
|
3822
3822
|
const { top: _ } = k.getBoundingClientRect();
|
|
3823
3823
|
return _ + C >= 0 && _ - C <= window.innerHeight;
|
|
3824
3824
|
};
|
|
@@ -3826,7 +3826,7 @@ const StaticBlocksRenderer = () => {
|
|
|
3826
3826
|
var k, C;
|
|
3827
3827
|
if (a && a.type !== "Multiple" && i.current) {
|
|
3828
3828
|
const _ = getElementByDataBlockId(i.current.contentDocument, a._id);
|
|
3829
|
-
_ && (
|
|
3829
|
+
_ && (j(_) || (C = (k = i.current) == null ? void 0 : k.contentWindow) == null || C.scrollTo({ top: _.offsetTop, behavior: "smooth" }), g([_]));
|
|
3830
3830
|
}
|
|
3831
3831
|
}, [a]), useEffect(() => {
|
|
3832
3832
|
if (!isEmpty(h) && i.current) {
|
|
@@ -3834,11 +3834,11 @@ const StaticBlocksRenderer = () => {
|
|
|
3834
3834
|
i.current.contentDocument,
|
|
3835
3835
|
first(h).id
|
|
3836
3836
|
);
|
|
3837
|
-
|
|
3837
|
+
m(k ? [k] : [null]);
|
|
3838
3838
|
} else
|
|
3839
|
-
|
|
3839
|
+
m([null]);
|
|
3840
3840
|
}, [h]);
|
|
3841
|
-
const
|
|
3841
|
+
const E = useMemo(() => {
|
|
3842
3842
|
let k = IframeInitialContent;
|
|
3843
3843
|
return k = k.replace("__HTML_DIR__", R), o === "offline" && (k = k.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), k;
|
|
3844
3844
|
}, [o, R]);
|
|
@@ -3859,7 +3859,7 @@ const StaticBlocksRenderer = () => {
|
|
|
3859
3859
|
id: "canvas-iframe",
|
|
3860
3860
|
style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
|
|
3861
3861
|
className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
|
|
3862
|
-
initialContent:
|
|
3862
|
+
initialContent: E,
|
|
3863
3863
|
children: [
|
|
3864
3864
|
/* @__PURE__ */ jsxRuntimeExports.jsx(KeyboardHandler, {}),
|
|
3865
3865
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -4112,14 +4112,14 @@ const StaticBlocksRenderer = () => {
|
|
|
4112
4112
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
4113
4113
|
const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), [c, d] = useTheme(), p = useThemeOptions(), { t: u } = useTranslation(), x = (y) => {
|
|
4114
4114
|
a(y);
|
|
4115
|
-
},
|
|
4115
|
+
}, g = () => {
|
|
4116
4116
|
const y = l.find((R) => Object.keys(R)[0] === r);
|
|
4117
4117
|
if (y) {
|
|
4118
4118
|
const R = Object.values(y)[0];
|
|
4119
4119
|
R && typeof R == "object" && "fontFamily" in R && "borderRadius" in R && "colors" in R ? d(R) : console.error("Invalid preset structure:", R);
|
|
4120
4120
|
} else
|
|
4121
4121
|
console.error("Preset not found:", r);
|
|
4122
|
-
},
|
|
4122
|
+
}, m = useDebouncedCallback(
|
|
4123
4123
|
(y, R) => {
|
|
4124
4124
|
d(() => ({
|
|
4125
4125
|
...c,
|
|
@@ -4162,10 +4162,10 @@ const StaticBlocksRenderer = () => {
|
|
|
4162
4162
|
ColorPickerInput,
|
|
4163
4163
|
{
|
|
4164
4164
|
value: w,
|
|
4165
|
-
onChange: (
|
|
4165
|
+
onChange: (j) => h(R, j)
|
|
4166
4166
|
}
|
|
4167
4167
|
),
|
|
4168
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: R.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((
|
|
4168
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: R.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((j) => j.charAt(0).toUpperCase() + j.slice(1)).join(" ") + (!R.toLowerCase().includes("foreground") && !R.toLowerCase().includes("border") && !R.toLowerCase().includes("input") && !R.toLowerCase().includes("ring") && !R.toLowerCase().includes("background") ? " Background" : "") })
|
|
4169
4169
|
] }, R);
|
|
4170
4170
|
}) });
|
|
4171
4171
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative w-full", children: [
|
|
@@ -4192,7 +4192,7 @@ const StaticBlocksRenderer = () => {
|
|
|
4192
4192
|
className: "w-full text-sm",
|
|
4193
4193
|
disabled: r === "",
|
|
4194
4194
|
variant: "default",
|
|
4195
|
-
onClick:
|
|
4195
|
+
onClick: g,
|
|
4196
4196
|
children: u("Apply")
|
|
4197
4197
|
}
|
|
4198
4198
|
) })
|
|
@@ -4203,7 +4203,7 @@ const StaticBlocksRenderer = () => {
|
|
|
4203
4203
|
{
|
|
4204
4204
|
label: y,
|
|
4205
4205
|
value: c.fontFamily[y.replace(/font-/g, "")] || R[Object.keys(R)[0]],
|
|
4206
|
-
onChange: (w) =>
|
|
4206
|
+
onChange: (w) => m(y, w)
|
|
4207
4207
|
},
|
|
4208
4208
|
y
|
|
4209
4209
|
)) }),
|
|
@@ -4433,17 +4433,17 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4433
4433
|
pageTypes: n,
|
|
4434
4434
|
onChange: r
|
|
4435
4435
|
}) => {
|
|
4436
|
-
var
|
|
4437
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, I) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, x] = useState("page"), [
|
|
4436
|
+
var P;
|
|
4437
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, I) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, x] = useState("page"), [g, m] = useState(""), [f, h] = useState([]), [b, y] = useState(-1), R = useRef(null), w = (P = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : P.name;
|
|
4438
4438
|
useEffect(() => {
|
|
4439
|
-
if (
|
|
4439
|
+
if (m(""), h([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4440
4440
|
const v = split(o, ":"), I = get(v, 1, "page") || "page";
|
|
4441
4441
|
x(I), (async () => {
|
|
4442
4442
|
const B = await l(I, [get(v, 2, "page")]);
|
|
4443
|
-
B && Array.isArray(B) &&
|
|
4443
|
+
B && Array.isArray(B) && m(get(B, [0, "name"], ""));
|
|
4444
4444
|
})();
|
|
4445
4445
|
}, [o]);
|
|
4446
|
-
const
|
|
4446
|
+
const j = useDebouncedCallback(
|
|
4447
4447
|
async (v) => {
|
|
4448
4448
|
if (isEmpty(v))
|
|
4449
4449
|
h([]);
|
|
@@ -4455,9 +4455,9 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4455
4455
|
},
|
|
4456
4456
|
[u],
|
|
4457
4457
|
300
|
|
4458
|
-
),
|
|
4458
|
+
), E = (v) => {
|
|
4459
4459
|
const I = ["pageType", u, v.id];
|
|
4460
|
-
I[1] && (r(I.join(":")),
|
|
4460
|
+
I[1] && (r(I.join(":")), m(v.name), p(!1), h([]), y(-1));
|
|
4461
4461
|
}, k = (v) => {
|
|
4462
4462
|
switch (v.key) {
|
|
4463
4463
|
case "ArrowDown":
|
|
@@ -4468,7 +4468,7 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4468
4468
|
break;
|
|
4469
4469
|
case "Enter":
|
|
4470
4470
|
if (v.preventDefault(), f.length === 0) return;
|
|
4471
|
-
b >= 0 &&
|
|
4471
|
+
b >= 0 && E(f[b]);
|
|
4472
4472
|
break;
|
|
4473
4473
|
case "Escape":
|
|
4474
4474
|
v.preventDefault(), C();
|
|
@@ -4482,9 +4482,9 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4482
4482
|
}
|
|
4483
4483
|
}, [b]);
|
|
4484
4484
|
const C = () => {
|
|
4485
|
-
|
|
4485
|
+
m(""), h([]), y(-1), p(!1), r("");
|
|
4486
4486
|
}, _ = (v) => {
|
|
4487
|
-
|
|
4487
|
+
m(v), p(!isEmpty(v)), c(!0), j(v);
|
|
4488
4488
|
};
|
|
4489
4489
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
4490
4490
|
/* @__PURE__ */ jsxRuntimeExports.jsx("select", { name: "pageType", value: u, onChange: (v) => x(v.target.value), children: map(n, (v) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: v.key, children: v.name }, v.key)) }),
|
|
@@ -4493,14 +4493,14 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4493
4493
|
"input",
|
|
4494
4494
|
{
|
|
4495
4495
|
type: "text",
|
|
4496
|
-
value:
|
|
4496
|
+
value: g,
|
|
4497
4497
|
onChange: (v) => _(v.target.value),
|
|
4498
4498
|
onKeyDown: k,
|
|
4499
4499
|
placeholder: a(`Search ${w ?? ""}`),
|
|
4500
4500
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4501
4501
|
}
|
|
4502
4502
|
),
|
|
4503
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children:
|
|
4503
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: g && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: C, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "h-4 w-4" }) }) })
|
|
4504
4504
|
] }),
|
|
4505
4505
|
(i || !isEmpty(f) || d && isEmpty(f)) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1 p-2", children: [
|
|
4506
4506
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
@@ -4508,12 +4508,12 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4508
4508
|
] }) : d && isEmpty(f) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4509
4509
|
a("No results found for"),
|
|
4510
4510
|
' "',
|
|
4511
|
-
|
|
4511
|
+
g,
|
|
4512
4512
|
'"'
|
|
4513
4513
|
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { ref: R, children: map(f == null ? void 0 : f.slice(0, 20), (v, I) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4514
4514
|
"li",
|
|
4515
4515
|
{
|
|
4516
|
-
onClick: () =>
|
|
4516
|
+
onClick: () => E(v),
|
|
4517
4517
|
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : I === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
4518
4518
|
children: [
|
|
4519
4519
|
v.name,
|
|
@@ -4607,14 +4607,14 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4607
4607
|
}, [a]), useEffect(() => {
|
|
4608
4608
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
|
|
4609
4609
|
}, [o, u]);
|
|
4610
|
-
const
|
|
4610
|
+
const g = () => {
|
|
4611
4611
|
const h = findIndex(u, { _id: x });
|
|
4612
4612
|
if (h > -1) {
|
|
4613
4613
|
const b = (h + 1) % u.length, y = get(u, [b, "_id"]);
|
|
4614
4614
|
if (!y) return;
|
|
4615
4615
|
n({ ...o, currentSlide: y }), c([y]);
|
|
4616
4616
|
}
|
|
4617
|
-
},
|
|
4617
|
+
}, m = () => {
|
|
4618
4618
|
const h = findIndex(u, { _id: x });
|
|
4619
4619
|
if (h > -1) {
|
|
4620
4620
|
const b = (h - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
|
|
@@ -4630,7 +4630,7 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4630
4630
|
};
|
|
4631
4631
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4632
4632
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
4633
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick:
|
|
4633
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
|
|
4634
4634
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: x ? /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "", children: [
|
|
4635
4635
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("b", { className: "text-[12px]", children: [
|
|
4636
4636
|
" ",
|
|
@@ -4639,7 +4639,7 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4639
4639
|
"/",
|
|
4640
4640
|
u.length
|
|
4641
4641
|
] }) : "-" }),
|
|
4642
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick:
|
|
4642
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: g, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
|
|
4643
4643
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4644
4644
|
"button",
|
|
4645
4645
|
{
|
|
@@ -4744,19 +4744,19 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4744
4744
|
schema: u,
|
|
4745
4745
|
formData: x
|
|
4746
4746
|
}) => {
|
|
4747
|
-
const { selectedLang:
|
|
4747
|
+
const { selectedLang: g, fallbackLang: m, languages: f } = useLanguages(), h = isEmpty(f) ? "" : isEmpty(g) ? m : g, b = get(LANGUAGES, h, h), y = useSelectedBlock(), R = useRegisteredChaiBlocks(), w = get(R, [y == null ? void 0 : y._type, "i18nProps"], []) || [], [j, E] = useState(null);
|
|
4748
4748
|
if (d)
|
|
4749
4749
|
return null;
|
|
4750
4750
|
if (u.type === "boolean") return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: n, children: a });
|
|
4751
4751
|
const C = w == null ? void 0 : w.includes(o.replace("root.", ""));
|
|
4752
4752
|
if (u.type === "array") {
|
|
4753
|
-
const _ =
|
|
4753
|
+
const _ = j === o;
|
|
4754
4754
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${n} relative`, children: [
|
|
4755
4755
|
u.title && /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
4756
4756
|
"label",
|
|
4757
4757
|
{
|
|
4758
4758
|
htmlFor: o,
|
|
4759
|
-
onClick: () =>
|
|
4759
|
+
onClick: () => E(_ ? null : o),
|
|
4760
4760
|
className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
|
|
4761
4761
|
children: [
|
|
4762
4762
|
_ ? /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "h-3 w-3" }),
|
|
@@ -4799,9 +4799,9 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4799
4799
|
useEffect(() => {
|
|
4800
4800
|
c(a);
|
|
4801
4801
|
}, [o, d]);
|
|
4802
|
-
const
|
|
4803
|
-
async ({ formData:
|
|
4804
|
-
l({ formData:
|
|
4802
|
+
const g = useThrottledCallback(
|
|
4803
|
+
async ({ formData: m }, f) => {
|
|
4804
|
+
l({ formData: m }, f);
|
|
4805
4805
|
},
|
|
4806
4806
|
[l, d],
|
|
4807
4807
|
1e3
|
|
@@ -4840,8 +4840,8 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4840
4840
|
uiSchema: r,
|
|
4841
4841
|
schema: n,
|
|
4842
4842
|
formData: i,
|
|
4843
|
-
onChange: ({ formData:
|
|
4844
|
-
f && (c(
|
|
4843
|
+
onChange: ({ formData: m }, f) => {
|
|
4844
|
+
f && (c(m), g({ formData: m }, f));
|
|
4845
4845
|
}
|
|
4846
4846
|
},
|
|
4847
4847
|
d
|
|
@@ -4856,10 +4856,10 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4856
4856
|
return set(r, o, n), r;
|
|
4857
4857
|
};
|
|
4858
4858
|
function BlockSettings() {
|
|
4859
|
-
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), x = useWrapperBlock(),
|
|
4859
|
+
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), x = useWrapperBlock(), g = getRegisteredChaiBlock(x == null ? void 0 : x._type), m = formDataWithSelectedLang(x, o, g), f = ({ formData: k }, C, _) => {
|
|
4860
4860
|
if (C && (c == null ? void 0 : c._id) === n._id) {
|
|
4861
|
-
const
|
|
4862
|
-
a([n._id], { [
|
|
4861
|
+
const P = C.replace("root.", "");
|
|
4862
|
+
a([n._id], { [P]: get(k, P) }, _);
|
|
4863
4863
|
}
|
|
4864
4864
|
}, h = useCallback(
|
|
4865
4865
|
debounce(({ formData: k }, C, _) => {
|
|
@@ -4888,7 +4888,7 @@ function BlockSettings() {
|
|
|
4888
4888
|
const k = n == null ? void 0 : n._type;
|
|
4889
4889
|
if (k)
|
|
4890
4890
|
return getBlockFormSchemas(k);
|
|
4891
|
-
}, [n]), { wrapperSchema:
|
|
4891
|
+
}, [n]), { wrapperSchema: j, wrapperUiSchema: E } = useMemo(() => {
|
|
4892
4892
|
if (!x || !(x != null && x._type))
|
|
4893
4893
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
4894
4894
|
const k = x == null ? void 0 : x._type, { schema: C = {}, uiSchema: _ = {} } = getBlockFormSchemas(k);
|
|
@@ -4919,9 +4919,9 @@ function BlockSettings() {
|
|
|
4919
4919
|
{
|
|
4920
4920
|
id: x == null ? void 0 : x._id,
|
|
4921
4921
|
onChange: y,
|
|
4922
|
-
formData:
|
|
4923
|
-
schema:
|
|
4924
|
-
uiSchema:
|
|
4922
|
+
formData: m,
|
|
4923
|
+
schema: j,
|
|
4924
|
+
uiSchema: E
|
|
4925
4925
|
}
|
|
4926
4926
|
) })
|
|
4927
4927
|
] }),
|
|
@@ -5004,11 +5004,11 @@ function Countdown() {
|
|
|
5004
5004
|
const AskAIStyles = ({ blockId: o }) => {
|
|
5005
5005
|
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, x] = useState();
|
|
5006
5006
|
useEffect(() => {
|
|
5007
|
-
var
|
|
5008
|
-
(
|
|
5007
|
+
var m;
|
|
5008
|
+
(m = d.current) == null || m.focus();
|
|
5009
5009
|
}, []);
|
|
5010
|
-
const
|
|
5011
|
-
const { usage: f } =
|
|
5010
|
+
const g = (m) => {
|
|
5011
|
+
const { usage: f } = m || {};
|
|
5012
5012
|
!l && f && x(f), p.current = setTimeout(() => x(void 0), 1e4), l || c("");
|
|
5013
5013
|
};
|
|
5014
5014
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "", children: [
|
|
@@ -5018,12 +5018,12 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5018
5018
|
{
|
|
5019
5019
|
ref: d,
|
|
5020
5020
|
value: i,
|
|
5021
|
-
onChange: (
|
|
5021
|
+
onChange: (m) => c(m.target.value),
|
|
5022
5022
|
placeholder: n("Ask AI to edit styles"),
|
|
5023
5023
|
className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
|
|
5024
5024
|
rows: 4,
|
|
5025
|
-
onKeyDown: (
|
|
5026
|
-
|
|
5025
|
+
onKeyDown: (m) => {
|
|
5026
|
+
m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), x(void 0), r("styles", o, i, g));
|
|
5027
5027
|
}
|
|
5028
5028
|
}
|
|
5029
5029
|
),
|
|
@@ -5033,7 +5033,7 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5033
5033
|
{
|
|
5034
5034
|
disabled: i.trim().length < 5 || a,
|
|
5035
5035
|
onClick: () => {
|
|
5036
|
-
p.current && clearTimeout(p.current), x(void 0), r("styles", o, i,
|
|
5036
|
+
p.current && clearTimeout(p.current), x(void 0), r("styles", o, i, g);
|
|
5037
5037
|
},
|
|
5038
5038
|
variant: "default",
|
|
5039
5039
|
className: "w-fit",
|
|
@@ -5065,24 +5065,24 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5065
5065
|
};
|
|
5066
5066
|
function ManualClasses() {
|
|
5067
5067
|
var C;
|
|
5068
|
-
const o = useFuseSearch(), { t: n } = useTranslation(), [r] = useSelectedStylingBlocks(), a = useSelectedBlock(), l = useAddClassesToBlocks(), i = useRemoveClassesFromBlocks(), [c] = useSelectedBlockIds(), d = useBuilderProp("askAiCallBack", null), [p, u] = useState(""), { toast: x } = useToast(),
|
|
5068
|
+
const o = useFuseSearch(), { t: n } = useTranslation(), [r] = useSelectedStylingBlocks(), a = useSelectedBlock(), l = useAddClassesToBlocks(), i = useRemoveClassesFromBlocks(), [c] = useSelectedBlockIds(), d = useBuilderProp("askAiCallBack", null), [p, u] = useState(""), { toast: x } = useToast(), g = (C = first(r)) == null ? void 0 : C.prop, m = reject((get(a, g, "").replace(STYLES_KEY, "").split(",").pop() || "").split(" "), isEmpty), f = () => {
|
|
5069
5069
|
const _ = p.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5070
5070
|
l(c, _, !0), u("");
|
|
5071
5071
|
}, [h, b] = useState([]), y = ({ value: _ }) => {
|
|
5072
|
-
const
|
|
5072
|
+
const P = _.trim().toLowerCase(), v = P.match(/.+:/g);
|
|
5073
5073
|
let I = [];
|
|
5074
5074
|
if (v && v.length > 0) {
|
|
5075
|
-
const [B] = v, A =
|
|
5075
|
+
const [B] = v, A = P.replace(B, "");
|
|
5076
5076
|
I = o.search(A).map((T) => ({
|
|
5077
5077
|
...T,
|
|
5078
5078
|
item: { ...T.item, name: B + T.item.name }
|
|
5079
5079
|
}));
|
|
5080
5080
|
} else
|
|
5081
|
-
I = o.search(
|
|
5081
|
+
I = o.search(P);
|
|
5082
5082
|
return b(map(I, "item"));
|
|
5083
5083
|
}, R = () => {
|
|
5084
5084
|
b([]);
|
|
5085
|
-
}, w = (_) => _.name,
|
|
5085
|
+
}, w = (_) => _.name, j = (_) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md p-1", children: _.name }), E = {
|
|
5086
5086
|
autoComplete: "off",
|
|
5087
5087
|
autoCorrect: "off",
|
|
5088
5088
|
autoCapitalize: "off",
|
|
@@ -5092,7 +5092,7 @@ function ManualClasses() {
|
|
|
5092
5092
|
onKeyDown: (_) => {
|
|
5093
5093
|
_.key === "Enter" && p.trim() !== "" && f();
|
|
5094
5094
|
},
|
|
5095
|
-
onChange: (_, { newValue:
|
|
5095
|
+
onChange: (_, { newValue: P }) => u(P),
|
|
5096
5096
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
5097
5097
|
}, k = () => {
|
|
5098
5098
|
if (navigator.clipboard === void 0) {
|
|
@@ -5103,7 +5103,7 @@ function ManualClasses() {
|
|
|
5103
5103
|
});
|
|
5104
5104
|
return;
|
|
5105
5105
|
}
|
|
5106
|
-
navigator.clipboard.writeText(
|
|
5106
|
+
navigator.clipboard.writeText(m.join(" ")), x({
|
|
5107
5107
|
title: n("Copied"),
|
|
5108
5108
|
description: n("Classes copied to clipboard")
|
|
5109
5109
|
});
|
|
@@ -5133,8 +5133,8 @@ function ManualClasses() {
|
|
|
5133
5133
|
onSuggestionsFetchRequested: y,
|
|
5134
5134
|
onSuggestionsClearRequested: R,
|
|
5135
5135
|
getSuggestionValue: w,
|
|
5136
|
-
renderSuggestion:
|
|
5137
|
-
inputProps:
|
|
5136
|
+
renderSuggestion: j,
|
|
5137
|
+
inputProps: E,
|
|
5138
5138
|
containerProps: {
|
|
5139
5139
|
className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
|
|
5140
5140
|
},
|
|
@@ -5157,7 +5157,7 @@ function ManualClasses() {
|
|
|
5157
5157
|
}
|
|
5158
5158
|
)
|
|
5159
5159
|
] }),
|
|
5160
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children:
|
|
5160
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: m.map((_) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
5161
5161
|
"div",
|
|
5162
5162
|
{
|
|
5163
5163
|
className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate rounded border border-border bg-gray-200 p-px px-1.5 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",
|
|
@@ -5560,7 +5560,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5560
5560
|
ringColor: "ring",
|
|
5561
5561
|
ringOffsetColor: "ring-offset"
|
|
5562
5562
|
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
5563
|
-
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), x = get(u, "1", ""),
|
|
5563
|
+
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), x = get(u, "1", ""), g = get(u, "2", ""), m = useCallback(
|
|
5564
5564
|
// eslint-disable-next-line no-shadow
|
|
5565
5565
|
(b) => {
|
|
5566
5566
|
["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((y) => ({ ...y, color: b, shade: y.shade ? y.shade : "500" })));
|
|
@@ -5593,7 +5593,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5593
5593
|
disabled: !l,
|
|
5594
5594
|
rounded: !0,
|
|
5595
5595
|
selected: x,
|
|
5596
|
-
onChange:
|
|
5596
|
+
onChange: m,
|
|
5597
5597
|
options: [
|
|
5598
5598
|
"current",
|
|
5599
5599
|
"transparent",
|
|
@@ -5626,7 +5626,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5626
5626
|
]
|
|
5627
5627
|
}
|
|
5628
5628
|
) }),
|
|
5629
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DropDown, { rounded: !0, selected:
|
|
5629
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DropDown, { rounded: !0, selected: g, disabled: !x || !l, onChange: f, options: i }) })
|
|
5630
5630
|
] });
|
|
5631
5631
|
}, getUserInputValues = (o, n) => {
|
|
5632
5632
|
o = o.toLowerCase();
|
|
@@ -5773,14 +5773,14 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5773
5773
|
},
|
|
5774
5774
|
a
|
|
5775
5775
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
5776
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: x } = o, [
|
|
5776
|
+
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: x } = o, [g, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, h] = useState(!1), [b, y] = useState(""), [R, w] = useState(!1), [j, E] = useState(!1);
|
|
5777
5777
|
useEffect(() => {
|
|
5778
5778
|
const { value: v, unit: I } = getClassValueAndUnit(i);
|
|
5779
5779
|
if (I === "") {
|
|
5780
|
-
l(v),
|
|
5780
|
+
l(v), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
5781
5781
|
return;
|
|
5782
5782
|
}
|
|
5783
|
-
|
|
5783
|
+
m(I), l(I === "class" || isEmpty(v) ? "" : v);
|
|
5784
5784
|
}, [i, p, u]);
|
|
5785
5785
|
const k = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), C = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), _ = useCallback(
|
|
5786
5786
|
(v = !1) => {
|
|
@@ -5789,7 +5789,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5789
5789
|
h(!0);
|
|
5790
5790
|
return;
|
|
5791
5791
|
}
|
|
5792
|
-
const B = get(I, "unit") !== "" ? get(I, "unit") :
|
|
5792
|
+
const B = get(I, "unit") !== "" ? get(I, "unit") : g;
|
|
5793
5793
|
if (B === "auto" || B === "none") {
|
|
5794
5794
|
k(`${d}${B}`);
|
|
5795
5795
|
return;
|
|
@@ -5799,8 +5799,8 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5799
5799
|
const N = `${get(I, "value", "").startsWith("-") ? "-" : ""}${d}[${get(I, "value", "").replace("-", "")}${B === "-" ? "" : B}]`;
|
|
5800
5800
|
v ? C(N) : k(N);
|
|
5801
5801
|
},
|
|
5802
|
-
[k, C, a,
|
|
5803
|
-
),
|
|
5802
|
+
[k, C, a, g, d, u]
|
|
5803
|
+
), P = useCallback(
|
|
5804
5804
|
(v) => {
|
|
5805
5805
|
const I = getUserInputValues(`${a}`, u);
|
|
5806
5806
|
if (get(I, "error", !1)) {
|
|
@@ -5818,7 +5818,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5818
5818
|
},
|
|
5819
5819
|
[k, a, d, u]
|
|
5820
5820
|
);
|
|
5821
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-start", children:
|
|
5821
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-start", children: g === "class" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
|
|
5822
5822
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5823
5823
|
"input",
|
|
5824
5824
|
{
|
|
@@ -5833,25 +5833,25 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5833
5833
|
] })
|
|
5834
5834
|
] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `group relative flex items-center ${R ? "z-auto" : ""}`, children: [
|
|
5835
5835
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
5836
|
-
["none", "auto"].indexOf(
|
|
5836
|
+
["none", "auto"].indexOf(g) !== -1 ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5837
5837
|
"input",
|
|
5838
5838
|
{
|
|
5839
|
-
readOnly:
|
|
5839
|
+
readOnly: g === "class",
|
|
5840
5840
|
onKeyPress: (v) => {
|
|
5841
5841
|
v.key === "Enter" && _();
|
|
5842
5842
|
},
|
|
5843
5843
|
onKeyDown: (v) => {
|
|
5844
5844
|
if (v.keyCode !== 38 && v.keyCode !== 40)
|
|
5845
5845
|
return;
|
|
5846
|
-
v.preventDefault(),
|
|
5846
|
+
v.preventDefault(), E(!0);
|
|
5847
5847
|
const I = parseInt$1(v.target.value);
|
|
5848
5848
|
let B = isNaN$1(I) ? 0 : I;
|
|
5849
5849
|
v.keyCode === 38 && (B += 1), v.keyCode === 40 && (B -= 1);
|
|
5850
|
-
const A = `${B}`, T = `${A.startsWith("-") ? "-" : ""}${d}[${A.replace("-", "")}${
|
|
5850
|
+
const A = `${B}`, T = `${A.startsWith("-") ? "-" : ""}${d}[${A.replace("-", "")}${g === "-" ? "" : g}]`;
|
|
5851
5851
|
C(T);
|
|
5852
5852
|
},
|
|
5853
5853
|
onKeyUp: (v) => {
|
|
5854
|
-
|
|
5854
|
+
j && (v.preventDefault(), E(!1));
|
|
5855
5855
|
},
|
|
5856
5856
|
onBlur: () => _(),
|
|
5857
5857
|
onChange: (v) => {
|
|
@@ -5876,7 +5876,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5876
5876
|
onClick: () => r(!n),
|
|
5877
5877
|
className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
|
|
5878
5878
|
children: [
|
|
5879
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children:
|
|
5879
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: g }),
|
|
5880
5880
|
u.length > 1 ? /* @__PURE__ */ jsxRuntimeExports.jsx(TriangleDownIcon, {}) : null
|
|
5881
5881
|
]
|
|
5882
5882
|
}
|
|
@@ -5885,33 +5885,33 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
5885
5885
|
UnitSelection,
|
|
5886
5886
|
{
|
|
5887
5887
|
units: u,
|
|
5888
|
-
current:
|
|
5888
|
+
current: g,
|
|
5889
5889
|
onSelect: (v) => {
|
|
5890
|
-
r(!1),
|
|
5890
|
+
r(!1), m(v), P(v);
|
|
5891
5891
|
}
|
|
5892
5892
|
}
|
|
5893
5893
|
) }) })
|
|
5894
5894
|
] })
|
|
5895
5895
|
] }),
|
|
5896
|
-
["none", "auto"].indexOf(
|
|
5896
|
+
["none", "auto"].indexOf(g) !== -1 || R ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
5897
5897
|
DragStyleButton,
|
|
5898
5898
|
{
|
|
5899
5899
|
onDragStart: () => w(!0),
|
|
5900
5900
|
onDragEnd: (v) => {
|
|
5901
5901
|
if (y(() => ""), w(!1), isEmpty(v))
|
|
5902
5902
|
return;
|
|
5903
|
-
const I = `${v}`, A = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${
|
|
5903
|
+
const I = `${v}`, A = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${g === "-" ? "" : g}]`;
|
|
5904
5904
|
k(A);
|
|
5905
5905
|
},
|
|
5906
5906
|
onDrag: (v) => {
|
|
5907
5907
|
if (isEmpty(v))
|
|
5908
5908
|
return;
|
|
5909
5909
|
y(v);
|
|
5910
|
-
const I = `${v}`, A = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${
|
|
5910
|
+
const I = `${v}`, A = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${g === "-" ? "" : g}]`;
|
|
5911
5911
|
C(A);
|
|
5912
5912
|
},
|
|
5913
5913
|
currentValue: a,
|
|
5914
|
-
unit:
|
|
5914
|
+
unit: g,
|
|
5915
5915
|
negative: x,
|
|
5916
5916
|
cssProperty: p
|
|
5917
5917
|
}
|
|
@@ -6005,23 +6005,23 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6005
6005
|
"2xl": "1536px"
|
|
6006
6006
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6007
6007
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6008
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, x] = useCanvasWidth(),
|
|
6008
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, x] = useCanvasWidth(), g = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), b = useMemo(() => get(g, "fullCls", ""), [g]), y = useCallback(
|
|
6009
6009
|
(C, _ = !0) => {
|
|
6010
|
-
const
|
|
6011
|
-
(p || u !== "") && (
|
|
6012
|
-
const v = generateFullClsName(
|
|
6013
|
-
|
|
6010
|
+
const P = { dark: p, mq: x, mod: u, cls: C, property: l, fullCls: "" };
|
|
6011
|
+
(p || u !== "") && (P.mq = "xs");
|
|
6012
|
+
const v = generateFullClsName(P);
|
|
6013
|
+
m(h, [v], _);
|
|
6014
6014
|
},
|
|
6015
|
-
[h, p, x, u, l,
|
|
6015
|
+
[h, p, x, u, l, m]
|
|
6016
6016
|
), R = useCallback(() => {
|
|
6017
6017
|
f(h, [b]);
|
|
6018
|
-
}, [h, b, f]), w = useMemo(() => canChangeClass(
|
|
6018
|
+
}, [h, b, f]), w = useMemo(() => canChangeClass(g, x), [g, x]);
|
|
6019
6019
|
useEffect(() => {
|
|
6020
|
-
i(w,
|
|
6021
|
-
}, [w, i,
|
|
6022
|
-
const [, ,
|
|
6020
|
+
i(w, g);
|
|
6021
|
+
}, [w, i, g]);
|
|
6022
|
+
const [, , j] = useCanvasWidth(), E = useCallback(
|
|
6023
6023
|
(C) => {
|
|
6024
|
-
|
|
6024
|
+
j({
|
|
6025
6025
|
xs: 400,
|
|
6026
6026
|
sm: 640,
|
|
6027
6027
|
md: 800,
|
|
@@ -6030,16 +6030,16 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6030
6030
|
"2xl": 1920
|
|
6031
6031
|
}[C]);
|
|
6032
6032
|
},
|
|
6033
|
-
[
|
|
6034
|
-
), k = get(
|
|
6035
|
-
return /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyleProvider, { canChange: w, canReset:
|
|
6036
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `text-[11px] ${
|
|
6033
|
+
[j]
|
|
6034
|
+
), k = get(g, "dark", null) === p && get(g, "mod", null) === u && get(g, "mq", null) === x;
|
|
6035
|
+
return /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyleProvider, { canChange: w, canReset: g && k, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
6036
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `text-[11px] ${g && !k ? "text-foreground" : ""}`, children: n(a) }) }),
|
|
6037
6037
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6038
6038
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-[150px]", children: [
|
|
6039
6039
|
r === "arbitrary" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6040
6040
|
AdvanceChoices,
|
|
6041
6041
|
{
|
|
6042
|
-
currentClass: get(
|
|
6042
|
+
currentClass: get(g, "cls", ""),
|
|
6043
6043
|
classPrefix: get(CLASS_PREFIXES, l, ""),
|
|
6044
6044
|
units: c || [],
|
|
6045
6045
|
onChange: y,
|
|
@@ -6052,7 +6052,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6052
6052
|
r === "color" && /* @__PURE__ */ jsxRuntimeExports.jsx(ColorChoice, { property: l, onChange: y }),
|
|
6053
6053
|
r === "dropdown" && /* @__PURE__ */ jsxRuntimeExports.jsx(DropDownChoices, { label: a, property: l, onChange: y })
|
|
6054
6054
|
] }),
|
|
6055
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: k ? /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", onClick: () => R(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : w &&
|
|
6055
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: k ? /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", onClick: () => R(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : w && g ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6056
6056
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
6057
6057
|
"button",
|
|
6058
6058
|
{
|
|
@@ -6064,19 +6064,19 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6064
6064
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
|
|
6065
6065
|
"Current style is set at ",
|
|
6066
6066
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "font-bold", children: [
|
|
6067
|
-
getBreakpoint(get(
|
|
6068
|
-
p && !
|
|
6067
|
+
getBreakpoint(get(g, "mq")),
|
|
6068
|
+
p && !g.dark ? "(Light mode)" : ""
|
|
6069
6069
|
] }),
|
|
6070
6070
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
6071
6071
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
6072
6072
|
"button",
|
|
6073
6073
|
{
|
|
6074
6074
|
type: "button",
|
|
6075
|
-
onClick: () =>
|
|
6075
|
+
onClick: () => E(get(g, "mq")),
|
|
6076
6076
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
6077
6077
|
children: [
|
|
6078
6078
|
"Switch to ",
|
|
6079
|
-
get(
|
|
6079
|
+
get(g, "mq").toUpperCase()
|
|
6080
6080
|
]
|
|
6081
6081
|
}
|
|
6082
6082
|
)
|
|
@@ -6093,7 +6093,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6093
6093
|
units: i = basicUnits,
|
|
6094
6094
|
negative: c = !1
|
|
6095
6095
|
}) => {
|
|
6096
|
-
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), x = useSelectedBlockCurrentClasses(),
|
|
6096
|
+
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), x = useSelectedBlockCurrentClasses(), g = useCallback((m) => map(x, "property").includes(m), [x]);
|
|
6097
6097
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
6098
6098
|
"div",
|
|
6099
6099
|
{
|
|
@@ -6102,7 +6102,7 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6102
6102
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6103
6103
|
o && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6104
6104
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
|
|
6105
|
-
n.map(({ label:
|
|
6105
|
+
n.map(({ label: m, key: f }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
6106
6106
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
6107
6107
|
"button",
|
|
6108
6108
|
{
|
|
@@ -6111,13 +6111,13 @@ const RangeChoices = ({ property: o, onChange: n }) => {
|
|
|
6111
6111
|
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6112
6112
|
children: [
|
|
6113
6113
|
React__default.createElement("div", {
|
|
6114
|
-
className:
|
|
6114
|
+
className: g(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6115
6115
|
}),
|
|
6116
6116
|
React__default.createElement(get(EDITOR_ICONS, f, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6117
6117
|
]
|
|
6118
6118
|
}
|
|
6119
6119
|
) }),
|
|
6120
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: startCase(toLower(
|
|
6120
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: startCase(toLower(m)) })
|
|
6121
6121
|
] }) }))
|
|
6122
6122
|
) })
|
|
6123
6123
|
] }),
|
|
@@ -6256,13 +6256,13 @@ function BlockStyling() {
|
|
|
6256
6256
|
cssProperty: ""
|
|
6257
6257
|
}), d = useThrottledCallback(
|
|
6258
6258
|
(u) => {
|
|
6259
|
-
const x = !get(i, "negative", !1),
|
|
6260
|
-
let
|
|
6261
|
-
|
|
6259
|
+
const x = !get(i, "negative", !1), g = get(i, "cssProperty", "");
|
|
6260
|
+
let m = parseFloat(i.dragStartValue);
|
|
6261
|
+
m = isNaN(m) ? 0 : m;
|
|
6262
6262
|
let f = MAPPER[i.dragUnit];
|
|
6263
|
-
(startsWith(
|
|
6264
|
-
let b = (i.dragStartY - u.pageY) / f +
|
|
6265
|
-
x && b < 0 && (b = 0),
|
|
6263
|
+
(startsWith(g, "scale") || g === "opacity") && (f = 10);
|
|
6264
|
+
let b = (i.dragStartY - u.pageY) / f + m;
|
|
6265
|
+
x && b < 0 && (b = 0), g === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
|
|
6266
6266
|
},
|
|
6267
6267
|
[i],
|
|
6268
6268
|
50
|
|
@@ -6304,7 +6304,7 @@ const CoreBlock = ({
|
|
|
6304
6304
|
parentId: r,
|
|
6305
6305
|
position: a
|
|
6306
6306
|
}) => {
|
|
6307
|
-
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, x] = useSelectedBlockIds(), { clearHighlight:
|
|
6307
|
+
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, x] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = () => {
|
|
6308
6308
|
if (has(o, "blocks")) {
|
|
6309
6309
|
const b = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
|
|
6310
6310
|
u(syncBlocksWithDefaults(b), r || null, a);
|
|
@@ -6317,11 +6317,11 @@ const CoreBlock = ({
|
|
|
6317
6317
|
"button",
|
|
6318
6318
|
{
|
|
6319
6319
|
disabled: n,
|
|
6320
|
-
onClick:
|
|
6320
|
+
onClick: m,
|
|
6321
6321
|
type: "button",
|
|
6322
6322
|
onDragStart: (b) => {
|
|
6323
6323
|
b.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), b.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
6324
|
-
x([]),
|
|
6324
|
+
x([]), g();
|
|
6325
6325
|
}, 200);
|
|
6326
6326
|
},
|
|
6327
6327
|
draggable: f ? "true" : "false",
|
|
@@ -6501,22 +6501,22 @@ const CoreBlock = ({
|
|
|
6501
6501
|
}
|
|
6502
6502
|
}
|
|
6503
6503
|
}, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
|
|
6504
|
-
var
|
|
6504
|
+
var g, m, f, h, b, y, R, w;
|
|
6505
6505
|
if (r.type === "comment") return [];
|
|
6506
6506
|
console.log("node ===>", r);
|
|
6507
6507
|
let a = { _id: generateUUID() };
|
|
6508
6508
|
if (n && (a._parent = n.block._id), r.type === "text")
|
|
6509
6509
|
return isEmpty(get(r, "content", "")) ? [] : n && shouldAddText(n.node, n.block) ? (set(n, "block.content", get(r, "content", "")), []) : { ...a, _type: "Text", content: get(r, "content", "") };
|
|
6510
6510
|
const l = get(r, "attributes", []), i = l.find(
|
|
6511
|
-
(
|
|
6511
|
+
(j) => j.key === "data-chai-richtext" || j.key === "chai-richtext"
|
|
6512
6512
|
), c = l.find(
|
|
6513
|
-
(
|
|
6513
|
+
(j) => j.key === "data-chai-lightbox" || j.key === "chai-lightbox"
|
|
6514
6514
|
), d = l.find(
|
|
6515
|
-
(
|
|
6515
|
+
(j) => j.key === "data-chai-dropdown" || j.key === "chai-dropdown"
|
|
6516
6516
|
), p = l.find(
|
|
6517
|
-
(
|
|
6517
|
+
(j) => j.key === "data-chai-dropdown-button" || j.key === "chai-dropdown-button"
|
|
6518
6518
|
), u = l.find(
|
|
6519
|
-
(
|
|
6519
|
+
(j) => j.key === "data-chai-dropdown-content" || j.key === "chai-dropdown-content"
|
|
6520
6520
|
);
|
|
6521
6521
|
if (a = {
|
|
6522
6522
|
...a,
|
|
@@ -6524,13 +6524,13 @@ const CoreBlock = ({
|
|
|
6524
6524
|
...getAttrs(r),
|
|
6525
6525
|
...getStyles(r)
|
|
6526
6526
|
}, r.attributes) {
|
|
6527
|
-
const
|
|
6528
|
-
|
|
6527
|
+
const j = r.attributes.find((E) => includes(NAME_ATTRIBUTES, E.key));
|
|
6528
|
+
j && (a._name = j.value);
|
|
6529
6529
|
}
|
|
6530
6530
|
if (i)
|
|
6531
6531
|
return a.content = stringify(r.children), has(a, "styles_attrs.data-chai-richtext") && delete a.styles_attrs["data-chai-richtext"], has(a, "styles_attrs.chai-richtext") && delete a.styles_attrs["chai-richtext"], [a];
|
|
6532
6532
|
if (c) {
|
|
6533
|
-
const
|
|
6533
|
+
const j = [
|
|
6534
6534
|
"data-chai-lightbox",
|
|
6535
6535
|
"chai-lightbox",
|
|
6536
6536
|
"data-vbtype",
|
|
@@ -6542,26 +6542,26 @@ const CoreBlock = ({
|
|
|
6542
6542
|
];
|
|
6543
6543
|
a = {
|
|
6544
6544
|
...a,
|
|
6545
|
-
href: ((
|
|
6546
|
-
hrefType: ((
|
|
6547
|
-
autoplay: ((f = l.find((
|
|
6548
|
-
maxWidth: ((b = (h = l.find((
|
|
6549
|
-
backdropColor: ((y = l.find((
|
|
6550
|
-
galleryName: ((R = l.find((
|
|
6551
|
-
}, forEach(
|
|
6552
|
-
has(a, `styles_attrs.${
|
|
6545
|
+
href: ((g = l.find((E) => E.key === "href")) == null ? void 0 : g.value) || "",
|
|
6546
|
+
hrefType: ((m = l.find((E) => E.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
|
|
6547
|
+
autoplay: ((f = l.find((E) => E.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
|
|
6548
|
+
maxWidth: ((b = (h = l.find((E) => E.key === "data-maxwidth")) == null ? void 0 : h.value) == null ? void 0 : b.replace("px", "")) || "",
|
|
6549
|
+
backdropColor: ((y = l.find((E) => E.key === "data-overlay")) == null ? void 0 : y.value) || "",
|
|
6550
|
+
galleryName: ((R = l.find((E) => E.key === "data-gall")) == null ? void 0 : R.value) || ""
|
|
6551
|
+
}, forEach(j, (E) => {
|
|
6552
|
+
has(a, `styles_attrs.${E}`) && delete a.styles_attrs[E];
|
|
6553
6553
|
});
|
|
6554
6554
|
}
|
|
6555
6555
|
if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
|
|
6556
6556
|
delete a.styles_attrs;
|
|
6557
|
-
const
|
|
6558
|
-
a.content = getTextContent(
|
|
6559
|
-
const
|
|
6557
|
+
const j = filter(r.children || [], (k) => (k == null ? void 0 : k.tagName) !== "span");
|
|
6558
|
+
a.content = getTextContent(j);
|
|
6559
|
+
const E = find(
|
|
6560
6560
|
r.children || [],
|
|
6561
6561
|
(k) => (k == null ? void 0 : k.tagName) === "span" && some(k.children || [], (C) => (C == null ? void 0 : C.tagName) === "svg")
|
|
6562
6562
|
);
|
|
6563
|
-
if (
|
|
6564
|
-
const k = find(
|
|
6563
|
+
if (E) {
|
|
6564
|
+
const k = find(E.children || [], (C) => (C == null ? void 0 : C.tagName) === "svg");
|
|
6565
6565
|
if (k) {
|
|
6566
6566
|
a.icon = stringify([k]);
|
|
6567
6567
|
const { height: C, width: _ } = getSvgDimensions(k, "16px", "16px");
|
|
@@ -6571,14 +6571,14 @@ const CoreBlock = ({
|
|
|
6571
6571
|
return [a];
|
|
6572
6572
|
}
|
|
6573
6573
|
if (a._type === "Input") {
|
|
6574
|
-
const
|
|
6575
|
-
|
|
6574
|
+
const j = a.inputType || "text";
|
|
6575
|
+
j === "checkbox" ? set(a, "_type", "Checkbox") : j === "radio" && set(a, "_type", "Radio");
|
|
6576
6576
|
} else if (r.tagName === "video" || r.tagName === "iframe") {
|
|
6577
|
-
const
|
|
6578
|
-
return hasVideoEmbed(
|
|
6577
|
+
const j = stringify([r]);
|
|
6578
|
+
return hasVideoEmbed(j) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(j)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = j, [a];
|
|
6579
6579
|
} else if (r.tagName === "svg") {
|
|
6580
|
-
const
|
|
6581
|
-
return a.styles = `${STYLES_KEY}, ${cn(`w-${C} h-${k}`, _)}`.trim(), r.attributes = filter(r.attributes, (
|
|
6580
|
+
const j = find(r.attributes, { key: "height" }), E = find(r.attributes, { key: "width" }), k = get(j, "value") ? `[${get(j, "value")}px]` : "24px", C = get(E, "value") ? `[${get(E, "value")}px]` : "24px", _ = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
|
|
6581
|
+
return a.styles = `${STYLES_KEY}, ${cn(`w-${C} h-${k}`, _)}`.trim(), r.attributes = filter(r.attributes, (P) => !includes(["style", "width", "height", "class"], P.key)), a.icon = stringify([r]), [a];
|
|
6582
6582
|
} else if (r.tagName == "option" && n && ((w = n.block) == null ? void 0 : w._type) === "Select")
|
|
6583
6583
|
return n.block.options.push({
|
|
6584
6584
|
label: getTextContent(r.children),
|
|
@@ -6682,8 +6682,8 @@ const CoreBlock = ({
|
|
|
6682
6682
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
6683
6683
|
Tabs,
|
|
6684
6684
|
{
|
|
6685
|
-
onValueChange: (
|
|
6686
|
-
d(""), c(
|
|
6685
|
+
onValueChange: (g) => {
|
|
6686
|
+
d(""), c(g);
|
|
6687
6687
|
},
|
|
6688
6688
|
value: i,
|
|
6689
6689
|
className: "flex h-full max-h-full flex-col overflow-hidden",
|
|
@@ -6692,12 +6692,12 @@ const CoreBlock = ({
|
|
|
6692
6692
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
6693
6693
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
6694
6694
|
p ? /* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
6695
|
-
map(u, (
|
|
6695
|
+
map(u, (g) => /* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: g.key, children: React__default.createElement(g.tab) }))
|
|
6696
6696
|
] }),
|
|
6697
6697
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea, { className: "-mx-1.5 h-full max-h-full overflow-y-auto", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
|
|
6698
6698
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(UILibrariesPanel, { parentId: r, position: a }) }),
|
|
6699
6699
|
p ? /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ImportHTML, { parentId: r, position: a }) }) : null,
|
|
6700
|
-
map(u, (
|
|
6700
|
+
map(u, (g) => /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: g.key, children: React__default.createElement(g.tabContent, { close: x, parentId: r, position: a }) }))
|
|
6701
6701
|
]
|
|
6702
6702
|
}
|
|
6703
6703
|
)
|
|
@@ -6754,7 +6754,7 @@ const BlockCard = ({
|
|
|
6754
6754
|
parentId: r = void 0,
|
|
6755
6755
|
position: a = -1
|
|
6756
6756
|
}) => {
|
|
6757
|
-
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: x } = useBlockHighlight(),
|
|
6757
|
+
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: x } = useBlockHighlight(), g = get(o, "name", get(o, "label")), m = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), h = (R) => {
|
|
6758
6758
|
const w = has(R, "styles_attrs.data-page-section");
|
|
6759
6759
|
return R._type === "Box" && w;
|
|
6760
6760
|
}, b = useCallback(
|
|
@@ -6770,17 +6770,17 @@ const BlockCard = ({
|
|
|
6770
6770
|
[d, p, o, c, n, r, a]
|
|
6771
6771
|
), y = async (R) => {
|
|
6772
6772
|
const w = await c(n, o);
|
|
6773
|
-
let
|
|
6774
|
-
if (h(first(w)) && (
|
|
6775
|
-
const
|
|
6776
|
-
if (R.dataTransfer.setData("text/plain", JSON.stringify(
|
|
6773
|
+
let j = r;
|
|
6774
|
+
if (h(first(w)) && (j = null), !isEmpty(w)) {
|
|
6775
|
+
const E = { blocks: w, uiLibrary: !0, parent: j };
|
|
6776
|
+
if (R.dataTransfer.setData("text/plain", JSON.stringify(E)), o.preview) {
|
|
6777
6777
|
const k = new Image();
|
|
6778
6778
|
k.src = o.preview, k.onload = () => {
|
|
6779
6779
|
R.dataTransfer.setDragImage(k, 0, 0);
|
|
6780
6780
|
};
|
|
6781
6781
|
} else
|
|
6782
6782
|
R.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
6783
|
-
f(
|
|
6783
|
+
f(E), setTimeout(() => {
|
|
6784
6784
|
u([]), x(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6785
6785
|
}, 200);
|
|
6786
6786
|
}
|
|
@@ -6791,7 +6791,7 @@ const BlockCard = ({
|
|
|
6791
6791
|
{
|
|
6792
6792
|
onClick: l ? () => {
|
|
6793
6793
|
} : b,
|
|
6794
|
-
draggable:
|
|
6794
|
+
draggable: m ? "true" : "false",
|
|
6795
6795
|
onDragStart: y,
|
|
6796
6796
|
className: clsx(
|
|
6797
6797
|
"relative mt-2 cursor-pointer overflow-hidden rounded-md border border-border bg-white duration-200 hover:border-blue-500 hover:shadow-xl"
|
|
@@ -6801,11 +6801,11 @@ const BlockCard = ({
|
|
|
6801
6801
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
|
|
6802
6802
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
|
|
6803
6803
|
] }),
|
|
6804
|
-
o.preview ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt:
|
|
6804
|
+
o.preview ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: g }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-20 items-center justify-center rounded-md border border-border bg-gray-200", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "max-w-xs text-center text-sm text-gray-700", children: g }) })
|
|
6805
6805
|
]
|
|
6806
6806
|
}
|
|
6807
6807
|
) }),
|
|
6808
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children:
|
|
6808
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: g }) })
|
|
6809
6809
|
] });
|
|
6810
6810
|
}, libraryBlocksAtom = atom$1(
|
|
6811
6811
|
{}
|
|
@@ -6820,9 +6820,9 @@ const BlockCard = ({
|
|
|
6820
6820
|
})();
|
|
6821
6821
|
}, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
|
|
6822
6822
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
6823
|
-
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((
|
|
6823
|
+
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((j) => j.category === "custom"), d = l.find((j) => j.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), x = groupBy([...p, ...c], "group"), [g, m] = useState("Hero"), f = get(x, g, []), h = useRef(null), { t: b } = useTranslation(), y = (j) => {
|
|
6824
6824
|
h.current && (clearTimeout(h.current), h.current = null), h.current = setTimeout(() => {
|
|
6825
|
-
h.current &&
|
|
6825
|
+
h.current && m(j);
|
|
6826
6826
|
}, 300);
|
|
6827
6827
|
};
|
|
6828
6828
|
if (u)
|
|
@@ -6830,7 +6830,7 @@ const BlockCard = ({
|
|
|
6830
6830
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
6831
6831
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
6832
6832
|
] });
|
|
6833
|
-
const R = filter(f, (
|
|
6833
|
+
const R = filter(f, (j, E) => E % 2 === 0), w = filter(f, (j, E) => E % 2 === 1);
|
|
6834
6834
|
return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative mt-2 flex h-full max-h-full overflow-hidden bg-background", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full pt-2", children: [
|
|
6835
6835
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
6836
6836
|
/* @__PURE__ */ jsxRuntimeExports.jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
|
|
@@ -6838,22 +6838,22 @@ const BlockCard = ({
|
|
|
6838
6838
|
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-bold text-gray-500", children: b("Groups") }),
|
|
6839
6839
|
/* @__PURE__ */ jsxRuntimeExports.jsx("hr", { className: "mt-1 border-border" }),
|
|
6840
6840
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: React__default.Children.toArray(
|
|
6841
|
-
map(x, (
|
|
6841
|
+
map(x, (j, E) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
6842
6842
|
"div",
|
|
6843
6843
|
{
|
|
6844
|
-
onMouseEnter: () => y(
|
|
6844
|
+
onMouseEnter: () => y(E),
|
|
6845
6845
|
onMouseLeave: () => clearTimeout(h.current),
|
|
6846
|
-
onClick: () =>
|
|
6846
|
+
onClick: () => m(E),
|
|
6847
6847
|
className: cn(
|
|
6848
6848
|
"flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",
|
|
6849
|
-
|
|
6849
|
+
E === g ? "bg-blue-500 text-white hover:bg-blue-600" : ""
|
|
6850
6850
|
),
|
|
6851
6851
|
children: [
|
|
6852
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: capitalize(b(
|
|
6852
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: capitalize(b(E.toLowerCase())) }),
|
|
6853
6853
|
/* @__PURE__ */ jsxRuntimeExports.jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
|
|
6854
6854
|
]
|
|
6855
6855
|
},
|
|
6856
|
-
|
|
6856
|
+
E
|
|
6857
6857
|
))
|
|
6858
6858
|
) })
|
|
6859
6859
|
] })
|
|
@@ -6866,10 +6866,10 @@ const BlockCard = ({
|
|
|
6866
6866
|
children: [
|
|
6867
6867
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
|
|
6868
6868
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
6869
|
-
R.map((
|
|
6869
|
+
R.map((j) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: o, position: n, block: j, library: d }))
|
|
6870
6870
|
) }),
|
|
6871
6871
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
6872
|
-
w.map((
|
|
6872
|
+
w.map((j) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: o, position: n, block: j, library: d }))
|
|
6873
6873
|
) })
|
|
6874
6874
|
] }),
|
|
6875
6875
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
@@ -7092,45 +7092,45 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7092
7092
|
var T;
|
|
7093
7093
|
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
|
|
7094
7094
|
let p = null;
|
|
7095
|
-
const u = o.children.length > 0, { highlightBlock: x, clearHighlight:
|
|
7096
|
-
S.stopPropagation(), !i.includes(
|
|
7097
|
-
},
|
|
7095
|
+
const u = o.children.length > 0, { highlightBlock: x, clearHighlight: g } = useBlockHighlight(), { id: m, data: f, isSelected: h, willReceiveDrop: b, isDragging: y, isEditing: R, handleClick: w } = o, j = (S) => {
|
|
7096
|
+
S.stopPropagation(), !i.includes(m) && o.toggle();
|
|
7097
|
+
}, E = (S) => {
|
|
7098
7098
|
S.isInternal && (p = S.isOpen, S.isOpen && S.close());
|
|
7099
7099
|
}, k = (S) => {
|
|
7100
7100
|
S.isInternal && p !== null && (p ? S.open() : S.close(), p = null);
|
|
7101
|
-
}, [C, _] = useAtom$1(currentAddSelection),
|
|
7101
|
+
}, [C, _] = useAtom$1(currentAddSelection), P = () => {
|
|
7102
7102
|
var S;
|
|
7103
7103
|
v(), o.parent.isSelected || _((S = o == null ? void 0 : o.parent) == null ? void 0 : S.id);
|
|
7104
7104
|
}, v = () => {
|
|
7105
7105
|
_(null);
|
|
7106
7106
|
}, I = (S) => {
|
|
7107
|
-
v(), S.stopPropagation(), !o.isOpen && !i.includes(
|
|
7107
|
+
v(), S.stopPropagation(), !o.isOpen && !i.includes(m) && o.toggle(), w(S);
|
|
7108
7108
|
};
|
|
7109
7109
|
useEffect(() => {
|
|
7110
7110
|
const S = setTimeout(() => {
|
|
7111
|
-
b && !o.isOpen && !y && !i.includes(
|
|
7111
|
+
b && !o.isOpen && !y && !i.includes(m) && o.toggle();
|
|
7112
7112
|
}, 500);
|
|
7113
7113
|
return () => clearTimeout(S);
|
|
7114
7114
|
}, [b, o, y]);
|
|
7115
7115
|
const B = useMemo(() => {
|
|
7116
7116
|
const S = Object.keys(f), L = [];
|
|
7117
|
-
for (let
|
|
7118
|
-
if (S[
|
|
7119
|
-
const $ = f[S[
|
|
7117
|
+
for (let D = 0; D < S.length; D++)
|
|
7118
|
+
if (S[D].endsWith("_attrs")) {
|
|
7119
|
+
const $ = f[S[D]], O = Object.keys($).join("|");
|
|
7120
7120
|
O.match(/x-data/) && L.push("data"), O.match(/x-on/) && L.push("event"), O.match(/x-show|x-if/) && L.push("show");
|
|
7121
7121
|
}
|
|
7122
7122
|
return L;
|
|
7123
7123
|
}, [f]), A = (S, L) => {
|
|
7124
|
-
const
|
|
7124
|
+
const D = d.contentDocument || d.contentWindow.document, $ = D.querySelector(`[data-block-id=${S}]`);
|
|
7125
7125
|
$ && $.setAttribute("data-drop", L);
|
|
7126
7126
|
const O = $.getBoundingClientRect(), M = d.getBoundingClientRect();
|
|
7127
|
-
O.top >= M.top && O.left >= M.left && O.bottom <= M.bottom && O.right <= M.right || (
|
|
7127
|
+
O.top >= M.top && O.left >= M.left && O.bottom <= M.bottom && O.right <= M.right || (D.documentElement.scrollTop = $.offsetTop - M.top);
|
|
7128
7128
|
}, N = (S) => {
|
|
7129
7129
|
v();
|
|
7130
7130
|
const L = get(o, "parent.id");
|
|
7131
7131
|
L !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: L, position: S }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: S });
|
|
7132
7132
|
};
|
|
7133
|
-
return
|
|
7133
|
+
return m === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group relative w-full cursor-pointer", children: [
|
|
7134
7134
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
|
|
7135
7135
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
7136
7136
|
"div",
|
|
@@ -7145,25 +7145,25 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7145
7145
|
}
|
|
7146
7146
|
),
|
|
7147
7147
|
/* @__PURE__ */ jsxRuntimeExports.jsx("br", {})
|
|
7148
|
-
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(BlockContextMenu, { id:
|
|
7148
|
+
] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(BlockContextMenu, { id: m, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
7149
7149
|
"div",
|
|
7150
7150
|
{
|
|
7151
|
-
onMouseEnter: () => x(
|
|
7152
|
-
onMouseLeave: () =>
|
|
7151
|
+
onMouseEnter: () => x(m),
|
|
7152
|
+
onMouseLeave: () => g(),
|
|
7153
7153
|
onClick: I,
|
|
7154
7154
|
style: n,
|
|
7155
|
-
"data-node-id":
|
|
7156
|
-
ref: i.includes(
|
|
7157
|
-
onDragStart: () =>
|
|
7155
|
+
"data-node-id": m,
|
|
7156
|
+
ref: i.includes(m) ? null : r,
|
|
7157
|
+
onDragStart: () => E(o),
|
|
7158
7158
|
onDragEnd: () => k(o),
|
|
7159
7159
|
onDragOver: (S) => {
|
|
7160
|
-
S.preventDefault(), A(
|
|
7160
|
+
S.preventDefault(), A(m, "yes");
|
|
7161
7161
|
},
|
|
7162
7162
|
onDragLeave: (S) => {
|
|
7163
|
-
S.preventDefault(), A(
|
|
7163
|
+
S.preventDefault(), A(m, "no");
|
|
7164
7164
|
},
|
|
7165
7165
|
onDrop: (S) => {
|
|
7166
|
-
S.preventDefault(), A(
|
|
7166
|
+
S.preventDefault(), A(m, "no");
|
|
7167
7167
|
},
|
|
7168
7168
|
children: [
|
|
7169
7169
|
(o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((T = o == null ? void 0 : o.parent) == null ? void 0 : T.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
@@ -7172,7 +7172,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7172
7172
|
onClick: (S) => {
|
|
7173
7173
|
S.stopPropagation(), N(o.childIndex);
|
|
7174
7174
|
},
|
|
7175
|
-
onMouseEnter:
|
|
7175
|
+
onMouseEnter: P,
|
|
7176
7176
|
onMouseLeave: v,
|
|
7177
7177
|
className: "absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",
|
|
7178
7178
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500", children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { className: "h-3 w-3 stroke-[4] text-white" }) })
|
|
@@ -7187,7 +7187,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7187
7187
|
b && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
|
|
7188
7188
|
(o == null ? void 0 : o.id) === C ? "bg-purple-100" : "",
|
|
7189
7189
|
y && "opacity-20",
|
|
7190
|
-
i.includes(
|
|
7190
|
+
i.includes(m) ? "opacity-50" : ""
|
|
7191
7191
|
),
|
|
7192
7192
|
children: [
|
|
7193
7193
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
|
|
@@ -7195,7 +7195,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7195
7195
|
"div",
|
|
7196
7196
|
{
|
|
7197
7197
|
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
7198
|
-
children: u && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick:
|
|
7198
|
+
children: u && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: j, type: "button", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
7199
7199
|
ChevronRight,
|
|
7200
7200
|
{
|
|
7201
7201
|
className: `h-3 w-3 stroke-[3] ${h ? "text-slate-200" : "text-slate-400"}`
|
|
@@ -7223,22 +7223,22 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7223
7223
|
] })
|
|
7224
7224
|
] }),
|
|
7225
7225
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
7226
|
-
!i.includes(
|
|
7226
|
+
!i.includes(m) && a.map((S) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
7227
7227
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
7228
7228
|
TooltipTrigger,
|
|
7229
7229
|
{
|
|
7230
7230
|
className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
|
|
7231
7231
|
asChild: !0,
|
|
7232
|
-
children: React__default.createElement(S.item, { blockId:
|
|
7232
|
+
children: React__default.createElement(S.item, { blockId: m })
|
|
7233
7233
|
}
|
|
7234
7234
|
),
|
|
7235
7235
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-10", children: S.tooltip })
|
|
7236
7236
|
] })),
|
|
7237
|
-
canAddChildBlock(f == null ? void 0 : f._type) && !i.includes(
|
|
7237
|
+
canAddChildBlock(f == null ? void 0 : f._type) && !i.includes(m) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
7238
7238
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
7239
7239
|
TooltipTrigger,
|
|
7240
7240
|
{
|
|
7241
|
-
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id:
|
|
7241
|
+
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: m }),
|
|
7242
7242
|
className: "cursor-pointer rounded bg-transparent hover:text-black",
|
|
7243
7243
|
asChild: !0,
|
|
7244
7244
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { size: "15" })
|
|
@@ -7251,7 +7251,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7251
7251
|
TooltipTrigger,
|
|
7252
7252
|
{
|
|
7253
7253
|
onClick: (S) => {
|
|
7254
|
-
S.stopPropagation(), c(
|
|
7254
|
+
S.stopPropagation(), c(m), o.isOpen && o.toggle();
|
|
7255
7255
|
},
|
|
7256
7256
|
className: "cursor-pointer rounded bg-transparent hover:text-black",
|
|
7257
7257
|
asChild: !0,
|
|
@@ -7911,14 +7911,14 @@ function QuickPrompts({ onClick: o }) {
|
|
|
7911
7911
|
) }) });
|
|
7912
7912
|
}
|
|
7913
7913
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
7914
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, x] = useState(),
|
|
7914
|
+
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, x] = useState(), g = useRef(null), m = useRef(null);
|
|
7915
7915
|
useEffect(() => {
|
|
7916
7916
|
var h;
|
|
7917
|
-
(h =
|
|
7917
|
+
(h = g.current) == null || h.focus();
|
|
7918
7918
|
}, []);
|
|
7919
7919
|
const f = (h) => {
|
|
7920
7920
|
const { usage: b } = h || {};
|
|
7921
|
-
!l && b && x(b),
|
|
7921
|
+
!l && b && x(b), m.current = setTimeout(() => x(void 0), 1e4), l || c("");
|
|
7922
7922
|
};
|
|
7923
7923
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "", children: [
|
|
7924
7924
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
@@ -7936,14 +7936,14 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7936
7936
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
7937
7937
|
Textarea,
|
|
7938
7938
|
{
|
|
7939
|
-
ref:
|
|
7939
|
+
ref: g,
|
|
7940
7940
|
value: i,
|
|
7941
7941
|
onChange: (h) => c(h.target.value),
|
|
7942
7942
|
placeholder: n("Ask AI to edit content"),
|
|
7943
7943
|
className: "w-full",
|
|
7944
7944
|
rows: 3,
|
|
7945
7945
|
onKeyDown: (h) => {
|
|
7946
|
-
h.key === "Enter" && (h.preventDefault(),
|
|
7946
|
+
h.key === "Enter" && (h.preventDefault(), m.current && clearTimeout(m.current), x(void 0), r("content", o, i, f));
|
|
7947
7947
|
}
|
|
7948
7948
|
}
|
|
7949
7949
|
),
|
|
@@ -7953,7 +7953,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7953
7953
|
{
|
|
7954
7954
|
disabled: i.trim().length < 5 || a,
|
|
7955
7955
|
onClick: () => {
|
|
7956
|
-
|
|
7956
|
+
m.current && clearTimeout(m.current), x(void 0), r("content", o, i, f);
|
|
7957
7957
|
},
|
|
7958
7958
|
variant: "default",
|
|
7959
7959
|
className: "w-fit",
|
|
@@ -7986,7 +7986,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7986
7986
|
QuickPrompts,
|
|
7987
7987
|
{
|
|
7988
7988
|
onClick: (h) => {
|
|
7989
|
-
|
|
7989
|
+
m.current && clearTimeout(m.current), x(void 0), r("content", o, h, f);
|
|
7990
7990
|
}
|
|
7991
7991
|
}
|
|
7992
7992
|
)
|
|
@@ -7996,17 +7996,17 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
7996
7996
|
] }) }) : null
|
|
7997
7997
|
] });
|
|
7998
7998
|
}, AISetContext = () => {
|
|
7999
|
-
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, x] = useState(!1), { toast:
|
|
7999
|
+
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, x] = useState(!1), { toast: g } = useToast(), m = useRef(null);
|
|
8000
8000
|
useEffect(() => {
|
|
8001
8001
|
n && a(n);
|
|
8002
8002
|
}, [n]);
|
|
8003
8003
|
const f = async () => {
|
|
8004
8004
|
try {
|
|
8005
|
-
d(!0), u(null), await i(r),
|
|
8005
|
+
d(!0), u(null), await i(r), g({
|
|
8006
8006
|
title: o("Updated AI Context"),
|
|
8007
8007
|
description: o("You can now Ask AI to edit your content"),
|
|
8008
8008
|
variant: "default"
|
|
8009
|
-
}),
|
|
8009
|
+
}), m.current.click();
|
|
8010
8010
|
} catch (h) {
|
|
8011
8011
|
u(h);
|
|
8012
8012
|
} finally {
|
|
@@ -8022,7 +8022,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8022
8022
|
type: "single",
|
|
8023
8023
|
collapsible: !0,
|
|
8024
8024
|
children: /* @__PURE__ */ jsxRuntimeExports.jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
|
|
8025
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(AccordionTrigger, { ref:
|
|
8025
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(AccordionTrigger, { ref: m, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
|
|
8026
8026
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(AccordionContent, { children: [
|
|
8027
8027
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
8028
8028
|
Textarea,
|
|
@@ -8329,42 +8329,42 @@ const ClearCanvas = () => {
|
|
|
8329
8329
|
] })
|
|
8330
8330
|
] });
|
|
8331
8331
|
}, AttrsEditor = React__default.memo(function o({ preloadedAttributes: n = [], onAttributesChange: r }) {
|
|
8332
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, x] = useState(null), [
|
|
8332
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, x] = useState(null), [g, m] = useState(""), f = useRef(null), h = useRef(null);
|
|
8333
8333
|
useEffect(() => {
|
|
8334
8334
|
l(n);
|
|
8335
8335
|
}, [n]);
|
|
8336
8336
|
const b = () => {
|
|
8337
8337
|
if (i.startsWith("@")) {
|
|
8338
|
-
|
|
8338
|
+
m("Attribute keys cannot start with '@'");
|
|
8339
8339
|
return;
|
|
8340
8340
|
}
|
|
8341
8341
|
if (i) {
|
|
8342
|
-
const
|
|
8343
|
-
r(
|
|
8342
|
+
const E = [...a, { key: i, value: d }];
|
|
8343
|
+
r(E), l(a), c(""), p(""), m("");
|
|
8344
8344
|
}
|
|
8345
|
-
}, y = (
|
|
8346
|
-
const k = a.filter((C, _) => _ !==
|
|
8345
|
+
}, y = (E) => {
|
|
8346
|
+
const k = a.filter((C, _) => _ !== E);
|
|
8347
8347
|
r(k), l(k);
|
|
8348
|
-
}, R = (
|
|
8349
|
-
x(
|
|
8348
|
+
}, R = (E) => {
|
|
8349
|
+
x(E), c(a[E].key), p(a[E].value);
|
|
8350
8350
|
}, w = () => {
|
|
8351
8351
|
if (i.startsWith("@")) {
|
|
8352
|
-
|
|
8352
|
+
m("Attribute keys cannot start with '@'");
|
|
8353
8353
|
return;
|
|
8354
8354
|
}
|
|
8355
8355
|
if (u !== null && i) {
|
|
8356
|
-
const
|
|
8357
|
-
|
|
8356
|
+
const E = [...a];
|
|
8357
|
+
E[u] = { key: i, value: d }, r(E), l(E), x(null), c(""), p(""), m("");
|
|
8358
8358
|
}
|
|
8359
|
-
},
|
|
8360
|
-
|
|
8359
|
+
}, j = (E) => {
|
|
8360
|
+
E.key === "Enter" && !E.shiftKey && (E.preventDefault(), u !== null ? w() : b());
|
|
8361
8361
|
};
|
|
8362
8362
|
return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
|
|
8363
8363
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
8364
8364
|
"form",
|
|
8365
8365
|
{
|
|
8366
|
-
onSubmit: (
|
|
8367
|
-
|
|
8366
|
+
onSubmit: (E) => {
|
|
8367
|
+
E.preventDefault(), u !== null ? w() : b();
|
|
8368
8368
|
},
|
|
8369
8369
|
className: "space-y-3",
|
|
8370
8370
|
children: [
|
|
@@ -8380,7 +8380,7 @@ const ClearCanvas = () => {
|
|
|
8380
8380
|
id: "attrKey",
|
|
8381
8381
|
ref: f,
|
|
8382
8382
|
value: i,
|
|
8383
|
-
onChange: (
|
|
8383
|
+
onChange: (E) => c(E.target.value),
|
|
8384
8384
|
placeholder: "Enter Key",
|
|
8385
8385
|
className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
8386
8386
|
}
|
|
@@ -8398,8 +8398,8 @@ const ClearCanvas = () => {
|
|
|
8398
8398
|
rows: 2,
|
|
8399
8399
|
ref: h,
|
|
8400
8400
|
value: d,
|
|
8401
|
-
onChange: (
|
|
8402
|
-
onKeyDown:
|
|
8401
|
+
onChange: (E) => p(E.target.value),
|
|
8402
|
+
onKeyDown: j,
|
|
8403
8403
|
placeholder: "Enter Value",
|
|
8404
8404
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
8405
8405
|
}
|
|
@@ -8407,14 +8407,14 @@ const ClearCanvas = () => {
|
|
|
8407
8407
|
] })
|
|
8408
8408
|
] }),
|
|
8409
8409
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { type: "submit", disabled: !i.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: u !== null ? "Save" : "Add" }) }),
|
|
8410
|
-
|
|
8410
|
+
g && /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs text-red-500", children: g })
|
|
8411
8411
|
]
|
|
8412
8412
|
}
|
|
8413
8413
|
),
|
|
8414
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-1 py-4", children: a.map((
|
|
8414
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-1 py-4", children: a.map((E, k) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
|
|
8415
8415
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
8416
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children:
|
|
8417
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-wrap max-w-[200px] font-normal", children:
|
|
8416
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: E.key }),
|
|
8417
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-wrap max-w-[200px] font-normal", children: E.value.toString() })
|
|
8418
8418
|
] }),
|
|
8419
8419
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
8420
8420
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => R(k), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Edit2, { className: "h-3 w-3" }) }),
|
|
@@ -8617,7 +8617,7 @@ const RootLayout = () => {
|
|
|
8617
8617
|
h.preventDefault();
|
|
8618
8618
|
}, u = (h) => {
|
|
8619
8619
|
n(o === h ? null : h);
|
|
8620
|
-
}, x = useSidebarMenuItems(), { t:
|
|
8620
|
+
}, x = useSidebarMenuItems(), { t: g } = useTranslation(), m = [...x, ...c], f = useBuilderProp("htmlDir", "ltr");
|
|
8621
8621
|
return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dir: f, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(TooltipProvider, { children: [
|
|
8622
8622
|
/* @__PURE__ */ jsxRuntimeExports.jsxs(
|
|
8623
8623
|
"div",
|
|
@@ -8628,7 +8628,7 @@ const RootLayout = () => {
|
|
|
8628
8628
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(TopBar, {}) }) }),
|
|
8629
8629
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
8630
8630
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
8631
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children:
|
|
8631
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children: m.map((h, b) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
|
|
8632
8632
|
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
8633
8633
|
Button,
|
|
8634
8634
|
{
|
|
@@ -8639,7 +8639,7 @@ const RootLayout = () => {
|
|
|
8639
8639
|
},
|
|
8640
8640
|
b
|
|
8641
8641
|
) }),
|
|
8642
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children:
|
|
8642
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: g(h.label) }) })
|
|
8643
8643
|
] }, "button" + b)) }),
|
|
8644
8644
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col space-y-1" }),
|
|
8645
8645
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((h, b) => /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", {}), children: React__default.createElement(h, { key: b }) })) })
|
|
@@ -8653,10 +8653,10 @@ const RootLayout = () => {
|
|
|
8653
8653
|
transition: { duration: 0.3, ease: "easeInOut" },
|
|
8654
8654
|
children: o !== null && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "no-scrollbar overflow h-full overflow-x-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col p-3", children: [
|
|
8655
8655
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("h2", { className: "-mt-1 flex h-10 items-center space-x-1 text-base font-bold", children: [
|
|
8656
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(
|
|
8657
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: m
|
|
8656
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(m, `${o}.icon`, null) }),
|
|
8657
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: g(m[o].label) })
|
|
8658
8658
|
] }),
|
|
8659
|
-
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: React__default.createElement(get(
|
|
8659
|
+
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: React__default.createElement(get(m, `${o}.component`, null), {}) }) })
|
|
8660
8660
|
] }) })
|
|
8661
8661
|
}
|
|
8662
8662
|
),
|
|
@@ -8675,11 +8675,11 @@ const RootLayout = () => {
|
|
|
8675
8675
|
/* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "-mt-1 flex items-center space-x-1 text-base font-bold", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex grow items-center gap-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full items-center justify-between gap-2", children: l === "ai" ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8676
8676
|
/* @__PURE__ */ jsxRuntimeExports.jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
|
|
8677
8677
|
" ",
|
|
8678
|
-
|
|
8678
|
+
g("AI Assistant")
|
|
8679
8679
|
] }) }) : l === "theme" ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
8680
8680
|
/* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex items-center gap-2", children: [
|
|
8681
8681
|
/* @__PURE__ */ jsxRuntimeExports.jsx(Paintbrush, { className: "h-4 w-4 rtl:ml-2" }),
|
|
8682
|
-
|
|
8682
|
+
g("Theme Settings")
|
|
8683
8683
|
] }),
|
|
8684
8684
|
/* @__PURE__ */ jsxRuntimeExports.jsx(
|
|
8685
8685
|
Button,
|