@chaibuilder/sdk 2.0.6 → 2.0.7
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 +5 -5
- package/dist/core.js +739 -735
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -93,65 +93,65 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
93
93
|
for (const i of n.p)
|
|
94
94
|
l.add(i);
|
|
95
95
|
return l;
|
|
96
|
-
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (
|
|
97
|
-
var
|
|
98
|
-
return (
|
|
99
|
-
}, g = (
|
|
100
|
-
var
|
|
101
|
-
return (
|
|
96
|
+
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (h, ...f) => h.read(...f), p = (h, ...f) => h.write(...f), u = (h, f) => {
|
|
97
|
+
var x;
|
|
98
|
+
return (x = h.unstable_onInit) == null ? void 0 : x.call(h, f);
|
|
99
|
+
}, g = (h, f) => {
|
|
100
|
+
var x;
|
|
101
|
+
return (x = h.onMount) == null ? void 0 : x.call(h, f);
|
|
102
102
|
}, ...m) => {
|
|
103
|
-
const
|
|
104
|
-
let L = o.get(
|
|
105
|
-
return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(
|
|
103
|
+
const h = m[0] || ((B) => {
|
|
104
|
+
let L = o.get(B);
|
|
105
|
+
return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(B, L), u == null || u(B, C)), L;
|
|
106
106
|
}), f = m[1] || (() => {
|
|
107
|
-
let
|
|
107
|
+
let B, L;
|
|
108
108
|
const v = (y) => {
|
|
109
109
|
try {
|
|
110
110
|
y();
|
|
111
|
-
} catch (
|
|
112
|
-
|
|
111
|
+
} catch (_) {
|
|
112
|
+
B || (B = !0, L = _);
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
do {
|
|
116
116
|
c.f && v(c.f);
|
|
117
|
-
const y = /* @__PURE__ */ new Set(),
|
|
117
|
+
const y = /* @__PURE__ */ new Set(), _ = y.add.bind(y);
|
|
118
118
|
a.forEach((T) => {
|
|
119
119
|
var I;
|
|
120
|
-
return (I = n.get(T)) == null ? void 0 : I.l.forEach(
|
|
121
|
-
}), a.clear(), i.forEach(
|
|
120
|
+
return (I = n.get(T)) == null ? void 0 : I.l.forEach(_);
|
|
121
|
+
}), a.clear(), i.forEach(_), i.clear(), l.forEach(_), l.clear(), y.forEach(v), a.size && x();
|
|
122
122
|
} while (a.size || i.size || l.size);
|
|
123
|
-
if (
|
|
123
|
+
if (B)
|
|
124
124
|
throw L;
|
|
125
|
-
}),
|
|
126
|
-
const
|
|
125
|
+
}), x = m[2] || (() => {
|
|
126
|
+
const B = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), y = Array.from(a);
|
|
127
127
|
for (; y.length; ) {
|
|
128
|
-
const
|
|
129
|
-
if (v.has(
|
|
128
|
+
const _ = y[y.length - 1], T = h(_);
|
|
129
|
+
if (v.has(_)) {
|
|
130
130
|
y.pop();
|
|
131
131
|
continue;
|
|
132
132
|
}
|
|
133
|
-
if (L.has(
|
|
134
|
-
r.get(
|
|
133
|
+
if (L.has(_)) {
|
|
134
|
+
r.get(_) === T.n && B.push([_, T]), v.add(_), y.pop();
|
|
135
135
|
continue;
|
|
136
136
|
}
|
|
137
|
-
L.add(
|
|
138
|
-
for (const I of getMountedOrPendingDependents(
|
|
137
|
+
L.add(_);
|
|
138
|
+
for (const I of getMountedOrPendingDependents(_, T, n))
|
|
139
139
|
L.has(I) || y.push(I);
|
|
140
140
|
}
|
|
141
|
-
for (let
|
|
142
|
-
const [T, I] =
|
|
141
|
+
for (let _ = B.length - 1; _ >= 0; --_) {
|
|
142
|
+
const [T, I] = B[_];
|
|
143
143
|
let R = !1;
|
|
144
144
|
for (const P of I.d.keys())
|
|
145
145
|
if (P !== T && a.has(P)) {
|
|
146
146
|
R = !0;
|
|
147
147
|
break;
|
|
148
148
|
}
|
|
149
|
-
R && (b(T),
|
|
149
|
+
R && (b(T), S(T)), r.delete(T);
|
|
150
150
|
}
|
|
151
|
-
}), b = m[3] || ((
|
|
151
|
+
}), b = m[3] || ((B) => {
|
|
152
152
|
var L, v;
|
|
153
|
-
const y =
|
|
154
|
-
if (isAtomStateInitialized(y) && (n.has(
|
|
153
|
+
const y = h(B);
|
|
154
|
+
if (isAtomStateInitialized(y) && (n.has(B) && r.get(B) !== y.n || Array.from(y.d).every(
|
|
155
155
|
([D, O]) => (
|
|
156
156
|
// Recursively, read the atom state of the dependency, and
|
|
157
157
|
// check if the atom epoch number is unchanged
|
|
@@ -160,16 +160,16 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
160
160
|
)))
|
|
161
161
|
return y;
|
|
162
162
|
y.d.clear();
|
|
163
|
-
let
|
|
163
|
+
let _ = !0;
|
|
164
164
|
const T = () => {
|
|
165
|
-
n.has(
|
|
165
|
+
n.has(B) && (S(B), x(), f());
|
|
166
166
|
}, I = (D) => {
|
|
167
167
|
var O;
|
|
168
|
-
if (isSelfAtom(
|
|
169
|
-
const H =
|
|
168
|
+
if (isSelfAtom(B, D)) {
|
|
169
|
+
const H = h(D);
|
|
170
170
|
if (!isAtomStateInitialized(H))
|
|
171
171
|
if (hasInitialValue(D))
|
|
172
|
-
setAtomStateValueOrPromise(D, D.init,
|
|
172
|
+
setAtomStateValueOrPromise(D, D.init, h);
|
|
173
173
|
else
|
|
174
174
|
throw new Error("no atom init");
|
|
175
175
|
return returnAtomValue(H);
|
|
@@ -178,7 +178,7 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
178
178
|
try {
|
|
179
179
|
return returnAtomValue($);
|
|
180
180
|
} finally {
|
|
181
|
-
y.d.set(D, $.n), isPendingPromise(y.v) && addPendingPromiseToDependency(
|
|
181
|
+
y.d.set(D, $.n), isPendingPromise(y.v) && addPendingPromiseToDependency(B, y.v, $), (O = n.get(D)) == null || O.t.add(B), _ || T();
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
184
|
let R, P;
|
|
@@ -187,99 +187,99 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
187
187
|
return R || (R = new AbortController()), R.signal;
|
|
188
188
|
},
|
|
189
189
|
get setSelf() {
|
|
190
|
-
return !P && isActuallyWritableAtom(
|
|
191
|
-
if (!
|
|
190
|
+
return !P && isActuallyWritableAtom(B) && (P = (...D) => {
|
|
191
|
+
if (!_)
|
|
192
192
|
try {
|
|
193
|
-
return
|
|
193
|
+
return w(B, ...D);
|
|
194
194
|
} finally {
|
|
195
|
-
|
|
195
|
+
x(), f();
|
|
196
196
|
}
|
|
197
197
|
}), P;
|
|
198
198
|
}
|
|
199
199
|
}, M = y.n;
|
|
200
200
|
try {
|
|
201
|
-
const D = d(
|
|
202
|
-
return setAtomStateValueOrPromise(
|
|
201
|
+
const D = d(B, I, N);
|
|
202
|
+
return setAtomStateValueOrPromise(B, D, h), isPromiseLike$2(D) && ((L = D.onCancel) == null || L.call(D, () => R == null ? void 0 : R.abort()), D.then(
|
|
203
203
|
T,
|
|
204
204
|
T
|
|
205
205
|
)), y;
|
|
206
206
|
} catch (D) {
|
|
207
207
|
return delete y.v, y.e = D, ++y.n, y;
|
|
208
208
|
} finally {
|
|
209
|
-
|
|
209
|
+
_ = !1, M !== y.n && r.get(B) === M && (r.set(B, y.n), a.add(B), (v = c.c) == null || v.call(c, B));
|
|
210
210
|
}
|
|
211
|
-
}), k = m[4] || ((
|
|
212
|
-
const L = [
|
|
211
|
+
}), k = m[4] || ((B) => {
|
|
212
|
+
const L = [B];
|
|
213
213
|
for (; L.length; ) {
|
|
214
|
-
const v = L.pop(), y =
|
|
215
|
-
for (const
|
|
216
|
-
const T =
|
|
217
|
-
r.set(
|
|
214
|
+
const v = L.pop(), y = h(v);
|
|
215
|
+
for (const _ of getMountedOrPendingDependents(v, y, n)) {
|
|
216
|
+
const T = h(_);
|
|
217
|
+
r.set(_, T.n), L.push(_);
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
}),
|
|
220
|
+
}), w = m[5] || ((B, ...L) => {
|
|
221
221
|
let v = !0;
|
|
222
|
-
const y = (T) => returnAtomValue(b(T)),
|
|
222
|
+
const y = (T) => returnAtomValue(b(T)), _ = (T, ...I) => {
|
|
223
223
|
var R;
|
|
224
|
-
const P =
|
|
224
|
+
const P = h(T);
|
|
225
225
|
try {
|
|
226
|
-
if (isSelfAtom(
|
|
226
|
+
if (isSelfAtom(B, T)) {
|
|
227
227
|
if (!hasInitialValue(T))
|
|
228
228
|
throw new Error("atom not writable");
|
|
229
229
|
const N = P.n, M = I[0];
|
|
230
|
-
setAtomStateValueOrPromise(T, M,
|
|
230
|
+
setAtomStateValueOrPromise(T, M, h), S(T), N !== P.n && (a.add(T), (R = c.c) == null || R.call(c, T), k(T));
|
|
231
231
|
return;
|
|
232
232
|
} else
|
|
233
|
-
return
|
|
233
|
+
return w(T, ...I);
|
|
234
234
|
} finally {
|
|
235
|
-
v || (
|
|
235
|
+
v || (x(), f());
|
|
236
236
|
}
|
|
237
237
|
};
|
|
238
238
|
try {
|
|
239
|
-
return p(
|
|
239
|
+
return p(B, y, _, ...L);
|
|
240
240
|
} finally {
|
|
241
241
|
v = !1;
|
|
242
242
|
}
|
|
243
|
-
}),
|
|
243
|
+
}), S = m[6] || ((B) => {
|
|
244
244
|
var L;
|
|
245
|
-
const v =
|
|
245
|
+
const v = h(B), y = n.get(B);
|
|
246
246
|
if (y && !isPendingPromise(v.v)) {
|
|
247
|
-
for (const [
|
|
248
|
-
if (!y.d.has(
|
|
249
|
-
const I =
|
|
250
|
-
|
|
247
|
+
for (const [_, T] of v.d)
|
|
248
|
+
if (!y.d.has(_)) {
|
|
249
|
+
const I = h(_);
|
|
250
|
+
A(_).t.add(B), y.d.add(_), T !== I.n && (a.add(_), (L = c.c) == null || L.call(c, _), k(_));
|
|
251
251
|
}
|
|
252
|
-
for (const
|
|
253
|
-
if (!v.d.has(
|
|
254
|
-
y.d.delete(
|
|
255
|
-
const T =
|
|
256
|
-
T == null || T.t.delete(
|
|
252
|
+
for (const _ of y.d || [])
|
|
253
|
+
if (!v.d.has(_)) {
|
|
254
|
+
y.d.delete(_);
|
|
255
|
+
const T = E(_);
|
|
256
|
+
T == null || T.t.delete(B);
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
|
-
}),
|
|
259
|
+
}), A = m[7] || ((B) => {
|
|
260
260
|
var L;
|
|
261
|
-
const v =
|
|
262
|
-
let y = n.get(
|
|
261
|
+
const v = h(B);
|
|
262
|
+
let y = n.get(B);
|
|
263
263
|
if (!y) {
|
|
264
|
-
b(
|
|
265
|
-
for (const
|
|
266
|
-
|
|
264
|
+
b(B);
|
|
265
|
+
for (const _ of v.d.keys())
|
|
266
|
+
A(_).t.add(B);
|
|
267
267
|
if (y = {
|
|
268
268
|
l: /* @__PURE__ */ new Set(),
|
|
269
269
|
d: new Set(v.d.keys()),
|
|
270
270
|
t: /* @__PURE__ */ new Set()
|
|
271
|
-
}, n.set(
|
|
272
|
-
const
|
|
271
|
+
}, n.set(B, y), (L = c.m) == null || L.call(c, B), isActuallyWritableAtom(B)) {
|
|
272
|
+
const _ = () => {
|
|
273
273
|
let T = !0;
|
|
274
274
|
const I = (...R) => {
|
|
275
275
|
try {
|
|
276
|
-
return
|
|
276
|
+
return w(B, ...R);
|
|
277
277
|
} finally {
|
|
278
|
-
T || (
|
|
278
|
+
T || (x(), f());
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
281
|
try {
|
|
282
|
-
const R = g(
|
|
282
|
+
const R = g(B, I);
|
|
283
283
|
R && (y.u = () => {
|
|
284
284
|
T = !0;
|
|
285
285
|
try {
|
|
@@ -292,27 +292,27 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
292
292
|
T = !1;
|
|
293
293
|
}
|
|
294
294
|
};
|
|
295
|
-
l.add(
|
|
295
|
+
l.add(_);
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
298
|
return y;
|
|
299
|
-
}),
|
|
299
|
+
}), E = m[8] || ((B) => {
|
|
300
300
|
var L;
|
|
301
|
-
const v =
|
|
302
|
-
let y = n.get(
|
|
303
|
-
if (y && !y.l.size && !Array.from(y.t).some((
|
|
301
|
+
const v = h(B);
|
|
302
|
+
let y = n.get(B);
|
|
303
|
+
if (y && !y.l.size && !Array.from(y.t).some((_) => {
|
|
304
304
|
var T;
|
|
305
|
-
return (T = n.get(
|
|
305
|
+
return (T = n.get(_)) == null ? void 0 : T.d.has(B);
|
|
306
306
|
})) {
|
|
307
|
-
y.u && i.add(y.u), y = void 0, n.delete(
|
|
308
|
-
for (const
|
|
309
|
-
const T =
|
|
310
|
-
T == null || T.t.delete(
|
|
307
|
+
y.u && i.add(y.u), y = void 0, n.delete(B), (L = c.u) == null || L.call(c, B);
|
|
308
|
+
for (const _ of v.d.keys()) {
|
|
309
|
+
const T = E(_);
|
|
310
|
+
T == null || T.t.delete(B);
|
|
311
311
|
}
|
|
312
312
|
return;
|
|
313
313
|
}
|
|
314
314
|
return y;
|
|
315
|
-
}),
|
|
315
|
+
}), j = [
|
|
316
316
|
// store state
|
|
317
317
|
o,
|
|
318
318
|
n,
|
|
@@ -327,32 +327,32 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
327
327
|
u,
|
|
328
328
|
g,
|
|
329
329
|
// building-block functions
|
|
330
|
-
x,
|
|
331
|
-
f,
|
|
332
330
|
h,
|
|
331
|
+
f,
|
|
332
|
+
x,
|
|
333
333
|
b,
|
|
334
334
|
k,
|
|
335
|
+
w,
|
|
336
|
+
S,
|
|
335
337
|
A,
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
get: (w) => returnAtomValue(b(w)),
|
|
341
|
-
set: (w, ...L) => {
|
|
338
|
+
E
|
|
339
|
+
], C = {
|
|
340
|
+
get: (B) => returnAtomValue(b(B)),
|
|
341
|
+
set: (B, ...L) => {
|
|
342
342
|
try {
|
|
343
|
-
return
|
|
343
|
+
return w(B, ...L);
|
|
344
344
|
} finally {
|
|
345
|
-
|
|
345
|
+
x(), f();
|
|
346
346
|
}
|
|
347
347
|
},
|
|
348
|
-
sub: (
|
|
349
|
-
const y =
|
|
348
|
+
sub: (B, L) => {
|
|
349
|
+
const y = A(B).l;
|
|
350
350
|
return y.add(L), f(), () => {
|
|
351
|
-
y.delete(L),
|
|
351
|
+
y.delete(L), E(B), f();
|
|
352
352
|
};
|
|
353
353
|
}
|
|
354
354
|
};
|
|
355
|
-
return Object.defineProperty(
|
|
355
|
+
return Object.defineProperty(C, BUILDING_BLOCKS, { value: j }), C;
|
|
356
356
|
}, INTERNAL_buildStoreRev1 = buildStore;
|
|
357
357
|
let keyCount = 0;
|
|
358
358
|
function atom(o, n) {
|
|
@@ -388,36 +388,36 @@ function splitAtom(o, n) {
|
|
|
388
388
|
if (p)
|
|
389
389
|
return p;
|
|
390
390
|
const u = d && r.get(d), g = [], m = [];
|
|
391
|
-
return c.forEach((
|
|
392
|
-
const
|
|
393
|
-
m[f] =
|
|
394
|
-
const b = u && u.atomList[u.keyList.indexOf(
|
|
391
|
+
return c.forEach((h, f) => {
|
|
392
|
+
const x = f;
|
|
393
|
+
m[f] = x;
|
|
394
|
+
const b = u && u.atomList[u.keyList.indexOf(x)];
|
|
395
395
|
if (b) {
|
|
396
396
|
g[f] = b;
|
|
397
397
|
return;
|
|
398
398
|
}
|
|
399
|
-
const k = (
|
|
400
|
-
const
|
|
401
|
-
if (
|
|
402
|
-
const
|
|
403
|
-
if (
|
|
404
|
-
return
|
|
399
|
+
const k = (S) => {
|
|
400
|
+
const A = S(l), E = S(o), C = a(E, A == null ? void 0 : A.arr).keyList.indexOf(x);
|
|
401
|
+
if (C < 0 || C >= E.length) {
|
|
402
|
+
const B = c[a(c).keyList.indexOf(x)];
|
|
403
|
+
if (B)
|
|
404
|
+
return B;
|
|
405
405
|
throw new Error("splitAtom: index out of bounds for read");
|
|
406
406
|
}
|
|
407
|
-
return
|
|
408
|
-
},
|
|
409
|
-
const
|
|
410
|
-
if (L < 0 || L >=
|
|
407
|
+
return E[C];
|
|
408
|
+
}, w = (S, A, E) => {
|
|
409
|
+
const j = S(l), C = S(o), L = a(C, j == null ? void 0 : j.arr).keyList.indexOf(x);
|
|
410
|
+
if (L < 0 || L >= C.length)
|
|
411
411
|
throw new Error("splitAtom: index out of bounds for write");
|
|
412
|
-
const v = isFunction(
|
|
413
|
-
Object.is(
|
|
414
|
-
...
|
|
412
|
+
const v = isFunction(E) ? E(C[L]) : E;
|
|
413
|
+
Object.is(C[L], v) || A(o, [
|
|
414
|
+
...C.slice(0, L),
|
|
415
415
|
v,
|
|
416
|
-
...
|
|
416
|
+
...C.slice(L + 1)
|
|
417
417
|
]);
|
|
418
418
|
};
|
|
419
|
-
g[f] = isWritable(o) ? atom(k,
|
|
420
|
-
}), u && u.keyList.length === m.length && u.keyList.every((
|
|
419
|
+
g[f] = isWritable(o) ? atom(k, w) : atom(k);
|
|
420
|
+
}), u && u.keyList.length === m.length && u.keyList.every((h, f) => h === m[f]) ? p = u : p = { arr: c, atomList: g, keyList: m }, r.set(c, p), p;
|
|
421
421
|
}, l = atom((c) => {
|
|
422
422
|
const d = c(l), p = c(o);
|
|
423
423
|
return a(p, d == null ? void 0 : d.arr);
|
|
@@ -490,18 +490,18 @@ function createJSONStorage(o = () => {
|
|
|
490
490
|
const i = {
|
|
491
491
|
getItem: (p, u) => {
|
|
492
492
|
var g, m;
|
|
493
|
-
const
|
|
494
|
-
if (
|
|
493
|
+
const h = (x) => {
|
|
494
|
+
if (x = x || "", a !== x) {
|
|
495
495
|
try {
|
|
496
|
-
l = JSON.parse(
|
|
496
|
+
l = JSON.parse(x, n == null ? void 0 : n.reviver);
|
|
497
497
|
} catch {
|
|
498
498
|
return u;
|
|
499
499
|
}
|
|
500
|
-
a =
|
|
500
|
+
a = x;
|
|
501
501
|
}
|
|
502
502
|
return l;
|
|
503
503
|
}, f = (m = (g = o()) == null ? void 0 : g.getItem(p)) != null ? m : null;
|
|
504
|
-
return isPromiseLike$1(f) ? f.then(
|
|
504
|
+
return isPromiseLike$1(f) ? f.then(h) : h(f);
|
|
505
505
|
},
|
|
506
506
|
setItem: (p, u) => {
|
|
507
507
|
var g;
|
|
@@ -514,10 +514,10 @@ function createJSONStorage(o = () => {
|
|
|
514
514
|
var u;
|
|
515
515
|
return (u = o()) == null ? void 0 : u.removeItem(p);
|
|
516
516
|
}
|
|
517
|
-
}, c = (p) => (u, g, m) => p(u, (
|
|
517
|
+
}, c = (p) => (u, g, m) => p(u, (h) => {
|
|
518
518
|
let f;
|
|
519
519
|
try {
|
|
520
|
-
f = JSON.parse(
|
|
520
|
+
f = JSON.parse(h || "");
|
|
521
521
|
} catch {
|
|
522
522
|
f = m;
|
|
523
523
|
}
|
|
@@ -1157,15 +1157,15 @@ const useSelectedBlocksDisplayChild = () => ({
|
|
|
1157
1157
|
if (!p || !p._parent) return;
|
|
1158
1158
|
const u = p._parent, g = r.filter((m) => m._parent === u);
|
|
1159
1159
|
if (g.length === 2) {
|
|
1160
|
-
const m = g.find((
|
|
1160
|
+
const m = g.find((h) => h._id !== d);
|
|
1161
1161
|
if (m && m._type === "Text") {
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1162
|
+
const h = r.find((f) => f._id === u);
|
|
1163
|
+
h && "content" in h && (r = r.map((f) => {
|
|
1164
1164
|
if (f._id === u) {
|
|
1165
|
-
const
|
|
1165
|
+
const x = { ...f, content: m.content };
|
|
1166
1166
|
return Object.keys(m).forEach((b) => {
|
|
1167
|
-
b.startsWith("content-") && (
|
|
1168
|
-
}),
|
|
1167
|
+
b.startsWith("content-") && (x[b] = m[b]);
|
|
1168
|
+
}), x;
|
|
1169
1169
|
}
|
|
1170
1170
|
return f;
|
|
1171
1171
|
}), a.push(m._id));
|
|
@@ -1233,20 +1233,20 @@ function insertBlocksAtPosition(o, n, r, a) {
|
|
|
1233
1233
|
if (r) {
|
|
1234
1234
|
const u = o.find((g) => g._id === r);
|
|
1235
1235
|
if (u && u.content !== void 0 && u.content !== "" && !o.some((m) => m._parent === r)) {
|
|
1236
|
-
const
|
|
1236
|
+
const h = {
|
|
1237
1237
|
_id: generateUUID(),
|
|
1238
1238
|
_parent: r,
|
|
1239
1239
|
_type: "Text",
|
|
1240
1240
|
content: u.content
|
|
1241
1241
|
};
|
|
1242
1242
|
Object.keys(u).forEach((f) => {
|
|
1243
|
-
f.startsWith("content-") && (
|
|
1244
|
-
}), l.unshift(
|
|
1243
|
+
f.startsWith("content-") && (h[f] = u[f]);
|
|
1244
|
+
}), l.unshift(h), i = i.map((f) => {
|
|
1245
1245
|
if (f._id === r) {
|
|
1246
|
-
const
|
|
1247
|
-
return Object.keys(
|
|
1248
|
-
b.startsWith("content-") && (
|
|
1249
|
-
}),
|
|
1246
|
+
const x = { ...f, content: "" };
|
|
1247
|
+
return Object.keys(x).forEach((b) => {
|
|
1248
|
+
b.startsWith("content-") && (x[b] = "");
|
|
1249
|
+
}), x;
|
|
1250
1250
|
}
|
|
1251
1251
|
return f;
|
|
1252
1252
|
});
|
|
@@ -1396,65 +1396,65 @@ const useBlocksStoreManager = () => {
|
|
|
1396
1396
|
updateBlocksProps: c
|
|
1397
1397
|
} = useBlocksStoreManager();
|
|
1398
1398
|
return {
|
|
1399
|
-
moveBlocks: (
|
|
1400
|
-
const
|
|
1401
|
-
const
|
|
1402
|
-
return { _id:
|
|
1403
|
-
}),
|
|
1404
|
-
|
|
1405
|
-
undo: () => each(
|
|
1406
|
-
i([
|
|
1399
|
+
moveBlocks: (x, b, k) => {
|
|
1400
|
+
const w = map(x, (A) => {
|
|
1401
|
+
const j = n.find((L) => L._id === A)._parent || null, B = n.filter((L) => j ? L._parent === j : !L._parent).map((L) => L._id).indexOf(A);
|
|
1402
|
+
return { _id: A, oldParent: j, oldPosition: B };
|
|
1403
|
+
}), S = w.find(({ _id: A }) => A === x[0]);
|
|
1404
|
+
S && S.oldParent === b && S.oldPosition === k || (i(x, b, k), o({
|
|
1405
|
+
undo: () => each(w, ({ _id: A, oldParent: E, oldPosition: j }) => {
|
|
1406
|
+
i([A], E, j);
|
|
1407
1407
|
}),
|
|
1408
|
-
redo: () => i(
|
|
1408
|
+
redo: () => i(x, b, k)
|
|
1409
1409
|
}));
|
|
1410
1410
|
},
|
|
1411
|
-
addBlocks: (
|
|
1412
|
-
a(
|
|
1413
|
-
undo: () => l(map(
|
|
1414
|
-
redo: () => a(
|
|
1411
|
+
addBlocks: (x, b, k) => {
|
|
1412
|
+
a(x, b, k), o({
|
|
1413
|
+
undo: () => l(map(x, "_id")),
|
|
1414
|
+
redo: () => a(x, b, k)
|
|
1415
1415
|
});
|
|
1416
1416
|
},
|
|
1417
|
-
removeBlocks: (
|
|
1418
|
-
var
|
|
1419
|
-
const b = (
|
|
1420
|
-
l(map(
|
|
1421
|
-
undo: () => a(
|
|
1422
|
-
redo: () => l(map(
|
|
1417
|
+
removeBlocks: (x) => {
|
|
1418
|
+
var S;
|
|
1419
|
+
const b = (S = first(x)) == null ? void 0 : S._parent, w = n.filter((A) => b ? A._parent === b : !A._parent).indexOf(first(x));
|
|
1420
|
+
l(map(x, "_id")), o({
|
|
1421
|
+
undo: () => a(x, b, w),
|
|
1422
|
+
redo: () => l(map(x, "_id"))
|
|
1423
1423
|
});
|
|
1424
1424
|
},
|
|
1425
|
-
updateBlocks: (
|
|
1426
|
-
let
|
|
1425
|
+
updateBlocks: (x, b, k) => {
|
|
1426
|
+
let w = [];
|
|
1427
1427
|
if (k)
|
|
1428
|
-
|
|
1428
|
+
w = map(x, (S) => ({ _id: S, ...k }));
|
|
1429
1429
|
else {
|
|
1430
|
-
const
|
|
1431
|
-
|
|
1432
|
-
const
|
|
1433
|
-
return each(
|
|
1430
|
+
const S = keys(b);
|
|
1431
|
+
w = map(x, (A) => {
|
|
1432
|
+
const E = n.find((C) => C._id === A), j = { _id: A };
|
|
1433
|
+
return each(S, (C) => j[C] = E[C]), j;
|
|
1434
1434
|
});
|
|
1435
1435
|
}
|
|
1436
|
-
c(map(
|
|
1437
|
-
undo: () => c(
|
|
1438
|
-
redo: () => c(map(
|
|
1436
|
+
c(map(x, (S) => ({ _id: S, ...b }))), o({
|
|
1437
|
+
undo: () => c(w),
|
|
1438
|
+
redo: () => c(map(x, (S) => ({ _id: S, ...b })))
|
|
1439
1439
|
});
|
|
1440
1440
|
},
|
|
1441
|
-
updateBlocksRuntime: (
|
|
1442
|
-
c(map(
|
|
1441
|
+
updateBlocksRuntime: (x, b) => {
|
|
1442
|
+
c(map(x, (k) => ({ _id: k, ...b })));
|
|
1443
1443
|
},
|
|
1444
|
-
setNewBlocks: (
|
|
1445
|
-
r(
|
|
1444
|
+
setNewBlocks: (x) => {
|
|
1445
|
+
r(x), o({
|
|
1446
1446
|
undo: () => r(n),
|
|
1447
|
-
redo: () => r(
|
|
1447
|
+
redo: () => r(x)
|
|
1448
1448
|
});
|
|
1449
1449
|
},
|
|
1450
|
-
updateMultipleBlocksProps: (
|
|
1450
|
+
updateMultipleBlocksProps: (x) => {
|
|
1451
1451
|
let b = [];
|
|
1452
|
-
b = map(
|
|
1453
|
-
const
|
|
1454
|
-
return each(
|
|
1455
|
-
}), c(
|
|
1452
|
+
b = map(x, (k) => {
|
|
1453
|
+
const w = keys(k), S = n.find((E) => E._id === k._id), A = {};
|
|
1454
|
+
return each(w, (E) => A[E] = S[E]), A;
|
|
1455
|
+
}), c(x), o({
|
|
1456
1456
|
undo: () => c(b),
|
|
1457
|
-
redo: () => c(
|
|
1457
|
+
redo: () => c(x)
|
|
1458
1458
|
});
|
|
1459
1459
|
}
|
|
1460
1460
|
};
|
|
@@ -1506,17 +1506,17 @@ import.meta.vitest && describe("canDropBlock Function", () => {
|
|
|
1506
1506
|
const useAddBlock = () => {
|
|
1507
1507
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
1508
1508
|
(i, c, d) => {
|
|
1509
|
-
var
|
|
1509
|
+
var h;
|
|
1510
1510
|
for (let f = 0; f < i.length; f++) {
|
|
1511
|
-
const { _id:
|
|
1511
|
+
const { _id: x } = i[f];
|
|
1512
1512
|
i[f]._id = generateUUID();
|
|
1513
|
-
const b = filter(i, { _parent:
|
|
1513
|
+
const b = filter(i, { _parent: x });
|
|
1514
1514
|
for (let k = 0; k < b.length; k++)
|
|
1515
1515
|
b[k]._parent = i[f]._id;
|
|
1516
1516
|
}
|
|
1517
1517
|
const p = first(i);
|
|
1518
1518
|
let u, g;
|
|
1519
|
-
return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(
|
|
1519
|
+
return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(h = first(i)) == null ? void 0 : h._id]), first(i);
|
|
1520
1520
|
},
|
|
1521
1521
|
[r, o, n]
|
|
1522
1522
|
);
|
|
@@ -1533,8 +1533,8 @@ const useAddBlock = () => {
|
|
|
1533
1533
|
...has(i, "_name") && { _name: i._name },
|
|
1534
1534
|
...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
|
|
1535
1535
|
};
|
|
1536
|
-
let m,
|
|
1537
|
-
return c && (m = find(o, { _id: c }), g._parent = c,
|
|
1536
|
+
let m, h;
|
|
1537
|
+
return c && (m = find(o, { _id: c }), g._parent = c, h = c), !canAcceptChildBlock(m == null ? void 0 : m._type, g._type) && m && (g._parent = m._parent, h = m._parent), r([g], h, d), n([g._id]), g;
|
|
1538
1538
|
},
|
|
1539
1539
|
[r, a, o, n]
|
|
1540
1540
|
), addPredefinedBlock: a };
|
|
@@ -2980,39 +2980,39 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2980
2980
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
2981
2981
|
})
|
|
2982
2982
|
), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
|
|
2983
|
-
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(), g = p.length ? p : u, m = (
|
|
2984
|
-
const
|
|
2985
|
-
for (const b in
|
|
2986
|
-
const k =
|
|
2983
|
+
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(), g = p.length ? p : u, m = (h, f) => {
|
|
2984
|
+
const x = cloneDeep(f.find((b) => b._id === h));
|
|
2985
|
+
for (const b in x) {
|
|
2986
|
+
const k = x[b];
|
|
2987
2987
|
if (typeof k == "string" && startsWith(k, STYLES_KEY)) {
|
|
2988
|
-
const { baseClasses:
|
|
2989
|
-
|
|
2988
|
+
const { baseClasses: w, classes: S } = getSplitChaiClasses(k);
|
|
2989
|
+
x[b] = compact(flattenDeep([w, S])).join(" ");
|
|
2990
2990
|
} else
|
|
2991
|
-
b !== "_id" && delete
|
|
2991
|
+
b !== "_id" && delete x[b];
|
|
2992
2992
|
}
|
|
2993
|
-
return
|
|
2993
|
+
return x;
|
|
2994
2994
|
};
|
|
2995
2995
|
return {
|
|
2996
2996
|
askAi: useCallback(
|
|
2997
|
-
async (
|
|
2997
|
+
async (h, f, x, b) => {
|
|
2998
2998
|
if (l) {
|
|
2999
2999
|
n(!0), a(null);
|
|
3000
3000
|
try {
|
|
3001
|
-
const k = p === u ? "" : p,
|
|
3002
|
-
if (
|
|
3003
|
-
a(
|
|
3001
|
+
const k = p === u ? "" : p, w = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [m(f, d)], S = await l(h, addLangToPrompt(x, g, h), w, k), { blocks: A, error: E } = S;
|
|
3002
|
+
if (E) {
|
|
3003
|
+
a(E);
|
|
3004
3004
|
return;
|
|
3005
3005
|
}
|
|
3006
|
-
if (
|
|
3007
|
-
const
|
|
3008
|
-
for (const
|
|
3009
|
-
|
|
3010
|
-
return
|
|
3006
|
+
if (h === "styles") {
|
|
3007
|
+
const j = A.map((C) => {
|
|
3008
|
+
for (const B in C)
|
|
3009
|
+
B !== "_id" && (C[B] = `${STYLES_KEY},${C[B]}`);
|
|
3010
|
+
return C;
|
|
3011
3011
|
});
|
|
3012
|
-
c(
|
|
3012
|
+
c(j);
|
|
3013
3013
|
} else
|
|
3014
|
-
i(
|
|
3015
|
-
b && b(
|
|
3014
|
+
i(A);
|
|
3015
|
+
b && b(S);
|
|
3016
3016
|
} catch (k) {
|
|
3017
3017
|
a(k);
|
|
3018
3018
|
} finally {
|
|
@@ -3153,11 +3153,11 @@ const useBlockHighlight = () => {
|
|
|
3153
3153
|
(a, l = null) => {
|
|
3154
3154
|
const i = [];
|
|
3155
3155
|
each(a, (c) => {
|
|
3156
|
-
const d = o.find((
|
|
3156
|
+
const d = o.find((h) => h._id === c);
|
|
3157
3157
|
l ? l === "root" && (l = null) : l = d._parent;
|
|
3158
3158
|
const g = filter(
|
|
3159
3159
|
o,
|
|
3160
|
-
(
|
|
3160
|
+
(h) => isString(l) ? h._parent === l : !h._parent
|
|
3161
3161
|
).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
|
|
3162
3162
|
r(m, l, g), i.push(get(m, "0._id", ""));
|
|
3163
3163
|
}), n(i);
|
|
@@ -3253,12 +3253,12 @@ const useBlockHighlight = () => {
|
|
|
3253
3253
|
const d = o(c), p = a;
|
|
3254
3254
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
3255
3255
|
return each(p, (m) => {
|
|
3256
|
-
const
|
|
3256
|
+
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
3257
3257
|
u = u.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
3258
|
-
const
|
|
3259
|
-
includes(["2xl", "xl", "lg", "md", "sm"],
|
|
3258
|
+
const x = first(m.split(":"));
|
|
3259
|
+
includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(m.split(":").pop().trim());
|
|
3260
3260
|
}), each(p, (m) => {
|
|
3261
|
-
const
|
|
3261
|
+
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
3262
3262
|
g = g.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
3263
3263
|
}), {
|
|
3264
3264
|
ids: [d._id],
|
|
@@ -3377,21 +3377,21 @@ const CONTROLS = [
|
|
|
3377
3377
|
return "VERTICAL";
|
|
3378
3378
|
}
|
|
3379
3379
|
}, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
|
|
3380
|
-
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (
|
|
3381
|
-
(
|
|
3382
|
-
isDisabledControl(g, m,
|
|
3380
|
+
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, m = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, i, a), f = useCallback(
|
|
3381
|
+
(x) => {
|
|
3382
|
+
isDisabledControl(g, m, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), n());
|
|
3383
3383
|
},
|
|
3384
3384
|
[g, m, p, u, i, c, n]
|
|
3385
3385
|
);
|
|
3386
3386
|
return useHotkeys(
|
|
3387
3387
|
"shift+up, shift+down, shift+left, shift+right",
|
|
3388
|
-
({ key:
|
|
3388
|
+
({ key: x }) => {
|
|
3389
3389
|
var b;
|
|
3390
|
-
f((b =
|
|
3390
|
+
f((b = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : b.toUpperCase());
|
|
3391
3391
|
},
|
|
3392
3392
|
{ document: a == null ? void 0 : a.contentDocument },
|
|
3393
3393
|
[f]
|
|
3394
|
-
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: f, orientation:
|
|
3394
|
+
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: f, orientation: h };
|
|
3395
3395
|
}, BlockController = ({ block: o, updateFloatingBar: n }) => {
|
|
3396
3396
|
const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
|
|
3397
3397
|
o,
|
|
@@ -3430,8 +3430,8 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
|
3430
3430
|
if (m === "CHILD")
|
|
3431
3431
|
pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
|
|
3432
3432
|
else {
|
|
3433
|
-
const
|
|
3434
|
-
m === "BEFORE" ?
|
|
3433
|
+
const h = { _id: c || "", position: d == null ? void 0 : d.length };
|
|
3434
|
+
m === "BEFORE" ? h.position = Math.max(u, 0) : m === "AFTER" && (h.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, h);
|
|
3435
3435
|
}
|
|
3436
3436
|
};
|
|
3437
3437
|
return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
@@ -3461,15 +3461,15 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
|
3461
3461
|
}
|
|
3462
3462
|
);
|
|
3463
3463
|
}, BlockFloatingSelector = ({ selectedBlockElement: o, block: n }) => {
|
|
3464
|
-
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: g, refs: m, update:
|
|
3464
|
+
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: g, refs: m, update: h } = useFloating({
|
|
3465
3465
|
placement: "top-start",
|
|
3466
3466
|
middleware: [shift(), flip()],
|
|
3467
3467
|
elements: {
|
|
3468
3468
|
reference: o
|
|
3469
3469
|
}
|
|
3470
3470
|
});
|
|
3471
|
-
useResizeObserver(o, () =>
|
|
3472
|
-
const f = get(n, "_parent", null),
|
|
3471
|
+
useResizeObserver(o, () => h(), o !== null), useResizeObserver(u == null ? void 0 : u.body, () => h(), (u == null ? void 0 : u.body) !== null);
|
|
3472
|
+
const f = get(n, "_parent", null), x = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
|
|
3473
3473
|
return !o || !n || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
3474
3474
|
"div",
|
|
3475
3475
|
{
|
|
@@ -3495,12 +3495,12 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
|
3495
3495
|
}
|
|
3496
3496
|
}
|
|
3497
3497
|
),
|
|
3498
|
-
/* @__PURE__ */ jsx(BlockActionLabel, { label:
|
|
3498
|
+
/* @__PURE__ */ jsx(BlockActionLabel, { label: x, block: n }),
|
|
3499
3499
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
|
|
3500
3500
|
/* @__PURE__ */ jsx(AddBlockDropdown, { block: n, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
|
|
3501
3501
|
canDuplicateBlock(get(n, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([n == null ? void 0 : n._id]) }) : null,
|
|
3502
3502
|
canDeleteBlock(get(n, "_type", "")) && d(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([n == null ? void 0 : n._id]) }) : null,
|
|
3503
|
-
d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar:
|
|
3503
|
+
d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar: h })
|
|
3504
3504
|
] })
|
|
3505
3505
|
]
|
|
3506
3506
|
}
|
|
@@ -3561,15 +3561,15 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
|
3561
3561
|
<div class="frame-root h-full"></div>
|
|
3562
3562
|
</body>
|
|
3563
3563
|
</html>`, useKeyEventWatcher = (o) => {
|
|
3564
|
-
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(),
|
|
3564
|
+
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), h = o ? { document: o } : {};
|
|
3565
3565
|
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(
|
|
3566
3566
|
"ctrl+v,command+v",
|
|
3567
3567
|
() => {
|
|
3568
3568
|
g(n[0]) && m(n);
|
|
3569
3569
|
},
|
|
3570
|
-
{ ...
|
|
3570
|
+
{ ...h, preventDefault: !0 },
|
|
3571
3571
|
[n, g, m]
|
|
3572
|
-
), useHotkeys("esc", () => r([]),
|
|
3572
|
+
), useHotkeys("esc", () => r([]), h, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...h, preventDefault: !0 }, [
|
|
3573
3573
|
n,
|
|
3574
3574
|
i
|
|
3575
3575
|
]), useHotkeys(
|
|
@@ -3577,7 +3577,7 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
|
3577
3577
|
(f) => {
|
|
3578
3578
|
f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
|
|
3579
3579
|
},
|
|
3580
|
-
|
|
3580
|
+
h,
|
|
3581
3581
|
[n, l]
|
|
3582
3582
|
);
|
|
3583
3583
|
}, KeyboardHandler = () => {
|
|
@@ -3657,33 +3657,33 @@ const useDnd = () => {
|
|
|
3657
3657
|
};
|
|
3658
3658
|
return iframeDocument = o, {
|
|
3659
3659
|
isDragging: n,
|
|
3660
|
-
onDragOver: (
|
|
3661
|
-
|
|
3660
|
+
onDragOver: (h) => {
|
|
3661
|
+
h.preventDefault(), h.stopPropagation(), throttledDragOver(h);
|
|
3662
3662
|
},
|
|
3663
|
-
onDrop: (
|
|
3664
|
-
var
|
|
3665
|
-
const f = dropTarget, b = getOrientation(f) === "vertical" ?
|
|
3663
|
+
onDrop: (h) => {
|
|
3664
|
+
var E;
|
|
3665
|
+
const f = dropTarget, b = getOrientation(f) === "vertical" ? h.clientY + ((E = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : E.scrollY) : h.clientX;
|
|
3666
3666
|
dropIndex = calculateDropIndex(b, possiblePositions);
|
|
3667
|
-
const k = d,
|
|
3668
|
-
if ((k == null ? void 0 : k._id) ===
|
|
3667
|
+
const k = d, w = f.getAttribute("data-block-id"), S = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
|
|
3668
|
+
if ((k == null ? void 0 : k._id) === w || !S) {
|
|
3669
3669
|
m();
|
|
3670
3670
|
return;
|
|
3671
3671
|
}
|
|
3672
3672
|
if (!has(k, "_id")) {
|
|
3673
|
-
a(k,
|
|
3673
|
+
a(k, w === "canvas" ? null : w, dropIndex), setTimeout(m, 300);
|
|
3674
3674
|
return;
|
|
3675
3675
|
}
|
|
3676
|
-
let
|
|
3677
|
-
|
|
3676
|
+
let A = f.getAttribute("data-block-id");
|
|
3677
|
+
A === null && (A = h.target.parentElement.getAttribute("data-block-id")), c([k._id], A === "canvas" ? null : A, dropIndex), m(), setTimeout(removePlaceholder, 300);
|
|
3678
3678
|
},
|
|
3679
|
-
onDragEnter: (
|
|
3680
|
-
const f =
|
|
3681
|
-
dropTarget =
|
|
3682
|
-
const b =
|
|
3683
|
-
u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [], k && calculatePossiblePositions(
|
|
3679
|
+
onDragEnter: (h) => {
|
|
3680
|
+
const f = h, x = f.target;
|
|
3681
|
+
dropTarget = x;
|
|
3682
|
+
const b = x.getAttribute("data-block-id"), k = x.getAttribute("data-dnd-dragged") !== "yes";
|
|
3683
|
+
u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [], k && calculatePossiblePositions(x), r(!0), l(""), i([]);
|
|
3684
3684
|
},
|
|
3685
|
-
onDragLeave: (
|
|
3686
|
-
|
|
3685
|
+
onDragLeave: (h) => {
|
|
3686
|
+
h.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
|
|
3687
3687
|
}
|
|
3688
3688
|
};
|
|
3689
3689
|
};
|
|
@@ -3714,8 +3714,8 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3714
3714
|
const f = o.getHTML();
|
|
3715
3715
|
a([m], { content: f }), n.style.display = "none", u.style.visibility = "visible";
|
|
3716
3716
|
}), i(m);
|
|
3717
|
-
const
|
|
3718
|
-
o.commands.setContent(
|
|
3717
|
+
const h = d(m).content;
|
|
3718
|
+
o.commands.setContent(h), n.style.display = "block", u.style.visibility = "hidden", n.style.position = "absolute", n.style.top = `${u.offsetTop}px`, n.style.left = `${u.offsetLeft}px`, n.style.width = `${u.offsetWidth}px`, n.style.height = `${u.offsetHeight}px`, n.classList.add(...u.classList);
|
|
3719
3719
|
},
|
|
3720
3720
|
[l, c, d, i, a, o, n]
|
|
3721
3721
|
);
|
|
@@ -3756,17 +3756,17 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3756
3756
|
return;
|
|
3757
3757
|
const f = getElementByDataBlockId(n, first(r));
|
|
3758
3758
|
if (f) {
|
|
3759
|
-
const
|
|
3760
|
-
if (
|
|
3759
|
+
const x = f.getAttribute("data-style-prop");
|
|
3760
|
+
if (x) {
|
|
3761
3761
|
const b = f.getAttribute("data-style-id"), k = f.getAttribute("data-block-parent");
|
|
3762
|
-
l([{ id: b, prop:
|
|
3762
|
+
l([{ id: b, prop: x, blockId: k }]);
|
|
3763
3763
|
}
|
|
3764
3764
|
}
|
|
3765
3765
|
}, 100);
|
|
3766
3766
|
}, [n, r, l, a]);
|
|
3767
3767
|
const c = useEditor({
|
|
3768
3768
|
extensions: [StarterKit]
|
|
3769
|
-
}), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(),
|
|
3769
|
+
}), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(), h = useDnd();
|
|
3770
3770
|
return /* @__PURE__ */ jsx(
|
|
3771
3771
|
"div",
|
|
3772
3772
|
{
|
|
@@ -3776,8 +3776,8 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3776
3776
|
onDoubleClick: p,
|
|
3777
3777
|
onMouseMove: g,
|
|
3778
3778
|
onMouseLeave: m,
|
|
3779
|
-
...omit(
|
|
3780
|
-
className: "relative h-full max-w-full p-px " + (
|
|
3779
|
+
...omit(h, "isDragging"),
|
|
3780
|
+
className: "relative h-full max-w-full p-px " + (h.isDragging ? "dragging" : ""),
|
|
3781
3781
|
children: o
|
|
3782
3782
|
}
|
|
3783
3783
|
);
|
|
@@ -3786,7 +3786,7 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3786
3786
|
d == null ? void 0 : d.getElementById("selected-block")
|
|
3787
3787
|
), [m] = useState(
|
|
3788
3788
|
d == null ? void 0 : d.getElementById("selected-styling-block")
|
|
3789
|
-
), [
|
|
3789
|
+
), [h] = useState(
|
|
3790
3790
|
d == null ? void 0 : d.getElementById("dragged-block")
|
|
3791
3791
|
);
|
|
3792
3792
|
useEffect(() => {
|
|
@@ -3830,8 +3830,8 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3830
3830
|
outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
|
|
3831
3831
|
}`);
|
|
3832
3832
|
}, [r, g]), useEffect(() => {
|
|
3833
|
-
|
|
3834
|
-
}, [i,
|
|
3833
|
+
h.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
|
|
3834
|
+
}, [i, h]), useEffect(() => {
|
|
3835
3835
|
u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
|
|
3836
3836
|
}, [u]), useEffect(() => {
|
|
3837
3837
|
m && (m.textContent = `${map(l, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
|
|
@@ -3843,10 +3843,10 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3843
3843
|
const f = useMemo(
|
|
3844
3844
|
() => getChaiThemeCssVariables(o),
|
|
3845
3845
|
[o]
|
|
3846
|
-
),
|
|
3846
|
+
), x = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
|
|
3847
3847
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3848
3848
|
/* @__PURE__ */ jsx("style", { id: "chai-theme", children: f }),
|
|
3849
|
-
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html:
|
|
3849
|
+
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: x } })
|
|
3850
3850
|
] });
|
|
3851
3851
|
}, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
|
|
3852
3852
|
const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), c = useDebouncedCallback(
|
|
@@ -3926,10 +3926,10 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3926
3926
|
const [r] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), m = useMemo(
|
|
3927
3927
|
() => u ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
|
|
3928
3928
|
[r, l, a, d, u]
|
|
3929
|
-
),
|
|
3929
|
+
), h = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), f = useMemo(
|
|
3930
3930
|
() => c(r._id, getBlockRuntimeProps(r._type)),
|
|
3931
3931
|
[r._id, r._type, c, getBlockRuntimeProps]
|
|
3932
|
-
),
|
|
3932
|
+
), x = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), b = useMemo(
|
|
3933
3933
|
() => ({
|
|
3934
3934
|
blockProps: {
|
|
3935
3935
|
"data-block-id": r._id,
|
|
@@ -3938,9 +3938,9 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3938
3938
|
inBuilder: !0,
|
|
3939
3939
|
lang: l || i,
|
|
3940
3940
|
...m,
|
|
3941
|
-
...
|
|
3941
|
+
...h,
|
|
3942
3942
|
...f,
|
|
3943
|
-
...
|
|
3943
|
+
...x
|
|
3944
3944
|
}),
|
|
3945
3945
|
[
|
|
3946
3946
|
r._id,
|
|
@@ -3948,9 +3948,9 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3948
3948
|
l,
|
|
3949
3949
|
i,
|
|
3950
3950
|
m,
|
|
3951
|
-
|
|
3951
|
+
h,
|
|
3952
3952
|
f,
|
|
3953
|
-
|
|
3953
|
+
x
|
|
3954
3954
|
]
|
|
3955
3955
|
);
|
|
3956
3956
|
return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...b, children: n }) });
|
|
@@ -3982,11 +3982,11 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3982
3982
|
if (d < n) {
|
|
3983
3983
|
const u = parseFloat((d / n).toFixed(2).toString());
|
|
3984
3984
|
let g = {};
|
|
3985
|
-
const m = p * u,
|
|
3985
|
+
const m = p * u, h = d * u;
|
|
3986
3986
|
p && (g = {
|
|
3987
3987
|
// Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
|
|
3988
3988
|
height: 100 + (p - m) / m * 100 + "%",
|
|
3989
|
-
width: 100 + (d -
|
|
3989
|
+
width: 100 + (d - h) / h * 100 + "%"
|
|
3990
3990
|
}), i({
|
|
3991
3991
|
position: "relative",
|
|
3992
3992
|
top: 0,
|
|
@@ -4003,39 +4003,39 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4003
4003
|
c();
|
|
4004
4004
|
}, [n, o, r, c]), l;
|
|
4005
4005
|
}, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
|
|
4006
|
-
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, m] = useState([]), [,
|
|
4007
|
-
p((
|
|
4006
|
+
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, m] = useState([]), [, h] = useState([]), [, f] = useAtom$1(canvasIframeAtom), [x, b] = useSelectedStylingBlocks(), k = useBuilderProp("loading", !1), w = useBuilderProp("htmlDir", "ltr"), S = (j) => {
|
|
4007
|
+
p((C) => ({ ...C, width: j }));
|
|
4008
4008
|
};
|
|
4009
4009
|
useEffect(() => {
|
|
4010
4010
|
if (!c.current) return;
|
|
4011
|
-
const { clientWidth:
|
|
4012
|
-
p({ width:
|
|
4011
|
+
const { clientWidth: j, clientHeight: C } = c.current;
|
|
4012
|
+
p({ width: j, height: C });
|
|
4013
4013
|
}, [c, n]);
|
|
4014
|
-
const
|
|
4015
|
-
const { top:
|
|
4016
|
-
return
|
|
4014
|
+
const A = (j, C = 0) => {
|
|
4015
|
+
const { top: B } = j.getBoundingClientRect();
|
|
4016
|
+
return B + C >= 0 && B - C <= window.innerHeight;
|
|
4017
4017
|
};
|
|
4018
4018
|
useEffect(() => {
|
|
4019
|
-
var
|
|
4019
|
+
var j, C;
|
|
4020
4020
|
if (a && a.type !== "Multiple" && i.current) {
|
|
4021
|
-
const
|
|
4022
|
-
|
|
4021
|
+
const B = getElementByDataBlockId(i.current.contentDocument, a._id);
|
|
4022
|
+
B && (A(B) || (C = (j = i.current) == null ? void 0 : j.contentWindow) == null || C.scrollTo({ top: B.offsetTop, behavior: "smooth" }), m([B]));
|
|
4023
4023
|
}
|
|
4024
4024
|
}, [a]), useEffect(() => {
|
|
4025
|
-
if (!isEmpty(
|
|
4026
|
-
const
|
|
4025
|
+
if (!isEmpty(x) && i.current) {
|
|
4026
|
+
const j = getElementByStyleId(
|
|
4027
4027
|
i.current.contentDocument,
|
|
4028
|
-
first(
|
|
4028
|
+
first(x).id
|
|
4029
4029
|
);
|
|
4030
|
-
|
|
4030
|
+
h(j ? [j] : [null]);
|
|
4031
4031
|
} else
|
|
4032
|
-
|
|
4033
|
-
}, [
|
|
4034
|
-
const
|
|
4035
|
-
let
|
|
4036
|
-
return
|
|
4037
|
-
}, [o,
|
|
4038
|
-
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount:
|
|
4032
|
+
h([null]);
|
|
4033
|
+
}, [x]);
|
|
4034
|
+
const E = useMemo(() => {
|
|
4035
|
+
let j = IframeInitialContent;
|
|
4036
|
+
return j = j.replace("__HTML_DIR__", w), o === "offline" && (j = j.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), j;
|
|
4037
|
+
}, [o, w]);
|
|
4038
|
+
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: S, onResize: S, children: /* @__PURE__ */ jsx(
|
|
4039
4039
|
"div",
|
|
4040
4040
|
{
|
|
4041
4041
|
onClick: () => {
|
|
@@ -4052,7 +4052,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4052
4052
|
id: "canvas-iframe",
|
|
4053
4053
|
style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
|
|
4054
4054
|
className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
|
|
4055
|
-
initialContent:
|
|
4055
|
+
initialContent: E,
|
|
4056
4056
|
children: [
|
|
4057
4057
|
/* @__PURE__ */ jsx(KeyboardHandler, {}),
|
|
4058
4058
|
/* @__PURE__ */ jsx(
|
|
@@ -4204,19 +4204,19 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4204
4204
|
}, [a, o]);
|
|
4205
4205
|
const u = (f) => Array.isArray(f) ? "array" : typeof f == "object" && f !== null ? "object" : "value", g = React.useCallback(
|
|
4206
4206
|
(f) => {
|
|
4207
|
-
const
|
|
4208
|
-
f.type === "object" ? (c((b) => [...b, f.key]), p(f.value)) :
|
|
4207
|
+
const x = (b) => r === "value" ? b === "value" || b === "object" : r === "array" ? b === "array" : b === r;
|
|
4208
|
+
f.type === "object" ? (c((b) => [...b, f.key]), p(f.value)) : x(f.type) && (n([...i, f.key].join(".")), l(!1));
|
|
4209
4209
|
},
|
|
4210
4210
|
[i, n, r]
|
|
4211
4211
|
), m = React.useCallback(() => {
|
|
4212
4212
|
if (i.length > 0) {
|
|
4213
4213
|
const f = i.slice(0, -1);
|
|
4214
|
-
c(f), p(f.reduce((
|
|
4214
|
+
c(f), p(f.reduce((x, b) => x[b], o));
|
|
4215
4215
|
}
|
|
4216
|
-
}, [i, o]),
|
|
4216
|
+
}, [i, o]), h = React.useMemo(() => Object.entries(d).map(([f, x]) => ({
|
|
4217
4217
|
key: f,
|
|
4218
|
-
value:
|
|
4219
|
-
type: u(
|
|
4218
|
+
value: x,
|
|
4219
|
+
type: u(x)
|
|
4220
4220
|
})).filter((f) => r === "value" ? f.type === "value" || f.type === "object" : r === "array" ? f.type === "array" || f.type === "object" : r === "object" ? f.type === "object" : !0), [d, r]);
|
|
4221
4221
|
return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
|
|
4222
4222
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
@@ -4242,7 +4242,7 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4242
4242
|
/* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
|
|
4243
4243
|
"Back"
|
|
4244
4244
|
] }),
|
|
4245
|
-
|
|
4245
|
+
h.map((f) => /* @__PURE__ */ jsxs(
|
|
4246
4246
|
CommandItem,
|
|
4247
4247
|
{
|
|
4248
4248
|
value: f.key,
|
|
@@ -4258,8 +4258,8 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4258
4258
|
size: "sm",
|
|
4259
4259
|
variant: "ghost",
|
|
4260
4260
|
className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
|
|
4261
|
-
onClick: (
|
|
4262
|
-
|
|
4261
|
+
onClick: (x) => {
|
|
4262
|
+
x.stopPropagation(), n([...i, f.key].join(".")), l(!1);
|
|
4263
4263
|
},
|
|
4264
4264
|
children: "Select"
|
|
4265
4265
|
}
|
|
@@ -4435,8 +4435,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4435
4435
|
z-index: 9999 !important;
|
|
4436
4436
|
}
|
|
4437
4437
|
`, document.head.appendChild(m), () => {
|
|
4438
|
-
const
|
|
4439
|
-
|
|
4438
|
+
const h = document.getElementById("rte-modal-styles");
|
|
4439
|
+
h && h.remove();
|
|
4440
4440
|
};
|
|
4441
4441
|
}
|
|
4442
4442
|
}, [o]);
|
|
@@ -4458,12 +4458,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4458
4458
|
],
|
|
4459
4459
|
content: a || "",
|
|
4460
4460
|
onUpdate: ({ editor: m }) => {
|
|
4461
|
-
const
|
|
4462
|
-
l(
|
|
4461
|
+
const h = m.getHTML();
|
|
4462
|
+
l(h);
|
|
4463
4463
|
},
|
|
4464
4464
|
onBlur: ({ editor: m }) => {
|
|
4465
|
-
const
|
|
4466
|
-
i(r,
|
|
4465
|
+
const h = m.getHTML();
|
|
4466
|
+
i(r, h);
|
|
4467
4467
|
},
|
|
4468
4468
|
editorProps: {
|
|
4469
4469
|
attributes: {
|
|
@@ -4480,17 +4480,17 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4480
4480
|
}, [u, o]);
|
|
4481
4481
|
const g = (m) => {
|
|
4482
4482
|
if (!u) return;
|
|
4483
|
-
const
|
|
4483
|
+
const h = `{{${m}}}`;
|
|
4484
4484
|
u.commands.focus();
|
|
4485
|
-
const { from: f, to:
|
|
4486
|
-
if (f !==
|
|
4487
|
-
u.chain().deleteSelection().insertContent(
|
|
4485
|
+
const { from: f, to: x } = u.state.selection;
|
|
4486
|
+
if (f !== x)
|
|
4487
|
+
u.chain().deleteSelection().insertContent(h).run();
|
|
4488
4488
|
else {
|
|
4489
|
-
const { state: k } = u,
|
|
4489
|
+
const { state: k } = u, w = k.selection.from, S = k.doc.textBetween(Math.max(0, w - 1), w), A = k.doc.textBetween(w, Math.min(w + 1, k.doc.content.size));
|
|
4490
|
+
let E = "";
|
|
4491
|
+
w > 0 && S !== " " && !/[.,!?;:]/.test(S) && (E = " ");
|
|
4490
4492
|
let j = "";
|
|
4491
|
-
A
|
|
4492
|
-
let _ = "";
|
|
4493
|
-
C && C !== " " && !/[.,!?;:]/.test(C) && (_ = " "), u.chain().insertContent(j + x + _).run();
|
|
4493
|
+
A && A !== " " && !/[.,!?;:]/.test(A) && (j = " "), u.chain().insertContent(E + h + j).run();
|
|
4494
4494
|
}
|
|
4495
4495
|
};
|
|
4496
4496
|
return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (m) => !m && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
|
|
@@ -4526,12 +4526,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4526
4526
|
],
|
|
4527
4527
|
content: r || "",
|
|
4528
4528
|
onUpdate: ({ editor: f }) => {
|
|
4529
|
-
const
|
|
4530
|
-
a(
|
|
4529
|
+
const x = f.getHTML();
|
|
4530
|
+
a(x), c || u(x);
|
|
4531
4531
|
},
|
|
4532
4532
|
onBlur: ({ editor: f }) => {
|
|
4533
|
-
const
|
|
4534
|
-
l(o,
|
|
4533
|
+
const x = f.getHTML();
|
|
4534
|
+
l(o, x);
|
|
4535
4535
|
},
|
|
4536
4536
|
editorProps: {
|
|
4537
4537
|
attributes: {
|
|
@@ -4546,7 +4546,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4546
4546
|
}, [r]);
|
|
4547
4547
|
const m = (f) => {
|
|
4548
4548
|
a(f);
|
|
4549
|
-
},
|
|
4549
|
+
}, h = () => {
|
|
4550
4550
|
d(!1), g && g.commands.setContent(p);
|
|
4551
4551
|
};
|
|
4552
4552
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -4558,7 +4558,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4558
4558
|
RTEModal,
|
|
4559
4559
|
{
|
|
4560
4560
|
isOpen: c,
|
|
4561
|
-
onClose:
|
|
4561
|
+
onClose: h,
|
|
4562
4562
|
id: o,
|
|
4563
4563
|
value: p,
|
|
4564
4564
|
onChange: m,
|
|
@@ -4572,31 +4572,31 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4572
4572
|
onChange: r
|
|
4573
4573
|
}) => {
|
|
4574
4574
|
var L;
|
|
4575
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, y) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m,
|
|
4575
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, y) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [f, x] = useState([]), [b, k] = useState(-1), w = useRef(null), S = (L = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : L.name;
|
|
4576
4576
|
useEffect(() => {
|
|
4577
|
-
if (
|
|
4577
|
+
if (h(""), x([]), k(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4578
4578
|
const v = split(o, ":"), y = get(v, 1, "page") || "page";
|
|
4579
4579
|
g(y), (async () => {
|
|
4580
|
-
const
|
|
4581
|
-
|
|
4580
|
+
const _ = await l(y, [get(v, 2, "page")]);
|
|
4581
|
+
_ && Array.isArray(_) && h(get(_, [0, "name"], ""));
|
|
4582
4582
|
})();
|
|
4583
4583
|
}, [o]);
|
|
4584
|
-
const
|
|
4584
|
+
const A = useDebouncedCallback(
|
|
4585
4585
|
async (v) => {
|
|
4586
4586
|
if (isEmpty(v))
|
|
4587
|
-
|
|
4587
|
+
x([]);
|
|
4588
4588
|
else {
|
|
4589
4589
|
const y = await l(u, v);
|
|
4590
|
-
|
|
4590
|
+
x(y);
|
|
4591
4591
|
}
|
|
4592
4592
|
c(!1), k(-1);
|
|
4593
4593
|
},
|
|
4594
4594
|
[u],
|
|
4595
4595
|
300
|
|
4596
|
-
),
|
|
4596
|
+
), E = (v) => {
|
|
4597
4597
|
const y = ["pageType", u, v.id];
|
|
4598
|
-
y[1] && (r(y.join(":")),
|
|
4599
|
-
},
|
|
4598
|
+
y[1] && (r(y.join(":")), h(v.name), p(!1), x([]), k(-1));
|
|
4599
|
+
}, j = (v) => {
|
|
4600
4600
|
switch (v.key) {
|
|
4601
4601
|
case "ArrowDown":
|
|
4602
4602
|
v.preventDefault(), k((y) => y < f.length - 1 ? y + 1 : y);
|
|
@@ -4606,23 +4606,23 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4606
4606
|
break;
|
|
4607
4607
|
case "Enter":
|
|
4608
4608
|
if (v.preventDefault(), f.length === 0) return;
|
|
4609
|
-
b >= 0 &&
|
|
4609
|
+
b >= 0 && E(f[b]);
|
|
4610
4610
|
break;
|
|
4611
4611
|
case "Escape":
|
|
4612
|
-
v.preventDefault(),
|
|
4612
|
+
v.preventDefault(), C();
|
|
4613
4613
|
break;
|
|
4614
4614
|
}
|
|
4615
4615
|
};
|
|
4616
4616
|
useEffect(() => {
|
|
4617
|
-
if (b >= 0 &&
|
|
4618
|
-
const v =
|
|
4617
|
+
if (b >= 0 && w.current) {
|
|
4618
|
+
const v = w.current.children[b];
|
|
4619
4619
|
v == null || v.scrollIntoView({ block: "nearest" });
|
|
4620
4620
|
}
|
|
4621
4621
|
}, [b]);
|
|
4622
|
-
const
|
|
4623
|
-
|
|
4624
|
-
},
|
|
4625
|
-
|
|
4622
|
+
const C = () => {
|
|
4623
|
+
h(""), x([]), k(-1), p(!1), r("");
|
|
4624
|
+
}, B = (v) => {
|
|
4625
|
+
h(v), p(!isEmpty(v)), c(!0), A(v);
|
|
4626
4626
|
};
|
|
4627
4627
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4628
4628
|
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (v) => g(v.target.value), children: map(n, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
|
|
@@ -4632,13 +4632,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4632
4632
|
{
|
|
4633
4633
|
type: "text",
|
|
4634
4634
|
value: m,
|
|
4635
|
-
onChange: (v) =>
|
|
4636
|
-
onKeyDown:
|
|
4637
|
-
placeholder: a(`Search ${
|
|
4635
|
+
onChange: (v) => B(v.target.value),
|
|
4636
|
+
onKeyDown: j,
|
|
4637
|
+
placeholder: a(`Search ${S ?? ""}`),
|
|
4638
4638
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4639
4639
|
}
|
|
4640
4640
|
),
|
|
4641
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick:
|
|
4641
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: C, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
|
|
4642
4642
|
] }),
|
|
4643
4643
|
(i || !isEmpty(f) || d && isEmpty(f)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
4644
4644
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
@@ -4648,10 +4648,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4648
4648
|
' "',
|
|
4649
4649
|
m,
|
|
4650
4650
|
'"'
|
|
4651
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref:
|
|
4651
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: w, children: map(f == null ? void 0 : f.slice(0, 20), (v, y) => /* @__PURE__ */ jsxs(
|
|
4652
4652
|
"li",
|
|
4653
4653
|
{
|
|
4654
|
-
onClick: () =>
|
|
4654
|
+
onClick: () => E(v),
|
|
4655
4655
|
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : y === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
4656
4656
|
children: [
|
|
4657
4657
|
v.name,
|
|
@@ -4746,29 +4746,29 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4746
4746
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
|
|
4747
4747
|
}, [o, u]);
|
|
4748
4748
|
const m = () => {
|
|
4749
|
-
const
|
|
4750
|
-
if (
|
|
4751
|
-
const b = (
|
|
4749
|
+
const x = findIndex(u, { _id: g });
|
|
4750
|
+
if (x > -1) {
|
|
4751
|
+
const b = (x + 1) % u.length, k = get(u, [b, "_id"]);
|
|
4752
4752
|
if (!k) return;
|
|
4753
4753
|
n({ ...o, currentSlide: k }), c([k]);
|
|
4754
4754
|
}
|
|
4755
|
-
},
|
|
4756
|
-
const
|
|
4757
|
-
if (
|
|
4758
|
-
const b = (
|
|
4755
|
+
}, h = () => {
|
|
4756
|
+
const x = findIndex(u, { _id: g });
|
|
4757
|
+
if (x > -1) {
|
|
4758
|
+
const b = (x - 1 + u.length) % u.length, k = get(u, [b, "_id"]);
|
|
4759
4759
|
if (!k) return;
|
|
4760
4760
|
n({ ...o, currentSlide: k }), c([k]);
|
|
4761
4761
|
}
|
|
4762
4762
|
}, f = () => {
|
|
4763
|
-
const
|
|
4763
|
+
const x = i(
|
|
4764
4764
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4765
4765
|
p == null ? void 0 : p._id
|
|
4766
|
-
), b =
|
|
4766
|
+
), b = x == null ? void 0 : x._id;
|
|
4767
4767
|
b && (n({ ...o, currentSlide: b }), c([b]));
|
|
4768
4768
|
};
|
|
4769
4769
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4770
4770
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
4771
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
4771
|
+
/* @__PURE__ */ jsx("button", { onClick: h, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
|
|
4772
4772
|
/* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
|
|
4773
4773
|
/* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
|
|
4774
4774
|
" ",
|
|
@@ -4842,8 +4842,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4842
4842
|
value: o == null ? void 0 : o.autoplayInterval,
|
|
4843
4843
|
className: "text-xs",
|
|
4844
4844
|
pattern: "[0-9]*",
|
|
4845
|
-
onChange: (
|
|
4846
|
-
let b =
|
|
4845
|
+
onChange: (x) => {
|
|
4846
|
+
let b = x.target.value;
|
|
4847
4847
|
b.length && (b = b.replace("-", "")), n({ ...o, autoplayInterval: b });
|
|
4848
4848
|
}
|
|
4849
4849
|
}
|
|
@@ -4883,12 +4883,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4883
4883
|
formData: g,
|
|
4884
4884
|
onChange: m
|
|
4885
4885
|
}) => {
|
|
4886
|
-
const { selectedLang:
|
|
4886
|
+
const { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), b = isEmpty(x) ? "" : isEmpty(h) ? f : h, k = get(LANGUAGES, b, b), w = usePageExternalData(), S = useSelectedBlock(), A = useRegisteredChaiBlocks(), E = get(A, [S == null ? void 0 : S._type, "i18nProps"], []) || [], [j, C] = useState(null), B = useCallback(
|
|
4887
4887
|
(y) => {
|
|
4888
|
-
const
|
|
4888
|
+
const _ = (P) => /[.,!?;:]/.test(P), T = (P, N, M) => {
|
|
4889
4889
|
let D = "", O = "";
|
|
4890
4890
|
const $ = N > 0 ? P[N - 1] : "", H = N < P.length ? P[N] : "";
|
|
4891
|
-
return N > 0 && ($ === "." || !
|
|
4891
|
+
return N > 0 && ($ === "." || !_($) && $ !== " ") && (D = " "), N < P.length && !_(H) && H !== " " && (O = " "), {
|
|
4892
4892
|
text: D + M + O,
|
|
4893
4893
|
prefixLength: D.length,
|
|
4894
4894
|
suffixLength: O.length
|
|
@@ -4907,9 +4907,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4907
4907
|
else {
|
|
4908
4908
|
const { state: $ } = P, H = $.selection.from, U = $.doc.textBetween(Math.max(0, H - 1), H), F = $.doc.textBetween(H, Math.min(H + 1, $.doc.content.size));
|
|
4909
4909
|
let z = "";
|
|
4910
|
-
H > 0 && U !== " " && !
|
|
4910
|
+
H > 0 && U !== " " && !_(U) && (z = " ");
|
|
4911
4911
|
let W = "";
|
|
4912
|
-
F && F !== " " && !
|
|
4912
|
+
F && F !== " " && !_(F) && (W = " "), P.chain().insertContent(z + N + W).run();
|
|
4913
4913
|
}
|
|
4914
4914
|
setTimeout(() => m(P.getHTML(), {}, o), 100);
|
|
4915
4915
|
return;
|
|
@@ -4925,20 +4925,20 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4925
4925
|
m(U, {}, o);
|
|
4926
4926
|
}
|
|
4927
4927
|
},
|
|
4928
|
-
[o, m, g,
|
|
4928
|
+
[o, m, g, S == null ? void 0 : S._id]
|
|
4929
4929
|
);
|
|
4930
4930
|
if (d)
|
|
4931
4931
|
return null;
|
|
4932
4932
|
if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
|
|
4933
|
-
const v =
|
|
4933
|
+
const v = E == null ? void 0 : E.includes(o.replace("root.", ""));
|
|
4934
4934
|
if (u.type === "array") {
|
|
4935
|
-
const y =
|
|
4935
|
+
const y = j === o;
|
|
4936
4936
|
return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
|
|
4937
4937
|
u.title && /* @__PURE__ */ jsxs(
|
|
4938
4938
|
"label",
|
|
4939
4939
|
{
|
|
4940
4940
|
htmlFor: o,
|
|
4941
|
-
onClick: () =>
|
|
4941
|
+
onClick: () => C(y ? null : o),
|
|
4942
4942
|
className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
|
|
4943
4943
|
children: [
|
|
4944
4944
|
y ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
|
|
@@ -4968,7 +4968,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4968
4968
|
] }),
|
|
4969
4969
|
p && u.type !== "object" ? " *" : null
|
|
4970
4970
|
] }),
|
|
4971
|
-
u.type === "string" && !u.enum && !u.oneOf &&
|
|
4971
|
+
u.type === "string" && !u.enum && !u.oneOf && w && /* @__PURE__ */ jsx(NestedPathSelector, { data: w, onSelect: B, dataType: "value" })
|
|
4972
4972
|
] }),
|
|
4973
4973
|
c,
|
|
4974
4974
|
a,
|
|
@@ -5023,8 +5023,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5023
5023
|
formData: a,
|
|
5024
5024
|
onChange: ({ formData: g }, m) => {
|
|
5025
5025
|
if (!m || o !== (g == null ? void 0 : g._id)) return;
|
|
5026
|
-
const
|
|
5027
|
-
u({ formData: g },
|
|
5026
|
+
const h = take(m.split("."), 2).join(".").replace("root.", "");
|
|
5027
|
+
u({ formData: g }, h);
|
|
5028
5028
|
}
|
|
5029
5029
|
},
|
|
5030
5030
|
i
|
|
@@ -5067,35 +5067,35 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5067
5067
|
}), a;
|
|
5068
5068
|
};
|
|
5069
5069
|
function BlockSettings() {
|
|
5070
|
-
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), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type),
|
|
5071
|
-
|
|
5072
|
-
},
|
|
5073
|
-
debounce(({ formData:
|
|
5074
|
-
f({ formData:
|
|
5070
|
+
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), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), f = ({ formData: j }, C, B) => {
|
|
5071
|
+
C && (c == null ? void 0 : c._id) === n._id && a([n._id], { [C]: get(j, C) }, B);
|
|
5072
|
+
}, x = useCallback(
|
|
5073
|
+
debounce(({ formData: j }, C, B) => {
|
|
5074
|
+
f({ formData: j }, C, B), d(j);
|
|
5075
5075
|
}, 1500),
|
|
5076
5076
|
[n == null ? void 0 : n._id, o]
|
|
5077
|
-
), b = ({ formData:
|
|
5078
|
-
|
|
5079
|
-
}, k = ({ formData:
|
|
5080
|
-
|
|
5077
|
+
), b = ({ formData: j }, C) => {
|
|
5078
|
+
C && (r([n._id], { [C]: get(j, C) }), x({ formData: j }, C, { [C]: get(c, C) }));
|
|
5079
|
+
}, k = ({ formData: j }, C) => {
|
|
5080
|
+
C && (r([g._id], { [C]: get(j, C) }), x({ formData: j }, C, { [C]: get(c, C) }));
|
|
5081
5081
|
};
|
|
5082
5082
|
keys(get(i, "_bindings", {}));
|
|
5083
|
-
const { schema:
|
|
5084
|
-
const
|
|
5085
|
-
if (
|
|
5086
|
-
return getBlockFormSchemas(
|
|
5087
|
-
}, [n]), { wrapperSchema:
|
|
5083
|
+
const { schema: w, uiSchema: S } = useMemo(() => {
|
|
5084
|
+
const j = n == null ? void 0 : n._type;
|
|
5085
|
+
if (j)
|
|
5086
|
+
return getBlockFormSchemas(j);
|
|
5087
|
+
}, [n]), { wrapperSchema: A, wrapperUiSchema: E } = useMemo(() => {
|
|
5088
5088
|
if (!g || !(g != null && g._type))
|
|
5089
5089
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5090
|
-
const
|
|
5091
|
-
return { wrapperSchema:
|
|
5090
|
+
const j = g == null ? void 0 : g._type, { schema: C = {}, uiSchema: B = {} } = getBlockFormSchemas(j);
|
|
5091
|
+
return { wrapperSchema: C, wrapperUiSchema: B };
|
|
5092
5092
|
}, [g]);
|
|
5093
5093
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5094
5094
|
!isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
5095
5095
|
/* @__PURE__ */ jsxs(
|
|
5096
5096
|
"div",
|
|
5097
5097
|
{
|
|
5098
|
-
onClick: () => u((
|
|
5098
|
+
onClick: () => u((j) => !j),
|
|
5099
5099
|
className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
|
|
5100
5100
|
children: [
|
|
5101
5101
|
p ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 stroke-[3] text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 stroke-[3] text-slate-400" }),
|
|
@@ -5115,20 +5115,20 @@ function BlockSettings() {
|
|
|
5115
5115
|
{
|
|
5116
5116
|
blockId: g == null ? void 0 : g._id,
|
|
5117
5117
|
onChange: k,
|
|
5118
|
-
formData:
|
|
5119
|
-
schema:
|
|
5120
|
-
uiSchema:
|
|
5118
|
+
formData: h,
|
|
5119
|
+
schema: A,
|
|
5120
|
+
uiSchema: E
|
|
5121
5121
|
}
|
|
5122
5122
|
) })
|
|
5123
5123
|
] }),
|
|
5124
|
-
isEmpty(
|
|
5124
|
+
isEmpty(w) ? null : /* @__PURE__ */ jsx(
|
|
5125
5125
|
JSONForm,
|
|
5126
5126
|
{
|
|
5127
5127
|
blockId: n == null ? void 0 : n._id,
|
|
5128
5128
|
onChange: b,
|
|
5129
5129
|
formData: i,
|
|
5130
|
-
schema:
|
|
5131
|
-
uiSchema:
|
|
5130
|
+
schema: w,
|
|
5131
|
+
uiSchema: S
|
|
5132
5132
|
}
|
|
5133
5133
|
),
|
|
5134
5134
|
(n == null ? void 0 : n._type) === "GlobalBlock" ? /* @__PURE__ */ jsx(GlobalBlockSettings, {}) : null
|
|
@@ -5233,23 +5233,23 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5233
5233
|
canvas: n = !1,
|
|
5234
5234
|
tooltip: r = !0
|
|
5235
5235
|
}) => {
|
|
5236
|
-
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(),
|
|
5237
|
-
u.includes(k) ? u.length > 2 && g(u.filter((
|
|
5238
|
-
},
|
|
5236
|
+
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (k) => {
|
|
5237
|
+
u.includes(k) ? u.length > 2 && g(u.filter((w) => w !== k)) : g((w) => [...w, k]);
|
|
5238
|
+
}, x = (k) => {
|
|
5239
5239
|
n || l(k), c(k);
|
|
5240
5240
|
}, b = getBreakpointValue(n ? i : a).toLowerCase();
|
|
5241
|
-
return
|
|
5241
|
+
return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (k) => /* @__PURE__ */ createElement(
|
|
5242
5242
|
BreakpointCard,
|
|
5243
5243
|
{
|
|
5244
5244
|
canvas: n,
|
|
5245
5245
|
...k,
|
|
5246
|
-
onClick:
|
|
5246
|
+
onClick: x,
|
|
5247
5247
|
key: k.breakpoint,
|
|
5248
5248
|
currentBreakpoint: b
|
|
5249
5249
|
}
|
|
5250
5250
|
)) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
|
|
5251
5251
|
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
|
|
5252
|
-
|
|
5252
|
+
h.filter((k) => includes(u, toUpper(k.breakpoint))),
|
|
5253
5253
|
(k) => /* @__PURE__ */ createElement(
|
|
5254
5254
|
BreakpointCard,
|
|
5255
5255
|
{
|
|
@@ -5257,7 +5257,7 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5257
5257
|
openDelay: o,
|
|
5258
5258
|
tooltip: r,
|
|
5259
5259
|
...k,
|
|
5260
|
-
onClick:
|
|
5260
|
+
onClick: x,
|
|
5261
5261
|
key: k.breakpoint,
|
|
5262
5262
|
currentBreakpoint: b
|
|
5263
5263
|
}
|
|
@@ -5268,7 +5268,7 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5268
5268
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
|
|
5269
5269
|
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: m("Screen sizes") }),
|
|
5270
5270
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
5271
|
-
map(
|
|
5271
|
+
map(h, (k) => /* @__PURE__ */ jsx(
|
|
5272
5272
|
DropdownMenuCheckboxItem,
|
|
5273
5273
|
{
|
|
5274
5274
|
disabled: k.breakpoint === "xs",
|
|
@@ -5353,11 +5353,11 @@ function Countdown() {
|
|
|
5353
5353
|
const AskAIStyles = ({ blockId: o }) => {
|
|
5354
5354
|
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
|
|
5355
5355
|
useEffect(() => {
|
|
5356
|
-
var
|
|
5357
|
-
(
|
|
5356
|
+
var h;
|
|
5357
|
+
(h = d.current) == null || h.focus();
|
|
5358
5358
|
}, []);
|
|
5359
|
-
const m = (
|
|
5360
|
-
const { usage: f } =
|
|
5359
|
+
const m = (h) => {
|
|
5360
|
+
const { usage: f } = h || {};
|
|
5361
5361
|
!l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
5362
5362
|
};
|
|
5363
5363
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
@@ -5367,12 +5367,12 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5367
5367
|
{
|
|
5368
5368
|
ref: d,
|
|
5369
5369
|
value: i,
|
|
5370
|
-
onChange: (
|
|
5370
|
+
onChange: (h) => c(h.target.value),
|
|
5371
5371
|
placeholder: n("Ask AI to edit styles"),
|
|
5372
5372
|
className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
|
|
5373
5373
|
rows: 4,
|
|
5374
|
-
onKeyDown: (
|
|
5375
|
-
|
|
5374
|
+
onKeyDown: (h) => {
|
|
5375
|
+
h.key === "Enter" && (h.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
|
|
5376
5376
|
}
|
|
5377
5377
|
}
|
|
5378
5378
|
),
|
|
@@ -5414,10 +5414,10 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5414
5414
|
};
|
|
5415
5415
|
function ManualClasses() {
|
|
5416
5416
|
var T;
|
|
5417
|
-
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(),
|
|
5417
|
+
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), b = (T = first(d)) == null ? void 0 : T.prop, { classes: k } = getSplitChaiClasses(get(p, b, "")), w = k.split(" ").filter((I) => !isEmpty(I)), S = () => {
|
|
5418
5418
|
const I = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5419
|
-
u(m, I, !0),
|
|
5420
|
-
}, [
|
|
5419
|
+
u(m, I, !0), x("");
|
|
5420
|
+
}, [A, E] = useState([]), j = ({ value: I }) => {
|
|
5421
5421
|
const R = I.trim().toLowerCase(), P = R.match(/.+:/g);
|
|
5422
5422
|
let N = [];
|
|
5423
5423
|
if (P && P.length > 0) {
|
|
@@ -5428,10 +5428,10 @@ function ManualClasses() {
|
|
|
5428
5428
|
}));
|
|
5429
5429
|
} else
|
|
5430
5430
|
N = i.search(R);
|
|
5431
|
-
return
|
|
5432
|
-
},
|
|
5433
|
-
|
|
5434
|
-
},
|
|
5431
|
+
return E(map(N, "item"));
|
|
5432
|
+
}, C = () => {
|
|
5433
|
+
E([]);
|
|
5434
|
+
}, B = (I) => I.name, L = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), v = useMemo(
|
|
5435
5435
|
() => ({
|
|
5436
5436
|
ref: o,
|
|
5437
5437
|
autoComplete: "off",
|
|
@@ -5441,9 +5441,9 @@ function ManualClasses() {
|
|
|
5441
5441
|
placeholder: c("Enter classes separated by space"),
|
|
5442
5442
|
value: f,
|
|
5443
5443
|
onKeyDown: (I) => {
|
|
5444
|
-
I.key === "Enter" && f.trim() !== "" &&
|
|
5444
|
+
I.key === "Enter" && f.trim() !== "" && S();
|
|
5445
5445
|
},
|
|
5446
|
-
onChange: (I, { newValue: R }) =>
|
|
5446
|
+
onChange: (I, { newValue: R }) => x(R),
|
|
5447
5447
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
5448
5448
|
}),
|
|
5449
5449
|
[f, c, o]
|
|
@@ -5451,23 +5451,23 @@ function ManualClasses() {
|
|
|
5451
5451
|
debugger;
|
|
5452
5452
|
const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5453
5453
|
g(m, [I]), u(m, R, !0), r(""), l(-1);
|
|
5454
|
-
},
|
|
5454
|
+
}, _ = () => {
|
|
5455
5455
|
if (navigator.clipboard === void 0) {
|
|
5456
5456
|
toast.error(c("Clipboard not supported"));
|
|
5457
5457
|
return;
|
|
5458
5458
|
}
|
|
5459
|
-
navigator.clipboard.writeText(
|
|
5459
|
+
navigator.clipboard.writeText(w.join(" ")), toast.success(c("Classes copied to clipboard"));
|
|
5460
5460
|
};
|
|
5461
5461
|
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
|
|
5462
5462
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
|
|
5463
5463
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
|
|
5464
5464
|
/* @__PURE__ */ jsx("span", { children: c("Classes") }),
|
|
5465
5465
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5466
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick:
|
|
5466
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: _, className: "cursor-pointer" }) }),
|
|
5467
5467
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
|
|
5468
5468
|
] })
|
|
5469
5469
|
] }),
|
|
5470
|
-
|
|
5470
|
+
h ? /* @__PURE__ */ jsxs(Popover, { children: [
|
|
5471
5471
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
|
|
5472
5472
|
/* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4" }),
|
|
5473
5473
|
/* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
|
|
@@ -5479,10 +5479,10 @@ function ManualClasses() {
|
|
|
5479
5479
|
/* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
|
|
5480
5480
|
Autosuggest,
|
|
5481
5481
|
{
|
|
5482
|
-
suggestions:
|
|
5483
|
-
onSuggestionsFetchRequested:
|
|
5484
|
-
onSuggestionsClearRequested:
|
|
5485
|
-
getSuggestionValue:
|
|
5482
|
+
suggestions: A,
|
|
5483
|
+
onSuggestionsFetchRequested: j,
|
|
5484
|
+
onSuggestionsClearRequested: C,
|
|
5485
|
+
getSuggestionValue: B,
|
|
5486
5486
|
renderSuggestion: L,
|
|
5487
5487
|
inputProps: v,
|
|
5488
5488
|
containerProps: {
|
|
@@ -5500,14 +5500,14 @@ function ManualClasses() {
|
|
|
5500
5500
|
{
|
|
5501
5501
|
variant: "outline",
|
|
5502
5502
|
className: "h-6 border-border",
|
|
5503
|
-
onClick:
|
|
5503
|
+
onClick: S,
|
|
5504
5504
|
disabled: f.trim() === "",
|
|
5505
5505
|
size: "sm",
|
|
5506
5506
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
5507
5507
|
}
|
|
5508
5508
|
)
|
|
5509
5509
|
] }),
|
|
5510
|
-
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children:
|
|
5510
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: w.map(
|
|
5511
5511
|
(I, R) => a === R ? /* @__PURE__ */ jsx(
|
|
5512
5512
|
"input",
|
|
5513
5513
|
{
|
|
@@ -5709,7 +5709,7 @@ const COLOR_PROP = {
|
|
|
5709
5709
|
ringColor: "ring",
|
|
5710
5710
|
ringOffsetColor: "ring-offset"
|
|
5711
5711
|
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
5712
|
-
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("-"), g = get(u, "1", ""), m = get(u, "2", ""),
|
|
5712
|
+
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("-"), g = get(u, "1", ""), m = get(u, "2", ""), h = useCallback(
|
|
5713
5713
|
// eslint-disable-next-line no-shadow
|
|
5714
5714
|
(b) => {
|
|
5715
5715
|
["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((k) => ({ ...k, color: b, shade: k.shade ? k.shade : "500" })));
|
|
@@ -5731,18 +5731,18 @@ const COLOR_PROP = {
|
|
|
5731
5731
|
useEffect(() => {
|
|
5732
5732
|
p({ color: "", shade: "" });
|
|
5733
5733
|
}, [r]);
|
|
5734
|
-
const { match:
|
|
5734
|
+
const { match: x } = useTailwindClassList();
|
|
5735
5735
|
return useEffect(() => {
|
|
5736
5736
|
const k = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
5737
|
-
|
|
5738
|
-
}, [
|
|
5737
|
+
x(o, k) && n(k, o);
|
|
5738
|
+
}, [x, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
|
|
5739
5739
|
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
5740
5740
|
DropDown,
|
|
5741
5741
|
{
|
|
5742
5742
|
disabled: !l,
|
|
5743
5743
|
rounded: !0,
|
|
5744
5744
|
selected: g,
|
|
5745
|
-
onChange:
|
|
5745
|
+
onChange: h,
|
|
5746
5746
|
options: [
|
|
5747
5747
|
"current",
|
|
5748
5748
|
"transparent",
|
|
@@ -6166,50 +6166,50 @@ const COLOR_PROP = {
|
|
|
6166
6166
|
},
|
|
6167
6167
|
a
|
|
6168
6168
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
6169
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m,
|
|
6169
|
+
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [b, k] = useState(""), [w, S] = useState(!1), [A, E] = useState(!1);
|
|
6170
6170
|
useEffect(() => {
|
|
6171
6171
|
const { value: v, unit: y } = getClassValueAndUnit(i);
|
|
6172
6172
|
if (y === "") {
|
|
6173
|
-
l(v),
|
|
6173
|
+
l(v), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
6174
6174
|
return;
|
|
6175
6175
|
}
|
|
6176
|
-
|
|
6176
|
+
h(y), l(y === "class" || isEmpty(v) ? "" : v);
|
|
6177
6177
|
}, [i, p, u]);
|
|
6178
|
-
const
|
|
6178
|
+
const j = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), C = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), B = useCallback(
|
|
6179
6179
|
(v = !1) => {
|
|
6180
6180
|
const y = getUserInputValues(`${a}`, u);
|
|
6181
6181
|
if (get(y, "error", !1)) {
|
|
6182
|
-
|
|
6182
|
+
x(!0);
|
|
6183
6183
|
return;
|
|
6184
6184
|
}
|
|
6185
|
-
const
|
|
6186
|
-
if (
|
|
6187
|
-
|
|
6185
|
+
const _ = get(y, "unit") !== "" ? get(y, "unit") : m;
|
|
6186
|
+
if (_ === "auto" || _ === "none") {
|
|
6187
|
+
j(`${d}${_}`);
|
|
6188
6188
|
return;
|
|
6189
6189
|
}
|
|
6190
6190
|
if (get(y, "value") === "")
|
|
6191
6191
|
return;
|
|
6192
|
-
const I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${
|
|
6193
|
-
v ?
|
|
6192
|
+
const I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
|
|
6193
|
+
v ? C(I) : j(I);
|
|
6194
6194
|
},
|
|
6195
|
-
[
|
|
6195
|
+
[j, C, a, m, d, u]
|
|
6196
6196
|
), L = useCallback(
|
|
6197
6197
|
(v) => {
|
|
6198
6198
|
const y = getUserInputValues(`${a}`, u);
|
|
6199
6199
|
if (get(y, "error", !1)) {
|
|
6200
|
-
|
|
6200
|
+
x(!0);
|
|
6201
6201
|
return;
|
|
6202
6202
|
}
|
|
6203
6203
|
if (v === "auto" || v === "none") {
|
|
6204
|
-
|
|
6204
|
+
j(`${d}${v}`);
|
|
6205
6205
|
return;
|
|
6206
6206
|
}
|
|
6207
6207
|
if (get(y, "value") === "")
|
|
6208
6208
|
return;
|
|
6209
|
-
const
|
|
6210
|
-
|
|
6209
|
+
const _ = get(y, "unit") !== "" ? get(y, "unit") : v, I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
|
|
6210
|
+
j(I);
|
|
6211
6211
|
},
|
|
6212
|
-
[
|
|
6212
|
+
[j, a, d, u]
|
|
6213
6213
|
);
|
|
6214
6214
|
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: m === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6215
6215
|
/* @__PURE__ */ jsx(
|
|
@@ -6224,37 +6224,37 @@ const COLOR_PROP = {
|
|
|
6224
6224
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsx(InfoCircledIcon, {}) }) }),
|
|
6225
6225
|
/* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
|
|
6226
6226
|
] })
|
|
6227
|
-
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${
|
|
6227
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${w ? "z-auto" : ""}`, children: [
|
|
6228
6228
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
6229
6229
|
["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
|
|
6230
6230
|
"input",
|
|
6231
6231
|
{
|
|
6232
6232
|
readOnly: m === "class",
|
|
6233
6233
|
onKeyPress: (v) => {
|
|
6234
|
-
v.key === "Enter" &&
|
|
6234
|
+
v.key === "Enter" && B();
|
|
6235
6235
|
},
|
|
6236
6236
|
onKeyDown: (v) => {
|
|
6237
6237
|
if (v.keyCode !== 38 && v.keyCode !== 40)
|
|
6238
6238
|
return;
|
|
6239
|
-
v.preventDefault(),
|
|
6239
|
+
v.preventDefault(), E(!0);
|
|
6240
6240
|
const y = parseInt$1(v.target.value);
|
|
6241
|
-
let
|
|
6242
|
-
v.keyCode === 38 && (
|
|
6243
|
-
const T = `${
|
|
6244
|
-
|
|
6241
|
+
let _ = isNaN$1(y) ? 0 : y;
|
|
6242
|
+
v.keyCode === 38 && (_ += 1), v.keyCode === 40 && (_ -= 1);
|
|
6243
|
+
const T = `${_}`, R = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6244
|
+
C(R);
|
|
6245
6245
|
},
|
|
6246
6246
|
onKeyUp: (v) => {
|
|
6247
|
-
|
|
6247
|
+
A && (v.preventDefault(), E(!1));
|
|
6248
6248
|
},
|
|
6249
|
-
onBlur: () =>
|
|
6249
|
+
onBlur: () => B(),
|
|
6250
6250
|
onChange: (v) => {
|
|
6251
|
-
|
|
6251
|
+
x(!1), l(v.target.value);
|
|
6252
6252
|
},
|
|
6253
6253
|
onClick: (v) => {
|
|
6254
6254
|
var y;
|
|
6255
6255
|
(y = v == null ? void 0 : v.target) == null || y.select(), r(!1);
|
|
6256
6256
|
},
|
|
6257
|
-
value:
|
|
6257
|
+
value: w ? b : a,
|
|
6258
6258
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
6259
6259
|
" ",
|
|
6260
6260
|
f ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
@@ -6280,28 +6280,28 @@ const COLOR_PROP = {
|
|
|
6280
6280
|
units: u,
|
|
6281
6281
|
current: m,
|
|
6282
6282
|
onSelect: (v) => {
|
|
6283
|
-
r(!1),
|
|
6283
|
+
r(!1), h(v), L(v);
|
|
6284
6284
|
}
|
|
6285
6285
|
}
|
|
6286
6286
|
) }) })
|
|
6287
6287
|
] })
|
|
6288
6288
|
] }),
|
|
6289
|
-
["none", "auto"].indexOf(m) !== -1 ||
|
|
6289
|
+
["none", "auto"].indexOf(m) !== -1 || w ? null : /* @__PURE__ */ jsx(
|
|
6290
6290
|
DragStyleButton,
|
|
6291
6291
|
{
|
|
6292
|
-
onDragStart: () =>
|
|
6292
|
+
onDragStart: () => S(!0),
|
|
6293
6293
|
onDragEnd: (v) => {
|
|
6294
|
-
if (k(() => ""),
|
|
6294
|
+
if (k(() => ""), S(!1), isEmpty(v))
|
|
6295
6295
|
return;
|
|
6296
6296
|
const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6297
|
-
|
|
6297
|
+
j(T);
|
|
6298
6298
|
},
|
|
6299
6299
|
onDrag: (v) => {
|
|
6300
6300
|
if (isEmpty(v))
|
|
6301
6301
|
return;
|
|
6302
6302
|
k(v);
|
|
6303
6303
|
const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6304
|
-
|
|
6304
|
+
C(T);
|
|
6305
6305
|
},
|
|
6306
6306
|
currentValue: a,
|
|
6307
6307
|
unit: m,
|
|
@@ -6398,35 +6398,35 @@ const COLOR_PROP = {
|
|
|
6398
6398
|
"2xl": "1536px"
|
|
6399
6399
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6400
6400
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6401
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l),
|
|
6402
|
-
(
|
|
6403
|
-
const L = { dark: p, mq: g, mod: u, cls:
|
|
6401
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), k = useCallback(
|
|
6402
|
+
(C, B = !0) => {
|
|
6403
|
+
const L = { dark: p, mq: g, mod: u, cls: C, property: l, fullCls: "" };
|
|
6404
6404
|
(p || u !== "") && (L.mq = "xs");
|
|
6405
6405
|
const v = generateFullClsName(L);
|
|
6406
|
-
x
|
|
6406
|
+
h(x, [v], B);
|
|
6407
6407
|
},
|
|
6408
|
-
[
|
|
6409
|
-
),
|
|
6410
|
-
f(
|
|
6411
|
-
}, [
|
|
6408
|
+
[x, p, g, u, l, h]
|
|
6409
|
+
), w = useCallback(() => {
|
|
6410
|
+
f(x, [b], !0);
|
|
6411
|
+
}, [x, b, f]), S = useMemo(() => canChangeClass(m, g), [m, g]);
|
|
6412
6412
|
useEffect(() => {
|
|
6413
|
-
i(
|
|
6414
|
-
}, [
|
|
6415
|
-
const [, ,
|
|
6416
|
-
(
|
|
6417
|
-
|
|
6413
|
+
i(S, m);
|
|
6414
|
+
}, [S, i, m]);
|
|
6415
|
+
const [, , A] = useScreenSizeWidth(), E = useCallback(
|
|
6416
|
+
(C) => {
|
|
6417
|
+
A({
|
|
6418
6418
|
xs: 400,
|
|
6419
6419
|
sm: 640,
|
|
6420
6420
|
md: 800,
|
|
6421
6421
|
lg: 1024,
|
|
6422
6422
|
xl: 1420,
|
|
6423
6423
|
"2xl": 1920
|
|
6424
|
-
}[
|
|
6424
|
+
}[C]);
|
|
6425
6425
|
},
|
|
6426
|
-
[
|
|
6427
|
-
),
|
|
6428
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange:
|
|
6429
|
-
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !
|
|
6426
|
+
[A]
|
|
6427
|
+
), j = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
|
|
6428
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: S, canReset: m && j, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
6429
|
+
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !j ? "text-foreground" : ""}`, children: n(a) }) }),
|
|
6430
6430
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6431
6431
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
6432
6432
|
r === "arbitrary" ? /* @__PURE__ */ jsx(
|
|
@@ -6445,7 +6445,7 @@ const COLOR_PROP = {
|
|
|
6445
6445
|
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: k }),
|
|
6446
6446
|
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: k })
|
|
6447
6447
|
] }),
|
|
6448
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children:
|
|
6448
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: j ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => w(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : S && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6449
6449
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6450
6450
|
"button",
|
|
6451
6451
|
{
|
|
@@ -6465,7 +6465,7 @@ const COLOR_PROP = {
|
|
|
6465
6465
|
"button",
|
|
6466
6466
|
{
|
|
6467
6467
|
type: "button",
|
|
6468
|
-
onClick: () =>
|
|
6468
|
+
onClick: () => E(get(m, "mq")),
|
|
6469
6469
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
6470
6470
|
children: [
|
|
6471
6471
|
"Switch to ",
|
|
@@ -6486,7 +6486,7 @@ const COLOR_PROP = {
|
|
|
6486
6486
|
units: i = basicUnits,
|
|
6487
6487
|
negative: c = !1
|
|
6488
6488
|
}) => {
|
|
6489
|
-
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((
|
|
6489
|
+
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((h) => map(g, "property").includes(h), [g]);
|
|
6490
6490
|
return /* @__PURE__ */ jsxs(
|
|
6491
6491
|
"div",
|
|
6492
6492
|
{
|
|
@@ -6494,7 +6494,7 @@ const COLOR_PROP = {
|
|
|
6494
6494
|
children: [
|
|
6495
6495
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6496
6496
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6497
|
-
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label:
|
|
6497
|
+
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: h, key: f }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6498
6498
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6499
6499
|
"button",
|
|
6500
6500
|
{
|
|
@@ -6509,8 +6509,8 @@ const COLOR_PROP = {
|
|
|
6509
6509
|
]
|
|
6510
6510
|
}
|
|
6511
6511
|
) }),
|
|
6512
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(
|
|
6513
|
-
] }) }, `option-${
|
|
6512
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(h)) })
|
|
6513
|
+
] }) }, `option-${x}`)) })
|
|
6514
6514
|
] }),
|
|
6515
6515
|
/* @__PURE__ */ jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsx(
|
|
6516
6516
|
BlockStyle,
|
|
@@ -6591,11 +6591,11 @@ function BlockStyling() {
|
|
|
6591
6591
|
}), d = useThrottledCallback(
|
|
6592
6592
|
(u) => {
|
|
6593
6593
|
const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
|
|
6594
|
-
let
|
|
6595
|
-
|
|
6594
|
+
let h = parseFloat(i.dragStartValue);
|
|
6595
|
+
h = isNaN(h) ? 0 : h;
|
|
6596
6596
|
let f = MAPPER[i.dragUnit];
|
|
6597
6597
|
(startsWith(m, "scale") || m === "opacity") && (f = 10);
|
|
6598
|
-
let b = (i.dragStartY - u.pageY) / f +
|
|
6598
|
+
let b = (i.dragStartY - u.pageY) / f + h;
|
|
6599
6599
|
g && b < 0 && (b = 0), m === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
|
|
6600
6600
|
},
|
|
6601
6601
|
[i],
|
|
@@ -6641,20 +6641,20 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
6641
6641
|
parentId: r,
|
|
6642
6642
|
position: a
|
|
6643
6643
|
}) => {
|
|
6644
|
-
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(),
|
|
6644
|
+
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), h = () => {
|
|
6645
6645
|
if (console.log("addBlockToPage", o), has(o, "blocks")) {
|
|
6646
6646
|
const b = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
|
|
6647
6647
|
u(syncBlocksWithDefaults(b), r || null, a);
|
|
6648
6648
|
} else
|
|
6649
6649
|
p(o, r || null, a);
|
|
6650
6650
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6651
|
-
}, f = useFeature("dnd"), { t:
|
|
6651
|
+
}, f = useFeature("dnd"), { t: x } = useTranslation();
|
|
6652
6652
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6653
6653
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6654
6654
|
"button",
|
|
6655
6655
|
{
|
|
6656
6656
|
disabled: n,
|
|
6657
|
-
onClick:
|
|
6657
|
+
onClick: h,
|
|
6658
6658
|
type: "button",
|
|
6659
6659
|
onDragStart: (b) => {
|
|
6660
6660
|
b.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), b.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
@@ -6665,11 +6665,11 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
6665
6665
|
className: "cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",
|
|
6666
6666
|
children: [
|
|
6667
6667
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
6668
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(
|
|
6668
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(d || i)) })
|
|
6669
6669
|
]
|
|
6670
6670
|
}
|
|
6671
6671
|
) }),
|
|
6672
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
6672
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(d || i) }) })
|
|
6673
6673
|
] }) });
|
|
6674
6674
|
}, DefaultChaiBlocks = ({
|
|
6675
6675
|
parentId: o,
|
|
@@ -6857,22 +6857,22 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
6857
6857
|
}
|
|
6858
6858
|
}
|
|
6859
6859
|
}, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
|
|
6860
|
-
var m,
|
|
6860
|
+
var m, h, f, x, b, k, w, S;
|
|
6861
6861
|
if (r.type === "comment") return [];
|
|
6862
6862
|
console.log("node ===>", r);
|
|
6863
6863
|
let a = { _id: generateUUID() };
|
|
6864
6864
|
if (n && (a._parent = n.block._id), r.type === "text")
|
|
6865
6865
|
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", "") };
|
|
6866
6866
|
const l = get(r, "attributes", []), i = l.find(
|
|
6867
|
-
(
|
|
6867
|
+
(A) => A.key === "data-chai-richtext" || A.key === "chai-richtext"
|
|
6868
6868
|
), c = l.find(
|
|
6869
|
-
(
|
|
6869
|
+
(A) => A.key === "data-chai-lightbox" || A.key === "chai-lightbox"
|
|
6870
6870
|
), d = l.find(
|
|
6871
|
-
(
|
|
6871
|
+
(A) => A.key === "data-chai-dropdown" || A.key === "chai-dropdown"
|
|
6872
6872
|
), p = l.find(
|
|
6873
|
-
(
|
|
6873
|
+
(A) => A.key === "data-chai-dropdown-button" || A.key === "chai-dropdown-button"
|
|
6874
6874
|
), u = l.find(
|
|
6875
|
-
(
|
|
6875
|
+
(A) => A.key === "data-chai-dropdown-content" || A.key === "chai-dropdown-content"
|
|
6876
6876
|
);
|
|
6877
6877
|
if (a = {
|
|
6878
6878
|
...a,
|
|
@@ -6880,13 +6880,13 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
6880
6880
|
...getAttrs(r),
|
|
6881
6881
|
...getStyles(r)
|
|
6882
6882
|
}, r.attributes) {
|
|
6883
|
-
const
|
|
6884
|
-
|
|
6883
|
+
const A = r.attributes.find((E) => includes(NAME_ATTRIBUTES, E.key));
|
|
6884
|
+
A && (a._name = A.value);
|
|
6885
6885
|
}
|
|
6886
6886
|
if (i)
|
|
6887
6887
|
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];
|
|
6888
6888
|
if (c) {
|
|
6889
|
-
const
|
|
6889
|
+
const A = [
|
|
6890
6890
|
"data-chai-lightbox",
|
|
6891
6891
|
"chai-lightbox",
|
|
6892
6892
|
"data-vbtype",
|
|
@@ -6898,44 +6898,44 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
6898
6898
|
];
|
|
6899
6899
|
a = {
|
|
6900
6900
|
...a,
|
|
6901
|
-
href: ((m = l.find((
|
|
6902
|
-
hrefType: ((
|
|
6903
|
-
autoplay: ((f = l.find((
|
|
6904
|
-
maxWidth: ((b = (
|
|
6905
|
-
backdropColor: ((k = l.find((
|
|
6906
|
-
galleryName: ((
|
|
6907
|
-
}, forEach(
|
|
6908
|
-
has(a, `styles_attrs.${
|
|
6901
|
+
href: ((m = l.find((E) => E.key === "href")) == null ? void 0 : m.value) || "",
|
|
6902
|
+
hrefType: ((h = l.find((E) => E.key === "data-vbtype")) == null ? void 0 : h.value) || "video",
|
|
6903
|
+
autoplay: ((f = l.find((E) => E.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
|
|
6904
|
+
maxWidth: ((b = (x = l.find((E) => E.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : b.replace("px", "")) || "",
|
|
6905
|
+
backdropColor: ((k = l.find((E) => E.key === "data-overlay")) == null ? void 0 : k.value) || "",
|
|
6906
|
+
galleryName: ((w = l.find((E) => E.key === "data-gall")) == null ? void 0 : w.value) || ""
|
|
6907
|
+
}, forEach(A, (E) => {
|
|
6908
|
+
has(a, `styles_attrs.${E}`) && delete a.styles_attrs[E];
|
|
6909
6909
|
});
|
|
6910
6910
|
}
|
|
6911
6911
|
if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
|
|
6912
6912
|
delete a.styles_attrs;
|
|
6913
|
-
const
|
|
6914
|
-
a.content = getTextContent(
|
|
6915
|
-
const
|
|
6913
|
+
const A = filter(r.children || [], (j) => (j == null ? void 0 : j.tagName) !== "span");
|
|
6914
|
+
a.content = getTextContent(A);
|
|
6915
|
+
const E = find(
|
|
6916
6916
|
r.children || [],
|
|
6917
|
-
(
|
|
6917
|
+
(j) => (j == null ? void 0 : j.tagName) === "span" && some(j.children || [], (C) => (C == null ? void 0 : C.tagName) === "svg")
|
|
6918
6918
|
);
|
|
6919
|
-
if (
|
|
6920
|
-
const
|
|
6921
|
-
if (
|
|
6922
|
-
a.icon = stringify([
|
|
6923
|
-
const { height:
|
|
6924
|
-
a.iconHeight =
|
|
6919
|
+
if (E) {
|
|
6920
|
+
const j = find(E.children || [], (C) => (C == null ? void 0 : C.tagName) === "svg");
|
|
6921
|
+
if (j) {
|
|
6922
|
+
a.icon = stringify([j]);
|
|
6923
|
+
const { height: C, width: B } = getSvgDimensions(j, "16px", "16px");
|
|
6924
|
+
a.iconHeight = C, a.iconWidth = B;
|
|
6925
6925
|
}
|
|
6926
6926
|
}
|
|
6927
6927
|
return [a];
|
|
6928
6928
|
}
|
|
6929
6929
|
if (a._type === "Input") {
|
|
6930
|
-
const
|
|
6931
|
-
|
|
6930
|
+
const A = a.inputType || "text";
|
|
6931
|
+
A === "checkbox" ? set(a, "_type", "Checkbox") : A === "radio" && set(a, "_type", "Radio");
|
|
6932
6932
|
} else if (r.tagName === "video" || r.tagName === "iframe") {
|
|
6933
|
-
const
|
|
6934
|
-
return hasVideoEmbed(
|
|
6933
|
+
const A = stringify([r]);
|
|
6934
|
+
return hasVideoEmbed(A) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(A)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = A, [a];
|
|
6935
6935
|
} else if (r.tagName === "svg") {
|
|
6936
|
-
const
|
|
6937
|
-
return a.styles = `${STYLES_KEY}, ${cn$1(`w-${
|
|
6938
|
-
} else if (r.tagName == "option" && n && ((
|
|
6936
|
+
const A = find(r.attributes, { key: "height" }), E = find(r.attributes, { key: "width" }), j = get(A, "value") ? `[${get(A, "value")}px]` : "24px", C = get(E, "value") ? `[${get(E, "value")}px]` : "24px", B = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
|
|
6937
|
+
return a.styles = `${STYLES_KEY}, ${cn$1(`w-${C} h-${j}`, B)}`.trim(), r.attributes = filter(r.attributes, (L) => !includes(["style", "width", "height", "class"], L.key)), a.icon = stringify([r]), [a];
|
|
6938
|
+
} else if (r.tagName == "option" && n && ((S = n.block) == null ? void 0 : S._type) === "Select")
|
|
6939
6939
|
return n.block.options.push({
|
|
6940
6940
|
label: getTextContent(r.children),
|
|
6941
6941
|
...getAttrs(r)
|
|
@@ -7008,29 +7008,29 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7008
7008
|
error: c
|
|
7009
7009
|
}), g(!0);
|
|
7010
7010
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7011
|
-
const
|
|
7012
|
-
const k = b,
|
|
7011
|
+
const h = Object.entries(a).map(([x, b]) => {
|
|
7012
|
+
const k = b, w = k.type || "partial", S = formatReadableName(w);
|
|
7013
7013
|
return {
|
|
7014
7014
|
type: "PartialBlock",
|
|
7015
7015
|
// Set the type to PartialBlock
|
|
7016
|
-
label: formatReadableName(k.name ||
|
|
7016
|
+
label: formatReadableName(k.name || x),
|
|
7017
7017
|
description: k.description || "",
|
|
7018
7018
|
icon: Globe,
|
|
7019
|
-
group:
|
|
7019
|
+
group: S,
|
|
7020
7020
|
// Use formatted type as group
|
|
7021
7021
|
category: "partial",
|
|
7022
|
-
partialBlockId:
|
|
7022
|
+
partialBlockId: x,
|
|
7023
7023
|
// Store the original ID as partialBlockId
|
|
7024
7024
|
_name: k.name
|
|
7025
7025
|
};
|
|
7026
|
-
}), f = uniq(map(
|
|
7026
|
+
}), f = uniq(map(h, "group"));
|
|
7027
7027
|
p({
|
|
7028
|
-
blocks:
|
|
7028
|
+
blocks: h,
|
|
7029
7029
|
groups: f,
|
|
7030
7030
|
isLoading: !1,
|
|
7031
7031
|
error: null
|
|
7032
7032
|
}), g(!0);
|
|
7033
|
-
} else l ? p((
|
|
7033
|
+
} else l ? p((h) => ({ ...h, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
|
|
7034
7034
|
blocks: [],
|
|
7035
7035
|
groups: [],
|
|
7036
7036
|
isLoading: !1,
|
|
@@ -7046,7 +7046,7 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7046
7046
|
c
|
|
7047
7047
|
]);
|
|
7048
7048
|
const m = () => {
|
|
7049
|
-
p((
|
|
7049
|
+
p((h) => ({ ...h, isLoading: !0, error: null })), g(!1), i();
|
|
7050
7050
|
};
|
|
7051
7051
|
return d.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : d.error || d.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
|
|
7052
7052
|
/* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
|
|
@@ -7070,11 +7070,11 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7070
7070
|
);
|
|
7071
7071
|
}, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
7072
7072
|
var v;
|
|
7073
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (v = find(c, (y) => y._id === r)) == null ? void 0 : v._type, [
|
|
7073
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (v = find(c, (y) => y._id === r)) == null ? void 0 : v._type, [h, f] = useState("all"), [x, b] = useState(null), k = useRef(null);
|
|
7074
7074
|
useEffect(() => {
|
|
7075
7075
|
const y = setTimeout(() => {
|
|
7076
|
-
var
|
|
7077
|
-
(
|
|
7076
|
+
var _;
|
|
7077
|
+
(_ = u.current) == null || _.focus();
|
|
7078
7078
|
}, 0);
|
|
7079
7079
|
return () => clearTimeout(y);
|
|
7080
7080
|
}, [g]), useEffect(() => {
|
|
@@ -7084,29 +7084,29 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7084
7084
|
}, 500), () => {
|
|
7085
7085
|
k.current && k.current.cancel();
|
|
7086
7086
|
}), []);
|
|
7087
|
-
const
|
|
7087
|
+
const w = useCallback((y) => {
|
|
7088
7088
|
b(y), k.current && k.current(y);
|
|
7089
|
-
}, []),
|
|
7089
|
+
}, []), S = useCallback(() => {
|
|
7090
7090
|
b(null), k.current && k.current.cancel();
|
|
7091
|
-
}, []),
|
|
7091
|
+
}, []), A = useCallback((y) => {
|
|
7092
7092
|
k.current && k.current.cancel(), f(y), b(null);
|
|
7093
|
-
}, []),
|
|
7093
|
+
}, []), E = useMemo(
|
|
7094
7094
|
() => d ? values(n).filter(
|
|
7095
7095
|
(y) => {
|
|
7096
|
-
var
|
|
7097
|
-
return (((
|
|
7096
|
+
var _, T;
|
|
7097
|
+
return (((_ = y.label) == null ? void 0 : _.toLowerCase()) + " " + ((T = y.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
|
|
7098
7098
|
}
|
|
7099
7099
|
) : n,
|
|
7100
7100
|
[n, d]
|
|
7101
|
-
),
|
|
7101
|
+
), j = useMemo(
|
|
7102
7102
|
() => d ? o.filter(
|
|
7103
|
-
(y) => reject(filter(values(
|
|
7103
|
+
(y) => reject(filter(values(E), { group: y }), { hidden: !0 }).length > 0
|
|
7104
7104
|
) : o.filter((y) => reject(filter(values(n), { group: y }), { hidden: !0 }).length > 0),
|
|
7105
|
-
[n,
|
|
7106
|
-
),
|
|
7107
|
-
() => sortBy(
|
|
7108
|
-
[
|
|
7109
|
-
),
|
|
7105
|
+
[n, E, o, d]
|
|
7106
|
+
), C = useMemo(
|
|
7107
|
+
() => sortBy(j, (y) => CORE_GROUPS.indexOf(y) === -1 ? 99 : CORE_GROUPS.indexOf(y)),
|
|
7108
|
+
[j]
|
|
7109
|
+
), B = useMemo(() => h === "all" ? E : filter(values(E), { group: h }), [E, h]), L = useMemo(() => h === "all" ? C : [h], [C, h]);
|
|
7110
7110
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7111
7111
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7112
7112
|
Input$1,
|
|
@@ -7120,31 +7120,31 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7120
7120
|
}
|
|
7121
7121
|
) }),
|
|
7122
7122
|
/* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
|
|
7123
|
-
|
|
7123
|
+
C.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
7124
7124
|
/* @__PURE__ */ jsx(
|
|
7125
7125
|
"button",
|
|
7126
7126
|
{
|
|
7127
|
-
onClick: () =>
|
|
7128
|
-
onMouseEnter: () =>
|
|
7129
|
-
onMouseLeave:
|
|
7130
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${
|
|
7127
|
+
onClick: () => A("all"),
|
|
7128
|
+
onMouseEnter: () => w("all"),
|
|
7129
|
+
onMouseLeave: S,
|
|
7130
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" || x === "all" ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
|
|
7131
7131
|
children: i("All")
|
|
7132
7132
|
},
|
|
7133
7133
|
"sidebar-all"
|
|
7134
7134
|
),
|
|
7135
|
-
|
|
7135
|
+
C.map((y) => /* @__PURE__ */ jsx(
|
|
7136
7136
|
"button",
|
|
7137
7137
|
{
|
|
7138
|
-
onClick: () =>
|
|
7139
|
-
onMouseEnter: () =>
|
|
7140
|
-
onMouseLeave:
|
|
7141
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${
|
|
7138
|
+
onClick: () => A(y),
|
|
7139
|
+
onMouseEnter: () => w(y),
|
|
7140
|
+
onMouseLeave: S,
|
|
7141
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === y || x === y ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
|
|
7142
7142
|
children: capitalize(i(y.toLowerCase()))
|
|
7143
7143
|
},
|
|
7144
7144
|
`sidebar-${y}`
|
|
7145
7145
|
))
|
|
7146
7146
|
] }) }) }),
|
|
7147
|
-
/* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children:
|
|
7147
|
+
/* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children: j.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
|
|
7148
7148
|
i("No blocks found matching"),
|
|
7149
7149
|
' "',
|
|
7150
7150
|
d,
|
|
@@ -7152,17 +7152,17 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7152
7152
|
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((y) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7153
7153
|
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(y.toLowerCase())) }),
|
|
7154
7154
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
|
|
7155
|
-
|
|
7155
|
+
h === "all" ? filter(values(B), { group: y }) : values(B),
|
|
7156
7156
|
{ hidden: !0 }
|
|
7157
|
-
).map((
|
|
7157
|
+
).map((_) => /* @__PURE__ */ jsx(
|
|
7158
7158
|
CoreBlock,
|
|
7159
7159
|
{
|
|
7160
7160
|
parentId: r,
|
|
7161
7161
|
position: a,
|
|
7162
|
-
block:
|
|
7163
|
-
disabled: !canAcceptChildBlock(m,
|
|
7162
|
+
block: _,
|
|
7163
|
+
disabled: !canAcceptChildBlock(m, _.type) || !canBeNestedInside(m, _.type)
|
|
7164
7164
|
},
|
|
7165
|
-
|
|
7165
|
+
_.type
|
|
7166
7166
|
)) })
|
|
7167
7167
|
] }, y)) }) }) })
|
|
7168
7168
|
] })
|
|
@@ -7173,13 +7173,13 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7173
7173
|
parentId: r = void 0,
|
|
7174
7174
|
position: a = -1
|
|
7175
7175
|
}) => {
|
|
7176
|
-
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(), m = Object.keys(g || {}).length > 0, { hasPermission:
|
|
7176
|
+
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(), m = Object.keys(g || {}).length > 0, { hasPermission: h } = usePermissions();
|
|
7177
7177
|
useEffect(() => {
|
|
7178
7178
|
i === "partials" && !m && c("library");
|
|
7179
7179
|
}, [i, m, c]);
|
|
7180
7180
|
const f = useCallback(() => {
|
|
7181
7181
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7182
|
-
}, []),
|
|
7182
|
+
}, []), x = p && h(PERMISSIONS.IMPORT_HTML);
|
|
7183
7183
|
return /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
7184
7184
|
n ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
|
|
7185
7185
|
/* @__PURE__ */ jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: l("Add block") }),
|
|
@@ -7198,13 +7198,13 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7198
7198
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
7199
7199
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
7200
7200
|
m && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
|
|
7201
|
-
|
|
7201
|
+
x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
7202
7202
|
map(u, (b) => /* @__PURE__ */ jsx(TabsTrigger, { value: b.key, children: React__default.createElement(b.tab) }))
|
|
7203
7203
|
] }),
|
|
7204
7204
|
/* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
|
|
7205
7205
|
/* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
|
|
7206
7206
|
m && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
|
|
7207
|
-
|
|
7207
|
+
x ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
|
|
7208
7208
|
map(u, (b) => /* @__PURE__ */ jsx(TabsContent, { value: b.key, children: React__default.createElement(b.tabContent, { close: f, parentId: r, position: a }) }))
|
|
7209
7209
|
]
|
|
7210
7210
|
}
|
|
@@ -7262,18 +7262,18 @@ const BlockCard = ({
|
|
|
7262
7262
|
parentId: r = void 0,
|
|
7263
7263
|
position: a = -1
|
|
7264
7264
|
}) => {
|
|
7265
|
-
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")),
|
|
7266
|
-
const
|
|
7267
|
-
return
|
|
7265
|
+
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), x = (w) => {
|
|
7266
|
+
const S = has(w, "styles_attrs.data-page-section");
|
|
7267
|
+
return w._type === "Box" && S;
|
|
7268
7268
|
}, b = useCallback(
|
|
7269
|
-
async (
|
|
7270
|
-
if (
|
|
7269
|
+
async (w) => {
|
|
7270
|
+
if (w.stopPropagation(), has(o, "component")) {
|
|
7271
7271
|
d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7272
7272
|
return;
|
|
7273
7273
|
}
|
|
7274
7274
|
i(!0);
|
|
7275
|
-
const
|
|
7276
|
-
isEmpty(
|
|
7275
|
+
const S = await c(n, o);
|
|
7276
|
+
isEmpty(S) || p(syncBlocksWithDefaults(S), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7277
7277
|
},
|
|
7278
7278
|
[d, p, o, c, n, r, a]
|
|
7279
7279
|
);
|
|
@@ -7283,20 +7283,20 @@ const BlockCard = ({
|
|
|
7283
7283
|
{
|
|
7284
7284
|
onClick: l ? () => {
|
|
7285
7285
|
} : b,
|
|
7286
|
-
draggable:
|
|
7287
|
-
onDragStart: async (
|
|
7288
|
-
const
|
|
7289
|
-
let
|
|
7290
|
-
if (
|
|
7291
|
-
const
|
|
7292
|
-
if (
|
|
7293
|
-
const
|
|
7294
|
-
|
|
7295
|
-
|
|
7286
|
+
draggable: h ? "true" : "false",
|
|
7287
|
+
onDragStart: async (w) => {
|
|
7288
|
+
const S = await c(n, o);
|
|
7289
|
+
let A = r;
|
|
7290
|
+
if (x(first(S)) && (A = null), !isEmpty(S)) {
|
|
7291
|
+
const E = { blocks: S, uiLibrary: !0, parent: A };
|
|
7292
|
+
if (w.dataTransfer.setData("text/plain", JSON.stringify(E)), o.preview) {
|
|
7293
|
+
const j = new Image();
|
|
7294
|
+
j.src = o.preview, j.onload = () => {
|
|
7295
|
+
w.dataTransfer.setDragImage(j, 0, 0);
|
|
7296
7296
|
};
|
|
7297
7297
|
} else
|
|
7298
|
-
|
|
7299
|
-
f(
|
|
7298
|
+
w.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7299
|
+
f(E), setTimeout(() => {
|
|
7300
7300
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7301
7301
|
}, 200);
|
|
7302
7302
|
}
|
|
@@ -7316,39 +7316,43 @@ const BlockCard = ({
|
|
|
7316
7316
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: m }) })
|
|
7317
7317
|
] });
|
|
7318
7318
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
7319
|
-
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i =
|
|
7319
|
+
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = l.find((w) => w.id === r) || first(l), { data: c, isLoading: d } = useLibraryBlocks(i), p = groupBy([...c], "group"), [u, g] = useState(null);
|
|
7320
|
+
useEffect(() => {
|
|
7321
|
+
u || g(first(keys(p)));
|
|
7322
|
+
}, [p, u]);
|
|
7323
|
+
const m = get(p, u, []), h = useRef(null), { t: f } = useTranslation(), x = (w) => {
|
|
7320
7324
|
h.current && (clearTimeout(h.current), h.current = null), h.current = setTimeout(() => {
|
|
7321
|
-
h.current &&
|
|
7325
|
+
h.current && g(w);
|
|
7322
7326
|
}, 300);
|
|
7323
7327
|
};
|
|
7324
|
-
if (
|
|
7328
|
+
if (d)
|
|
7325
7329
|
return /* @__PURE__ */ jsxs("div", { className: "mt-4 grid h-full w-full grid-cols-12 gap-2", children: [
|
|
7326
7330
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7327
7331
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7328
7332
|
] });
|
|
7329
|
-
const
|
|
7333
|
+
const b = filter(m, (w, S) => S % 2 === 0), k = filter(m, (w, S) => S % 2 === 1);
|
|
7330
7334
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { className: "relative mt-2 flex h-full max-h-full overflow-hidden bg-background", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full pt-2", children: [
|
|
7331
7335
|
/* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
7332
|
-
/* @__PURE__ */ jsx(UILibrariesSelect, { library:
|
|
7336
|
+
/* @__PURE__ */ jsx(UILibrariesSelect, { library: i == null ? void 0 : i.id, setLibrary: a, uiLibraries: l }),
|
|
7333
7337
|
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
|
|
7334
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children:
|
|
7338
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: f("Groups") }),
|
|
7335
7339
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7336
|
-
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: map(
|
|
7340
|
+
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: map(p, (w, S) => /* @__PURE__ */ jsxs(
|
|
7337
7341
|
"div",
|
|
7338
7342
|
{
|
|
7339
|
-
onMouseEnter: () =>
|
|
7343
|
+
onMouseEnter: () => x(S),
|
|
7340
7344
|
onMouseLeave: () => clearTimeout(h.current),
|
|
7341
|
-
onClick: () =>
|
|
7345
|
+
onClick: () => g(S),
|
|
7342
7346
|
className: cn$1(
|
|
7343
7347
|
"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",
|
|
7344
|
-
|
|
7348
|
+
S === u ? "bg-blue-500 text-white hover:bg-blue-600" : ""
|
|
7345
7349
|
),
|
|
7346
7350
|
children: [
|
|
7347
|
-
/* @__PURE__ */ jsx("span", { children: capitalize(
|
|
7351
|
+
/* @__PURE__ */ jsx("span", { children: capitalize(f(S.toLowerCase())) }),
|
|
7348
7352
|
/* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
|
|
7349
7353
|
]
|
|
7350
7354
|
},
|
|
7351
|
-
|
|
7355
|
+
S
|
|
7352
7356
|
)) })
|
|
7353
7357
|
] })
|
|
7354
7358
|
] }),
|
|
@@ -7359,25 +7363,25 @@ const BlockCard = ({
|
|
|
7359
7363
|
className: "z-10 -mt-2 flex h-full max-h-full w-full flex-col gap-2 border-l border-border transition-all ease-linear",
|
|
7360
7364
|
children: [
|
|
7361
7365
|
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
|
|
7362
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children:
|
|
7366
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: b.map((w, S) => /* @__PURE__ */ jsx(
|
|
7363
7367
|
BlockCard,
|
|
7364
7368
|
{
|
|
7365
7369
|
parentId: o,
|
|
7366
7370
|
position: n,
|
|
7367
|
-
block:
|
|
7368
|
-
library:
|
|
7371
|
+
block: w,
|
|
7372
|
+
library: i
|
|
7369
7373
|
},
|
|
7370
|
-
`block-${
|
|
7374
|
+
`block-${S}`
|
|
7371
7375
|
)) }),
|
|
7372
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children:
|
|
7376
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: k.map((w, S) => /* @__PURE__ */ jsx(
|
|
7373
7377
|
BlockCard,
|
|
7374
7378
|
{
|
|
7375
7379
|
parentId: o,
|
|
7376
7380
|
position: n,
|
|
7377
|
-
block:
|
|
7378
|
-
library:
|
|
7381
|
+
block: w,
|
|
7382
|
+
library: i
|
|
7379
7383
|
},
|
|
7380
|
-
`block-${
|
|
7384
|
+
`block-${S}`
|
|
7381
7385
|
)) })
|
|
7382
7386
|
] }),
|
|
7383
7387
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -7621,35 +7625,35 @@ const selectParent = (o, n) => {
|
|
|
7621
7625
|
var P;
|
|
7622
7626
|
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom), { hasPermission: p } = usePermissions();
|
|
7623
7627
|
let u = null;
|
|
7624
|
-
const g = o.children.length > 0, { highlightBlock: m, clearHighlight:
|
|
7628
|
+
const g = o.children.length > 0, { highlightBlock: m, clearHighlight: h } = useBlockHighlight(), { id: f, data: x, isSelected: b, willReceiveDrop: k, isDragging: w, isEditing: S, handleClick: A } = o, E = (N) => {
|
|
7625
7629
|
N.stopPropagation(), !i.includes(f) && o.toggle();
|
|
7626
|
-
},
|
|
7630
|
+
}, j = (N) => {
|
|
7627
7631
|
N.isInternal && (u = N.isOpen, N.isOpen && N.close());
|
|
7628
|
-
},
|
|
7632
|
+
}, C = (N) => {
|
|
7629
7633
|
N.isInternal && u !== null && (u ? N.open() : N.close(), u = null);
|
|
7630
|
-
}, [
|
|
7634
|
+
}, [B, L] = useAtom$1(currentAddSelection), v = () => {
|
|
7631
7635
|
var N;
|
|
7632
7636
|
y(), o.parent.isSelected || L((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
|
|
7633
7637
|
}, y = () => {
|
|
7634
7638
|
L(null);
|
|
7635
|
-
},
|
|
7636
|
-
y(), N.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(),
|
|
7639
|
+
}, _ = (N) => {
|
|
7640
|
+
y(), N.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(), A(N);
|
|
7637
7641
|
};
|
|
7638
7642
|
useEffect(() => {
|
|
7639
7643
|
const N = setTimeout(() => {
|
|
7640
|
-
k && !o.isOpen && !
|
|
7644
|
+
k && !o.isOpen && !w && !i.includes(f) && o.toggle();
|
|
7641
7645
|
}, 500);
|
|
7642
7646
|
return () => clearTimeout(N);
|
|
7643
|
-
}, [k, o,
|
|
7647
|
+
}, [k, o, w]);
|
|
7644
7648
|
const T = useMemo(() => {
|
|
7645
|
-
const N = Object.keys(
|
|
7649
|
+
const N = Object.keys(x), M = [];
|
|
7646
7650
|
for (let D = 0; D < N.length; D++)
|
|
7647
7651
|
if (N[D].endsWith("_attrs")) {
|
|
7648
|
-
const O =
|
|
7652
|
+
const O = x[N[D]], $ = Object.keys(O).join("|");
|
|
7649
7653
|
$.match(/x-data/) && M.push("data"), $.match(/x-on/) && M.push("event"), $.match(/x-show|x-if/) && M.push("show");
|
|
7650
7654
|
}
|
|
7651
7655
|
return M;
|
|
7652
|
-
}, [
|
|
7656
|
+
}, [x]), I = (N, M) => {
|
|
7653
7657
|
const D = d.contentDocument || d.contentWindow.document, O = D.querySelector(`[data-block-id=${N}]`);
|
|
7654
7658
|
O && O.setAttribute("data-drop", M);
|
|
7655
7659
|
const $ = O.getBoundingClientRect(), H = d.getBoundingClientRect();
|
|
@@ -7679,13 +7683,13 @@ const selectParent = (o, n) => {
|
|
|
7679
7683
|
"div",
|
|
7680
7684
|
{
|
|
7681
7685
|
onMouseEnter: () => m(f),
|
|
7682
|
-
onMouseLeave: () =>
|
|
7683
|
-
onClick:
|
|
7686
|
+
onMouseLeave: () => h(),
|
|
7687
|
+
onClick: _,
|
|
7684
7688
|
style: n,
|
|
7685
7689
|
"data-node-id": f,
|
|
7686
7690
|
ref: i.includes(f) ? null : r,
|
|
7687
|
-
onDragStart: () =>
|
|
7688
|
-
onDragEnd: () =>
|
|
7691
|
+
onDragStart: () => j(o),
|
|
7692
|
+
onDragEnd: () => C(o),
|
|
7689
7693
|
onDragOver: (N) => {
|
|
7690
7694
|
N.preventDefault(), I(f, "yes");
|
|
7691
7695
|
},
|
|
@@ -7714,9 +7718,9 @@ const selectParent = (o, n) => {
|
|
|
7714
7718
|
className: cn$1(
|
|
7715
7719
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
|
|
7716
7720
|
b ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
|
|
7717
|
-
k && canAcceptChildBlock(
|
|
7718
|
-
(o == null ? void 0 : o.id) ===
|
|
7719
|
-
|
|
7721
|
+
k && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
|
|
7722
|
+
(o == null ? void 0 : o.id) === B ? "bg-purple-100" : "",
|
|
7723
|
+
w && "opacity-20",
|
|
7720
7724
|
i.includes(f) ? "opacity-50" : ""
|
|
7721
7725
|
),
|
|
7722
7726
|
children: [
|
|
@@ -7725,12 +7729,12 @@ const selectParent = (o, n) => {
|
|
|
7725
7729
|
"div",
|
|
7726
7730
|
{
|
|
7727
7731
|
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
7728
|
-
children: g && /* @__PURE__ */ jsx("button", { onClick:
|
|
7732
|
+
children: g && /* @__PURE__ */ jsx("button", { onClick: E, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${b ? "text-slate-200" : "text-slate-400"}` }) })
|
|
7729
7733
|
}
|
|
7730
7734
|
),
|
|
7731
7735
|
/* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
|
|
7732
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
7733
|
-
|
|
7736
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: x == null ? void 0 : x._type }),
|
|
7737
|
+
S ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
|
|
7734
7738
|
"div",
|
|
7735
7739
|
{
|
|
7736
7740
|
className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
|
|
@@ -7738,7 +7742,7 @@ const selectParent = (o, n) => {
|
|
|
7738
7742
|
N.stopPropagation(), o.edit(), o.deselect();
|
|
7739
7743
|
},
|
|
7740
7744
|
children: [
|
|
7741
|
-
/* @__PURE__ */ jsx("span", { children: (
|
|
7745
|
+
/* @__PURE__ */ jsx("span", { children: (x == null ? void 0 : x._name) || (x == null ? void 0 : x._type.split("/").pop()) }),
|
|
7742
7746
|
T.includes("data") && /* @__PURE__ */ jsx(FileJson, { className: "h-3 w-3 text-orange-600" }),
|
|
7743
7747
|
T.includes("event") && /* @__PURE__ */ jsx(Zap, { className: "h-3 w-3 text-yellow-500" }),
|
|
7744
7748
|
T.includes("show") && /* @__PURE__ */ jsx(EyeOff, { className: "h-3 w-3 text-orange-600" })
|
|
@@ -7759,7 +7763,7 @@ const selectParent = (o, n) => {
|
|
|
7759
7763
|
),
|
|
7760
7764
|
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: N.tooltip })
|
|
7761
7765
|
] })),
|
|
7762
|
-
canAddChildBlock(
|
|
7766
|
+
canAddChildBlock(x == null ? void 0 : x._type) && !i.includes(f) && p(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7763
7767
|
/* @__PURE__ */ jsx(
|
|
7764
7768
|
TooltipTrigger,
|
|
7765
7769
|
{
|
|
@@ -8089,63 +8093,63 @@ const selectParent = (o, n) => {
|
|
|
8089
8093
|
}
|
|
8090
8094
|
);
|
|
8091
8095
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
8092
|
-
const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), m = (
|
|
8093
|
-
a(
|
|
8094
|
-
},
|
|
8095
|
-
const
|
|
8096
|
-
if (
|
|
8097
|
-
const
|
|
8098
|
-
|
|
8096
|
+
const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), m = (w) => {
|
|
8097
|
+
a(w);
|
|
8098
|
+
}, h = () => {
|
|
8099
|
+
const w = l.find((S) => Object.keys(S)[0] === r);
|
|
8100
|
+
if (w) {
|
|
8101
|
+
const S = Object.values(w)[0];
|
|
8102
|
+
S && typeof S == "object" && "fontFamily" in S && "borderRadius" in S && "colors" in S ? p(S) : console.error("Invalid preset structure:", S);
|
|
8099
8103
|
} else
|
|
8100
8104
|
console.error("Preset not found:", r);
|
|
8101
8105
|
}, f = useDebouncedCallback(
|
|
8102
|
-
(
|
|
8106
|
+
(w, S) => {
|
|
8103
8107
|
p(() => ({
|
|
8104
8108
|
...d,
|
|
8105
8109
|
fontFamily: {
|
|
8106
8110
|
...d.fontFamily,
|
|
8107
|
-
[
|
|
8111
|
+
[w.replace(/font-/g, "")]: S
|
|
8108
8112
|
}
|
|
8109
8113
|
}));
|
|
8110
8114
|
},
|
|
8111
8115
|
[d],
|
|
8112
8116
|
200
|
|
8113
|
-
),
|
|
8114
|
-
(
|
|
8117
|
+
), x = useDebouncedCallback(
|
|
8118
|
+
(w) => {
|
|
8115
8119
|
p(() => ({
|
|
8116
8120
|
...d,
|
|
8117
|
-
borderRadius: `${
|
|
8121
|
+
borderRadius: `${w}px`
|
|
8118
8122
|
}));
|
|
8119
8123
|
},
|
|
8120
8124
|
[d],
|
|
8121
8125
|
200
|
|
8122
8126
|
), b = useDebouncedCallback(
|
|
8123
|
-
(
|
|
8127
|
+
(w, S) => {
|
|
8124
8128
|
p(() => {
|
|
8125
|
-
const
|
|
8126
|
-
return n ? set(
|
|
8129
|
+
const A = get(d, `colors.${w}`);
|
|
8130
|
+
return n ? set(A, 1, S) : set(A, 0, S), {
|
|
8127
8131
|
...d,
|
|
8128
8132
|
colors: {
|
|
8129
8133
|
...d.colors,
|
|
8130
|
-
[
|
|
8134
|
+
[w]: A
|
|
8131
8135
|
}
|
|
8132
8136
|
};
|
|
8133
8137
|
});
|
|
8134
8138
|
},
|
|
8135
8139
|
[d],
|
|
8136
8140
|
200
|
|
8137
|
-
), k = (
|
|
8138
|
-
const
|
|
8141
|
+
), k = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([S]) => {
|
|
8142
|
+
const A = get(d, `colors.${S}.${n ? 1 : 0}`);
|
|
8139
8143
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
8140
8144
|
/* @__PURE__ */ jsx(
|
|
8141
8145
|
ColorPickerInput,
|
|
8142
8146
|
{
|
|
8143
|
-
value:
|
|
8144
|
-
onChange: (
|
|
8147
|
+
value: A,
|
|
8148
|
+
onChange: (E) => b(S, E)
|
|
8145
8149
|
}
|
|
8146
8150
|
),
|
|
8147
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children:
|
|
8148
|
-
] },
|
|
8151
|
+
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: S.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((E) => E.charAt(0).toUpperCase() + E.slice(1)).join(" ") + (!S.toLowerCase().includes("foreground") && !S.toLowerCase().includes("border") && !S.toLowerCase().includes("input") && !S.toLowerCase().includes("ring") && !S.toLowerCase().includes("background") ? " Background" : "") })
|
|
8152
|
+
] }, S);
|
|
8149
8153
|
}) });
|
|
8150
8154
|
return c("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
8151
8155
|
/* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
@@ -8156,11 +8160,11 @@ const selectParent = (o, n) => {
|
|
|
8156
8160
|
"select",
|
|
8157
8161
|
{
|
|
8158
8162
|
value: r,
|
|
8159
|
-
onChange: (
|
|
8163
|
+
onChange: (w) => m(w.target.value),
|
|
8160
8164
|
className: "w-full space-y-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
8161
8165
|
children: [
|
|
8162
8166
|
/* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
|
|
8163
|
-
Array.isArray(l) && l.map((
|
|
8167
|
+
Array.isArray(l) && l.map((w) => /* @__PURE__ */ jsx("option", { value: Object.keys(w)[0], children: capitalize(Object.keys(w)[0]) }, Object.keys(w)[0]))
|
|
8164
8168
|
]
|
|
8165
8169
|
}
|
|
8166
8170
|
)
|
|
@@ -8171,31 +8175,31 @@ const selectParent = (o, n) => {
|
|
|
8171
8175
|
className: "w-full text-sm",
|
|
8172
8176
|
disabled: r === "",
|
|
8173
8177
|
variant: "default",
|
|
8174
|
-
onClick:
|
|
8178
|
+
onClick: h,
|
|
8175
8179
|
children: g("Apply")
|
|
8176
8180
|
}
|
|
8177
8181
|
) })
|
|
8178
8182
|
] }),
|
|
8179
8183
|
/* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
|
|
8180
|
-
(u == null ? void 0 : u.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(u.fontFamily).map(([
|
|
8184
|
+
(u == null ? void 0 : u.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(u.fontFamily).map(([w, S]) => /* @__PURE__ */ jsx(
|
|
8181
8185
|
FontSelector,
|
|
8182
8186
|
{
|
|
8183
|
-
label:
|
|
8184
|
-
value: d.fontFamily[
|
|
8185
|
-
onChange: (
|
|
8187
|
+
label: w,
|
|
8188
|
+
value: d.fontFamily[w.replace(/font-/g, "")] || S[Object.keys(S)[0]],
|
|
8189
|
+
onChange: (A) => f(w, A)
|
|
8186
8190
|
},
|
|
8187
|
-
|
|
8191
|
+
w
|
|
8188
8192
|
)) }),
|
|
8189
8193
|
(u == null ? void 0 : u.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
|
|
8190
8194
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Border Radius") }),
|
|
8191
8195
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
|
|
8192
|
-
/* @__PURE__ */ jsx(BorderRadiusInput, { value: d.borderRadius, onChange:
|
|
8196
|
+
/* @__PURE__ */ jsx(BorderRadiusInput, { value: d.borderRadius, onChange: x }),
|
|
8193
8197
|
/* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: d.borderRadius })
|
|
8194
8198
|
] })
|
|
8195
8199
|
] }),
|
|
8196
8200
|
(u == null ? void 0 : u.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
|
|
8197
8201
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Colors") }),
|
|
8198
|
-
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: u.colors.map((
|
|
8202
|
+
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: u.colors.map((w) => k(w)) }, n ? "dark" : "light")
|
|
8199
8203
|
] })
|
|
8200
8204
|
] }),
|
|
8201
8205
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -8665,14 +8669,14 @@ function QuickPrompts({ onClick: o }) {
|
|
|
8665
8669
|
) }) });
|
|
8666
8670
|
}
|
|
8667
8671
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
8668
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null),
|
|
8672
|
+
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null), h = useRef(null);
|
|
8669
8673
|
useEffect(() => {
|
|
8670
|
-
var
|
|
8671
|
-
(
|
|
8674
|
+
var x;
|
|
8675
|
+
(x = m.current) == null || x.focus();
|
|
8672
8676
|
}, []);
|
|
8673
|
-
const f = (
|
|
8674
|
-
const { usage: b } =
|
|
8675
|
-
!l && b && g(b),
|
|
8677
|
+
const f = (x) => {
|
|
8678
|
+
const { usage: b } = x || {};
|
|
8679
|
+
!l && b && g(b), h.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
8676
8680
|
};
|
|
8677
8681
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
8678
8682
|
/* @__PURE__ */ jsxs(
|
|
@@ -8692,12 +8696,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8692
8696
|
{
|
|
8693
8697
|
ref: m,
|
|
8694
8698
|
value: i,
|
|
8695
|
-
onChange: (
|
|
8699
|
+
onChange: (x) => c(x.target.value),
|
|
8696
8700
|
placeholder: n("Ask AI to edit content"),
|
|
8697
8701
|
className: "w-full",
|
|
8698
8702
|
rows: 3,
|
|
8699
|
-
onKeyDown: (
|
|
8700
|
-
|
|
8703
|
+
onKeyDown: (x) => {
|
|
8704
|
+
x.key === "Enter" && (x.preventDefault(), h.current && clearTimeout(h.current), g(void 0), r("content", o, i, f));
|
|
8701
8705
|
}
|
|
8702
8706
|
}
|
|
8703
8707
|
),
|
|
@@ -8707,7 +8711,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8707
8711
|
{
|
|
8708
8712
|
disabled: i.trim().length < 5 || a,
|
|
8709
8713
|
onClick: () => {
|
|
8710
|
-
|
|
8714
|
+
h.current && clearTimeout(h.current), g(void 0), r("content", o, i, f);
|
|
8711
8715
|
},
|
|
8712
8716
|
variant: "default",
|
|
8713
8717
|
className: "w-fit",
|
|
@@ -8739,8 +8743,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8739
8743
|
/* @__PURE__ */ jsx(
|
|
8740
8744
|
QuickPrompts,
|
|
8741
8745
|
{
|
|
8742
|
-
onClick: (
|
|
8743
|
-
|
|
8746
|
+
onClick: (x) => {
|
|
8747
|
+
h.current && clearTimeout(h.current), g(void 0), r("content", o, x, f);
|
|
8744
8748
|
}
|
|
8745
8749
|
}
|
|
8746
8750
|
)
|
|
@@ -8754,7 +8758,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8754
8758
|
useEffect(() => {
|
|
8755
8759
|
n && a(n);
|
|
8756
8760
|
}, [n]);
|
|
8757
|
-
const
|
|
8761
|
+
const h = async () => {
|
|
8758
8762
|
try {
|
|
8759
8763
|
d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
|
|
8760
8764
|
} catch (f) {
|
|
@@ -8784,7 +8788,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8784
8788
|
className: "mt-1 w-full",
|
|
8785
8789
|
rows: 10,
|
|
8786
8790
|
onKeyDown: (f) => {
|
|
8787
|
-
f.key === "Enter" && (f.preventDefault(),
|
|
8791
|
+
f.key === "Enter" && (f.preventDefault(), h());
|
|
8788
8792
|
}
|
|
8789
8793
|
}
|
|
8790
8794
|
),
|
|
@@ -8796,7 +8800,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8796
8800
|
Button,
|
|
8797
8801
|
{
|
|
8798
8802
|
disabled: r.trim().length < 5,
|
|
8799
|
-
onClick: () =>
|
|
8803
|
+
onClick: () => h(),
|
|
8800
8804
|
variant: "default",
|
|
8801
8805
|
className: "w-fit",
|
|
8802
8806
|
size: "sm",
|
|
@@ -8825,7 +8829,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8825
8829
|
AlertDialogAction,
|
|
8826
8830
|
{
|
|
8827
8831
|
onClick: () => {
|
|
8828
|
-
a(""),
|
|
8832
|
+
a(""), h();
|
|
8829
8833
|
},
|
|
8830
8834
|
children: o("Yes, Delete")
|
|
8831
8835
|
}
|
|
@@ -8982,53 +8986,53 @@ const AiAssistant = () => {
|
|
|
8982
8986
|
preloadedAttributes: n = [],
|
|
8983
8987
|
onAttributesChange: r
|
|
8984
8988
|
}) {
|
|
8985
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m,
|
|
8989
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""), f = useRef(null), x = useRef(null), b = usePageExternalData();
|
|
8986
8990
|
useEffect(() => {
|
|
8987
8991
|
l(n);
|
|
8988
8992
|
}, [n]);
|
|
8989
8993
|
const k = () => {
|
|
8990
8994
|
if (i.startsWith("@")) {
|
|
8991
|
-
|
|
8995
|
+
h("Attribute keys cannot start with '@'");
|
|
8992
8996
|
return;
|
|
8993
8997
|
}
|
|
8994
8998
|
if (i) {
|
|
8995
|
-
const
|
|
8996
|
-
r(
|
|
8999
|
+
const C = [...a, { key: i, value: d }];
|
|
9000
|
+
r(C), l(a), c(""), p(""), h("");
|
|
8997
9001
|
}
|
|
8998
|
-
},
|
|
8999
|
-
const
|
|
9000
|
-
r(
|
|
9001
|
-
},
|
|
9002
|
-
g(
|
|
9003
|
-
},
|
|
9002
|
+
}, w = (C) => {
|
|
9003
|
+
const B = a.filter((L, v) => v !== C);
|
|
9004
|
+
r(B), l(B);
|
|
9005
|
+
}, S = (C) => {
|
|
9006
|
+
g(C), c(a[C].key), p(a[C].value);
|
|
9007
|
+
}, A = () => {
|
|
9004
9008
|
if (i.startsWith("@")) {
|
|
9005
|
-
|
|
9009
|
+
h("Attribute keys cannot start with '@'");
|
|
9006
9010
|
return;
|
|
9007
9011
|
}
|
|
9008
9012
|
if (u !== null && i) {
|
|
9009
|
-
const
|
|
9010
|
-
|
|
9013
|
+
const C = [...a];
|
|
9014
|
+
C[u] = { key: i, value: d }, r(C), l(C), g(null), c(""), p(""), h("");
|
|
9011
9015
|
}
|
|
9012
|
-
},
|
|
9013
|
-
|
|
9014
|
-
},
|
|
9015
|
-
const
|
|
9016
|
+
}, E = (C) => {
|
|
9017
|
+
C.key === "Enter" && !C.shiftKey && (C.preventDefault(), u !== null ? A() : k());
|
|
9018
|
+
}, j = useCallback((C) => {
|
|
9019
|
+
const B = (y) => /[.,!?;:]/.test(y), L = (y, _, T) => {
|
|
9016
9020
|
let I = "", R = "";
|
|
9017
|
-
const P =
|
|
9018
|
-
return
|
|
9021
|
+
const P = _ > 0 ? y[_ - 1] : "", N = _ < y.length ? y[_] : "";
|
|
9022
|
+
return _ > 0 && (P === "." || !B(P) && P !== " ") && (I = " "), _ < y.length && !B(N) && N !== " " && (R = " "), {
|
|
9019
9023
|
text: I + T + R,
|
|
9020
9024
|
prefixLength: I.length,
|
|
9021
9025
|
suffixLength: R.length
|
|
9022
9026
|
};
|
|
9023
|
-
}, v =
|
|
9027
|
+
}, v = x.current;
|
|
9024
9028
|
if (v) {
|
|
9025
|
-
const y = v.selectionStart || 0,
|
|
9029
|
+
const y = v.selectionStart || 0, _ = v.value || "", T = v.selectionEnd || y;
|
|
9026
9030
|
if (T > y) {
|
|
9027
|
-
const M = `{{${
|
|
9031
|
+
const M = `{{${C}}}`, { text: D } = L(_, y, M), O = _.slice(0, y) + D + _.slice(T);
|
|
9028
9032
|
p(O);
|
|
9029
9033
|
return;
|
|
9030
9034
|
}
|
|
9031
|
-
const R = `{{${
|
|
9035
|
+
const R = `{{${C}}}`, { text: P } = L(_, y, R), N = _.slice(0, y) + P + _.slice(y);
|
|
9032
9036
|
p(N);
|
|
9033
9037
|
}
|
|
9034
9038
|
}, []);
|
|
@@ -9036,8 +9040,8 @@ const AiAssistant = () => {
|
|
|
9036
9040
|
/* @__PURE__ */ jsxs(
|
|
9037
9041
|
"form",
|
|
9038
9042
|
{
|
|
9039
|
-
onSubmit: (
|
|
9040
|
-
|
|
9043
|
+
onSubmit: (C) => {
|
|
9044
|
+
C.preventDefault(), u !== null ? A() : k();
|
|
9041
9045
|
},
|
|
9042
9046
|
className: "space-y-3",
|
|
9043
9047
|
children: [
|
|
@@ -9053,7 +9057,7 @@ const AiAssistant = () => {
|
|
|
9053
9057
|
id: "attrKey",
|
|
9054
9058
|
ref: f,
|
|
9055
9059
|
value: i,
|
|
9056
|
-
onChange: (
|
|
9060
|
+
onChange: (C) => c(C.target.value),
|
|
9057
9061
|
placeholder: "Enter Key",
|
|
9058
9062
|
className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9059
9063
|
}
|
|
@@ -9062,7 +9066,7 @@ const AiAssistant = () => {
|
|
|
9062
9066
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
9063
9067
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
9064
9068
|
/* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
|
|
9065
|
-
!isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect:
|
|
9069
|
+
!isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: j })
|
|
9066
9070
|
] }),
|
|
9067
9071
|
/* @__PURE__ */ jsx(
|
|
9068
9072
|
Textarea,
|
|
@@ -9072,10 +9076,10 @@ const AiAssistant = () => {
|
|
|
9072
9076
|
spellCheck: "false",
|
|
9073
9077
|
id: "attrValue",
|
|
9074
9078
|
rows: 2,
|
|
9075
|
-
ref:
|
|
9079
|
+
ref: x,
|
|
9076
9080
|
value: d,
|
|
9077
|
-
onChange: (
|
|
9078
|
-
onKeyDown:
|
|
9081
|
+
onChange: (C) => p(C.target.value),
|
|
9082
|
+
onKeyDown: E,
|
|
9079
9083
|
placeholder: "Enter Value",
|
|
9080
9084
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9081
9085
|
}
|
|
@@ -9087,16 +9091,16 @@ const AiAssistant = () => {
|
|
|
9087
9091
|
]
|
|
9088
9092
|
}
|
|
9089
9093
|
),
|
|
9090
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((
|
|
9094
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((C, B) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
|
|
9091
9095
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
9092
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children:
|
|
9093
|
-
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children:
|
|
9096
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: C.key }),
|
|
9097
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: C.value.toString() })
|
|
9094
9098
|
] }),
|
|
9095
9099
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
9096
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B
|
|
9097
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
9100
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => S(B), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
|
|
9101
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => w(B), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
|
|
9098
9102
|
] })
|
|
9099
|
-
] },
|
|
9103
|
+
] }, B)) })
|
|
9100
9104
|
] });
|
|
9101
9105
|
}), BlockAttributesEditor = React.memo(() => {
|
|
9102
9106
|
const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
|
|
@@ -9306,11 +9310,11 @@ const RootLayout = () => {
|
|
|
9306
9310
|
usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
|
|
9307
9311
|
n(1);
|
|
9308
9312
|
});
|
|
9309
|
-
const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (
|
|
9310
|
-
|
|
9311
|
-
}, u = (
|
|
9312
|
-
n(o ===
|
|
9313
|
-
}, g = useSidebarMenuItems(), { t: m } = useTranslation(),
|
|
9313
|
+
const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (x) => {
|
|
9314
|
+
x.preventDefault();
|
|
9315
|
+
}, u = (x) => {
|
|
9316
|
+
n(o === x ? null : x);
|
|
9317
|
+
}, g = useSidebarMenuItems(), { t: m } = useTranslation(), h = [...g, ...c], f = useBuilderProp("htmlDir", "ltr");
|
|
9314
9318
|
return /* @__PURE__ */ jsx("div", { dir: f, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
|
|
9315
9319
|
/* @__PURE__ */ jsxs(
|
|
9316
9320
|
"div",
|
|
@@ -9321,21 +9325,21 @@ const RootLayout = () => {
|
|
|
9321
9325
|
/* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
|
|
9322
9326
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
9323
9327
|
/* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
9324
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children:
|
|
9328
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: h.map((x, b) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9325
9329
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
9326
9330
|
Button,
|
|
9327
9331
|
{
|
|
9328
9332
|
variant: o === b ? "default" : "ghost",
|
|
9329
9333
|
className: "mb-2 rounded-lg p-2 transition-colors",
|
|
9330
9334
|
onClick: () => u(b),
|
|
9331
|
-
children: get(
|
|
9335
|
+
children: get(x, "icon", null)
|
|
9332
9336
|
},
|
|
9333
9337
|
b
|
|
9334
9338
|
) }),
|
|
9335
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(
|
|
9339
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(x.label) }) })
|
|
9336
9340
|
] }, "button" + b)) }),
|
|
9337
9341
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
9338
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((
|
|
9342
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((x, b) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(x, {}) }, `sidebar-component-${b}`)) })
|
|
9339
9343
|
] }),
|
|
9340
9344
|
/* @__PURE__ */ jsx(
|
|
9341
9345
|
motion.div,
|
|
@@ -9348,14 +9352,14 @@ const RootLayout = () => {
|
|
|
9348
9352
|
/* @__PURE__ */ jsxs(
|
|
9349
9353
|
"div",
|
|
9350
9354
|
{
|
|
9351
|
-
className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(
|
|
9355
|
+
className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(h, `${o}.isInternal`, !1) ? "" : "w-64"}`,
|
|
9352
9356
|
children: [
|
|
9353
|
-
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(
|
|
9354
|
-
/* @__PURE__ */ jsx("span", { children: m(
|
|
9357
|
+
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(h, `${o}.icon`, null) }),
|
|
9358
|
+
/* @__PURE__ */ jsx("span", { children: m(h[o].label) })
|
|
9355
9359
|
]
|
|
9356
9360
|
}
|
|
9357
9361
|
),
|
|
9358
|
-
/* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(
|
|
9362
|
+
/* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(h, `${o}.component`, null), {}) }) })
|
|
9359
9363
|
] })
|
|
9360
9364
|
}
|
|
9361
9365
|
),
|