@chaibuilder/sdk 2.0.2 → 2.0.3
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.d.ts +22 -3
- package/dist/core.js +1134 -1133
- package/dist/render.cjs +2 -2
- package/dist/render.js +40 -38
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
var G = Object.defineProperty;
|
|
2
2
|
var K = (o, n, r) => n in o ? G(o, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[n] = r;
|
|
3
3
|
var V = (o, n, r) => K(o, typeof n != "symbol" ? n + "" : n, r);
|
|
4
|
-
import { jsx,
|
|
4
|
+
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import React__default, { createContext, useReducer, useEffect, useDebugValue, useCallback, useContext, useMemo, Component, Children, useState, useRef, Suspense, createElement, memo, lazy } from "react";
|
|
7
7
|
import { O as DropdownMenu, P as DropdownMenuTrigger, Q as DropdownMenuContent, R as DropdownMenuItem, S as Skeleton, B as Button, a6 as Label, H as Dialog, I as DialogTrigger, J as DialogContent, a7 as Popover, ak as Tooltip, al as TooltipTrigger, a8 as PopoverTrigger, am as TooltipContent, a9 as PopoverContent, v as Command, x as CommandInput, y as CommandList, z as CommandEmpty, D as CommandGroup, E as CommandItem, K as DialogHeader, M as DialogTitle, n as Badge, V as DropdownMenuLabel, W as DropdownMenuSeparator, T as DropdownMenuCheckboxItem, a2 as HoverCard, a3 as HoverCardTrigger, a4 as HoverCardContent, aj as Textarea, a5 as Input$1, ao as TooltipPortal, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, aa as ScrollArea, Y as DropdownMenuGroup, X as DropdownMenuShortcut, A as Accordion, C as Card, q as CardHeader, t as CardDescription, u as CardContent, r as CardFooter, af as Tabs, ag as TabsList, ah as TabsTrigger, ai as TabsContent, e as AlertDialog, f as AlertDialogTrigger, g as AlertDialogContent, h as AlertDialogHeader, j as AlertDialogTitle, k as AlertDialogDescription, i as AlertDialogFooter, m as AlertDialogCancel, l as AlertDialogAction, ae as Switch, ac as Separator, an as TooltipProvider, ad as Toaster } from "./tooltip-PKiP886L.js";
|
|
8
|
-
import { atom as atom$1,
|
|
9
|
-
import { find, filter, flatten, map, omit, isString, has, isObject, memoize,
|
|
8
|
+
import { atom as atom$1, useAtomValue as useAtomValue$1, useAtom as useAtom$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
|
|
9
|
+
import { find, filter, flatten, map, omit, isString, has, get, isObject, memoize, compact, isEmpty, noop, includes, without, each, first, keys, range, values, flattenDeep, set, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, findIndex, throttle, isFunction as isFunction$1, reverse, startCase, debounce, capitalize, split, take, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, uniq, flatMapDeep, some, reject, sortBy, round } from "lodash-es";
|
|
10
10
|
import { Provider as Provider$1 } from "react-wrap-balancer";
|
|
11
11
|
import { useTranslation, initReactI18next } from "react-i18next";
|
|
12
12
|
import { useTranslation as Ve } from "react-i18next";
|
|
@@ -94,197 +94,197 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
94
94
|
for (const i of n.p)
|
|
95
95
|
l.add(i);
|
|
96
96
|
return l;
|
|
97
|
-
}, 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 = (
|
|
98
|
-
var
|
|
99
|
-
return (
|
|
100
|
-
}, g = (
|
|
101
|
-
var
|
|
102
|
-
return (
|
|
97
|
+
}, 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 = (x, ...f) => x.read(...f), p = (x, ...f) => x.write(...f), u = (x, f) => {
|
|
98
|
+
var h;
|
|
99
|
+
return (h = x.unstable_onInit) == null ? void 0 : h.call(x, f);
|
|
100
|
+
}, g = (x, f) => {
|
|
101
|
+
var h;
|
|
102
|
+
return (h = x.onMount) == null ? void 0 : h.call(x, f);
|
|
103
103
|
}, ...m) => {
|
|
104
|
-
const
|
|
105
|
-
let L = o.get(
|
|
106
|
-
return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(
|
|
104
|
+
const x = m[0] || ((w) => {
|
|
105
|
+
let L = o.get(w);
|
|
106
|
+
return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(w, L), u == null || u(w, S)), L;
|
|
107
107
|
}), f = m[1] || (() => {
|
|
108
|
-
let
|
|
109
|
-
const v = (
|
|
108
|
+
let w, L;
|
|
109
|
+
const v = (y) => {
|
|
110
110
|
try {
|
|
111
|
-
|
|
112
|
-
} catch (
|
|
113
|
-
|
|
111
|
+
y();
|
|
112
|
+
} catch (E) {
|
|
113
|
+
w || (w = !0, L = E);
|
|
114
114
|
}
|
|
115
115
|
};
|
|
116
116
|
do {
|
|
117
117
|
c.f && v(c.f);
|
|
118
|
-
const
|
|
118
|
+
const y = /* @__PURE__ */ new Set(), E = y.add.bind(y);
|
|
119
119
|
a.forEach((T) => {
|
|
120
120
|
var I;
|
|
121
|
-
return (I = n.get(T)) == null ? void 0 : I.l.forEach(
|
|
122
|
-
}), a.clear(), i.forEach(
|
|
121
|
+
return (I = n.get(T)) == null ? void 0 : I.l.forEach(E);
|
|
122
|
+
}), a.clear(), i.forEach(E), i.clear(), l.forEach(E), l.clear(), y.forEach(v), a.size && h();
|
|
123
123
|
} while (a.size || i.size || l.size);
|
|
124
|
-
if (
|
|
124
|
+
if (w)
|
|
125
125
|
throw L;
|
|
126
|
-
}),
|
|
127
|
-
const
|
|
128
|
-
for (;
|
|
129
|
-
const
|
|
130
|
-
if (v.has(
|
|
131
|
-
|
|
126
|
+
}), h = m[2] || (() => {
|
|
127
|
+
const w = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), y = Array.from(a);
|
|
128
|
+
for (; y.length; ) {
|
|
129
|
+
const E = y[y.length - 1], T = x(E);
|
|
130
|
+
if (v.has(E)) {
|
|
131
|
+
y.pop();
|
|
132
132
|
continue;
|
|
133
133
|
}
|
|
134
|
-
if (L.has(
|
|
135
|
-
r.get(
|
|
134
|
+
if (L.has(E)) {
|
|
135
|
+
r.get(E) === T.n && w.push([E, T]), v.add(E), y.pop();
|
|
136
136
|
continue;
|
|
137
137
|
}
|
|
138
|
-
L.add(
|
|
139
|
-
for (const I of getMountedOrPendingDependents(
|
|
140
|
-
L.has(I) ||
|
|
138
|
+
L.add(E);
|
|
139
|
+
for (const I of getMountedOrPendingDependents(E, T, n))
|
|
140
|
+
L.has(I) || y.push(I);
|
|
141
141
|
}
|
|
142
|
-
for (let
|
|
143
|
-
const [T, I] =
|
|
144
|
-
let
|
|
145
|
-
for (const
|
|
146
|
-
if (
|
|
147
|
-
|
|
142
|
+
for (let E = w.length - 1; E >= 0; --E) {
|
|
143
|
+
const [T, I] = w[E];
|
|
144
|
+
let R = !1;
|
|
145
|
+
for (const P of I.d.keys())
|
|
146
|
+
if (P !== T && a.has(P)) {
|
|
147
|
+
R = !0;
|
|
148
148
|
break;
|
|
149
149
|
}
|
|
150
|
-
|
|
150
|
+
R && (b(T), B(T)), r.delete(T);
|
|
151
151
|
}
|
|
152
|
-
}), b = m[3] || ((
|
|
152
|
+
}), b = m[3] || ((w) => {
|
|
153
153
|
var L, v;
|
|
154
|
-
const
|
|
155
|
-
if (isAtomStateInitialized(
|
|
156
|
-
([
|
|
154
|
+
const y = x(w);
|
|
155
|
+
if (isAtomStateInitialized(y) && (n.has(w) && r.get(w) !== y.n || Array.from(y.d).every(
|
|
156
|
+
([D, O]) => (
|
|
157
157
|
// Recursively, read the atom state of the dependency, and
|
|
158
158
|
// check if the atom epoch number is unchanged
|
|
159
|
-
b(
|
|
159
|
+
b(D).n === O
|
|
160
160
|
)
|
|
161
161
|
)))
|
|
162
|
-
return
|
|
163
|
-
|
|
164
|
-
let
|
|
162
|
+
return y;
|
|
163
|
+
y.d.clear();
|
|
164
|
+
let E = !0;
|
|
165
165
|
const T = () => {
|
|
166
|
-
n.has(
|
|
167
|
-
}, I = (
|
|
166
|
+
n.has(w) && (B(w), h(), f());
|
|
167
|
+
}, I = (D) => {
|
|
168
168
|
var O;
|
|
169
|
-
if (isSelfAtom(
|
|
170
|
-
const H =
|
|
169
|
+
if (isSelfAtom(w, D)) {
|
|
170
|
+
const H = x(D);
|
|
171
171
|
if (!isAtomStateInitialized(H))
|
|
172
|
-
if (hasInitialValue(
|
|
173
|
-
setAtomStateValueOrPromise(
|
|
172
|
+
if (hasInitialValue(D))
|
|
173
|
+
setAtomStateValueOrPromise(D, D.init, x);
|
|
174
174
|
else
|
|
175
175
|
throw new Error("no atom init");
|
|
176
176
|
return returnAtomValue(H);
|
|
177
177
|
}
|
|
178
|
-
const
|
|
178
|
+
const $ = b(D);
|
|
179
179
|
try {
|
|
180
|
-
return returnAtomValue(
|
|
180
|
+
return returnAtomValue($);
|
|
181
181
|
} finally {
|
|
182
|
-
|
|
182
|
+
y.d.set(D, $.n), isPendingPromise(y.v) && addPendingPromiseToDependency(w, y.v, $), (O = n.get(D)) == null || O.t.add(w), E || T();
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
|
-
let
|
|
186
|
-
const
|
|
185
|
+
let R, P;
|
|
186
|
+
const N = {
|
|
187
187
|
get signal() {
|
|
188
|
-
return
|
|
188
|
+
return R || (R = new AbortController()), R.signal;
|
|
189
189
|
},
|
|
190
190
|
get setSelf() {
|
|
191
|
-
return !
|
|
192
|
-
if (!
|
|
191
|
+
return !P && isActuallyWritableAtom(w) && (P = (...D) => {
|
|
192
|
+
if (!E)
|
|
193
193
|
try {
|
|
194
|
-
return
|
|
194
|
+
return A(w, ...D);
|
|
195
195
|
} finally {
|
|
196
|
-
|
|
196
|
+
h(), f();
|
|
197
197
|
}
|
|
198
|
-
}),
|
|
198
|
+
}), P;
|
|
199
199
|
}
|
|
200
|
-
},
|
|
200
|
+
}, M = y.n;
|
|
201
201
|
try {
|
|
202
|
-
const
|
|
203
|
-
return setAtomStateValueOrPromise(
|
|
202
|
+
const D = d(w, I, N);
|
|
203
|
+
return setAtomStateValueOrPromise(w, D, x), isPromiseLike$2(D) && ((L = D.onCancel) == null || L.call(D, () => R == null ? void 0 : R.abort()), D.then(
|
|
204
204
|
T,
|
|
205
205
|
T
|
|
206
|
-
)),
|
|
207
|
-
} catch (
|
|
208
|
-
return delete
|
|
206
|
+
)), y;
|
|
207
|
+
} catch (D) {
|
|
208
|
+
return delete y.v, y.e = D, ++y.n, y;
|
|
209
209
|
} finally {
|
|
210
|
-
|
|
210
|
+
E = !1, M !== y.n && r.get(w) === M && (r.set(w, y.n), a.add(w), (v = c.c) == null || v.call(c, w));
|
|
211
211
|
}
|
|
212
|
-
}),
|
|
213
|
-
const L = [
|
|
212
|
+
}), k = m[4] || ((w) => {
|
|
213
|
+
const L = [w];
|
|
214
214
|
for (; L.length; ) {
|
|
215
|
-
const v = L.pop(),
|
|
216
|
-
for (const
|
|
217
|
-
const T =
|
|
218
|
-
r.set(
|
|
215
|
+
const v = L.pop(), y = x(v);
|
|
216
|
+
for (const E of getMountedOrPendingDependents(v, y, n)) {
|
|
217
|
+
const T = x(E);
|
|
218
|
+
r.set(E, T.n), L.push(E);
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
|
-
}),
|
|
221
|
+
}), A = m[5] || ((w, ...L) => {
|
|
222
222
|
let v = !0;
|
|
223
|
-
const
|
|
224
|
-
var
|
|
225
|
-
const
|
|
223
|
+
const y = (T) => returnAtomValue(b(T)), E = (T, ...I) => {
|
|
224
|
+
var R;
|
|
225
|
+
const P = x(T);
|
|
226
226
|
try {
|
|
227
|
-
if (isSelfAtom(
|
|
227
|
+
if (isSelfAtom(w, T)) {
|
|
228
228
|
if (!hasInitialValue(T))
|
|
229
229
|
throw new Error("atom not writable");
|
|
230
|
-
const
|
|
231
|
-
setAtomStateValueOrPromise(T,
|
|
230
|
+
const N = P.n, M = I[0];
|
|
231
|
+
setAtomStateValueOrPromise(T, M, x), B(T), N !== P.n && (a.add(T), (R = c.c) == null || R.call(c, T), k(T));
|
|
232
232
|
return;
|
|
233
233
|
} else
|
|
234
|
-
return
|
|
234
|
+
return A(T, ...I);
|
|
235
235
|
} finally {
|
|
236
|
-
v || (
|
|
236
|
+
v || (h(), f());
|
|
237
237
|
}
|
|
238
238
|
};
|
|
239
239
|
try {
|
|
240
|
-
return p(
|
|
240
|
+
return p(w, y, E, ...L);
|
|
241
241
|
} finally {
|
|
242
242
|
v = !1;
|
|
243
243
|
}
|
|
244
|
-
}),
|
|
244
|
+
}), B = m[6] || ((w) => {
|
|
245
245
|
var L;
|
|
246
|
-
const v =
|
|
247
|
-
if (
|
|
248
|
-
for (const [
|
|
249
|
-
if (!
|
|
250
|
-
const I =
|
|
251
|
-
|
|
246
|
+
const v = x(w), y = n.get(w);
|
|
247
|
+
if (y && !isPendingPromise(v.v)) {
|
|
248
|
+
for (const [E, T] of v.d)
|
|
249
|
+
if (!y.d.has(E)) {
|
|
250
|
+
const I = x(E);
|
|
251
|
+
C(E).t.add(w), y.d.add(E), T !== I.n && (a.add(E), (L = c.c) == null || L.call(c, E), k(E));
|
|
252
252
|
}
|
|
253
|
-
for (const
|
|
254
|
-
if (!v.d.has(
|
|
255
|
-
|
|
256
|
-
const T =
|
|
257
|
-
T == null || T.t.delete(
|
|
253
|
+
for (const E of y.d || [])
|
|
254
|
+
if (!v.d.has(E)) {
|
|
255
|
+
y.d.delete(E);
|
|
256
|
+
const T = j(E);
|
|
257
|
+
T == null || T.t.delete(w);
|
|
258
258
|
}
|
|
259
259
|
}
|
|
260
|
-
}),
|
|
260
|
+
}), C = m[7] || ((w) => {
|
|
261
261
|
var L;
|
|
262
|
-
const v =
|
|
263
|
-
let
|
|
264
|
-
if (!
|
|
265
|
-
b(
|
|
266
|
-
for (const
|
|
267
|
-
|
|
268
|
-
if (
|
|
262
|
+
const v = x(w);
|
|
263
|
+
let y = n.get(w);
|
|
264
|
+
if (!y) {
|
|
265
|
+
b(w);
|
|
266
|
+
for (const E of v.d.keys())
|
|
267
|
+
C(E).t.add(w);
|
|
268
|
+
if (y = {
|
|
269
269
|
l: /* @__PURE__ */ new Set(),
|
|
270
270
|
d: new Set(v.d.keys()),
|
|
271
271
|
t: /* @__PURE__ */ new Set()
|
|
272
|
-
}, n.set(
|
|
273
|
-
const
|
|
272
|
+
}, n.set(w, y), (L = c.m) == null || L.call(c, w), isActuallyWritableAtom(w)) {
|
|
273
|
+
const E = () => {
|
|
274
274
|
let T = !0;
|
|
275
|
-
const I = (...
|
|
275
|
+
const I = (...R) => {
|
|
276
276
|
try {
|
|
277
|
-
return
|
|
277
|
+
return A(w, ...R);
|
|
278
278
|
} finally {
|
|
279
|
-
T || (
|
|
279
|
+
T || (h(), f());
|
|
280
280
|
}
|
|
281
281
|
};
|
|
282
282
|
try {
|
|
283
|
-
const
|
|
284
|
-
|
|
283
|
+
const R = g(w, I);
|
|
284
|
+
R && (y.u = () => {
|
|
285
285
|
T = !0;
|
|
286
286
|
try {
|
|
287
|
-
|
|
287
|
+
R();
|
|
288
288
|
} finally {
|
|
289
289
|
T = !1;
|
|
290
290
|
}
|
|
@@ -293,27 +293,27 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
293
293
|
T = !1;
|
|
294
294
|
}
|
|
295
295
|
};
|
|
296
|
-
l.add(
|
|
296
|
+
l.add(E);
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
return
|
|
300
|
-
}),
|
|
299
|
+
return y;
|
|
300
|
+
}), j = m[8] || ((w) => {
|
|
301
301
|
var L;
|
|
302
|
-
const v =
|
|
303
|
-
let
|
|
304
|
-
if (
|
|
302
|
+
const v = x(w);
|
|
303
|
+
let y = n.get(w);
|
|
304
|
+
if (y && !y.l.size && !Array.from(y.t).some((E) => {
|
|
305
305
|
var T;
|
|
306
|
-
return (T = n.get(
|
|
306
|
+
return (T = n.get(E)) == null ? void 0 : T.d.has(w);
|
|
307
307
|
})) {
|
|
308
|
-
|
|
309
|
-
for (const
|
|
310
|
-
const T =
|
|
311
|
-
T == null || T.t.delete(
|
|
308
|
+
y.u && i.add(y.u), y = void 0, n.delete(w), (L = c.u) == null || L.call(c, w);
|
|
309
|
+
for (const E of v.d.keys()) {
|
|
310
|
+
const T = j(E);
|
|
311
|
+
T == null || T.t.delete(w);
|
|
312
312
|
}
|
|
313
313
|
return;
|
|
314
314
|
}
|
|
315
|
-
return
|
|
316
|
-
}),
|
|
315
|
+
return y;
|
|
316
|
+
}), _ = [
|
|
317
317
|
// store state
|
|
318
318
|
o,
|
|
319
319
|
n,
|
|
@@ -328,32 +328,32 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
328
328
|
u,
|
|
329
329
|
g,
|
|
330
330
|
// building-block functions
|
|
331
|
-
h,
|
|
332
|
-
f,
|
|
333
331
|
x,
|
|
332
|
+
f,
|
|
333
|
+
h,
|
|
334
334
|
b,
|
|
335
|
-
|
|
335
|
+
k,
|
|
336
|
+
A,
|
|
336
337
|
B,
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
_
|
|
338
|
+
C,
|
|
339
|
+
j
|
|
340
340
|
], S = {
|
|
341
|
-
get: (
|
|
342
|
-
set: (
|
|
341
|
+
get: (w) => returnAtomValue(b(w)),
|
|
342
|
+
set: (w, ...L) => {
|
|
343
343
|
try {
|
|
344
|
-
return
|
|
344
|
+
return A(w, ...L);
|
|
345
345
|
} finally {
|
|
346
|
-
|
|
346
|
+
h(), f();
|
|
347
347
|
}
|
|
348
348
|
},
|
|
349
|
-
sub: (
|
|
350
|
-
const
|
|
351
|
-
return
|
|
352
|
-
|
|
349
|
+
sub: (w, L) => {
|
|
350
|
+
const y = C(w).l;
|
|
351
|
+
return y.add(L), f(), () => {
|
|
352
|
+
y.delete(L), j(w), f();
|
|
353
353
|
};
|
|
354
354
|
}
|
|
355
355
|
};
|
|
356
|
-
return Object.defineProperty(S, BUILDING_BLOCKS, { value:
|
|
356
|
+
return Object.defineProperty(S, BUILDING_BLOCKS, { value: _ }), S;
|
|
357
357
|
}, INTERNAL_buildStoreRev1 = buildStore;
|
|
358
358
|
let keyCount = 0;
|
|
359
359
|
function atom(o, n) {
|
|
@@ -389,36 +389,36 @@ function splitAtom(o, n) {
|
|
|
389
389
|
if (p)
|
|
390
390
|
return p;
|
|
391
391
|
const u = d && r.get(d), g = [], m = [];
|
|
392
|
-
return c.forEach((
|
|
393
|
-
const
|
|
394
|
-
m[f] =
|
|
395
|
-
const b = u && u.atomList[u.keyList.indexOf(
|
|
392
|
+
return c.forEach((x, f) => {
|
|
393
|
+
const h = f;
|
|
394
|
+
m[f] = h;
|
|
395
|
+
const b = u && u.atomList[u.keyList.indexOf(h)];
|
|
396
396
|
if (b) {
|
|
397
397
|
g[f] = b;
|
|
398
398
|
return;
|
|
399
399
|
}
|
|
400
|
-
const
|
|
401
|
-
const
|
|
402
|
-
if (S < 0 || S >=
|
|
403
|
-
const
|
|
404
|
-
if (
|
|
405
|
-
return
|
|
400
|
+
const k = (B) => {
|
|
401
|
+
const C = B(l), j = B(o), S = a(j, C == null ? void 0 : C.arr).keyList.indexOf(h);
|
|
402
|
+
if (S < 0 || S >= j.length) {
|
|
403
|
+
const w = c[a(c).keyList.indexOf(h)];
|
|
404
|
+
if (w)
|
|
405
|
+
return w;
|
|
406
406
|
throw new Error("splitAtom: index out of bounds for read");
|
|
407
407
|
}
|
|
408
|
-
return
|
|
409
|
-
},
|
|
410
|
-
const
|
|
408
|
+
return j[S];
|
|
409
|
+
}, A = (B, C, j) => {
|
|
410
|
+
const _ = B(l), S = B(o), L = a(S, _ == null ? void 0 : _.arr).keyList.indexOf(h);
|
|
411
411
|
if (L < 0 || L >= S.length)
|
|
412
412
|
throw new Error("splitAtom: index out of bounds for write");
|
|
413
|
-
const v = isFunction(
|
|
414
|
-
Object.is(S[L], v) ||
|
|
413
|
+
const v = isFunction(j) ? j(S[L]) : j;
|
|
414
|
+
Object.is(S[L], v) || C(o, [
|
|
415
415
|
...S.slice(0, L),
|
|
416
416
|
v,
|
|
417
417
|
...S.slice(L + 1)
|
|
418
418
|
]);
|
|
419
419
|
};
|
|
420
|
-
g[f] = isWritable(o) ? atom(
|
|
421
|
-
}), u && u.keyList.length === m.length && u.keyList.every((
|
|
420
|
+
g[f] = isWritable(o) ? atom(k, A) : atom(k);
|
|
421
|
+
}), u && u.keyList.length === m.length && u.keyList.every((x, f) => x === m[f]) ? p = u : p = { arr: c, atomList: g, keyList: m }, r.set(c, p), p;
|
|
422
422
|
}, l = atom((c) => {
|
|
423
423
|
const d = c(l), p = c(o);
|
|
424
424
|
return a(p, d == null ? void 0 : d.arr);
|
|
@@ -491,18 +491,18 @@ function createJSONStorage(o = () => {
|
|
|
491
491
|
const i = {
|
|
492
492
|
getItem: (p, u) => {
|
|
493
493
|
var g, m;
|
|
494
|
-
const
|
|
495
|
-
if (
|
|
494
|
+
const x = (h) => {
|
|
495
|
+
if (h = h || "", a !== h) {
|
|
496
496
|
try {
|
|
497
|
-
l = JSON.parse(
|
|
497
|
+
l = JSON.parse(h, n == null ? void 0 : n.reviver);
|
|
498
498
|
} catch {
|
|
499
499
|
return u;
|
|
500
500
|
}
|
|
501
|
-
a =
|
|
501
|
+
a = h;
|
|
502
502
|
}
|
|
503
503
|
return l;
|
|
504
504
|
}, f = (m = (g = o()) == null ? void 0 : g.getItem(p)) != null ? m : null;
|
|
505
|
-
return isPromiseLike$1(f) ? f.then(
|
|
505
|
+
return isPromiseLike$1(f) ? f.then(x) : x(f);
|
|
506
506
|
},
|
|
507
507
|
setItem: (p, u) => {
|
|
508
508
|
var g;
|
|
@@ -515,10 +515,10 @@ function createJSONStorage(o = () => {
|
|
|
515
515
|
var u;
|
|
516
516
|
return (u = o()) == null ? void 0 : u.removeItem(p);
|
|
517
517
|
}
|
|
518
|
-
}, c = (p) => (u, g, m) => p(u, (
|
|
518
|
+
}, c = (p) => (u, g, m) => p(u, (x) => {
|
|
519
519
|
let f;
|
|
520
520
|
try {
|
|
521
|
-
f = JSON.parse(
|
|
521
|
+
f = JSON.parse(x || "");
|
|
522
522
|
} catch {
|
|
523
523
|
f = m;
|
|
524
524
|
}
|
|
@@ -653,8 +653,6 @@ const activePanelAtom = atom$1("outline");
|
|
|
653
653
|
activePanelAtom.debugLabel = "activePanelAtom";
|
|
654
654
|
const showPredefinedBlockCategoryAtom = atom$1("");
|
|
655
655
|
showPredefinedBlockCategoryAtom.debugLabel = "showPredefinedBlockCategoryAtom";
|
|
656
|
-
const historyStatesAtom = atom$1({ undoCount: 0, redoCount: 0 });
|
|
657
|
-
historyStatesAtom.debugLabel = "historyStatesAtom";
|
|
658
656
|
const inlineEditingActiveAtom = atom$1("");
|
|
659
657
|
inlineEditingActiveAtom.debugLabel = "inlineEditingActiveAtom";
|
|
660
658
|
const draggingFlagAtom = atom$1(!1);
|
|
@@ -930,7 +928,22 @@ function requireUndomanager() {
|
|
|
930
928
|
}(undomanager)), undomanager.exports;
|
|
931
929
|
}
|
|
932
930
|
var undomanagerExports = requireUndomanager();
|
|
933
|
-
const UndoManager = /* @__PURE__ */ getDefaultExportFromCjs(undomanagerExports),
|
|
931
|
+
const UndoManager = /* @__PURE__ */ getDefaultExportFromCjs(undomanagerExports), chaiBuilderPropsAtom = atom$1(null);
|
|
932
|
+
chaiBuilderPropsAtom.debugLabel = "chaiBuilderPropsAtom";
|
|
933
|
+
const chaiExternalDataAtom = atom$1({});
|
|
934
|
+
chaiExternalDataAtom.debugLabel = "chaiExternalDataAtom";
|
|
935
|
+
const chaiRjsfFieldsAtom = atom$1({});
|
|
936
|
+
chaiRjsfFieldsAtom.debugLabel = "chaiRjsfFieldsAtom";
|
|
937
|
+
const chaiRjsfWidgetsAtom = atom$1({});
|
|
938
|
+
chaiRjsfWidgetsAtom.debugLabel = "chaiRjsfWidgetsAtom";
|
|
939
|
+
const chaiRjsfTemplatesAtom = atom$1({});
|
|
940
|
+
chaiRjsfTemplatesAtom.debugLabel = "chaiRjsfTemplatesAtom";
|
|
941
|
+
const chaiPageExternalDataAtom = atom$1({});
|
|
942
|
+
chaiPageExternalDataAtom.debugLabel = "chaiPageExternalDataAtom";
|
|
943
|
+
const usePageExternalData = () => useAtomValue$1(chaiPageExternalDataAtom), useBuilderProp = (o, n = void 0) => {
|
|
944
|
+
const r = useAtomValue$1(chaiBuilderPropsAtom);
|
|
945
|
+
return get(r, o, n);
|
|
946
|
+
}, MODIFIERS = [
|
|
934
947
|
"hover",
|
|
935
948
|
"focus",
|
|
936
949
|
"focus-within",
|
|
@@ -1003,21 +1016,12 @@ const useBrandingOptions = () => {
|
|
|
1003
1016
|
blocks: a
|
|
1004
1017
|
};
|
|
1005
1018
|
}, [o, n, r]);
|
|
1006
|
-
},
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
const chaiRjsfWidgetsAtom = atom$1({});
|
|
1013
|
-
chaiRjsfWidgetsAtom.debugLabel = "chaiRjsfWidgetsAtom";
|
|
1014
|
-
const chaiRjsfTemplatesAtom = atom$1({});
|
|
1015
|
-
chaiRjsfTemplatesAtom.debugLabel = "chaiRjsfTemplatesAtom";
|
|
1016
|
-
const chaiPageExternalDataAtom = atom$1({});
|
|
1017
|
-
chaiPageExternalDataAtom.debugLabel = "chaiPageExternalDataAtom";
|
|
1018
|
-
const usePageExternalData = () => useAtomValue$1(chaiPageExternalDataAtom), useBuilderProp = (o, n = void 0) => {
|
|
1019
|
-
const r = useAtomValue$1(chaiBuilderPropsAtom);
|
|
1020
|
-
return get(r, o, n);
|
|
1019
|
+
}, usePermissions = () => {
|
|
1020
|
+
const o = useBuilderProp("permissions", void 0);
|
|
1021
|
+
return { hasPermission: useCallback(
|
|
1022
|
+
(r) => o ? o.includes(r) : !0,
|
|
1023
|
+
[o]
|
|
1024
|
+
) };
|
|
1021
1025
|
}, getDefaultThemeValues = (o = defaultThemeOptions) => {
|
|
1022
1026
|
const n = {};
|
|
1023
1027
|
return o.fontFamily && (n.fontFamily = Object.entries(o.fontFamily).reduce(
|
|
@@ -1044,15 +1048,17 @@ const usePageExternalData = () => useAtomValue$1(chaiPageExternalDataAtom), useB
|
|
|
1044
1048
|
}, rightPanelAtom = atom$1("block"), useRightPanel = () => useAtom$1(rightPanelAtom), builderSaveStateAtom = atom$1("SAVED");
|
|
1045
1049
|
builderSaveStateAtom.debugLabel = "builderSaveStateAtom";
|
|
1046
1050
|
const useSavePage = () => {
|
|
1047
|
-
const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (
|
|
1048
|
-
}), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme();
|
|
1051
|
+
const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (p) => {
|
|
1052
|
+
}), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions();
|
|
1049
1053
|
return { savePage: useThrottledCallback(
|
|
1050
|
-
async (
|
|
1054
|
+
async (p = !1) => {
|
|
1055
|
+
if (!c("save_page"))
|
|
1056
|
+
return;
|
|
1051
1057
|
n("SAVING"), a("SAVING");
|
|
1052
|
-
const
|
|
1058
|
+
const u = l();
|
|
1053
1059
|
return await r({
|
|
1054
|
-
autoSave:
|
|
1055
|
-
blocks:
|
|
1060
|
+
autoSave: p,
|
|
1061
|
+
blocks: u.blocks,
|
|
1056
1062
|
theme: i
|
|
1057
1063
|
}), setTimeout(() => {
|
|
1058
1064
|
n("SAVED"), a("SAVED");
|
|
@@ -1152,15 +1158,15 @@ const useSelectedBlocksDisplayChild = () => ({
|
|
|
1152
1158
|
if (!p || !p._parent) return;
|
|
1153
1159
|
const u = p._parent, g = r.filter((m) => m._parent === u);
|
|
1154
1160
|
if (g.length === 2) {
|
|
1155
|
-
const m = g.find((
|
|
1161
|
+
const m = g.find((x) => x._id !== d);
|
|
1156
1162
|
if (m && m._type === "Text") {
|
|
1157
|
-
const
|
|
1158
|
-
|
|
1163
|
+
const x = r.find((f) => f._id === u);
|
|
1164
|
+
x && "content" in x && (r = r.map((f) => {
|
|
1159
1165
|
if (f._id === u) {
|
|
1160
|
-
const
|
|
1166
|
+
const h = { ...f, content: m.content };
|
|
1161
1167
|
return Object.keys(m).forEach((b) => {
|
|
1162
|
-
b.startsWith("content-") && (
|
|
1163
|
-
}),
|
|
1168
|
+
b.startsWith("content-") && (h[b] = m[b]);
|
|
1169
|
+
}), h;
|
|
1164
1170
|
}
|
|
1165
1171
|
return f;
|
|
1166
1172
|
}), a.push(m._id));
|
|
@@ -1170,14 +1176,15 @@ const useSelectedBlocksDisplayChild = () => ({
|
|
|
1170
1176
|
const l = [...n, ...a], i = [], c = filter(r, (d) => includes(l, d._id) || includes(l, d._parent) ? (i.push(d._id), !1) : !0);
|
|
1171
1177
|
return isEmpty(i) ? c : removeNestedBlocks(c, i);
|
|
1172
1178
|
}, useRemoveBlocks = () => {
|
|
1173
|
-
const [o] = useBlocksStore(), [n, r] = useSelectedBlockIds(), { setNewBlocks: a } = useBlocksStoreUndoableActions();
|
|
1179
|
+
const [o] = useBlocksStore(), [n, r] = useSelectedBlockIds(), { setNewBlocks: a } = useBlocksStoreUndoableActions(), { hasPermission: l } = usePermissions();
|
|
1174
1180
|
return useCallback(
|
|
1175
|
-
(
|
|
1176
|
-
var
|
|
1177
|
-
|
|
1178
|
-
|
|
1181
|
+
(i) => {
|
|
1182
|
+
var d;
|
|
1183
|
+
if (!l(PERMISSIONS.DELETE_BLOCK)) return;
|
|
1184
|
+
const c = ((d = find(o, { _id: i[0] })) == null ? void 0 : d._parent) || null;
|
|
1185
|
+
a(removeNestedBlocks(o, i)), setTimeout(() => r(c ? [c] : []), 200);
|
|
1179
1186
|
},
|
|
1180
|
-
[o, r, n]
|
|
1187
|
+
[o, r, n, l]
|
|
1181
1188
|
);
|
|
1182
1189
|
}, builderStore = getDefaultStore$1(), writeAtomValue = atom$1(
|
|
1183
1190
|
null,
|
|
@@ -1227,20 +1234,20 @@ function insertBlocksAtPosition(o, n, r, a) {
|
|
|
1227
1234
|
if (r) {
|
|
1228
1235
|
const u = o.find((g) => g._id === r);
|
|
1229
1236
|
if (u && u.content !== void 0 && u.content !== "" && !o.some((m) => m._parent === r)) {
|
|
1230
|
-
const
|
|
1237
|
+
const x = {
|
|
1231
1238
|
_id: generateUUID(),
|
|
1232
1239
|
_parent: r,
|
|
1233
1240
|
_type: "Text",
|
|
1234
1241
|
content: u.content
|
|
1235
1242
|
};
|
|
1236
1243
|
Object.keys(u).forEach((f) => {
|
|
1237
|
-
f.startsWith("content-") && (
|
|
1238
|
-
}), l.unshift(
|
|
1244
|
+
f.startsWith("content-") && (x[f] = u[f]);
|
|
1245
|
+
}), l.unshift(x), i = i.map((f) => {
|
|
1239
1246
|
if (f._id === r) {
|
|
1240
|
-
const
|
|
1241
|
-
return Object.keys(
|
|
1242
|
-
b.startsWith("content-") && (
|
|
1243
|
-
}),
|
|
1247
|
+
const h = { ...f, content: "" };
|
|
1248
|
+
return Object.keys(h).forEach((b) => {
|
|
1249
|
+
b.startsWith("content-") && (h[b] = "");
|
|
1250
|
+
}), h;
|
|
1244
1251
|
}
|
|
1245
1252
|
return f;
|
|
1246
1253
|
});
|
|
@@ -1390,65 +1397,65 @@ const useBlocksStoreManager = () => {
|
|
|
1390
1397
|
updateBlocksProps: c
|
|
1391
1398
|
} = useBlocksStoreManager();
|
|
1392
1399
|
return {
|
|
1393
|
-
moveBlocks: (
|
|
1394
|
-
const
|
|
1395
|
-
const
|
|
1396
|
-
return { _id:
|
|
1397
|
-
}),
|
|
1398
|
-
|
|
1399
|
-
undo: () => each(
|
|
1400
|
-
i([
|
|
1400
|
+
moveBlocks: (h, b, k) => {
|
|
1401
|
+
const A = map(h, (C) => {
|
|
1402
|
+
const _ = n.find((L) => L._id === C)._parent || null, w = n.filter((L) => _ ? L._parent === _ : !L._parent).map((L) => L._id).indexOf(C);
|
|
1403
|
+
return { _id: C, oldParent: _, oldPosition: w };
|
|
1404
|
+
}), B = A.find(({ _id: C }) => C === h[0]);
|
|
1405
|
+
B && B.oldParent === b && B.oldPosition === k || (i(h, b, k), o({
|
|
1406
|
+
undo: () => each(A, ({ _id: C, oldParent: j, oldPosition: _ }) => {
|
|
1407
|
+
i([C], j, _);
|
|
1401
1408
|
}),
|
|
1402
|
-
redo: () => i(
|
|
1409
|
+
redo: () => i(h, b, k)
|
|
1403
1410
|
}));
|
|
1404
1411
|
},
|
|
1405
|
-
addBlocks: (
|
|
1406
|
-
a(
|
|
1407
|
-
undo: () => l(map(
|
|
1408
|
-
redo: () => a(
|
|
1412
|
+
addBlocks: (h, b, k) => {
|
|
1413
|
+
a(h, b, k), o({
|
|
1414
|
+
undo: () => l(map(h, "_id")),
|
|
1415
|
+
redo: () => a(h, b, k)
|
|
1409
1416
|
});
|
|
1410
1417
|
},
|
|
1411
|
-
removeBlocks: (
|
|
1412
|
-
var
|
|
1413
|
-
const b = (
|
|
1414
|
-
l(map(
|
|
1415
|
-
undo: () => a(
|
|
1416
|
-
redo: () => l(map(
|
|
1418
|
+
removeBlocks: (h) => {
|
|
1419
|
+
var B;
|
|
1420
|
+
const b = (B = first(h)) == null ? void 0 : B._parent, A = n.filter((C) => b ? C._parent === b : !C._parent).indexOf(first(h));
|
|
1421
|
+
l(map(h, "_id")), o({
|
|
1422
|
+
undo: () => a(h, b, A),
|
|
1423
|
+
redo: () => l(map(h, "_id"))
|
|
1417
1424
|
});
|
|
1418
1425
|
},
|
|
1419
|
-
updateBlocks: (
|
|
1420
|
-
let
|
|
1421
|
-
if (
|
|
1422
|
-
|
|
1426
|
+
updateBlocks: (h, b, k) => {
|
|
1427
|
+
let A = [];
|
|
1428
|
+
if (k)
|
|
1429
|
+
A = map(h, (B) => ({ _id: B, ...k }));
|
|
1423
1430
|
else {
|
|
1424
|
-
const
|
|
1425
|
-
|
|
1426
|
-
const
|
|
1427
|
-
return each(
|
|
1431
|
+
const B = keys(b);
|
|
1432
|
+
A = map(h, (C) => {
|
|
1433
|
+
const j = n.find((S) => S._id === C), _ = { _id: C };
|
|
1434
|
+
return each(B, (S) => _[S] = j[S]), _;
|
|
1428
1435
|
});
|
|
1429
1436
|
}
|
|
1430
|
-
c(map(
|
|
1431
|
-
undo: () => c(
|
|
1432
|
-
redo: () => c(map(
|
|
1437
|
+
c(map(h, (B) => ({ _id: B, ...b }))), o({
|
|
1438
|
+
undo: () => c(A),
|
|
1439
|
+
redo: () => c(map(h, (B) => ({ _id: B, ...b })))
|
|
1433
1440
|
});
|
|
1434
1441
|
},
|
|
1435
|
-
updateBlocksRuntime: (
|
|
1436
|
-
c(map(
|
|
1442
|
+
updateBlocksRuntime: (h, b) => {
|
|
1443
|
+
c(map(h, (k) => ({ _id: k, ...b })));
|
|
1437
1444
|
},
|
|
1438
|
-
setNewBlocks: (
|
|
1439
|
-
r(
|
|
1445
|
+
setNewBlocks: (h) => {
|
|
1446
|
+
r(h), o({
|
|
1440
1447
|
undo: () => r(n),
|
|
1441
|
-
redo: () => r(
|
|
1448
|
+
redo: () => r(h)
|
|
1442
1449
|
});
|
|
1443
1450
|
},
|
|
1444
|
-
updateMultipleBlocksProps: (
|
|
1451
|
+
updateMultipleBlocksProps: (h) => {
|
|
1445
1452
|
let b = [];
|
|
1446
|
-
b = map(
|
|
1447
|
-
const
|
|
1448
|
-
return each(
|
|
1449
|
-
}), c(
|
|
1453
|
+
b = map(h, (k) => {
|
|
1454
|
+
const A = keys(k), B = n.find((j) => j._id === k._id), C = {};
|
|
1455
|
+
return each(A, (j) => C[j] = B[j]), C;
|
|
1456
|
+
}), c(h), o({
|
|
1450
1457
|
undo: () => c(b),
|
|
1451
|
-
redo: () => c(
|
|
1458
|
+
redo: () => c(h)
|
|
1452
1459
|
});
|
|
1453
1460
|
}
|
|
1454
1461
|
};
|
|
@@ -1484,17 +1491,17 @@ import.meta.vitest && describe("canDropBlock Function", () => {
|
|
|
1484
1491
|
const useAddBlock = () => {
|
|
1485
1492
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
1486
1493
|
(i, c, d) => {
|
|
1487
|
-
var
|
|
1494
|
+
var x;
|
|
1488
1495
|
for (let f = 0; f < i.length; f++) {
|
|
1489
|
-
const { _id:
|
|
1496
|
+
const { _id: h } = i[f];
|
|
1490
1497
|
i[f]._id = generateUUID();
|
|
1491
|
-
const b = filter(i, { _parent:
|
|
1492
|
-
for (let
|
|
1493
|
-
b[
|
|
1498
|
+
const b = filter(i, { _parent: h });
|
|
1499
|
+
for (let k = 0; k < b.length; k++)
|
|
1500
|
+
b[k]._parent = i[f]._id;
|
|
1494
1501
|
}
|
|
1495
1502
|
const p = first(i);
|
|
1496
1503
|
let u, g;
|
|
1497
|
-
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([(
|
|
1504
|
+
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([(x = first(i)) == null ? void 0 : x._id]), first(i);
|
|
1498
1505
|
},
|
|
1499
1506
|
[r, o, n]
|
|
1500
1507
|
);
|
|
@@ -1511,8 +1518,8 @@ const useAddBlock = () => {
|
|
|
1511
1518
|
...has(i, "_name") && { _name: i._name },
|
|
1512
1519
|
...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
|
|
1513
1520
|
};
|
|
1514
|
-
let m,
|
|
1515
|
-
return c && (m = find(o, { _id: c }), g._parent = c,
|
|
1521
|
+
let m, x;
|
|
1522
|
+
return c && (m = find(o, { _id: c }), g._parent = c, x = c), !canAcceptChildBlock(m == null ? void 0 : m._type, g._type) && m && (g._parent = m._parent, x = m._parent), r([g], x, d), n([g._id]), g;
|
|
1516
1523
|
},
|
|
1517
1524
|
[r, a, o, n]
|
|
1518
1525
|
), addPredefinedBlock: a };
|
|
@@ -2958,41 +2965,41 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2958
2965
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
2959
2966
|
})
|
|
2960
2967
|
), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
|
|
2961
|
-
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 = (
|
|
2962
|
-
const
|
|
2963
|
-
for (const b in
|
|
2964
|
-
const
|
|
2965
|
-
if (typeof
|
|
2966
|
-
const { baseClasses:
|
|
2967
|
-
|
|
2968
|
+
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 = (x, f) => {
|
|
2969
|
+
const h = cloneDeep(f.find((b) => b._id === x));
|
|
2970
|
+
for (const b in h) {
|
|
2971
|
+
const k = h[b];
|
|
2972
|
+
if (typeof k == "string" && startsWith(k, STYLES_KEY)) {
|
|
2973
|
+
const { baseClasses: A, classes: B } = getSplitChaiClasses(k);
|
|
2974
|
+
h[b] = compact(flattenDeep([A, B])).join(" ");
|
|
2968
2975
|
} else
|
|
2969
|
-
b !== "_id" && delete
|
|
2976
|
+
b !== "_id" && delete h[b];
|
|
2970
2977
|
}
|
|
2971
|
-
return
|
|
2978
|
+
return h;
|
|
2972
2979
|
};
|
|
2973
2980
|
return {
|
|
2974
2981
|
askAi: useCallback(
|
|
2975
|
-
async (
|
|
2982
|
+
async (x, f, h, b) => {
|
|
2976
2983
|
if (l) {
|
|
2977
2984
|
n(!0), a(null);
|
|
2978
2985
|
try {
|
|
2979
|
-
const
|
|
2980
|
-
if (
|
|
2981
|
-
a(
|
|
2986
|
+
const k = p === u ? "" : p, A = x === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [m(f, d)], B = await l(x, addLangToPrompt(h, g, x), A, k), { blocks: C, error: j } = B;
|
|
2987
|
+
if (j) {
|
|
2988
|
+
a(j);
|
|
2982
2989
|
return;
|
|
2983
2990
|
}
|
|
2984
|
-
if (
|
|
2985
|
-
const
|
|
2986
|
-
for (const
|
|
2987
|
-
|
|
2991
|
+
if (x === "styles") {
|
|
2992
|
+
const _ = C.map((S) => {
|
|
2993
|
+
for (const w in S)
|
|
2994
|
+
w !== "_id" && (S[w] = `${STYLES_KEY},${S[w]}`);
|
|
2988
2995
|
return S;
|
|
2989
2996
|
});
|
|
2990
|
-
c(
|
|
2997
|
+
c(_);
|
|
2991
2998
|
} else
|
|
2992
|
-
i(
|
|
2993
|
-
b && b(
|
|
2994
|
-
} catch (
|
|
2995
|
-
a(
|
|
2999
|
+
i(C);
|
|
3000
|
+
b && b(B);
|
|
3001
|
+
} catch (k) {
|
|
3002
|
+
a(k);
|
|
2996
3003
|
} finally {
|
|
2997
3004
|
n(!1), b && b();
|
|
2998
3005
|
}
|
|
@@ -3083,9 +3090,9 @@ const useBlockHighlight = () => {
|
|
|
3083
3090
|
d();
|
|
3084
3091
|
}, []), { data: l, isLoading: o, refetch: d, error: r };
|
|
3085
3092
|
}, useBuilderReset = () => {
|
|
3086
|
-
const
|
|
3093
|
+
const { clear: o } = useUndoManager(), [, n] = useSelectedBlockIds(), { clearHighlight: r } = useBlockHighlight(), [, a] = useSelectedStylingBlocks(), [, l] = useAtom(aiAssistantActiveAtom), { reset: i } = usePartailBlocksStore(), { setSaveState: c } = useSavePage();
|
|
3087
3094
|
return () => {
|
|
3088
|
-
|
|
3095
|
+
n([]), a([]), r(), o(), l(!1), i(), c("SAVED");
|
|
3089
3096
|
};
|
|
3090
3097
|
}, canvasZoomAtom = atomWithStorage("canvasZoom", 100), useCanvasZoom = () => useAtom$1(canvasZoomAtom), codeEditorAtom = atom$1(null), useCodeEditor = () => useAtom$1(codeEditorAtom), cutBlockIdsAtom = atom$1([]), useCutBlockIds = () => {
|
|
3091
3098
|
const [o, n] = useAtom$1(cutBlockIdsAtom), r = useSetAtom$1(copiedBlockIdsAtom), a = useCallback(
|
|
@@ -3131,11 +3138,11 @@ const useBlockHighlight = () => {
|
|
|
3131
3138
|
(a, l = null) => {
|
|
3132
3139
|
const i = [];
|
|
3133
3140
|
each(a, (c) => {
|
|
3134
|
-
const d = o.find((
|
|
3141
|
+
const d = o.find((x) => x._id === c);
|
|
3135
3142
|
l ? l === "root" && (l = null) : l = d._parent;
|
|
3136
3143
|
const g = filter(
|
|
3137
3144
|
o,
|
|
3138
|
-
(
|
|
3145
|
+
(x) => isString(l) ? x._parent === l : !x._parent
|
|
3139
3146
|
).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
|
|
3140
3147
|
r(m, l, g), i.push(get(m, "0._id", ""));
|
|
3141
3148
|
}), n(i);
|
|
@@ -3231,12 +3238,12 @@ const useBlockHighlight = () => {
|
|
|
3231
3238
|
const d = o(c), p = a;
|
|
3232
3239
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
3233
3240
|
return each(p, (m) => {
|
|
3234
|
-
const
|
|
3241
|
+
const x = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${x}(?=\\s|$)`, "g");
|
|
3235
3242
|
u = u.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
3236
|
-
const
|
|
3237
|
-
includes(["2xl", "xl", "lg", "md", "sm"],
|
|
3243
|
+
const h = first(m.split(":"));
|
|
3244
|
+
includes(["2xl", "xl", "lg", "md", "sm"], h) && p.push(m.split(":").pop().trim());
|
|
3238
3245
|
}), each(p, (m) => {
|
|
3239
|
-
const
|
|
3246
|
+
const x = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${x}(?=\\s|$)`, "g");
|
|
3240
3247
|
g = g.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
3241
3248
|
}), {
|
|
3242
3249
|
ids: [d._id],
|
|
@@ -3323,136 +3330,53 @@ wrapperBlockAtom.debugLabel = "wrapperBlockAtom";
|
|
|
3323
3330
|
const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), layoutVariantAtom = atomWithStorage("_layout_variant_mode", "DUAL_SIDE_PANEL"), useLayoutVariant = () => {
|
|
3324
3331
|
const [o, n] = useAtom$1(layoutVariantAtom), r = useBuilderProp("layoutVariant", "DUAL_SIDE_PANEL");
|
|
3325
3332
|
return [o || r, n];
|
|
3326
|
-
}, draggedBlockAtom = atom$1(null), dropTargetBlockIdAtom = atom$1(null);
|
|
3327
|
-
class PubSub {
|
|
3328
|
-
constructor() {
|
|
3329
|
-
V(this, "subscribers", /* @__PURE__ */ new Map());
|
|
3330
|
-
}
|
|
3331
|
-
subscribe(n, r) {
|
|
3332
|
-
return this.subscribers.has(n) || this.subscribers.set(n, /* @__PURE__ */ new Set()), this.subscribers.get(n).add(r), () => {
|
|
3333
|
-
const a = this.subscribers.get(n);
|
|
3334
|
-
a && (a.delete(r), a.size === 0 && this.subscribers.delete(n));
|
|
3335
|
-
};
|
|
3336
|
-
}
|
|
3337
|
-
publish(n, r) {
|
|
3338
|
-
const a = this.subscribers.get(n);
|
|
3339
|
-
a && a.forEach((l) => l(r));
|
|
3340
|
-
}
|
|
3341
|
-
}
|
|
3342
|
-
const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
3343
|
-
const { t: r } = useTranslation(), [a] = useBlocksStore(), l = get(o, "_id"), i = get(o, "_parent"), c = filter(a, (g) => i ? get(g, "_parent") === i : !get(g, "_parent")), d = canAddChildBlock(get(o, "_type", "")), p = findIndex(c, { _id: l }), u = (g) => {
|
|
3344
|
-
if (g === "CHILD")
|
|
3345
|
-
pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
|
|
3346
|
-
else {
|
|
3347
|
-
const m = { _id: i || "", position: c == null ? void 0 : c.length };
|
|
3348
|
-
g === "BEFORE" ? m.position = Math.max(p, 0) : g === "AFTER" && (m.position = p + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, m);
|
|
3349
|
-
}
|
|
3350
|
-
};
|
|
3351
|
-
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
3352
|
-
/* @__PURE__ */ jsx(DropdownMenuTrigger, { children: n }),
|
|
3353
|
-
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "border border-blue-500 bg-blue-500 text-white shadow-2xl", children: [
|
|
3354
|
-
d && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => u("CHILD"), children: r("Add inside") }),
|
|
3355
|
-
/* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => u("BEFORE"), children: r("Add before") }),
|
|
3356
|
-
/* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => u("AFTER"), children: r("Add after") })
|
|
3357
|
-
] })
|
|
3358
|
-
] });
|
|
3359
3333
|
};
|
|
3360
|
-
function getOrientation(o) {
|
|
3361
|
-
const
|
|
3362
|
-
if (
|
|
3363
|
-
const
|
|
3364
|
-
return
|
|
3365
|
-
} else if (
|
|
3366
|
-
const
|
|
3367
|
-
return
|
|
3368
|
-
|
|
3369
|
-
} else if (
|
|
3370
|
-
return "
|
|
3371
|
-
return "
|
|
3372
|
-
}
|
|
3373
|
-
if (import.meta.vitest) {
|
|
3374
|
-
const { test: o, expect: n } = import.meta.vitest;
|
|
3375
|
-
o("getOrientation default div should be vertical", () => {
|
|
3376
|
-
n(getOrientation(document.createElement("div"))).toBe("vertical");
|
|
3377
|
-
}), o("getOrientation flex with default direction should be horizontal", () => {
|
|
3378
|
-
const r = document.createElement("div");
|
|
3379
|
-
r.style.display = "flex", n(getOrientation(r)).toBe("horizontal");
|
|
3380
|
-
}), o("getOrientation inline-flex with default direction should be horizontal", () => {
|
|
3381
|
-
const r = document.createElement("div");
|
|
3382
|
-
r.style.display = "inline-flex", n(getOrientation(r)).toBe("horizontal");
|
|
3383
|
-
}), o("getOrientation flex with row direction should be horizontal", () => {
|
|
3384
|
-
const r = document.createElement("div");
|
|
3385
|
-
r.style.display = "flex", r.style.flexDirection = "row", n(getOrientation(r)).toBe("horizontal");
|
|
3386
|
-
}), o("getOrientation flex with row-reverse direction should be horizontal", () => {
|
|
3387
|
-
const r = document.createElement("div");
|
|
3388
|
-
r.style.display = "flex", r.style.flexDirection = "row-reverse", n(getOrientation(r)).toBe("horizontal");
|
|
3389
|
-
}), o("getOrientation flex with column direction should be vertical", () => {
|
|
3390
|
-
const r = document.createElement("div");
|
|
3391
|
-
r.style.display = "flex", r.style.flexDirection = "column", n(getOrientation(r)).toBe("vertical");
|
|
3392
|
-
}), o("getOrientation flex with column-reverse direction should be vertical", () => {
|
|
3393
|
-
const r = document.createElement("div");
|
|
3394
|
-
r.style.display = "flex", r.style.flexDirection = "column-reverse", n(getOrientation(r)).toBe("vertical");
|
|
3395
|
-
}), o("getOrientation grid with default settings should be horizontal", () => {
|
|
3396
|
-
const r = document.createElement("div");
|
|
3397
|
-
r.style.display = "grid", n(getOrientation(r)).toBe("horizontal");
|
|
3398
|
-
}), o("getOrientation grid with row auto-flow should be horizontal", () => {
|
|
3399
|
-
const r = document.createElement("div");
|
|
3400
|
-
r.style.display = "grid", r.style.gridAutoFlow = "row", n(getOrientation(r)).toBe("horizontal");
|
|
3401
|
-
}), o("getOrientation grid with column auto-flow should be vertical", () => {
|
|
3402
|
-
const r = document.createElement("div");
|
|
3403
|
-
r.style.display = "grid", r.style.gridAutoFlow = "column", n(getOrientation(r)).toBe("vertical");
|
|
3404
|
-
}), o("getOrientation grid with dense column auto-flow should be vertical", () => {
|
|
3405
|
-
const r = document.createElement("div");
|
|
3406
|
-
r.style.display = "grid", r.style.gridAutoFlow = "column dense", n(getOrientation(r)).toBe("vertical");
|
|
3407
|
-
}), o("getOrientation grid with single column should be vertical", () => {
|
|
3408
|
-
const r = document.createElement("div");
|
|
3409
|
-
r.style.display = "grid", r.style.gridTemplateColumns = "1fr", n(getOrientation(r)).toBe("vertical");
|
|
3410
|
-
}), o("getOrientation grid with multiple columns should be horizontal", () => {
|
|
3411
|
-
const r = document.createElement("div");
|
|
3412
|
-
r.style.display = "grid", r.style.gridTemplateColumns = "1fr 1fr", n(getOrientation(r)).toBe("horizontal");
|
|
3413
|
-
}), o("getOrientation block should be vertical", () => {
|
|
3414
|
-
const r = document.createElement("div");
|
|
3415
|
-
r.style.display = "block", n(getOrientation(r)).toBe("vertical");
|
|
3416
|
-
}), o("getOrientation inline-block should be vertical", () => {
|
|
3417
|
-
const r = document.createElement("div");
|
|
3418
|
-
r.style.display = "inline-block", n(getOrientation(r)).toBe("vertical");
|
|
3419
|
-
}), o("getOrientation inline should be horizontal", () => {
|
|
3420
|
-
const r = document.createElement("div");
|
|
3421
|
-
r.style.display = "inline", n(getOrientation(r)).toBe("horizontal");
|
|
3422
|
-
}), o("getOrientation table should be horizontal", () => {
|
|
3423
|
-
const r = document.createElement("div");
|
|
3424
|
-
r.style.display = "table", n(getOrientation(r)).toBe("horizontal");
|
|
3425
|
-
});
|
|
3334
|
+
function getOrientation(o, n = null) {
|
|
3335
|
+
const r = window.getComputedStyle(o), a = n ? window.getComputedStyle(n) : null, l = r.display, i = a ? a.display : null;
|
|
3336
|
+
if (l === "flex" || l === "inline-flex") {
|
|
3337
|
+
const c = r.flexDirection;
|
|
3338
|
+
return c === "column" || c === "column-reverse" ? "vertical" : "horizontal";
|
|
3339
|
+
} else if (l === "grid") {
|
|
3340
|
+
const c = r.gridAutoFlow, d = r.gridTemplateColumns;
|
|
3341
|
+
return c.includes("column") || d && d !== "none" && d !== "" && !d.includes("calc") && // Handle calc expressions
|
|
3342
|
+
d.split(" ").length <= 1 ? "vertical" : "horizontal";
|
|
3343
|
+
} else if (i === "inline-block" || i === "inline")
|
|
3344
|
+
return "horizontal";
|
|
3345
|
+
return "vertical";
|
|
3426
3346
|
}
|
|
3427
3347
|
const CONTROLS = [
|
|
3428
3348
|
{ ControlIcon: PinTopIcon, dir: "VERTICAL", key: "UP" },
|
|
3429
3349
|
{ ControlIcon: PinBottomIcon, dir: "VERTICAL", key: "DOWN" },
|
|
3430
3350
|
{ ControlIcon: PinLeftIcon, dir: "HORIZONTAL", key: "LEFT" },
|
|
3431
3351
|
{ ControlIcon: PinRightIcon, dir: "HORIZONTAL", key: "RIGHT" }
|
|
3432
|
-
], getParentBlockOrientation = (o, n) => {
|
|
3352
|
+
], getParentBlockOrientation = (o, n, r) => {
|
|
3433
3353
|
try {
|
|
3434
|
-
if (!o || !
|
|
3435
|
-
const
|
|
3436
|
-
|
|
3354
|
+
if (!o || !r) return "VERTICAL";
|
|
3355
|
+
const a = `[data-block-id='${o}']`, l = r == null ? void 0 : r.querySelector(a);
|
|
3356
|
+
if (l) {
|
|
3357
|
+
const i = r == null ? void 0 : r.querySelector(`[data-block-id='${n}']`);
|
|
3358
|
+
return getOrientation(l, i).toUpperCase();
|
|
3359
|
+
}
|
|
3360
|
+
return "VERTICAL";
|
|
3437
3361
|
} catch {
|
|
3438
3362
|
return "VERTICAL";
|
|
3439
3363
|
}
|
|
3440
3364
|
}, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
|
|
3441
|
-
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (
|
|
3442
|
-
(
|
|
3443
|
-
isDisabledControl(g, m,
|
|
3365
|
+
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (h) => c ? get(h, "_parent") === c : !get(h, "_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), x = getParentBlockOrientation(c, i, a), f = useCallback(
|
|
3366
|
+
(h) => {
|
|
3367
|
+
isDisabledControl(g, m, h) || p || (h === "UP" || h === "LEFT" ? l([i], c || null, u - 1) : (h === "DOWN" || h === "RIGHT") && l([i], c || null, u + 2), n());
|
|
3444
3368
|
},
|
|
3445
3369
|
[g, m, p, u, i, c, n]
|
|
3446
3370
|
);
|
|
3447
3371
|
return useHotkeys(
|
|
3448
3372
|
"shift+up, shift+down, shift+left, shift+right",
|
|
3449
|
-
({ key:
|
|
3373
|
+
({ key: h }) => {
|
|
3450
3374
|
var b;
|
|
3451
|
-
f((b =
|
|
3375
|
+
f((b = h == null ? void 0 : h.replace("Arrow", "")) == null ? void 0 : b.toUpperCase());
|
|
3452
3376
|
},
|
|
3453
3377
|
{ document: a == null ? void 0 : a.contentDocument },
|
|
3454
3378
|
[f]
|
|
3455
|
-
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: f, orientation:
|
|
3379
|
+
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: f, orientation: x };
|
|
3456
3380
|
}, BlockController = ({ block: o, updateFloatingBar: n }) => {
|
|
3457
3381
|
const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
|
|
3458
3382
|
o,
|
|
@@ -3470,7 +3394,40 @@ const CONTROLS = [
|
|
|
3470
3394
|
u
|
|
3471
3395
|
);
|
|
3472
3396
|
}) });
|
|
3473
|
-
}
|
|
3397
|
+
};
|
|
3398
|
+
class PubSub {
|
|
3399
|
+
constructor() {
|
|
3400
|
+
V(this, "subscribers", /* @__PURE__ */ new Map());
|
|
3401
|
+
}
|
|
3402
|
+
subscribe(n, r) {
|
|
3403
|
+
return this.subscribers.has(n) || this.subscribers.set(n, /* @__PURE__ */ new Set()), this.subscribers.get(n).add(r), () => {
|
|
3404
|
+
const a = this.subscribers.get(n);
|
|
3405
|
+
a && (a.delete(r), a.size === 0 && this.subscribers.delete(n));
|
|
3406
|
+
};
|
|
3407
|
+
}
|
|
3408
|
+
publish(n, r) {
|
|
3409
|
+
const a = this.subscribers.get(n);
|
|
3410
|
+
a && a.forEach((l) => l(r));
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3413
|
+
const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
3414
|
+
const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (m) => c ? get(m, "_parent") === c : !get(m, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), g = (m) => {
|
|
3415
|
+
if (m === "CHILD")
|
|
3416
|
+
pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
|
|
3417
|
+
else {
|
|
3418
|
+
const x = { _id: c || "", position: d == null ? void 0 : d.length };
|
|
3419
|
+
m === "BEFORE" ? x.position = Math.max(u, 0) : m === "AFTER" && (x.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, x);
|
|
3420
|
+
}
|
|
3421
|
+
};
|
|
3422
|
+
return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
3423
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { children: n }),
|
|
3424
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "border border-blue-500 bg-blue-500 text-white shadow-2xl", children: [
|
|
3425
|
+
p && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("CHILD"), children: r("Add inside") }),
|
|
3426
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("BEFORE"), children: r("Add before") }),
|
|
3427
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("AFTER"), children: r("Add after") })
|
|
3428
|
+
] })
|
|
3429
|
+
] }) : null;
|
|
3430
|
+
}, draggedBlockAtom = atom$1(null), dropTargetBlockIdAtom = atom$1(null), BlockActionLabel = ({ block: o, label: n }) => {
|
|
3474
3431
|
const [, r] = useSelectedBlockIds(), [, a] = useHighlightBlockId(), [, l] = useAtom$1(draggedBlockAtom), i = useFeature("dnd");
|
|
3475
3432
|
return /* @__PURE__ */ jsxs(
|
|
3476
3433
|
"div",
|
|
@@ -3489,46 +3446,46 @@ const CONTROLS = [
|
|
|
3489
3446
|
}
|
|
3490
3447
|
);
|
|
3491
3448
|
}, BlockFloatingSelector = ({ selectedBlockElement: o, block: n }) => {
|
|
3492
|
-
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), [
|
|
3449
|
+
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: x } = useFloating({
|
|
3493
3450
|
placement: "top-start",
|
|
3494
3451
|
middleware: [shift(), flip()],
|
|
3495
3452
|
elements: {
|
|
3496
3453
|
reference: o
|
|
3497
3454
|
}
|
|
3498
3455
|
});
|
|
3499
|
-
useResizeObserver(o, () =>
|
|
3500
|
-
const
|
|
3501
|
-
return !o || !n ||
|
|
3456
|
+
useResizeObserver(o, () => x(), o !== null), useResizeObserver(u == null ? void 0 : u.body, () => x(), (u == null ? void 0 : u.body) !== null);
|
|
3457
|
+
const f = get(n, "_parent", null), h = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
|
|
3458
|
+
return !o || !n || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
3502
3459
|
"div",
|
|
3503
3460
|
{
|
|
3504
3461
|
role: "button",
|
|
3505
3462
|
tabIndex: 0,
|
|
3506
|
-
ref:
|
|
3507
|
-
style:
|
|
3508
|
-
onClick: (
|
|
3509
|
-
|
|
3463
|
+
ref: m.setFloating,
|
|
3464
|
+
style: g,
|
|
3465
|
+
onClick: (b) => {
|
|
3466
|
+
b.stopPropagation(), b.preventDefault();
|
|
3510
3467
|
},
|
|
3511
|
-
onMouseEnter: (
|
|
3512
|
-
|
|
3468
|
+
onMouseEnter: (b) => {
|
|
3469
|
+
b.stopPropagation(), i(null);
|
|
3513
3470
|
},
|
|
3514
|
-
onKeyDown: (
|
|
3471
|
+
onKeyDown: (b) => b.stopPropagation(),
|
|
3515
3472
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3516
3473
|
children: [
|
|
3517
|
-
|
|
3474
|
+
f && /* @__PURE__ */ jsx(
|
|
3518
3475
|
ArrowUpIcon,
|
|
3519
3476
|
{
|
|
3520
3477
|
className: "hover:scale-105",
|
|
3521
3478
|
onClick: () => {
|
|
3522
|
-
c([]), l([
|
|
3479
|
+
c([]), l([f]);
|
|
3523
3480
|
}
|
|
3524
3481
|
}
|
|
3525
3482
|
),
|
|
3526
|
-
/* @__PURE__ */ jsx(BlockActionLabel, { label:
|
|
3483
|
+
/* @__PURE__ */ jsx(BlockActionLabel, { label: h, block: n }),
|
|
3527
3484
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
|
|
3528
3485
|
/* @__PURE__ */ jsx(AddBlockDropdown, { block: n, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
|
|
3529
|
-
canDuplicateBlock(get(n, "_type", "")) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([n == null ? void 0 : n._id]) }) : null,
|
|
3530
|
-
canDeleteBlock(get(n, "_type", "")) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([n == null ? void 0 : n._id]) }) : null,
|
|
3531
|
-
/* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar:
|
|
3486
|
+
canDuplicateBlock(get(n, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([n == null ? void 0 : n._id]) }) : null,
|
|
3487
|
+
canDeleteBlock(get(n, "_type", "")) && d(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([n == null ? void 0 : n._id]) }) : null,
|
|
3488
|
+
d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar: x })
|
|
3532
3489
|
] })
|
|
3533
3490
|
]
|
|
3534
3491
|
}
|
|
@@ -3589,15 +3546,15 @@ const CONTROLS = [
|
|
|
3589
3546
|
<div class="frame-root h-full"></div>
|
|
3590
3547
|
</body>
|
|
3591
3548
|
</html>`, useKeyEventWatcher = (o) => {
|
|
3592
|
-
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(),
|
|
3549
|
+
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), x = o ? { document: o } : {};
|
|
3593
3550
|
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(
|
|
3594
3551
|
"ctrl+v,command+v",
|
|
3595
3552
|
() => {
|
|
3596
3553
|
g(n[0]) && m(n);
|
|
3597
3554
|
},
|
|
3598
|
-
{ ...
|
|
3555
|
+
{ ...x, preventDefault: !0 },
|
|
3599
3556
|
[n, g, m]
|
|
3600
|
-
), useHotkeys("esc", () => r([]),
|
|
3557
|
+
), useHotkeys("esc", () => r([]), x, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...x, preventDefault: !0 }, [
|
|
3601
3558
|
n,
|
|
3602
3559
|
i
|
|
3603
3560
|
]), useHotkeys(
|
|
@@ -3605,25 +3562,22 @@ const CONTROLS = [
|
|
|
3605
3562
|
(f) => {
|
|
3606
3563
|
f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
|
|
3607
3564
|
},
|
|
3608
|
-
|
|
3565
|
+
x,
|
|
3609
3566
|
[n, l]
|
|
3610
3567
|
);
|
|
3611
3568
|
}, KeyboardHandler = () => {
|
|
3612
3569
|
const { document: o } = useFrame();
|
|
3613
3570
|
return useKeyEventWatcher(o), null;
|
|
3614
|
-
}, CHAI_BUILDER_EVENTS = {
|
|
3615
|
-
OPEN_ADD_BLOCK: "OPEN_ADD_BLOCK",
|
|
3616
|
-
CLOSE_ADD_BLOCK: "CLOSE_ADD_BLOCK",
|
|
3617
|
-
SHOW_BLOCK_SETTINGS: "SHOW_BLOCK_SETTINGS"
|
|
3618
3571
|
}, AddBlockAtBottom = () => {
|
|
3619
|
-
const { t: o } = useTranslation();
|
|
3620
|
-
return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer py-2", children: [
|
|
3572
|
+
const { t: o } = useTranslation(), { hasPermission: n } = usePermissions();
|
|
3573
|
+
return n(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer py-2", children: [
|
|
3621
3574
|
/* @__PURE__ */ jsx("br", {}),
|
|
3622
3575
|
/* @__PURE__ */ jsx(
|
|
3623
3576
|
"div",
|
|
3624
3577
|
{
|
|
3578
|
+
role: "button",
|
|
3625
3579
|
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK),
|
|
3626
|
-
className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
|
|
3580
|
+
className: "block h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
|
|
3627
3581
|
children: /* @__PURE__ */ jsxs("div", { className: "absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-purple-500 px-3 py-1 text-xs leading-tight text-white hover:bg-purple-500", children: [
|
|
3628
3582
|
/* @__PURE__ */ jsx(PlusIcon$1, { className: "size-2.5 stroke-[3]" }),
|
|
3629
3583
|
" ",
|
|
@@ -3632,7 +3586,7 @@ const CONTROLS = [
|
|
|
3632
3586
|
}
|
|
3633
3587
|
),
|
|
3634
3588
|
/* @__PURE__ */ jsx("br", {})
|
|
3635
|
-
] });
|
|
3589
|
+
] }) : null;
|
|
3636
3590
|
};
|
|
3637
3591
|
let iframeDocument = null, possiblePositions = [], dropTarget = null, dropIndex = null;
|
|
3638
3592
|
const positionPlaceholder = (o, n, r) => {
|
|
@@ -3688,33 +3642,33 @@ const useDnd = () => {
|
|
|
3688
3642
|
};
|
|
3689
3643
|
return iframeDocument = o, {
|
|
3690
3644
|
isDragging: n,
|
|
3691
|
-
onDragOver: (
|
|
3692
|
-
|
|
3645
|
+
onDragOver: (x) => {
|
|
3646
|
+
x.preventDefault(), x.stopPropagation(), throttledDragOver(x);
|
|
3693
3647
|
},
|
|
3694
|
-
onDrop: (
|
|
3695
|
-
var
|
|
3696
|
-
const f = dropTarget, b = getOrientation(f) === "vertical" ?
|
|
3648
|
+
onDrop: (x) => {
|
|
3649
|
+
var j;
|
|
3650
|
+
const f = dropTarget, b = getOrientation(f) === "vertical" ? x.clientY + ((j = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : j.scrollY) : x.clientX;
|
|
3697
3651
|
dropIndex = calculateDropIndex(b, possiblePositions);
|
|
3698
|
-
const
|
|
3699
|
-
if ((
|
|
3652
|
+
const k = d, A = f.getAttribute("data-block-id"), B = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
|
|
3653
|
+
if ((k == null ? void 0 : k._id) === A || !B) {
|
|
3700
3654
|
m();
|
|
3701
3655
|
return;
|
|
3702
3656
|
}
|
|
3703
|
-
if (!has(
|
|
3704
|
-
a(
|
|
3657
|
+
if (!has(k, "_id")) {
|
|
3658
|
+
a(k, A === "canvas" ? null : A, dropIndex), setTimeout(m, 300);
|
|
3705
3659
|
return;
|
|
3706
3660
|
}
|
|
3707
|
-
let
|
|
3708
|
-
|
|
3661
|
+
let C = f.getAttribute("data-block-id");
|
|
3662
|
+
C === null && (C = x.target.parentElement.getAttribute("data-block-id")), c([k._id], C === "canvas" ? null : C, dropIndex), m(), setTimeout(removePlaceholder, 300);
|
|
3709
3663
|
},
|
|
3710
|
-
onDragEnter: (
|
|
3711
|
-
const f =
|
|
3712
|
-
dropTarget =
|
|
3713
|
-
const b =
|
|
3714
|
-
u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [],
|
|
3664
|
+
onDragEnter: (x) => {
|
|
3665
|
+
const f = x, h = f.target;
|
|
3666
|
+
dropTarget = h;
|
|
3667
|
+
const b = h.getAttribute("data-block-id"), k = h.getAttribute("data-dnd-dragged") !== "yes";
|
|
3668
|
+
u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [], k && calculatePossiblePositions(h), r(!0), l(""), i([]);
|
|
3715
3669
|
},
|
|
3716
|
-
onDragLeave: (
|
|
3717
|
-
|
|
3670
|
+
onDragLeave: (x) => {
|
|
3671
|
+
x.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
|
|
3718
3672
|
}
|
|
3719
3673
|
};
|
|
3720
3674
|
};
|
|
@@ -3745,8 +3699,8 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3745
3699
|
const f = o.getHTML();
|
|
3746
3700
|
a([m], { content: f }), n.style.display = "none", u.style.visibility = "visible";
|
|
3747
3701
|
}), i(m);
|
|
3748
|
-
const
|
|
3749
|
-
o.commands.setContent(
|
|
3702
|
+
const x = d(m).content;
|
|
3703
|
+
o.commands.setContent(x), 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);
|
|
3750
3704
|
},
|
|
3751
3705
|
[l, c, d, i, a, o, n]
|
|
3752
3706
|
);
|
|
@@ -3787,17 +3741,17 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3787
3741
|
return;
|
|
3788
3742
|
const f = getElementByDataBlockId(n, first(r));
|
|
3789
3743
|
if (f) {
|
|
3790
|
-
const
|
|
3791
|
-
if (
|
|
3792
|
-
const b = f.getAttribute("data-style-id"),
|
|
3793
|
-
l([{ id: b, prop:
|
|
3744
|
+
const h = f.getAttribute("data-style-prop");
|
|
3745
|
+
if (h) {
|
|
3746
|
+
const b = f.getAttribute("data-style-id"), k = f.getAttribute("data-block-parent");
|
|
3747
|
+
l([{ id: b, prop: h, blockId: k }]);
|
|
3794
3748
|
}
|
|
3795
3749
|
}
|
|
3796
3750
|
}, 100);
|
|
3797
3751
|
}, [n, r, l, a]);
|
|
3798
3752
|
const c = useEditor({
|
|
3799
3753
|
extensions: [StarterKit]
|
|
3800
|
-
}), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(),
|
|
3754
|
+
}), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(), x = useDnd();
|
|
3801
3755
|
return /* @__PURE__ */ jsx(
|
|
3802
3756
|
"div",
|
|
3803
3757
|
{
|
|
@@ -3807,8 +3761,8 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3807
3761
|
onDoubleClick: p,
|
|
3808
3762
|
onMouseMove: g,
|
|
3809
3763
|
onMouseLeave: m,
|
|
3810
|
-
...omit(
|
|
3811
|
-
className: "relative h-full max-w-full p-px " + (
|
|
3764
|
+
...omit(x, "isDragging"),
|
|
3765
|
+
className: "relative h-full max-w-full p-px " + (x.isDragging ? "dragging" : ""),
|
|
3812
3766
|
children: o
|
|
3813
3767
|
}
|
|
3814
3768
|
);
|
|
@@ -3817,7 +3771,7 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3817
3771
|
d == null ? void 0 : d.getElementById("selected-block")
|
|
3818
3772
|
), [m] = useState(
|
|
3819
3773
|
d == null ? void 0 : d.getElementById("selected-styling-block")
|
|
3820
|
-
), [
|
|
3774
|
+
), [x] = useState(
|
|
3821
3775
|
d == null ? void 0 : d.getElementById("dragged-block")
|
|
3822
3776
|
);
|
|
3823
3777
|
useEffect(() => {
|
|
@@ -3842,15 +3796,15 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3842
3796
|
forms,
|
|
3843
3797
|
aspectRatio,
|
|
3844
3798
|
containerQueries,
|
|
3845
|
-
plugin(function({ addBase: b, theme:
|
|
3799
|
+
plugin(function({ addBase: b, theme: k }) {
|
|
3846
3800
|
b({
|
|
3847
3801
|
"h1,h2,h3,h4,h5,h6": {
|
|
3848
|
-
fontFamily:
|
|
3802
|
+
fontFamily: k("fontFamily.heading")
|
|
3849
3803
|
},
|
|
3850
3804
|
body: {
|
|
3851
|
-
fontFamily:
|
|
3852
|
-
color:
|
|
3853
|
-
backgroundColor:
|
|
3805
|
+
fontFamily: k("fontFamily.body"),
|
|
3806
|
+
color: k("colors.foreground"),
|
|
3807
|
+
backgroundColor: k("colors.background")
|
|
3854
3808
|
}
|
|
3855
3809
|
});
|
|
3856
3810
|
})
|
|
@@ -3861,8 +3815,8 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3861
3815
|
outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
|
|
3862
3816
|
}`);
|
|
3863
3817
|
}, [r, g]), useEffect(() => {
|
|
3864
|
-
|
|
3865
|
-
}, [i,
|
|
3818
|
+
x.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
|
|
3819
|
+
}, [i, x]), useEffect(() => {
|
|
3866
3820
|
u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
|
|
3867
3821
|
}, [u]), useEffect(() => {
|
|
3868
3822
|
m && (m.textContent = `${map(l, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
|
|
@@ -3874,10 +3828,10 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3874
3828
|
const f = useMemo(
|
|
3875
3829
|
() => getChaiThemeCssVariables(o),
|
|
3876
3830
|
[o]
|
|
3877
|
-
),
|
|
3831
|
+
), h = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
|
|
3878
3832
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3879
3833
|
/* @__PURE__ */ jsx("style", { id: "chai-theme", children: f }),
|
|
3880
|
-
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html:
|
|
3834
|
+
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: h } })
|
|
3881
3835
|
] });
|
|
3882
3836
|
}, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
|
|
3883
3837
|
const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), c = useDebouncedCallback(
|
|
@@ -3957,10 +3911,10 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3957
3911
|
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(
|
|
3958
3912
|
() => u ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
|
|
3959
3913
|
[r, l, a, d, u]
|
|
3960
|
-
),
|
|
3914
|
+
), x = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), f = useMemo(
|
|
3961
3915
|
() => c(r._id, getBlockRuntimeProps(r._type)),
|
|
3962
3916
|
[r._id, r._type, c, getBlockRuntimeProps]
|
|
3963
|
-
),
|
|
3917
|
+
), h = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), b = useMemo(
|
|
3964
3918
|
() => ({
|
|
3965
3919
|
blockProps: {
|
|
3966
3920
|
"data-block-id": r._id,
|
|
@@ -3969,9 +3923,9 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3969
3923
|
inBuilder: !0,
|
|
3970
3924
|
lang: l || i,
|
|
3971
3925
|
...m,
|
|
3972
|
-
...
|
|
3926
|
+
...x,
|
|
3973
3927
|
...f,
|
|
3974
|
-
...
|
|
3928
|
+
...h
|
|
3975
3929
|
}),
|
|
3976
3930
|
[
|
|
3977
3931
|
r._id,
|
|
@@ -3979,9 +3933,9 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3979
3933
|
l,
|
|
3980
3934
|
i,
|
|
3981
3935
|
m,
|
|
3982
|
-
|
|
3936
|
+
x,
|
|
3983
3937
|
f,
|
|
3984
|
-
|
|
3938
|
+
h
|
|
3985
3939
|
]
|
|
3986
3940
|
);
|
|
3987
3941
|
return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...b, children: n }) });
|
|
@@ -4013,11 +3967,11 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4013
3967
|
if (d < n) {
|
|
4014
3968
|
const u = parseFloat((d / n).toFixed(2).toString());
|
|
4015
3969
|
let g = {};
|
|
4016
|
-
const m = p * u,
|
|
3970
|
+
const m = p * u, x = d * u;
|
|
4017
3971
|
p && (g = {
|
|
4018
3972
|
// Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
|
|
4019
3973
|
height: 100 + (p - m) / m * 100 + "%",
|
|
4020
|
-
width: 100 + (d -
|
|
3974
|
+
width: 100 + (d - x) / x * 100 + "%"
|
|
4021
3975
|
}), i({
|
|
4022
3976
|
position: "relative",
|
|
4023
3977
|
top: 0,
|
|
@@ -4034,39 +3988,39 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4034
3988
|
c();
|
|
4035
3989
|
}, [n, o, r, c]), l;
|
|
4036
3990
|
}, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
|
|
4037
|
-
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([]), [,
|
|
4038
|
-
p((S) => ({ ...S, width:
|
|
3991
|
+
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([]), [, x] = useState([]), [, f] = useAtom$1(canvasIframeAtom), [h, b] = useSelectedStylingBlocks(), k = useBuilderProp("loading", !1), A = useBuilderProp("htmlDir", "ltr"), B = (_) => {
|
|
3992
|
+
p((S) => ({ ...S, width: _ }));
|
|
4039
3993
|
};
|
|
4040
3994
|
useEffect(() => {
|
|
4041
3995
|
if (!c.current) return;
|
|
4042
|
-
const { clientWidth:
|
|
4043
|
-
p({ width:
|
|
3996
|
+
const { clientWidth: _, clientHeight: S } = c.current;
|
|
3997
|
+
p({ width: _, height: S });
|
|
4044
3998
|
}, [c, n]);
|
|
4045
|
-
const
|
|
4046
|
-
const { top:
|
|
4047
|
-
return
|
|
3999
|
+
const C = (_, S = 0) => {
|
|
4000
|
+
const { top: w } = _.getBoundingClientRect();
|
|
4001
|
+
return w + S >= 0 && w - S <= window.innerHeight;
|
|
4048
4002
|
};
|
|
4049
4003
|
useEffect(() => {
|
|
4050
|
-
var
|
|
4004
|
+
var _, S;
|
|
4051
4005
|
if (a && a.type !== "Multiple" && i.current) {
|
|
4052
|
-
const
|
|
4053
|
-
|
|
4006
|
+
const w = getElementByDataBlockId(i.current.contentDocument, a._id);
|
|
4007
|
+
w && (C(w) || (S = (_ = i.current) == null ? void 0 : _.contentWindow) == null || S.scrollTo({ top: w.offsetTop, behavior: "smooth" }), m([w]));
|
|
4054
4008
|
}
|
|
4055
4009
|
}, [a]), useEffect(() => {
|
|
4056
|
-
if (!isEmpty(
|
|
4057
|
-
const
|
|
4010
|
+
if (!isEmpty(h) && i.current) {
|
|
4011
|
+
const _ = getElementByStyleId(
|
|
4058
4012
|
i.current.contentDocument,
|
|
4059
|
-
first(
|
|
4013
|
+
first(h).id
|
|
4060
4014
|
);
|
|
4061
|
-
|
|
4015
|
+
x(_ ? [_] : [null]);
|
|
4062
4016
|
} else
|
|
4063
|
-
|
|
4064
|
-
}, [
|
|
4065
|
-
const
|
|
4066
|
-
let
|
|
4067
|
-
return
|
|
4068
|
-
}, [o,
|
|
4069
|
-
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount:
|
|
4017
|
+
x([null]);
|
|
4018
|
+
}, [h]);
|
|
4019
|
+
const j = useMemo(() => {
|
|
4020
|
+
let _ = IframeInitialContent;
|
|
4021
|
+
return _ = _.replace("__HTML_DIR__", A), o === "offline" && (_ = _.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), _;
|
|
4022
|
+
}, [o, A]);
|
|
4023
|
+
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: B, onResize: B, children: /* @__PURE__ */ jsx(
|
|
4070
4024
|
"div",
|
|
4071
4025
|
{
|
|
4072
4026
|
onClick: () => {
|
|
@@ -4083,7 +4037,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4083
4037
|
id: "canvas-iframe",
|
|
4084
4038
|
style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
|
|
4085
4039
|
className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
|
|
4086
|
-
initialContent:
|
|
4040
|
+
initialContent: j,
|
|
4087
4041
|
children: [
|
|
4088
4042
|
/* @__PURE__ */ jsx(KeyboardHandler, {}),
|
|
4089
4043
|
/* @__PURE__ */ jsx(
|
|
@@ -4095,7 +4049,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4095
4049
|
),
|
|
4096
4050
|
/* @__PURE__ */ jsx(HeadTags, {}),
|
|
4097
4051
|
/* @__PURE__ */ jsx(Provider$1, { children: /* @__PURE__ */ jsxs(Canvas, { children: [
|
|
4098
|
-
|
|
4052
|
+
k ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
|
|
4099
4053
|
/* @__PURE__ */ jsx(AddBlockAtBottom, {}),
|
|
4100
4054
|
/* @__PURE__ */ jsx("br", {}),
|
|
4101
4055
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -4256,78 +4210,78 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4256
4210
|
}
|
|
4257
4211
|
);
|
|
4258
4212
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
4259
|
-
const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null),
|
|
4260
|
-
a(
|
|
4261
|
-
},
|
|
4262
|
-
const
|
|
4263
|
-
if (
|
|
4264
|
-
const B = Object.values(
|
|
4265
|
-
B && typeof B == "object" && "fontFamily" in B && "borderRadius" in B && "colors" in B ?
|
|
4213
|
+
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 = (A) => {
|
|
4214
|
+
a(A);
|
|
4215
|
+
}, x = () => {
|
|
4216
|
+
const A = l.find((B) => Object.keys(B)[0] === r);
|
|
4217
|
+
if (A) {
|
|
4218
|
+
const B = Object.values(A)[0];
|
|
4219
|
+
B && typeof B == "object" && "fontFamily" in B && "borderRadius" in B && "colors" in B ? p(B) : console.error("Invalid preset structure:", B);
|
|
4266
4220
|
} else
|
|
4267
4221
|
console.error("Preset not found:", r);
|
|
4268
|
-
},
|
|
4269
|
-
(
|
|
4270
|
-
|
|
4271
|
-
...
|
|
4222
|
+
}, f = useDebouncedCallback(
|
|
4223
|
+
(A, B) => {
|
|
4224
|
+
p(() => ({
|
|
4225
|
+
...d,
|
|
4272
4226
|
fontFamily: {
|
|
4273
|
-
...
|
|
4274
|
-
[
|
|
4227
|
+
...d.fontFamily,
|
|
4228
|
+
[A.replace(/font-/g, "")]: B
|
|
4275
4229
|
}
|
|
4276
4230
|
}));
|
|
4277
4231
|
},
|
|
4278
|
-
[
|
|
4232
|
+
[d],
|
|
4279
4233
|
200
|
|
4280
|
-
),
|
|
4281
|
-
(
|
|
4282
|
-
|
|
4283
|
-
...
|
|
4284
|
-
borderRadius: `${
|
|
4234
|
+
), h = useDebouncedCallback(
|
|
4235
|
+
(A) => {
|
|
4236
|
+
p(() => ({
|
|
4237
|
+
...d,
|
|
4238
|
+
borderRadius: `${A}px`
|
|
4285
4239
|
}));
|
|
4286
4240
|
},
|
|
4287
|
-
[
|
|
4241
|
+
[d],
|
|
4288
4242
|
200
|
|
4289
|
-
),
|
|
4290
|
-
(
|
|
4291
|
-
|
|
4292
|
-
const
|
|
4293
|
-
return n ? set(
|
|
4294
|
-
...
|
|
4243
|
+
), b = useDebouncedCallback(
|
|
4244
|
+
(A, B) => {
|
|
4245
|
+
p(() => {
|
|
4246
|
+
const C = get(d, `colors.${A}`);
|
|
4247
|
+
return n ? set(C, 1, B) : set(C, 0, B), {
|
|
4248
|
+
...d,
|
|
4295
4249
|
colors: {
|
|
4296
|
-
...
|
|
4297
|
-
[
|
|
4250
|
+
...d.colors,
|
|
4251
|
+
[A]: C
|
|
4298
4252
|
}
|
|
4299
4253
|
};
|
|
4300
4254
|
});
|
|
4301
4255
|
},
|
|
4302
|
-
[
|
|
4256
|
+
[d],
|
|
4303
4257
|
200
|
|
4304
|
-
),
|
|
4305
|
-
const
|
|
4258
|
+
), k = (A) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(A.items).map(([B]) => {
|
|
4259
|
+
const C = get(d, `colors.${B}.${n ? 1 : 0}`);
|
|
4306
4260
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
4307
4261
|
/* @__PURE__ */ jsx(
|
|
4308
4262
|
ColorPickerInput,
|
|
4309
4263
|
{
|
|
4310
|
-
value:
|
|
4311
|
-
onChange: (
|
|
4264
|
+
value: C,
|
|
4265
|
+
onChange: (j) => b(B, j)
|
|
4312
4266
|
}
|
|
4313
4267
|
),
|
|
4314
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((
|
|
4268
|
+
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((j) => j.charAt(0).toUpperCase() + j.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
|
|
4315
4269
|
] }, B);
|
|
4316
4270
|
}) });
|
|
4317
|
-
return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
4271
|
+
return c("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
4318
4272
|
/* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
4319
4273
|
l.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 py-2", children: [
|
|
4320
4274
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
4321
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children:
|
|
4275
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Presets") }),
|
|
4322
4276
|
/* @__PURE__ */ jsxs(
|
|
4323
4277
|
"select",
|
|
4324
4278
|
{
|
|
4325
4279
|
value: r,
|
|
4326
|
-
onChange: (
|
|
4280
|
+
onChange: (A) => m(A.target.value),
|
|
4327
4281
|
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",
|
|
4328
4282
|
children: [
|
|
4329
4283
|
/* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
|
|
4330
|
-
Array.isArray(l) && l.map((
|
|
4284
|
+
Array.isArray(l) && l.map((A) => /* @__PURE__ */ jsx("option", { value: Object.keys(A)[0], children: capitalize(Object.keys(A)[0]) }, Object.keys(A)[0]))
|
|
4331
4285
|
]
|
|
4332
4286
|
}
|
|
4333
4287
|
)
|
|
@@ -4338,31 +4292,31 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4338
4292
|
className: "w-full text-sm",
|
|
4339
4293
|
disabled: r === "",
|
|
4340
4294
|
variant: "default",
|
|
4341
|
-
onClick:
|
|
4342
|
-
children:
|
|
4295
|
+
onClick: x,
|
|
4296
|
+
children: g("Apply")
|
|
4343
4297
|
}
|
|
4344
4298
|
) })
|
|
4345
4299
|
] }),
|
|
4346
4300
|
/* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
|
|
4347
|
-
(
|
|
4301
|
+
(u == null ? void 0 : u.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(u.fontFamily).map(([A, B]) => /* @__PURE__ */ jsx(
|
|
4348
4302
|
FontSelector,
|
|
4349
4303
|
{
|
|
4350
|
-
label:
|
|
4351
|
-
value:
|
|
4352
|
-
onChange: (
|
|
4304
|
+
label: A,
|
|
4305
|
+
value: d.fontFamily[A.replace(/font-/g, "")] || B[Object.keys(B)[0]],
|
|
4306
|
+
onChange: (C) => f(A, C)
|
|
4353
4307
|
},
|
|
4354
|
-
|
|
4308
|
+
A
|
|
4355
4309
|
)) }),
|
|
4356
|
-
(
|
|
4357
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children:
|
|
4310
|
+
(u == null ? void 0 : u.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
|
|
4311
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Border Radius") }),
|
|
4358
4312
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
|
|
4359
|
-
/* @__PURE__ */ jsx(BorderRadiusInput, { value:
|
|
4360
|
-
/* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children:
|
|
4313
|
+
/* @__PURE__ */ jsx(BorderRadiusInput, { value: d.borderRadius, onChange: h }),
|
|
4314
|
+
/* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: d.borderRadius })
|
|
4361
4315
|
] })
|
|
4362
4316
|
] }),
|
|
4363
|
-
(
|
|
4364
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children:
|
|
4365
|
-
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children:
|
|
4317
|
+
(u == null ? void 0 : u.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
|
|
4318
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Colors") }),
|
|
4319
|
+
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: u.colors.map((A) => k(A)) }, n ? "dark" : "light")
|
|
4366
4320
|
] })
|
|
4367
4321
|
] }),
|
|
4368
4322
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -4371,7 +4325,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4371
4325
|
/* @__PURE__ */ jsx("br", {})
|
|
4372
4326
|
] }),
|
|
4373
4327
|
i && /* @__PURE__ */ jsx("div", { className: "absolute bottom-4 w-full", children: React.createElement(i) })
|
|
4374
|
-
] });
|
|
4328
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "relative w-full", children: /* @__PURE__ */ jsx("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto text-center", o), children: /* @__PURE__ */ jsx("div", { className: "mt-10 h-full items-center justify-center gap-2 text-muted-foreground", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: "You don't have permission to edit the theme. Please contact your administrator to get access." }) }) }) });
|
|
4375
4329
|
}), removeSizeAttributes = (o) => {
|
|
4376
4330
|
try {
|
|
4377
4331
|
return o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi, "<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi, "<svg$1$2>");
|
|
@@ -4455,19 +4409,19 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4455
4409
|
}, [a, o]);
|
|
4456
4410
|
const u = (f) => Array.isArray(f) ? "array" : typeof f == "object" && f !== null ? "object" : "value", g = React.useCallback(
|
|
4457
4411
|
(f) => {
|
|
4458
|
-
const
|
|
4459
|
-
f.type === "object" ? (c((b) => [...b, f.key]), p(f.value)) :
|
|
4412
|
+
const h = (b) => r === "value" ? b === "value" || b === "object" : r === "array" ? b === "array" : b === r;
|
|
4413
|
+
f.type === "object" ? (c((b) => [...b, f.key]), p(f.value)) : h(f.type) && (n([...i, f.key].join(".")), l(!1));
|
|
4460
4414
|
},
|
|
4461
4415
|
[i, n, r]
|
|
4462
4416
|
), m = React.useCallback(() => {
|
|
4463
4417
|
if (i.length > 0) {
|
|
4464
4418
|
const f = i.slice(0, -1);
|
|
4465
|
-
c(f), p(f.reduce((
|
|
4419
|
+
c(f), p(f.reduce((h, b) => h[b], o));
|
|
4466
4420
|
}
|
|
4467
|
-
}, [i, o]),
|
|
4421
|
+
}, [i, o]), x = React.useMemo(() => Object.entries(d).map(([f, h]) => ({
|
|
4468
4422
|
key: f,
|
|
4469
|
-
value:
|
|
4470
|
-
type: u(
|
|
4423
|
+
value: h,
|
|
4424
|
+
type: u(h)
|
|
4471
4425
|
})).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]);
|
|
4472
4426
|
return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
|
|
4473
4427
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
@@ -4493,7 +4447,7 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4493
4447
|
/* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
|
|
4494
4448
|
"Back"
|
|
4495
4449
|
] }),
|
|
4496
|
-
|
|
4450
|
+
x.map((f) => /* @__PURE__ */ jsxs(
|
|
4497
4451
|
CommandItem,
|
|
4498
4452
|
{
|
|
4499
4453
|
value: f.key,
|
|
@@ -4509,8 +4463,8 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4509
4463
|
size: "sm",
|
|
4510
4464
|
variant: "ghost",
|
|
4511
4465
|
className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
|
|
4512
|
-
onClick: (
|
|
4513
|
-
|
|
4466
|
+
onClick: (h) => {
|
|
4467
|
+
h.stopPropagation(), n([...i, f.key].join(".")), l(!1);
|
|
4514
4468
|
},
|
|
4515
4469
|
children: "Select"
|
|
4516
4470
|
}
|
|
@@ -4686,8 +4640,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4686
4640
|
z-index: 9999 !important;
|
|
4687
4641
|
}
|
|
4688
4642
|
`, document.head.appendChild(m), () => {
|
|
4689
|
-
const
|
|
4690
|
-
|
|
4643
|
+
const x = document.getElementById("rte-modal-styles");
|
|
4644
|
+
x && x.remove();
|
|
4691
4645
|
};
|
|
4692
4646
|
}
|
|
4693
4647
|
}, [o]);
|
|
@@ -4709,12 +4663,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4709
4663
|
],
|
|
4710
4664
|
content: a || "",
|
|
4711
4665
|
onUpdate: ({ editor: m }) => {
|
|
4712
|
-
const
|
|
4713
|
-
l(
|
|
4666
|
+
const x = m.getHTML();
|
|
4667
|
+
l(x);
|
|
4714
4668
|
},
|
|
4715
4669
|
onBlur: ({ editor: m }) => {
|
|
4716
|
-
const
|
|
4717
|
-
i(r,
|
|
4670
|
+
const x = m.getHTML();
|
|
4671
|
+
i(r, x);
|
|
4718
4672
|
},
|
|
4719
4673
|
editorProps: {
|
|
4720
4674
|
attributes: {
|
|
@@ -4731,17 +4685,17 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4731
4685
|
}, [u, o]);
|
|
4732
4686
|
const g = (m) => {
|
|
4733
4687
|
if (!u) return;
|
|
4734
|
-
const
|
|
4688
|
+
const x = `{{${m}}}`;
|
|
4735
4689
|
u.commands.focus();
|
|
4736
|
-
const { from: f, to:
|
|
4737
|
-
if (f !==
|
|
4738
|
-
u.chain().deleteSelection().insertContent(
|
|
4690
|
+
const { from: f, to: h } = u.state.selection;
|
|
4691
|
+
if (f !== h)
|
|
4692
|
+
u.chain().deleteSelection().insertContent(x).run();
|
|
4739
4693
|
else {
|
|
4740
|
-
const { state:
|
|
4741
|
-
let _ = "";
|
|
4742
|
-
B > 0 && E !== " " && !/[.,!?;:]/.test(E) && (_ = " ");
|
|
4694
|
+
const { state: k } = u, A = k.selection.from, B = k.doc.textBetween(Math.max(0, A - 1), A), C = k.doc.textBetween(A, Math.min(A + 1, k.doc.content.size));
|
|
4743
4695
|
let j = "";
|
|
4744
|
-
|
|
4696
|
+
A > 0 && B !== " " && !/[.,!?;:]/.test(B) && (j = " ");
|
|
4697
|
+
let _ = "";
|
|
4698
|
+
C && C !== " " && !/[.,!?;:]/.test(C) && (_ = " "), u.chain().insertContent(j + x + _).run();
|
|
4745
4699
|
}
|
|
4746
4700
|
};
|
|
4747
4701
|
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: [
|
|
@@ -4777,12 +4731,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4777
4731
|
],
|
|
4778
4732
|
content: r || "",
|
|
4779
4733
|
onUpdate: ({ editor: f }) => {
|
|
4780
|
-
const
|
|
4781
|
-
a(
|
|
4734
|
+
const h = f.getHTML();
|
|
4735
|
+
a(h), c || u(h);
|
|
4782
4736
|
},
|
|
4783
4737
|
onBlur: ({ editor: f }) => {
|
|
4784
|
-
const
|
|
4785
|
-
l(o,
|
|
4738
|
+
const h = f.getHTML();
|
|
4739
|
+
l(o, h);
|
|
4786
4740
|
},
|
|
4787
4741
|
editorProps: {
|
|
4788
4742
|
attributes: {
|
|
@@ -4797,7 +4751,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4797
4751
|
}, [r]);
|
|
4798
4752
|
const m = (f) => {
|
|
4799
4753
|
a(f);
|
|
4800
|
-
},
|
|
4754
|
+
}, x = () => {
|
|
4801
4755
|
d(!1), g && g.commands.setContent(p);
|
|
4802
4756
|
};
|
|
4803
4757
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -4809,7 +4763,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4809
4763
|
RTEModal,
|
|
4810
4764
|
{
|
|
4811
4765
|
isOpen: c,
|
|
4812
|
-
onClose:
|
|
4766
|
+
onClose: x,
|
|
4813
4767
|
id: o,
|
|
4814
4768
|
value: p,
|
|
4815
4769
|
onChange: m,
|
|
@@ -4823,41 +4777,41 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4823
4777
|
onChange: r
|
|
4824
4778
|
}) => {
|
|
4825
4779
|
var L;
|
|
4826
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v,
|
|
4780
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, y) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, x] = useState(""), [f, h] = useState([]), [b, k] = useState(-1), A = useRef(null), B = (L = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : L.name;
|
|
4827
4781
|
useEffect(() => {
|
|
4828
|
-
if (
|
|
4829
|
-
const v = split(o, ":"),
|
|
4830
|
-
g(
|
|
4831
|
-
const
|
|
4832
|
-
|
|
4782
|
+
if (x(""), h([]), k(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4783
|
+
const v = split(o, ":"), y = get(v, 1, "page") || "page";
|
|
4784
|
+
g(y), (async () => {
|
|
4785
|
+
const E = await l(y, [get(v, 2, "page")]);
|
|
4786
|
+
E && Array.isArray(E) && x(get(E, [0, "name"], ""));
|
|
4833
4787
|
})();
|
|
4834
4788
|
}, [o]);
|
|
4835
|
-
const
|
|
4789
|
+
const C = useDebouncedCallback(
|
|
4836
4790
|
async (v) => {
|
|
4837
4791
|
if (isEmpty(v))
|
|
4838
|
-
|
|
4792
|
+
h([]);
|
|
4839
4793
|
else {
|
|
4840
|
-
const
|
|
4841
|
-
|
|
4794
|
+
const y = await l(u, v);
|
|
4795
|
+
h(y);
|
|
4842
4796
|
}
|
|
4843
|
-
c(!1),
|
|
4797
|
+
c(!1), k(-1);
|
|
4844
4798
|
},
|
|
4845
4799
|
[u],
|
|
4846
4800
|
300
|
|
4847
|
-
),
|
|
4848
|
-
const
|
|
4849
|
-
|
|
4850
|
-
},
|
|
4801
|
+
), j = (v) => {
|
|
4802
|
+
const y = ["pageType", u, v.id];
|
|
4803
|
+
y[1] && (r(y.join(":")), x(v.name), p(!1), h([]), k(-1));
|
|
4804
|
+
}, _ = (v) => {
|
|
4851
4805
|
switch (v.key) {
|
|
4852
4806
|
case "ArrowDown":
|
|
4853
|
-
v.preventDefault(),
|
|
4807
|
+
v.preventDefault(), k((y) => y < f.length - 1 ? y + 1 : y);
|
|
4854
4808
|
break;
|
|
4855
4809
|
case "ArrowUp":
|
|
4856
|
-
v.preventDefault(),
|
|
4810
|
+
v.preventDefault(), k((y) => y > 0 ? y - 1 : y);
|
|
4857
4811
|
break;
|
|
4858
4812
|
case "Enter":
|
|
4859
4813
|
if (v.preventDefault(), f.length === 0) return;
|
|
4860
|
-
b >= 0 &&
|
|
4814
|
+
b >= 0 && j(f[b]);
|
|
4861
4815
|
break;
|
|
4862
4816
|
case "Escape":
|
|
4863
4817
|
v.preventDefault(), S();
|
|
@@ -4865,15 +4819,15 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4865
4819
|
}
|
|
4866
4820
|
};
|
|
4867
4821
|
useEffect(() => {
|
|
4868
|
-
if (b >= 0 &&
|
|
4869
|
-
const v =
|
|
4822
|
+
if (b >= 0 && A.current) {
|
|
4823
|
+
const v = A.current.children[b];
|
|
4870
4824
|
v == null || v.scrollIntoView({ block: "nearest" });
|
|
4871
4825
|
}
|
|
4872
4826
|
}, [b]);
|
|
4873
4827
|
const S = () => {
|
|
4874
|
-
|
|
4875
|
-
},
|
|
4876
|
-
|
|
4828
|
+
x(""), h([]), k(-1), p(!1), r("");
|
|
4829
|
+
}, w = (v) => {
|
|
4830
|
+
x(v), p(!isEmpty(v)), c(!0), C(v);
|
|
4877
4831
|
};
|
|
4878
4832
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4879
4833
|
/* @__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)) }),
|
|
@@ -4883,9 +4837,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4883
4837
|
{
|
|
4884
4838
|
type: "text",
|
|
4885
4839
|
value: m,
|
|
4886
|
-
onChange: (v) =>
|
|
4887
|
-
onKeyDown:
|
|
4888
|
-
placeholder: a(`Search ${
|
|
4840
|
+
onChange: (v) => w(v.target.value),
|
|
4841
|
+
onKeyDown: _,
|
|
4842
|
+
placeholder: a(`Search ${B ?? ""}`),
|
|
4889
4843
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4890
4844
|
}
|
|
4891
4845
|
),
|
|
@@ -4899,11 +4853,11 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4899
4853
|
' "',
|
|
4900
4854
|
m,
|
|
4901
4855
|
'"'
|
|
4902
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref:
|
|
4856
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(f == null ? void 0 : f.slice(0, 20), (v, y) => /* @__PURE__ */ jsxs(
|
|
4903
4857
|
"li",
|
|
4904
4858
|
{
|
|
4905
|
-
onClick: () =>
|
|
4906
|
-
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" :
|
|
4859
|
+
onClick: () => j(v),
|
|
4860
|
+
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"}`,
|
|
4907
4861
|
children: [
|
|
4908
4862
|
v.name,
|
|
4909
4863
|
" ",
|
|
@@ -4997,29 +4951,29 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4997
4951
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
|
|
4998
4952
|
}, [o, u]);
|
|
4999
4953
|
const m = () => {
|
|
5000
|
-
const
|
|
5001
|
-
if (
|
|
5002
|
-
const b = (
|
|
5003
|
-
if (!
|
|
5004
|
-
n({ ...o, currentSlide:
|
|
4954
|
+
const h = findIndex(u, { _id: g });
|
|
4955
|
+
if (h > -1) {
|
|
4956
|
+
const b = (h + 1) % u.length, k = get(u, [b, "_id"]);
|
|
4957
|
+
if (!k) return;
|
|
4958
|
+
n({ ...o, currentSlide: k }), c([k]);
|
|
5005
4959
|
}
|
|
5006
|
-
},
|
|
5007
|
-
const
|
|
5008
|
-
if (
|
|
5009
|
-
const b = (
|
|
5010
|
-
if (!
|
|
5011
|
-
n({ ...o, currentSlide:
|
|
4960
|
+
}, x = () => {
|
|
4961
|
+
const h = findIndex(u, { _id: g });
|
|
4962
|
+
if (h > -1) {
|
|
4963
|
+
const b = (h - 1 + u.length) % u.length, k = get(u, [b, "_id"]);
|
|
4964
|
+
if (!k) return;
|
|
4965
|
+
n({ ...o, currentSlide: k }), c([k]);
|
|
5012
4966
|
}
|
|
5013
4967
|
}, f = () => {
|
|
5014
|
-
const
|
|
4968
|
+
const h = i(
|
|
5015
4969
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
5016
4970
|
p == null ? void 0 : p._id
|
|
5017
|
-
), b =
|
|
4971
|
+
), b = h == null ? void 0 : h._id;
|
|
5018
4972
|
b && (n({ ...o, currentSlide: b }), c([b]));
|
|
5019
4973
|
};
|
|
5020
4974
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
5021
4975
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
5022
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
4976
|
+
/* @__PURE__ */ jsx("button", { onClick: x, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
|
|
5023
4977
|
/* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
|
|
5024
4978
|
/* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
|
|
5025
4979
|
" ",
|
|
@@ -5093,8 +5047,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5093
5047
|
value: o == null ? void 0 : o.autoplayInterval,
|
|
5094
5048
|
className: "text-xs",
|
|
5095
5049
|
pattern: "[0-9]*",
|
|
5096
|
-
onChange: (
|
|
5097
|
-
let b =
|
|
5050
|
+
onChange: (h) => {
|
|
5051
|
+
let b = h.target.value;
|
|
5098
5052
|
b.length && (b = b.replace("-", "")), n({ ...o, autoplayInterval: b });
|
|
5099
5053
|
}
|
|
5100
5054
|
}
|
|
@@ -5134,65 +5088,65 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5134
5088
|
formData: g,
|
|
5135
5089
|
onChange: m
|
|
5136
5090
|
}) => {
|
|
5137
|
-
const { selectedLang:
|
|
5138
|
-
(
|
|
5139
|
-
const
|
|
5140
|
-
let
|
|
5141
|
-
const
|
|
5142
|
-
return
|
|
5143
|
-
text:
|
|
5144
|
-
prefixLength:
|
|
5091
|
+
const { selectedLang: x, fallbackLang: f, languages: h } = useLanguages(), b = isEmpty$1(h) ? "" : isEmpty$1(x) ? f : x, k = get$1(LANGUAGES, b, b), A = usePageExternalData(), B = useSelectedBlock(), C = useRegisteredChaiBlocks(), j = get$1(C, [B == null ? void 0 : B._type, "i18nProps"], []) || [], [_, S] = useState(null), w = useCallback(
|
|
5092
|
+
(y) => {
|
|
5093
|
+
const E = (P) => /[.,!?;:]/.test(P), T = (P, N, M) => {
|
|
5094
|
+
let D = "", O = "";
|
|
5095
|
+
const $ = N > 0 ? P[N - 1] : "", H = N < P.length ? P[N] : "";
|
|
5096
|
+
return N > 0 && ($ === "." || !E($) && $ !== " ") && (D = " "), N < P.length && !E(H) && H !== " " && (O = " "), {
|
|
5097
|
+
text: D + M + O,
|
|
5098
|
+
prefixLength: D.length,
|
|
5145
5099
|
suffixLength: O.length
|
|
5146
5100
|
};
|
|
5147
5101
|
}, I = document.getElementById(o);
|
|
5148
5102
|
if (!I) return;
|
|
5149
|
-
const
|
|
5150
|
-
if (
|
|
5151
|
-
const
|
|
5152
|
-
if (
|
|
5153
|
-
const
|
|
5154
|
-
|
|
5155
|
-
const { from:
|
|
5156
|
-
if (
|
|
5157
|
-
|
|
5103
|
+
const R = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
|
|
5104
|
+
if (R && (R.querySelector(".ProseMirror") || R.__chaiRTE)) {
|
|
5105
|
+
const P = R.__chaiRTE;
|
|
5106
|
+
if (P) {
|
|
5107
|
+
const N = `{{${y}}}`;
|
|
5108
|
+
P.commands.focus();
|
|
5109
|
+
const { from: M, to: D } = P.state.selection;
|
|
5110
|
+
if (M !== D)
|
|
5111
|
+
P.chain().deleteSelection().insertContent(N).run();
|
|
5158
5112
|
else {
|
|
5159
|
-
const { state:
|
|
5113
|
+
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));
|
|
5160
5114
|
let z = "";
|
|
5161
|
-
H > 0 &&
|
|
5115
|
+
H > 0 && U !== " " && !E(U) && (z = " ");
|
|
5162
5116
|
let W = "";
|
|
5163
|
-
|
|
5117
|
+
F && F !== " " && !E(F) && (W = " "), P.chain().insertContent(z + N + W).run();
|
|
5164
5118
|
}
|
|
5165
|
-
setTimeout(() => m(
|
|
5119
|
+
setTimeout(() => m(P.getHTML(), {}, o), 100);
|
|
5166
5120
|
return;
|
|
5167
5121
|
}
|
|
5168
5122
|
} else {
|
|
5169
|
-
const
|
|
5170
|
-
if (
|
|
5171
|
-
const
|
|
5123
|
+
const P = I, N = P.selectionStart || 0, M = P.value || "", D = P.selectionEnd || N;
|
|
5124
|
+
if (D > N) {
|
|
5125
|
+
const F = `{{${y}}}`, { text: z } = T(M, N, F), W = M.slice(0, N) + z + M.slice(D);
|
|
5172
5126
|
m(W, {}, o);
|
|
5173
5127
|
return;
|
|
5174
5128
|
}
|
|
5175
|
-
const
|
|
5176
|
-
m(
|
|
5129
|
+
const $ = `{{${y}}}`, { text: H } = T(M, N, $), U = M.slice(0, N) + H + M.slice(N);
|
|
5130
|
+
m(U, {}, o);
|
|
5177
5131
|
}
|
|
5178
5132
|
},
|
|
5179
|
-
[o, m, g,
|
|
5133
|
+
[o, m, g, B == null ? void 0 : B._id]
|
|
5180
5134
|
);
|
|
5181
5135
|
if (d)
|
|
5182
5136
|
return null;
|
|
5183
5137
|
if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
|
|
5184
|
-
const v =
|
|
5138
|
+
const v = j == null ? void 0 : j.includes(o.replace("root.", ""));
|
|
5185
5139
|
if (u.type === "array") {
|
|
5186
|
-
const
|
|
5140
|
+
const y = _ === o;
|
|
5187
5141
|
return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
|
|
5188
5142
|
u.title && /* @__PURE__ */ jsxs(
|
|
5189
5143
|
"label",
|
|
5190
5144
|
{
|
|
5191
5145
|
htmlFor: o,
|
|
5192
|
-
onClick: () => S(
|
|
5146
|
+
onClick: () => S(y ? null : o),
|
|
5193
5147
|
className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
|
|
5194
5148
|
children: [
|
|
5195
|
-
|
|
5149
|
+
y ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
|
|
5196
5150
|
/* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
|
|
5197
5151
|
/* @__PURE__ */ jsx("span", { className: "leading-tight", children: r }),
|
|
5198
5152
|
" ",
|
|
@@ -5200,7 +5154,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5200
5154
|
]
|
|
5201
5155
|
}
|
|
5202
5156
|
),
|
|
5203
|
-
(g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${
|
|
5157
|
+
(g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${y ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
|
|
5204
5158
|
c,
|
|
5205
5159
|
a,
|
|
5206
5160
|
l,
|
|
@@ -5215,11 +5169,11 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5215
5169
|
" ",
|
|
5216
5170
|
v && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
|
|
5217
5171
|
" ",
|
|
5218
|
-
|
|
5172
|
+
k
|
|
5219
5173
|
] }),
|
|
5220
5174
|
p && u.type !== "object" ? " *" : null
|
|
5221
5175
|
] }),
|
|
5222
|
-
u.type === "string" && !u.enum && !u.oneOf &&
|
|
5176
|
+
u.type === "string" && !u.enum && !u.oneOf && A && /* @__PURE__ */ jsx(NestedPathSelector, { data: A, onSelect: w, dataType: "value" })
|
|
5223
5177
|
] }),
|
|
5224
5178
|
c,
|
|
5225
5179
|
a,
|
|
@@ -5274,8 +5228,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5274
5228
|
formData: a,
|
|
5275
5229
|
onChange: ({ formData: g }, m) => {
|
|
5276
5230
|
if (!m || o !== (g == null ? void 0 : g._id)) return;
|
|
5277
|
-
const
|
|
5278
|
-
u({ formData: g },
|
|
5231
|
+
const x = take(m.split("."), 2).join(".").replace("root.", "");
|
|
5232
|
+
u({ formData: g }, x);
|
|
5279
5233
|
}
|
|
5280
5234
|
},
|
|
5281
5235
|
i
|
|
@@ -5318,35 +5272,35 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5318
5272
|
}), a;
|
|
5319
5273
|
};
|
|
5320
5274
|
function BlockSettings() {
|
|
5321
|
-
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),
|
|
5322
|
-
S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(
|
|
5323
|
-
},
|
|
5324
|
-
debounce(({ formData:
|
|
5325
|
-
f({ formData:
|
|
5275
|
+
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), x = formDataWithSelectedLang(g, o, m), f = ({ formData: _ }, S, w) => {
|
|
5276
|
+
S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(_, S) }, w);
|
|
5277
|
+
}, h = useCallback(
|
|
5278
|
+
debounce(({ formData: _ }, S, w) => {
|
|
5279
|
+
f({ formData: _ }, S, w), d(_);
|
|
5326
5280
|
}, 1500),
|
|
5327
5281
|
[n == null ? void 0 : n._id, o]
|
|
5328
|
-
), b = ({ formData:
|
|
5329
|
-
S && (r([n._id], { [S]: get(
|
|
5330
|
-
},
|
|
5331
|
-
S && (r([g._id], { [S]: get(
|
|
5282
|
+
), b = ({ formData: _ }, S) => {
|
|
5283
|
+
S && (r([n._id], { [S]: get(_, S) }), h({ formData: _ }, S, { [S]: get(c, S) }));
|
|
5284
|
+
}, k = ({ formData: _ }, S) => {
|
|
5285
|
+
S && (r([g._id], { [S]: get(_, S) }), h({ formData: _ }, S, { [S]: get(c, S) }));
|
|
5332
5286
|
};
|
|
5333
5287
|
keys(get(i, "_bindings", {}));
|
|
5334
|
-
const { schema:
|
|
5335
|
-
const
|
|
5336
|
-
if (
|
|
5337
|
-
return getBlockFormSchemas(
|
|
5338
|
-
}, [n]), { wrapperSchema:
|
|
5288
|
+
const { schema: A, uiSchema: B } = useMemo(() => {
|
|
5289
|
+
const _ = n == null ? void 0 : n._type;
|
|
5290
|
+
if (_)
|
|
5291
|
+
return getBlockFormSchemas(_);
|
|
5292
|
+
}, [n]), { wrapperSchema: C, wrapperUiSchema: j } = useMemo(() => {
|
|
5339
5293
|
if (!g || !(g != null && g._type))
|
|
5340
5294
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5341
|
-
const
|
|
5342
|
-
return { wrapperSchema: S, wrapperUiSchema:
|
|
5295
|
+
const _ = g == null ? void 0 : g._type, { schema: S = {}, uiSchema: w = {} } = getBlockFormSchemas(_);
|
|
5296
|
+
return { wrapperSchema: S, wrapperUiSchema: w };
|
|
5343
5297
|
}, [g]);
|
|
5344
5298
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5345
5299
|
!isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
5346
5300
|
/* @__PURE__ */ jsxs(
|
|
5347
5301
|
"div",
|
|
5348
5302
|
{
|
|
5349
|
-
onClick: () => u((
|
|
5303
|
+
onClick: () => u((_) => !_),
|
|
5350
5304
|
className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
|
|
5351
5305
|
children: [
|
|
5352
5306
|
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" }),
|
|
@@ -5365,21 +5319,21 @@ function BlockSettings() {
|
|
|
5365
5319
|
JSONForm,
|
|
5366
5320
|
{
|
|
5367
5321
|
blockId: g == null ? void 0 : g._id,
|
|
5368
|
-
onChange:
|
|
5369
|
-
formData:
|
|
5370
|
-
schema:
|
|
5371
|
-
uiSchema:
|
|
5322
|
+
onChange: k,
|
|
5323
|
+
formData: x,
|
|
5324
|
+
schema: C,
|
|
5325
|
+
uiSchema: j
|
|
5372
5326
|
}
|
|
5373
5327
|
) })
|
|
5374
5328
|
] }),
|
|
5375
|
-
isEmpty(
|
|
5329
|
+
isEmpty(A) ? null : /* @__PURE__ */ jsx(
|
|
5376
5330
|
JSONForm,
|
|
5377
5331
|
{
|
|
5378
5332
|
blockId: n == null ? void 0 : n._id,
|
|
5379
5333
|
onChange: b,
|
|
5380
5334
|
formData: i,
|
|
5381
|
-
schema:
|
|
5382
|
-
uiSchema:
|
|
5335
|
+
schema: A,
|
|
5336
|
+
uiSchema: B
|
|
5383
5337
|
}
|
|
5384
5338
|
),
|
|
5385
5339
|
(n == null ? void 0 : n._type) === "GlobalBlock" ? /* @__PURE__ */ jsx(GlobalBlockSettings, {}) : null
|
|
@@ -5484,32 +5438,32 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5484
5438
|
canvas: n = !1,
|
|
5485
5439
|
tooltip: r = !0
|
|
5486
5440
|
}) => {
|
|
5487
|
-
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(),
|
|
5488
|
-
u.includes(
|
|
5489
|
-
},
|
|
5490
|
-
n || l(
|
|
5441
|
+
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), x = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (k) => {
|
|
5442
|
+
u.includes(k) ? u.length > 2 && g(u.filter((A) => A !== k)) : g((A) => [...A, k]);
|
|
5443
|
+
}, h = (k) => {
|
|
5444
|
+
n || l(k), c(k);
|
|
5491
5445
|
}, b = getBreakpointValue(n ? i : a).toLowerCase();
|
|
5492
|
-
return
|
|
5446
|
+
return x.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(x, (k) => /* @__PURE__ */ createElement(
|
|
5493
5447
|
BreakpointCard,
|
|
5494
5448
|
{
|
|
5495
5449
|
canvas: n,
|
|
5496
|
-
...
|
|
5497
|
-
onClick:
|
|
5498
|
-
key:
|
|
5450
|
+
...k,
|
|
5451
|
+
onClick: h,
|
|
5452
|
+
key: k.breakpoint,
|
|
5499
5453
|
currentBreakpoint: b
|
|
5500
5454
|
}
|
|
5501
5455
|
)) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
|
|
5502
5456
|
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
|
|
5503
|
-
|
|
5504
|
-
(
|
|
5457
|
+
x.filter((k) => includes(u, toUpper(k.breakpoint))),
|
|
5458
|
+
(k) => /* @__PURE__ */ createElement(
|
|
5505
5459
|
BreakpointCard,
|
|
5506
5460
|
{
|
|
5507
5461
|
canvas: n,
|
|
5508
5462
|
openDelay: o,
|
|
5509
5463
|
tooltip: r,
|
|
5510
|
-
...
|
|
5511
|
-
onClick:
|
|
5512
|
-
key:
|
|
5464
|
+
...k,
|
|
5465
|
+
onClick: h,
|
|
5466
|
+
key: k.breakpoint,
|
|
5513
5467
|
currentBreakpoint: b
|
|
5514
5468
|
}
|
|
5515
5469
|
)
|
|
@@ -5519,15 +5473,15 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5519
5473
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
|
|
5520
5474
|
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: m("Screen sizes") }),
|
|
5521
5475
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
5522
|
-
map(
|
|
5476
|
+
map(x, (k) => /* @__PURE__ */ jsx(
|
|
5523
5477
|
DropdownMenuCheckboxItem,
|
|
5524
5478
|
{
|
|
5525
|
-
disabled:
|
|
5526
|
-
onCheckedChange: () => f(toUpper(
|
|
5527
|
-
checked: includes(u, toUpper(
|
|
5528
|
-
children: m(
|
|
5479
|
+
disabled: k.breakpoint === "xs",
|
|
5480
|
+
onCheckedChange: () => f(toUpper(k.breakpoint)),
|
|
5481
|
+
checked: includes(u, toUpper(k.breakpoint)),
|
|
5482
|
+
children: m(k.title)
|
|
5529
5483
|
},
|
|
5530
|
-
|
|
5484
|
+
k.breakpoint
|
|
5531
5485
|
))
|
|
5532
5486
|
] })
|
|
5533
5487
|
] })
|
|
@@ -5604,11 +5558,11 @@ function Countdown() {
|
|
|
5604
5558
|
const AskAIStyles = ({ blockId: o }) => {
|
|
5605
5559
|
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
|
|
5606
5560
|
useEffect(() => {
|
|
5607
|
-
var
|
|
5608
|
-
(
|
|
5561
|
+
var x;
|
|
5562
|
+
(x = d.current) == null || x.focus();
|
|
5609
5563
|
}, []);
|
|
5610
|
-
const m = (
|
|
5611
|
-
const { usage: f } =
|
|
5564
|
+
const m = (x) => {
|
|
5565
|
+
const { usage: f } = x || {};
|
|
5612
5566
|
!l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
5613
5567
|
};
|
|
5614
5568
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
@@ -5618,12 +5572,12 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5618
5572
|
{
|
|
5619
5573
|
ref: d,
|
|
5620
5574
|
value: i,
|
|
5621
|
-
onChange: (
|
|
5575
|
+
onChange: (x) => c(x.target.value),
|
|
5622
5576
|
placeholder: n("Ask AI to edit styles"),
|
|
5623
5577
|
className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
|
|
5624
5578
|
rows: 4,
|
|
5625
|
-
onKeyDown: (
|
|
5626
|
-
|
|
5579
|
+
onKeyDown: (x) => {
|
|
5580
|
+
x.key === "Enter" && (x.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
|
|
5627
5581
|
}
|
|
5628
5582
|
}
|
|
5629
5583
|
),
|
|
@@ -5665,24 +5619,24 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5665
5619
|
};
|
|
5666
5620
|
function ManualClasses() {
|
|
5667
5621
|
var T;
|
|
5668
|
-
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(),
|
|
5622
|
+
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(), x = useBuilderProp("askAiCallBack", null), [f, h] = useState(""), b = (T = first(d)) == null ? void 0 : T.prop, { classes: k } = getSplitChaiClasses(get(p, b, "")), A = k.split(" ").filter((I) => !isEmpty(I)), B = () => {
|
|
5669
5623
|
const I = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5670
|
-
u(m, I, !0),
|
|
5671
|
-
}, [
|
|
5672
|
-
const
|
|
5673
|
-
let
|
|
5674
|
-
if (
|
|
5675
|
-
const [
|
|
5676
|
-
|
|
5677
|
-
|
|
5678
|
-
item: {
|
|
5624
|
+
u(m, I, !0), h("");
|
|
5625
|
+
}, [C, j] = useState([]), _ = ({ value: I }) => {
|
|
5626
|
+
const R = I.trim().toLowerCase(), P = R.match(/.+:/g);
|
|
5627
|
+
let N = [];
|
|
5628
|
+
if (P && P.length > 0) {
|
|
5629
|
+
const [M] = P, D = R.replace(M, "");
|
|
5630
|
+
N = i.search(D).map(($) => ({
|
|
5631
|
+
...$,
|
|
5632
|
+
item: { ...$.item, name: M + $.item.name }
|
|
5679
5633
|
}));
|
|
5680
5634
|
} else
|
|
5681
|
-
|
|
5682
|
-
return
|
|
5635
|
+
N = i.search(R);
|
|
5636
|
+
return j(map(N, "item"));
|
|
5683
5637
|
}, S = () => {
|
|
5684
|
-
|
|
5685
|
-
},
|
|
5638
|
+
j([]);
|
|
5639
|
+
}, w = (I) => I.name, L = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), v = useMemo(
|
|
5686
5640
|
() => ({
|
|
5687
5641
|
ref: o,
|
|
5688
5642
|
autoComplete: "off",
|
|
@@ -5692,33 +5646,33 @@ function ManualClasses() {
|
|
|
5692
5646
|
placeholder: c("Enter classes separated by space"),
|
|
5693
5647
|
value: f,
|
|
5694
5648
|
onKeyDown: (I) => {
|
|
5695
|
-
I.key === "Enter" && f.trim() !== "" &&
|
|
5649
|
+
I.key === "Enter" && f.trim() !== "" && B();
|
|
5696
5650
|
},
|
|
5697
|
-
onChange: (I, { newValue:
|
|
5651
|
+
onChange: (I, { newValue: R }) => h(R),
|
|
5698
5652
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
5699
5653
|
}),
|
|
5700
5654
|
[f, c, o]
|
|
5701
|
-
),
|
|
5655
|
+
), y = (I) => {
|
|
5702
5656
|
debugger;
|
|
5703
|
-
const
|
|
5704
|
-
g(m, [I]), u(m,
|
|
5705
|
-
},
|
|
5657
|
+
const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5658
|
+
g(m, [I]), u(m, R, !0), r(""), l(-1);
|
|
5659
|
+
}, E = () => {
|
|
5706
5660
|
if (navigator.clipboard === void 0) {
|
|
5707
5661
|
toast.error(c("Clipboard not supported"));
|
|
5708
5662
|
return;
|
|
5709
5663
|
}
|
|
5710
|
-
navigator.clipboard.writeText(
|
|
5664
|
+
navigator.clipboard.writeText(A.join(" ")), toast.success(c("Classes copied to clipboard"));
|
|
5711
5665
|
};
|
|
5712
5666
|
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
|
|
5713
5667
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
|
|
5714
5668
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
|
|
5715
5669
|
/* @__PURE__ */ jsx("span", { children: c("Classes") }),
|
|
5716
5670
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5717
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick:
|
|
5671
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: E, className: "cursor-pointer" }) }),
|
|
5718
5672
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
|
|
5719
5673
|
] })
|
|
5720
5674
|
] }),
|
|
5721
|
-
|
|
5675
|
+
x ? /* @__PURE__ */ jsxs(Popover, { children: [
|
|
5722
5676
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
|
|
5723
5677
|
/* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4" }),
|
|
5724
5678
|
/* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
|
|
@@ -5730,10 +5684,10 @@ function ManualClasses() {
|
|
|
5730
5684
|
/* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
|
|
5731
5685
|
Autosuggest,
|
|
5732
5686
|
{
|
|
5733
|
-
suggestions:
|
|
5734
|
-
onSuggestionsFetchRequested:
|
|
5687
|
+
suggestions: C,
|
|
5688
|
+
onSuggestionsFetchRequested: _,
|
|
5735
5689
|
onSuggestionsClearRequested: S,
|
|
5736
|
-
getSuggestionValue:
|
|
5690
|
+
getSuggestionValue: w,
|
|
5737
5691
|
renderSuggestion: L,
|
|
5738
5692
|
inputProps: v,
|
|
5739
5693
|
containerProps: {
|
|
@@ -5751,25 +5705,25 @@ function ManualClasses() {
|
|
|
5751
5705
|
{
|
|
5752
5706
|
variant: "outline",
|
|
5753
5707
|
className: "h-6 border-border",
|
|
5754
|
-
onClick:
|
|
5708
|
+
onClick: B,
|
|
5755
5709
|
disabled: f.trim() === "",
|
|
5756
5710
|
size: "sm",
|
|
5757
5711
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
5758
5712
|
}
|
|
5759
5713
|
)
|
|
5760
5714
|
] }),
|
|
5761
|
-
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children:
|
|
5762
|
-
(I,
|
|
5715
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: A.map(
|
|
5716
|
+
(I, R) => a === R ? /* @__PURE__ */ jsx(
|
|
5763
5717
|
"input",
|
|
5764
5718
|
{
|
|
5765
5719
|
ref: o,
|
|
5766
5720
|
value: n,
|
|
5767
|
-
onChange: (
|
|
5721
|
+
onChange: (P) => r(P.target.value),
|
|
5768
5722
|
onBlur: () => {
|
|
5769
|
-
|
|
5723
|
+
y(I);
|
|
5770
5724
|
},
|
|
5771
|
-
onKeyDown: (
|
|
5772
|
-
|
|
5725
|
+
onKeyDown: (P) => {
|
|
5726
|
+
P.key === "Enter" && y(I);
|
|
5773
5727
|
},
|
|
5774
5728
|
className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"
|
|
5775
5729
|
},
|
|
@@ -6129,10 +6083,10 @@ const COLOR_PROP = {
|
|
|
6129
6083
|
ringColor: "ring",
|
|
6130
6084
|
ringOffsetColor: "ring-offset"
|
|
6131
6085
|
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
6132
|
-
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", ""),
|
|
6086
|
+
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", ""), x = useCallback(
|
|
6133
6087
|
// eslint-disable-next-line no-shadow
|
|
6134
6088
|
(b) => {
|
|
6135
|
-
["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((
|
|
6089
|
+
["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" })));
|
|
6136
6090
|
},
|
|
6137
6091
|
[c, p]
|
|
6138
6092
|
);
|
|
@@ -6151,18 +6105,18 @@ const COLOR_PROP = {
|
|
|
6151
6105
|
useEffect(() => {
|
|
6152
6106
|
p({ color: "", shade: "" });
|
|
6153
6107
|
}, [r]);
|
|
6154
|
-
const { match:
|
|
6108
|
+
const { match: h } = useTailwindClassList();
|
|
6155
6109
|
return useEffect(() => {
|
|
6156
|
-
const
|
|
6157
|
-
|
|
6158
|
-
}, [
|
|
6110
|
+
const k = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
6111
|
+
h(o, k) && n(k, o);
|
|
6112
|
+
}, [h, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
|
|
6159
6113
|
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
6160
6114
|
DropDown,
|
|
6161
6115
|
{
|
|
6162
6116
|
disabled: !l,
|
|
6163
6117
|
rounded: !0,
|
|
6164
6118
|
selected: g,
|
|
6165
|
-
onChange:
|
|
6119
|
+
onChange: x,
|
|
6166
6120
|
options: [
|
|
6167
6121
|
"current",
|
|
6168
6122
|
"transparent",
|
|
@@ -6392,50 +6346,50 @@ const COLOR_PROP = {
|
|
|
6392
6346
|
},
|
|
6393
6347
|
a
|
|
6394
6348
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
6395
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m,
|
|
6349
|
+
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, x] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, h] = useState(!1), [b, k] = useState(""), [A, B] = useState(!1), [C, j] = useState(!1);
|
|
6396
6350
|
useEffect(() => {
|
|
6397
|
-
const { value: v, unit:
|
|
6398
|
-
if (
|
|
6399
|
-
l(v),
|
|
6351
|
+
const { value: v, unit: y } = getClassValueAndUnit(i);
|
|
6352
|
+
if (y === "") {
|
|
6353
|
+
l(v), x(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
6400
6354
|
return;
|
|
6401
6355
|
}
|
|
6402
|
-
|
|
6356
|
+
x(y), l(y === "class" || isEmpty(v) ? "" : v);
|
|
6403
6357
|
}, [i, p, u]);
|
|
6404
|
-
const
|
|
6358
|
+
const _ = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), S = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), w = useCallback(
|
|
6405
6359
|
(v = !1) => {
|
|
6406
|
-
const
|
|
6407
|
-
if (get(
|
|
6408
|
-
|
|
6360
|
+
const y = getUserInputValues(`${a}`, u);
|
|
6361
|
+
if (get(y, "error", !1)) {
|
|
6362
|
+
h(!0);
|
|
6409
6363
|
return;
|
|
6410
6364
|
}
|
|
6411
|
-
const
|
|
6412
|
-
if (
|
|
6413
|
-
|
|
6365
|
+
const E = get(y, "unit") !== "" ? get(y, "unit") : m;
|
|
6366
|
+
if (E === "auto" || E === "none") {
|
|
6367
|
+
_(`${d}${E}`);
|
|
6414
6368
|
return;
|
|
6415
6369
|
}
|
|
6416
|
-
if (get(
|
|
6370
|
+
if (get(y, "value") === "")
|
|
6417
6371
|
return;
|
|
6418
|
-
const I = `${get(
|
|
6419
|
-
v ? S(I) :
|
|
6372
|
+
const I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
|
|
6373
|
+
v ? S(I) : _(I);
|
|
6420
6374
|
},
|
|
6421
|
-
[
|
|
6375
|
+
[_, S, a, m, d, u]
|
|
6422
6376
|
), L = useCallback(
|
|
6423
6377
|
(v) => {
|
|
6424
|
-
const
|
|
6425
|
-
if (get(
|
|
6426
|
-
|
|
6378
|
+
const y = getUserInputValues(`${a}`, u);
|
|
6379
|
+
if (get(y, "error", !1)) {
|
|
6380
|
+
h(!0);
|
|
6427
6381
|
return;
|
|
6428
6382
|
}
|
|
6429
6383
|
if (v === "auto" || v === "none") {
|
|
6430
|
-
|
|
6384
|
+
_(`${d}${v}`);
|
|
6431
6385
|
return;
|
|
6432
6386
|
}
|
|
6433
|
-
if (get(
|
|
6387
|
+
if (get(y, "value") === "")
|
|
6434
6388
|
return;
|
|
6435
|
-
const
|
|
6436
|
-
|
|
6389
|
+
const E = get(y, "unit") !== "" ? get(y, "unit") : v, I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
|
|
6390
|
+
_(I);
|
|
6437
6391
|
},
|
|
6438
|
-
[
|
|
6392
|
+
[_, a, d, u]
|
|
6439
6393
|
);
|
|
6440
6394
|
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: [
|
|
6441
6395
|
/* @__PURE__ */ jsx(
|
|
@@ -6450,37 +6404,37 @@ const COLOR_PROP = {
|
|
|
6450
6404
|
/* @__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, {}) }) }),
|
|
6451
6405
|
/* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
|
|
6452
6406
|
] })
|
|
6453
|
-
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${
|
|
6407
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${A ? "z-auto" : ""}`, children: [
|
|
6454
6408
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
6455
6409
|
["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
|
|
6456
6410
|
"input",
|
|
6457
6411
|
{
|
|
6458
6412
|
readOnly: m === "class",
|
|
6459
6413
|
onKeyPress: (v) => {
|
|
6460
|
-
v.key === "Enter" &&
|
|
6414
|
+
v.key === "Enter" && w();
|
|
6461
6415
|
},
|
|
6462
6416
|
onKeyDown: (v) => {
|
|
6463
6417
|
if (v.keyCode !== 38 && v.keyCode !== 40)
|
|
6464
6418
|
return;
|
|
6465
|
-
v.preventDefault(),
|
|
6466
|
-
const
|
|
6467
|
-
let
|
|
6468
|
-
v.keyCode === 38 && (
|
|
6469
|
-
const T = `${
|
|
6470
|
-
S(
|
|
6419
|
+
v.preventDefault(), j(!0);
|
|
6420
|
+
const y = parseInt$1(v.target.value);
|
|
6421
|
+
let E = isNaN$1(y) ? 0 : y;
|
|
6422
|
+
v.keyCode === 38 && (E += 1), v.keyCode === 40 && (E -= 1);
|
|
6423
|
+
const T = `${E}`, R = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6424
|
+
S(R);
|
|
6471
6425
|
},
|
|
6472
6426
|
onKeyUp: (v) => {
|
|
6473
|
-
|
|
6427
|
+
C && (v.preventDefault(), j(!1));
|
|
6474
6428
|
},
|
|
6475
|
-
onBlur: () =>
|
|
6429
|
+
onBlur: () => w(),
|
|
6476
6430
|
onChange: (v) => {
|
|
6477
|
-
|
|
6431
|
+
h(!1), l(v.target.value);
|
|
6478
6432
|
},
|
|
6479
6433
|
onClick: (v) => {
|
|
6480
|
-
var
|
|
6481
|
-
(
|
|
6434
|
+
var y;
|
|
6435
|
+
(y = v == null ? void 0 : v.target) == null || y.select(), r(!1);
|
|
6482
6436
|
},
|
|
6483
|
-
value:
|
|
6437
|
+
value: A ? b : a,
|
|
6484
6438
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
6485
6439
|
" ",
|
|
6486
6440
|
f ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
@@ -6506,27 +6460,27 @@ const COLOR_PROP = {
|
|
|
6506
6460
|
units: u,
|
|
6507
6461
|
current: m,
|
|
6508
6462
|
onSelect: (v) => {
|
|
6509
|
-
r(!1),
|
|
6463
|
+
r(!1), x(v), L(v);
|
|
6510
6464
|
}
|
|
6511
6465
|
}
|
|
6512
6466
|
) }) })
|
|
6513
6467
|
] })
|
|
6514
6468
|
] }),
|
|
6515
|
-
["none", "auto"].indexOf(m) !== -1 ||
|
|
6469
|
+
["none", "auto"].indexOf(m) !== -1 || A ? null : /* @__PURE__ */ jsx(
|
|
6516
6470
|
DragStyleButton,
|
|
6517
6471
|
{
|
|
6518
|
-
onDragStart: () =>
|
|
6472
|
+
onDragStart: () => B(!0),
|
|
6519
6473
|
onDragEnd: (v) => {
|
|
6520
|
-
if (
|
|
6474
|
+
if (k(() => ""), B(!1), isEmpty(v))
|
|
6521
6475
|
return;
|
|
6522
|
-
const
|
|
6523
|
-
|
|
6476
|
+
const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6477
|
+
_(T);
|
|
6524
6478
|
},
|
|
6525
6479
|
onDrag: (v) => {
|
|
6526
6480
|
if (isEmpty(v))
|
|
6527
6481
|
return;
|
|
6528
|
-
|
|
6529
|
-
const
|
|
6482
|
+
k(v);
|
|
6483
|
+
const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6530
6484
|
S(T);
|
|
6531
6485
|
},
|
|
6532
6486
|
currentValue: a,
|
|
@@ -6624,23 +6578,23 @@ const COLOR_PROP = {
|
|
|
6624
6578
|
"2xl": "1536px"
|
|
6625
6579
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6626
6580
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6627
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l),
|
|
6628
|
-
(S,
|
|
6581
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), x = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), k = useCallback(
|
|
6582
|
+
(S, w = !0) => {
|
|
6629
6583
|
const L = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
|
|
6630
6584
|
(p || u !== "") && (L.mq = "xs");
|
|
6631
6585
|
const v = generateFullClsName(L);
|
|
6632
|
-
h
|
|
6586
|
+
x(h, [v], w);
|
|
6633
6587
|
},
|
|
6634
|
-
[
|
|
6635
|
-
),
|
|
6636
|
-
f(
|
|
6637
|
-
}, [
|
|
6588
|
+
[h, p, g, u, l, x]
|
|
6589
|
+
), A = useCallback(() => {
|
|
6590
|
+
f(h, [b], !0);
|
|
6591
|
+
}, [h, b, f]), B = useMemo(() => canChangeClass(m, g), [m, g]);
|
|
6638
6592
|
useEffect(() => {
|
|
6639
|
-
i(
|
|
6640
|
-
}, [
|
|
6641
|
-
const [, ,
|
|
6593
|
+
i(B, m);
|
|
6594
|
+
}, [B, i, m]);
|
|
6595
|
+
const [, , C] = useScreenSizeWidth(), j = useCallback(
|
|
6642
6596
|
(S) => {
|
|
6643
|
-
|
|
6597
|
+
C({
|
|
6644
6598
|
xs: 400,
|
|
6645
6599
|
sm: 640,
|
|
6646
6600
|
md: 800,
|
|
@@ -6649,10 +6603,10 @@ const COLOR_PROP = {
|
|
|
6649
6603
|
"2xl": 1920
|
|
6650
6604
|
}[S]);
|
|
6651
6605
|
},
|
|
6652
|
-
[
|
|
6653
|
-
),
|
|
6654
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange:
|
|
6655
|
-
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !
|
|
6606
|
+
[C]
|
|
6607
|
+
), _ = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
|
|
6608
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: m && _, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
6609
|
+
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !_ ? "text-foreground" : ""}`, children: n(a) }) }),
|
|
6656
6610
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6657
6611
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
6658
6612
|
r === "arbitrary" ? /* @__PURE__ */ jsx(
|
|
@@ -6661,17 +6615,17 @@ const COLOR_PROP = {
|
|
|
6661
6615
|
currentClass: get(m, "cls", ""),
|
|
6662
6616
|
classPrefix: get(CLASS_PREFIXES, l, ""),
|
|
6663
6617
|
units: c || [],
|
|
6664
|
-
onChange:
|
|
6618
|
+
onChange: k,
|
|
6665
6619
|
negative: d,
|
|
6666
6620
|
cssProperty: l
|
|
6667
6621
|
}
|
|
6668
6622
|
) : null,
|
|
6669
|
-
r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange:
|
|
6670
|
-
r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange:
|
|
6671
|
-
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange:
|
|
6672
|
-
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange:
|
|
6623
|
+
r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange: k }),
|
|
6624
|
+
r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange: k }),
|
|
6625
|
+
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: k }),
|
|
6626
|
+
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: k })
|
|
6673
6627
|
] }),
|
|
6674
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children:
|
|
6628
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: _ ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => A(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6675
6629
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6676
6630
|
"button",
|
|
6677
6631
|
{
|
|
@@ -6691,7 +6645,7 @@ const COLOR_PROP = {
|
|
|
6691
6645
|
"button",
|
|
6692
6646
|
{
|
|
6693
6647
|
type: "button",
|
|
6694
|
-
onClick: () =>
|
|
6648
|
+
onClick: () => j(get(m, "mq")),
|
|
6695
6649
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
6696
6650
|
children: [
|
|
6697
6651
|
"Switch to ",
|
|
@@ -6712,7 +6666,7 @@ const COLOR_PROP = {
|
|
|
6712
6666
|
units: i = basicUnits,
|
|
6713
6667
|
negative: c = !1
|
|
6714
6668
|
}) => {
|
|
6715
|
-
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((
|
|
6669
|
+
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((x) => map(g, "property").includes(x), [g]);
|
|
6716
6670
|
return /* @__PURE__ */ jsxs(
|
|
6717
6671
|
"div",
|
|
6718
6672
|
{
|
|
@@ -6721,7 +6675,7 @@ const COLOR_PROP = {
|
|
|
6721
6675
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6722
6676
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6723
6677
|
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
|
|
6724
|
-
n.map(({ label:
|
|
6678
|
+
n.map(({ label: x, key: f }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6725
6679
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6726
6680
|
"button",
|
|
6727
6681
|
{
|
|
@@ -6736,7 +6690,7 @@ const COLOR_PROP = {
|
|
|
6736
6690
|
]
|
|
6737
6691
|
}
|
|
6738
6692
|
) }),
|
|
6739
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(
|
|
6693
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(x)) })
|
|
6740
6694
|
] }) }))
|
|
6741
6695
|
) })
|
|
6742
6696
|
] }),
|
|
@@ -6876,11 +6830,11 @@ function BlockStyling() {
|
|
|
6876
6830
|
}), d = useThrottledCallback(
|
|
6877
6831
|
(u) => {
|
|
6878
6832
|
const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
|
|
6879
|
-
let
|
|
6880
|
-
|
|
6833
|
+
let x = parseFloat(i.dragStartValue);
|
|
6834
|
+
x = isNaN(x) ? 0 : x;
|
|
6881
6835
|
let f = MAPPER[i.dragUnit];
|
|
6882
6836
|
(startsWith(m, "scale") || m === "opacity") && (f = 10);
|
|
6883
|
-
let b = (i.dragStartY - u.pageY) / f +
|
|
6837
|
+
let b = (i.dragStartY - u.pageY) / f + x;
|
|
6884
6838
|
g && b < 0 && (b = 0), m === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
|
|
6885
6839
|
},
|
|
6886
6840
|
[i],
|
|
@@ -6917,26 +6871,30 @@ function BlockStyling() {
|
|
|
6917
6871
|
] })
|
|
6918
6872
|
] });
|
|
6919
6873
|
}
|
|
6920
|
-
const
|
|
6874
|
+
const CHAI_BUILDER_EVENTS = {
|
|
6875
|
+
OPEN_ADD_BLOCK: "OPEN_ADD_BLOCK",
|
|
6876
|
+
CLOSE_ADD_BLOCK: "CLOSE_ADD_BLOCK",
|
|
6877
|
+
SHOW_BLOCK_SETTINGS: "SHOW_BLOCK_SETTINGS"
|
|
6878
|
+
}, CoreBlock = ({
|
|
6921
6879
|
block: o,
|
|
6922
6880
|
disabled: n,
|
|
6923
6881
|
parentId: r,
|
|
6924
6882
|
position: a
|
|
6925
6883
|
}) => {
|
|
6926
|
-
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(),
|
|
6884
|
+
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), x = () => {
|
|
6927
6885
|
if (console.log("addBlockToPage", o), has(o, "blocks")) {
|
|
6928
6886
|
const b = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
|
|
6929
6887
|
u(syncBlocksWithDefaults(b), r || null, a);
|
|
6930
6888
|
} else
|
|
6931
6889
|
p(o, r || null, a);
|
|
6932
6890
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6933
|
-
}, f = useFeature("dnd"), { t:
|
|
6891
|
+
}, f = useFeature("dnd"), { t: h } = useTranslation();
|
|
6934
6892
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6935
6893
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6936
6894
|
"button",
|
|
6937
6895
|
{
|
|
6938
6896
|
disabled: n,
|
|
6939
|
-
onClick:
|
|
6897
|
+
onClick: x,
|
|
6940
6898
|
type: "button",
|
|
6941
6899
|
onDragStart: (b) => {
|
|
6942
6900
|
b.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), b.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
@@ -6947,11 +6905,11 @@ const CoreBlock = ({
|
|
|
6947
6905
|
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",
|
|
6948
6906
|
children: [
|
|
6949
6907
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
6950
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(
|
|
6908
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(h(d || i)) })
|
|
6951
6909
|
]
|
|
6952
6910
|
}
|
|
6953
6911
|
) }),
|
|
6954
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
6912
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: h(d || i) }) })
|
|
6955
6913
|
] }) });
|
|
6956
6914
|
}, DefaultChaiBlocks = ({
|
|
6957
6915
|
parentId: o,
|
|
@@ -7139,22 +7097,22 @@ const CoreBlock = ({
|
|
|
7139
7097
|
}
|
|
7140
7098
|
}
|
|
7141
7099
|
}, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
|
|
7142
|
-
var m,
|
|
7100
|
+
var m, x, f, h, b, k, A, B;
|
|
7143
7101
|
if (r.type === "comment") return [];
|
|
7144
7102
|
console.log("node ===>", r);
|
|
7145
7103
|
let a = { _id: generateUUID() };
|
|
7146
7104
|
if (n && (a._parent = n.block._id), r.type === "text")
|
|
7147
7105
|
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", "") };
|
|
7148
7106
|
const l = get(r, "attributes", []), i = l.find(
|
|
7149
|
-
(
|
|
7107
|
+
(C) => C.key === "data-chai-richtext" || C.key === "chai-richtext"
|
|
7150
7108
|
), c = l.find(
|
|
7151
|
-
(
|
|
7109
|
+
(C) => C.key === "data-chai-lightbox" || C.key === "chai-lightbox"
|
|
7152
7110
|
), d = l.find(
|
|
7153
|
-
(
|
|
7111
|
+
(C) => C.key === "data-chai-dropdown" || C.key === "chai-dropdown"
|
|
7154
7112
|
), p = l.find(
|
|
7155
|
-
(
|
|
7113
|
+
(C) => C.key === "data-chai-dropdown-button" || C.key === "chai-dropdown-button"
|
|
7156
7114
|
), u = l.find(
|
|
7157
|
-
(
|
|
7115
|
+
(C) => C.key === "data-chai-dropdown-content" || C.key === "chai-dropdown-content"
|
|
7158
7116
|
);
|
|
7159
7117
|
if (a = {
|
|
7160
7118
|
...a,
|
|
@@ -7162,13 +7120,13 @@ const CoreBlock = ({
|
|
|
7162
7120
|
...getAttrs(r),
|
|
7163
7121
|
...getStyles(r)
|
|
7164
7122
|
}, r.attributes) {
|
|
7165
|
-
const
|
|
7166
|
-
|
|
7123
|
+
const C = r.attributes.find((j) => includes(NAME_ATTRIBUTES, j.key));
|
|
7124
|
+
C && (a._name = C.value);
|
|
7167
7125
|
}
|
|
7168
7126
|
if (i)
|
|
7169
7127
|
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];
|
|
7170
7128
|
if (c) {
|
|
7171
|
-
const
|
|
7129
|
+
const C = [
|
|
7172
7130
|
"data-chai-lightbox",
|
|
7173
7131
|
"chai-lightbox",
|
|
7174
7132
|
"data-vbtype",
|
|
@@ -7180,44 +7138,44 @@ const CoreBlock = ({
|
|
|
7180
7138
|
];
|
|
7181
7139
|
a = {
|
|
7182
7140
|
...a,
|
|
7183
|
-
href: ((m = l.find((
|
|
7184
|
-
hrefType: ((
|
|
7185
|
-
autoplay: ((f = l.find((
|
|
7186
|
-
maxWidth: ((b = (
|
|
7187
|
-
backdropColor: ((
|
|
7188
|
-
galleryName: ((
|
|
7189
|
-
}, forEach(
|
|
7190
|
-
has(a, `styles_attrs.${
|
|
7141
|
+
href: ((m = l.find((j) => j.key === "href")) == null ? void 0 : m.value) || "",
|
|
7142
|
+
hrefType: ((x = l.find((j) => j.key === "data-vbtype")) == null ? void 0 : x.value) || "video",
|
|
7143
|
+
autoplay: ((f = l.find((j) => j.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
|
|
7144
|
+
maxWidth: ((b = (h = l.find((j) => j.key === "data-maxwidth")) == null ? void 0 : h.value) == null ? void 0 : b.replace("px", "")) || "",
|
|
7145
|
+
backdropColor: ((k = l.find((j) => j.key === "data-overlay")) == null ? void 0 : k.value) || "",
|
|
7146
|
+
galleryName: ((A = l.find((j) => j.key === "data-gall")) == null ? void 0 : A.value) || ""
|
|
7147
|
+
}, forEach(C, (j) => {
|
|
7148
|
+
has(a, `styles_attrs.${j}`) && delete a.styles_attrs[j];
|
|
7191
7149
|
});
|
|
7192
7150
|
}
|
|
7193
7151
|
if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
|
|
7194
7152
|
delete a.styles_attrs;
|
|
7195
|
-
const
|
|
7196
|
-
a.content = getTextContent(
|
|
7197
|
-
const
|
|
7153
|
+
const C = filter(r.children || [], (_) => (_ == null ? void 0 : _.tagName) !== "span");
|
|
7154
|
+
a.content = getTextContent(C);
|
|
7155
|
+
const j = find(
|
|
7198
7156
|
r.children || [],
|
|
7199
|
-
(
|
|
7157
|
+
(_) => (_ == null ? void 0 : _.tagName) === "span" && some(_.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg")
|
|
7200
7158
|
);
|
|
7201
|
-
if (
|
|
7202
|
-
const
|
|
7203
|
-
if (
|
|
7204
|
-
a.icon = stringify([
|
|
7205
|
-
const { height: S, width:
|
|
7206
|
-
a.iconHeight = S, a.iconWidth =
|
|
7159
|
+
if (j) {
|
|
7160
|
+
const _ = find(j.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg");
|
|
7161
|
+
if (_) {
|
|
7162
|
+
a.icon = stringify([_]);
|
|
7163
|
+
const { height: S, width: w } = getSvgDimensions(_, "16px", "16px");
|
|
7164
|
+
a.iconHeight = S, a.iconWidth = w;
|
|
7207
7165
|
}
|
|
7208
7166
|
}
|
|
7209
7167
|
return [a];
|
|
7210
7168
|
}
|
|
7211
7169
|
if (a._type === "Input") {
|
|
7212
|
-
const
|
|
7213
|
-
|
|
7170
|
+
const C = a.inputType || "text";
|
|
7171
|
+
C === "checkbox" ? set(a, "_type", "Checkbox") : C === "radio" && set(a, "_type", "Radio");
|
|
7214
7172
|
} else if (r.tagName === "video" || r.tagName === "iframe") {
|
|
7215
|
-
const
|
|
7216
|
-
return hasVideoEmbed(
|
|
7173
|
+
const C = stringify([r]);
|
|
7174
|
+
return hasVideoEmbed(C) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(C)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = C, [a];
|
|
7217
7175
|
} else if (r.tagName === "svg") {
|
|
7218
|
-
const
|
|
7219
|
-
return a.styles = `${STYLES_KEY}, ${cn$1(`w-${S} h-${
|
|
7220
|
-
} else if (r.tagName == "option" && n && ((
|
|
7176
|
+
const C = find(r.attributes, { key: "height" }), j = find(r.attributes, { key: "width" }), _ = get(C, "value") ? `[${get(C, "value")}px]` : "24px", S = get(j, "value") ? `[${get(j, "value")}px]` : "24px", w = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
|
|
7177
|
+
return a.styles = `${STYLES_KEY}, ${cn$1(`w-${S} h-${_}`, w)}`.trim(), r.attributes = filter(r.attributes, (L) => !includes(["style", "width", "height", "class"], L.key)), a.icon = stringify([r]), [a];
|
|
7178
|
+
} else if (r.tagName == "option" && n && ((B = n.block) == null ? void 0 : B._type) === "Select")
|
|
7221
7179
|
return n.block.options.push({
|
|
7222
7180
|
label: getTextContent(r.children),
|
|
7223
7181
|
...getAttrs(r)
|
|
@@ -7290,29 +7248,29 @@ const CoreBlock = ({
|
|
|
7290
7248
|
error: c
|
|
7291
7249
|
}), g(!0);
|
|
7292
7250
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7293
|
-
const
|
|
7294
|
-
const
|
|
7251
|
+
const x = Object.entries(a).map(([h, b]) => {
|
|
7252
|
+
const k = b, A = k.type || "partial", B = formatReadableName(A);
|
|
7295
7253
|
return {
|
|
7296
7254
|
type: "PartialBlock",
|
|
7297
7255
|
// Set the type to PartialBlock
|
|
7298
|
-
label: formatReadableName(
|
|
7299
|
-
description:
|
|
7256
|
+
label: formatReadableName(k.name || h),
|
|
7257
|
+
description: k.description || "",
|
|
7300
7258
|
icon: Globe,
|
|
7301
|
-
group:
|
|
7259
|
+
group: B,
|
|
7302
7260
|
// Use formatted type as group
|
|
7303
7261
|
category: "partial",
|
|
7304
|
-
partialBlockId:
|
|
7262
|
+
partialBlockId: h,
|
|
7305
7263
|
// Store the original ID as partialBlockId
|
|
7306
|
-
_name:
|
|
7264
|
+
_name: k.name
|
|
7307
7265
|
};
|
|
7308
|
-
}), f = uniq(map(
|
|
7266
|
+
}), f = uniq(map(x, "group"));
|
|
7309
7267
|
p({
|
|
7310
|
-
blocks:
|
|
7268
|
+
blocks: x,
|
|
7311
7269
|
groups: f,
|
|
7312
7270
|
isLoading: !1,
|
|
7313
7271
|
error: null
|
|
7314
7272
|
}), g(!0);
|
|
7315
|
-
} else l ? p((
|
|
7273
|
+
} else l ? p((x) => ({ ...x, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
|
|
7316
7274
|
blocks: [],
|
|
7317
7275
|
groups: [],
|
|
7318
7276
|
isLoading: !1,
|
|
@@ -7328,7 +7286,7 @@ const CoreBlock = ({
|
|
|
7328
7286
|
c
|
|
7329
7287
|
]);
|
|
7330
7288
|
const m = () => {
|
|
7331
|
-
p((
|
|
7289
|
+
p((x) => ({ ...x, isLoading: !0, error: null })), g(!1), i();
|
|
7332
7290
|
};
|
|
7333
7291
|
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: [
|
|
7334
7292
|
/* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
|
|
@@ -7352,43 +7310,43 @@ const CoreBlock = ({
|
|
|
7352
7310
|
);
|
|
7353
7311
|
}, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
7354
7312
|
var v;
|
|
7355
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (v = find(c, (
|
|
7313
|
+
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, [x, f] = useState("all"), [h, b] = useState(null), k = useRef(null);
|
|
7356
7314
|
useEffect(() => {
|
|
7357
|
-
const
|
|
7358
|
-
var
|
|
7359
|
-
(
|
|
7315
|
+
const y = setTimeout(() => {
|
|
7316
|
+
var E;
|
|
7317
|
+
(E = u.current) == null || E.focus();
|
|
7360
7318
|
}, 0);
|
|
7361
|
-
return () => clearTimeout(
|
|
7319
|
+
return () => clearTimeout(y);
|
|
7362
7320
|
}, [g]), useEffect(() => {
|
|
7363
7321
|
d && (f("all"), b(null));
|
|
7364
|
-
}, [d]), useEffect(() => (
|
|
7365
|
-
f(
|
|
7322
|
+
}, [d]), useEffect(() => (k.current = debounce((y) => {
|
|
7323
|
+
f(y);
|
|
7366
7324
|
}, 500), () => {
|
|
7367
|
-
|
|
7325
|
+
k.current && k.current.cancel();
|
|
7368
7326
|
}), []);
|
|
7369
|
-
const
|
|
7370
|
-
b(
|
|
7371
|
-
}, []),
|
|
7372
|
-
b(null),
|
|
7373
|
-
}, []),
|
|
7374
|
-
|
|
7375
|
-
}, []),
|
|
7327
|
+
const A = useCallback((y) => {
|
|
7328
|
+
b(y), k.current && k.current(y);
|
|
7329
|
+
}, []), B = useCallback(() => {
|
|
7330
|
+
b(null), k.current && k.current.cancel();
|
|
7331
|
+
}, []), C = useCallback((y) => {
|
|
7332
|
+
k.current && k.current.cancel(), f(y), b(null);
|
|
7333
|
+
}, []), j = useMemo(
|
|
7376
7334
|
() => d ? values(n).filter(
|
|
7377
|
-
(
|
|
7378
|
-
var
|
|
7379
|
-
return (((
|
|
7335
|
+
(y) => {
|
|
7336
|
+
var E, T;
|
|
7337
|
+
return (((E = y.label) == null ? void 0 : E.toLowerCase()) + " " + ((T = y.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
|
|
7380
7338
|
}
|
|
7381
7339
|
) : n,
|
|
7382
7340
|
[n, d]
|
|
7383
|
-
),
|
|
7341
|
+
), _ = useMemo(
|
|
7384
7342
|
() => d ? o.filter(
|
|
7385
|
-
(
|
|
7386
|
-
) : o.filter((
|
|
7387
|
-
[n,
|
|
7343
|
+
(y) => reject(filter(values(j), { group: y }), { hidden: !0 }).length > 0
|
|
7344
|
+
) : o.filter((y) => reject(filter(values(n), { group: y }), { hidden: !0 }).length > 0),
|
|
7345
|
+
[n, j, o, d]
|
|
7388
7346
|
), S = useMemo(
|
|
7389
|
-
() => sortBy(
|
|
7390
|
-
[
|
|
7391
|
-
),
|
|
7347
|
+
() => sortBy(_, (y) => CORE_GROUPS.indexOf(y) === -1 ? 99 : CORE_GROUPS.indexOf(y)),
|
|
7348
|
+
[_]
|
|
7349
|
+
), w = useMemo(() => x === "all" ? j : filter(values(j), { group: x }), [j, x]), L = useMemo(() => x === "all" ? S : [x], [S, x]);
|
|
7392
7350
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7393
7351
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7394
7352
|
Input$1,
|
|
@@ -7398,7 +7356,7 @@ const CoreBlock = ({
|
|
|
7398
7356
|
placeholder: i("Search blocks..."),
|
|
7399
7357
|
value: d,
|
|
7400
7358
|
className: "-ml-2",
|
|
7401
|
-
onChange: (
|
|
7359
|
+
onChange: (y) => p(y.target.value)
|
|
7402
7360
|
}
|
|
7403
7361
|
) }),
|
|
7404
7362
|
/* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
|
|
@@ -7406,49 +7364,49 @@ const CoreBlock = ({
|
|
|
7406
7364
|
/* @__PURE__ */ jsx(
|
|
7407
7365
|
"button",
|
|
7408
7366
|
{
|
|
7409
|
-
onClick: () =>
|
|
7410
|
-
onMouseEnter: () =>
|
|
7411
|
-
onMouseLeave:
|
|
7412
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${
|
|
7367
|
+
onClick: () => C("all"),
|
|
7368
|
+
onMouseEnter: () => A("all"),
|
|
7369
|
+
onMouseLeave: B,
|
|
7370
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${x === "all" || h === "all" ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
|
|
7413
7371
|
children: i("All")
|
|
7414
7372
|
},
|
|
7415
7373
|
"sidebar-all"
|
|
7416
7374
|
),
|
|
7417
|
-
S.map((
|
|
7375
|
+
S.map((y) => /* @__PURE__ */ jsx(
|
|
7418
7376
|
"button",
|
|
7419
7377
|
{
|
|
7420
|
-
onClick: () =>
|
|
7421
|
-
onMouseEnter: () =>
|
|
7422
|
-
onMouseLeave:
|
|
7423
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${
|
|
7424
|
-
children: capitalize(i(
|
|
7378
|
+
onClick: () => C(y),
|
|
7379
|
+
onMouseEnter: () => A(y),
|
|
7380
|
+
onMouseLeave: B,
|
|
7381
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${x === y || h === y ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
|
|
7382
|
+
children: capitalize(i(y.toLowerCase()))
|
|
7425
7383
|
},
|
|
7426
|
-
`sidebar-${
|
|
7384
|
+
`sidebar-${y}`
|
|
7427
7385
|
))
|
|
7428
7386
|
] }) }) }),
|
|
7429
|
-
/* @__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:
|
|
7387
|
+
/* @__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: _.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: [
|
|
7430
7388
|
i("No blocks found matching"),
|
|
7431
7389
|
' "',
|
|
7432
7390
|
d,
|
|
7433
7391
|
'"'
|
|
7434
|
-
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((
|
|
7435
|
-
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(
|
|
7392
|
+
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((y) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7393
|
+
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(y.toLowerCase())) }),
|
|
7436
7394
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: React__default.Children.toArray(
|
|
7437
7395
|
reject(
|
|
7438
|
-
|
|
7396
|
+
x === "all" ? filter(values(w), { group: y }) : values(w),
|
|
7439
7397
|
{ hidden: !0 }
|
|
7440
|
-
).map((
|
|
7398
|
+
).map((E) => /* @__PURE__ */ jsx(
|
|
7441
7399
|
CoreBlock,
|
|
7442
7400
|
{
|
|
7443
7401
|
parentId: r,
|
|
7444
7402
|
position: a,
|
|
7445
|
-
block:
|
|
7446
|
-
disabled: !canAcceptChildBlock(m,
|
|
7403
|
+
block: E,
|
|
7404
|
+
disabled: !canAcceptChildBlock(m, E.type) || !canBeNestedInside(m, E.type)
|
|
7447
7405
|
},
|
|
7448
|
-
|
|
7406
|
+
E.type
|
|
7449
7407
|
))
|
|
7450
7408
|
) })
|
|
7451
|
-
] },
|
|
7409
|
+
] }, y)) }) }) })
|
|
7452
7410
|
] })
|
|
7453
7411
|
] });
|
|
7454
7412
|
}, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
|
|
@@ -7457,13 +7415,13 @@ const CoreBlock = ({
|
|
|
7457
7415
|
parentId: r = void 0,
|
|
7458
7416
|
position: a = -1
|
|
7459
7417
|
}) => {
|
|
7460
|
-
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;
|
|
7418
|
+
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: x } = usePermissions();
|
|
7461
7419
|
useEffect(() => {
|
|
7462
7420
|
i === "partials" && !m && c("library");
|
|
7463
7421
|
}, [i, m, c]);
|
|
7464
|
-
const
|
|
7422
|
+
const f = useCallback(() => {
|
|
7465
7423
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7466
|
-
}, []);
|
|
7424
|
+
}, []), h = p && x(PERMISSIONS.IMPORT_HTML);
|
|
7467
7425
|
return /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
7468
7426
|
n ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
|
|
7469
7427
|
/* @__PURE__ */ jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: l("Add block") }),
|
|
@@ -7472,8 +7430,8 @@ const CoreBlock = ({
|
|
|
7472
7430
|
/* @__PURE__ */ jsxs(
|
|
7473
7431
|
Tabs,
|
|
7474
7432
|
{
|
|
7475
|
-
onValueChange: (
|
|
7476
|
-
d(""), c(
|
|
7433
|
+
onValueChange: (b) => {
|
|
7434
|
+
d(""), c(b);
|
|
7477
7435
|
},
|
|
7478
7436
|
value: i,
|
|
7479
7437
|
className: "flex h-full max-h-full flex-col overflow-hidden",
|
|
@@ -7482,14 +7440,14 @@ const CoreBlock = ({
|
|
|
7482
7440
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
7483
7441
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
7484
7442
|
m && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
|
|
7485
|
-
|
|
7486
|
-
map(u, (
|
|
7443
|
+
h ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
7444
|
+
map(u, (b) => /* @__PURE__ */ jsx(TabsTrigger, { value: b.key, children: React__default.createElement(b.tab) }))
|
|
7487
7445
|
] }),
|
|
7488
7446
|
/* @__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 }) }) }) }),
|
|
7489
7447
|
/* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
|
|
7490
7448
|
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 }) }) }) }),
|
|
7491
|
-
|
|
7492
|
-
map(u, (
|
|
7449
|
+
h ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
|
|
7450
|
+
map(u, (b) => /* @__PURE__ */ jsx(TabsContent, { value: b.key, children: React__default.createElement(b.tabContent, { close: f, parentId: r, position: a }) }))
|
|
7493
7451
|
]
|
|
7494
7452
|
}
|
|
7495
7453
|
)
|
|
@@ -7546,18 +7504,18 @@ const BlockCard = ({
|
|
|
7546
7504
|
parentId: r = void 0,
|
|
7547
7505
|
position: a = -1
|
|
7548
7506
|
}) => {
|
|
7549
|
-
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")),
|
|
7550
|
-
const
|
|
7551
|
-
return
|
|
7507
|
+
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")), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), h = (A) => {
|
|
7508
|
+
const B = has(A, "styles_attrs.data-page-section");
|
|
7509
|
+
return A._type === "Box" && B;
|
|
7552
7510
|
}, b = useCallback(
|
|
7553
|
-
async (
|
|
7554
|
-
if (
|
|
7511
|
+
async (A) => {
|
|
7512
|
+
if (A.stopPropagation(), has(o, "component")) {
|
|
7555
7513
|
d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7556
7514
|
return;
|
|
7557
7515
|
}
|
|
7558
7516
|
i(!0);
|
|
7559
|
-
const
|
|
7560
|
-
isEmpty(
|
|
7517
|
+
const B = await c(n, o);
|
|
7518
|
+
isEmpty(B) || p(syncBlocksWithDefaults(B), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7561
7519
|
},
|
|
7562
7520
|
[d, p, o, c, n, r, a]
|
|
7563
7521
|
);
|
|
@@ -7567,20 +7525,20 @@ const BlockCard = ({
|
|
|
7567
7525
|
{
|
|
7568
7526
|
onClick: l ? () => {
|
|
7569
7527
|
} : b,
|
|
7570
|
-
draggable:
|
|
7571
|
-
onDragStart: async (
|
|
7572
|
-
const
|
|
7573
|
-
let
|
|
7574
|
-
if (
|
|
7575
|
-
const
|
|
7576
|
-
if (
|
|
7577
|
-
const
|
|
7578
|
-
|
|
7579
|
-
|
|
7528
|
+
draggable: x ? "true" : "false",
|
|
7529
|
+
onDragStart: async (A) => {
|
|
7530
|
+
const B = await c(n, o);
|
|
7531
|
+
let C = r;
|
|
7532
|
+
if (h(first(B)) && (C = null), !isEmpty(B)) {
|
|
7533
|
+
const j = { blocks: B, uiLibrary: !0, parent: C };
|
|
7534
|
+
if (A.dataTransfer.setData("text/plain", JSON.stringify(j)), o.preview) {
|
|
7535
|
+
const _ = new Image();
|
|
7536
|
+
_.src = o.preview, _.onload = () => {
|
|
7537
|
+
A.dataTransfer.setDragImage(_, 0, 0);
|
|
7580
7538
|
};
|
|
7581
7539
|
} else
|
|
7582
|
-
|
|
7583
|
-
f(
|
|
7540
|
+
A.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7541
|
+
f(j), setTimeout(() => {
|
|
7584
7542
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7585
7543
|
}, 200);
|
|
7586
7544
|
}
|
|
@@ -7612,9 +7570,9 @@ const BlockCard = ({
|
|
|
7612
7570
|
})();
|
|
7613
7571
|
}, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
|
|
7614
7572
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
7615
|
-
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((
|
|
7616
|
-
|
|
7617
|
-
|
|
7573
|
+
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((C) => C.category === "custom"), d = l.find((C) => C.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [m, x] = useState("Hero"), f = get(g, m, []), h = useRef(null), { t: b } = useTranslation(), k = (C) => {
|
|
7574
|
+
h.current && (clearTimeout(h.current), h.current = null), h.current = setTimeout(() => {
|
|
7575
|
+
h.current && x(C);
|
|
7618
7576
|
}, 300);
|
|
7619
7577
|
};
|
|
7620
7578
|
if (u)
|
|
@@ -7622,7 +7580,7 @@ const BlockCard = ({
|
|
|
7622
7580
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7623
7581
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7624
7582
|
] });
|
|
7625
|
-
const
|
|
7583
|
+
const A = filter(f, (C, j) => j % 2 === 0), B = filter(f, (C, j) => j % 2 === 1);
|
|
7626
7584
|
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: [
|
|
7627
7585
|
/* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
7628
7586
|
/* @__PURE__ */ jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
|
|
@@ -7630,22 +7588,22 @@ const BlockCard = ({
|
|
|
7630
7588
|
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: b("Groups") }),
|
|
7631
7589
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7632
7590
|
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: React__default.Children.toArray(
|
|
7633
|
-
map(g, (
|
|
7591
|
+
map(g, (C, j) => /* @__PURE__ */ jsxs(
|
|
7634
7592
|
"div",
|
|
7635
7593
|
{
|
|
7636
|
-
onMouseEnter: () =>
|
|
7637
|
-
onMouseLeave: () => clearTimeout(
|
|
7638
|
-
onClick: () =>
|
|
7594
|
+
onMouseEnter: () => k(j),
|
|
7595
|
+
onMouseLeave: () => clearTimeout(h.current),
|
|
7596
|
+
onClick: () => x(j),
|
|
7639
7597
|
className: cn$1(
|
|
7640
7598
|
"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",
|
|
7641
|
-
|
|
7599
|
+
j === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
|
|
7642
7600
|
),
|
|
7643
7601
|
children: [
|
|
7644
|
-
/* @__PURE__ */ jsx("span", { children: capitalize(b(
|
|
7602
|
+
/* @__PURE__ */ jsx("span", { children: capitalize(b(j.toLowerCase())) }),
|
|
7645
7603
|
/* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
|
|
7646
7604
|
]
|
|
7647
7605
|
},
|
|
7648
|
-
|
|
7606
|
+
j
|
|
7649
7607
|
))
|
|
7650
7608
|
) })
|
|
7651
7609
|
] })
|
|
@@ -7653,15 +7611,15 @@ const BlockCard = ({
|
|
|
7653
7611
|
/* @__PURE__ */ jsxs(
|
|
7654
7612
|
ScrollArea,
|
|
7655
7613
|
{
|
|
7656
|
-
onMouseEnter: () =>
|
|
7614
|
+
onMouseEnter: () => h.current ? clearTimeout(h.current) : null,
|
|
7657
7615
|
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",
|
|
7658
7616
|
children: [
|
|
7659
7617
|
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
|
|
7660
7618
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
7661
|
-
|
|
7619
|
+
A.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
|
|
7662
7620
|
) }),
|
|
7663
7621
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
7664
|
-
|
|
7622
|
+
B.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
|
|
7665
7623
|
) })
|
|
7666
7624
|
] }),
|
|
7667
7625
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -7671,7 +7629,18 @@ const BlockCard = ({
|
|
|
7671
7629
|
}
|
|
7672
7630
|
)
|
|
7673
7631
|
] }) }) });
|
|
7674
|
-
}, UILibrariesPanel = ({ parentId: o, position: n }) => /* @__PURE__ */ jsx(UILibrarySection, { parentId: o, position: n }),
|
|
7632
|
+
}, UILibrariesPanel = ({ parentId: o, position: n }) => /* @__PURE__ */ jsx(UILibrarySection, { parentId: o, position: n }), PERMISSIONS = {
|
|
7633
|
+
ADD_BLOCK: "add_block",
|
|
7634
|
+
DELETE_BLOCK: "delete_block",
|
|
7635
|
+
EDIT_BLOCK: "edit_block",
|
|
7636
|
+
MOVE_BLOCK: "move_block",
|
|
7637
|
+
EDIT_THEME: "edit_theme",
|
|
7638
|
+
SAVE_PAGE: "save_page",
|
|
7639
|
+
EDIT_STYLES: "edit_styles",
|
|
7640
|
+
IMPORT_HTML: "import_html"
|
|
7641
|
+
};
|
|
7642
|
+
Object.values(PERMISSIONS);
|
|
7643
|
+
const PasteAtRootContextMenu = ({ parentContext: o, setParentContext: n }) => {
|
|
7675
7644
|
const { t: r } = useTranslation(), { canPaste: a, pasteBlocks: l } = usePasteBlocks();
|
|
7676
7645
|
return useEffect(() => {
|
|
7677
7646
|
a("root") || n(null);
|
|
@@ -7771,41 +7740,43 @@ const BlockCard = ({
|
|
|
7771
7740
|
}
|
|
7772
7741
|
);
|
|
7773
7742
|
}, BlockContextMenuContent = ({ node: o }) => {
|
|
7774
|
-
const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), i = useBuilderProp("blockMoreOptions", []),
|
|
7743
|
+
const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), { hasPermission: i } = usePermissions(), c = useBuilderProp("blockMoreOptions", []), d = useCallback(() => {
|
|
7775
7744
|
a(r);
|
|
7776
7745
|
}, [r, a]);
|
|
7777
7746
|
return /* @__PURE__ */ jsxs(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: [
|
|
7778
|
-
/* @__PURE__ */ jsxs(
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
|
|
7785
|
-
|
|
7786
|
-
|
|
7787
|
-
|
|
7788
|
-
|
|
7789
|
-
|
|
7790
|
-
|
|
7791
|
-
|
|
7792
|
-
|
|
7793
|
-
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7747
|
+
i(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7748
|
+
/* @__PURE__ */ jsxs(
|
|
7749
|
+
DropdownMenuItem,
|
|
7750
|
+
{
|
|
7751
|
+
disabled: !canAddChildBlock(l == null ? void 0 : l._type),
|
|
7752
|
+
className: "flex items-center gap-x-4 text-xs",
|
|
7753
|
+
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, l),
|
|
7754
|
+
children: [
|
|
7755
|
+
/* @__PURE__ */ jsx(PlusIcon$1, { size: "14" }),
|
|
7756
|
+
" ",
|
|
7757
|
+
n("Add block")
|
|
7758
|
+
]
|
|
7759
|
+
}
|
|
7760
|
+
),
|
|
7761
|
+
/* @__PURE__ */ jsxs(
|
|
7762
|
+
DropdownMenuItem,
|
|
7763
|
+
{
|
|
7764
|
+
disabled: !canDuplicateBlock(l == null ? void 0 : l._type),
|
|
7765
|
+
className: "flex items-center gap-x-4 text-xs",
|
|
7766
|
+
onClick: d,
|
|
7767
|
+
children: [
|
|
7768
|
+
/* @__PURE__ */ jsx(CardStackPlusIcon, {}),
|
|
7769
|
+
" ",
|
|
7770
|
+
n("Duplicate")
|
|
7771
|
+
]
|
|
7772
|
+
}
|
|
7773
|
+
)
|
|
7774
|
+
] }),
|
|
7804
7775
|
/* @__PURE__ */ jsx(RenameBlock, { node: o }),
|
|
7805
|
-
/* @__PURE__ */ jsx(CutBlocks, {}),
|
|
7806
|
-
/* @__PURE__ */ jsx(CopyPasteBlocks, {}),
|
|
7807
|
-
/* @__PURE__ */ jsx(RemoveBlocks, {}),
|
|
7808
|
-
|
|
7776
|
+
i(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(CutBlocks, {}),
|
|
7777
|
+
i(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(CopyPasteBlocks, {}),
|
|
7778
|
+
i(PERMISSIONS.DELETE_BLOCK) && /* @__PURE__ */ jsx(RemoveBlocks, {}),
|
|
7779
|
+
c.map((p, u) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("span", { children: "Loading..." }), children: React__default.createElement(p, { block: l }) }, `more-${u}`))
|
|
7809
7780
|
] });
|
|
7810
7781
|
}, BlockMoreOptions = ({ children: o, id: n, node: r }) => {
|
|
7811
7782
|
const [, a] = useSelectedBlockIds();
|
|
@@ -7890,52 +7861,53 @@ const selectParent = (o, n) => {
|
|
|
7890
7861
|
r.isInternal && n && r.close();
|
|
7891
7862
|
}, currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
7892
7863
|
var P;
|
|
7893
|
-
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
|
|
7894
|
-
let
|
|
7895
|
-
const
|
|
7896
|
-
N.stopPropagation(), !i.includes(
|
|
7864
|
+
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom), { hasPermission: p } = usePermissions();
|
|
7865
|
+
let u = null;
|
|
7866
|
+
const g = o.children.length > 0, { highlightBlock: m, clearHighlight: x } = useBlockHighlight(), { id: f, data: h, isSelected: b, willReceiveDrop: k, isDragging: A, isEditing: B, handleClick: C } = o, j = (N) => {
|
|
7867
|
+
N.stopPropagation(), !i.includes(f) && o.toggle();
|
|
7897
7868
|
}, _ = (N) => {
|
|
7898
|
-
N.isInternal && (
|
|
7899
|
-
},
|
|
7900
|
-
N.isInternal &&
|
|
7901
|
-
}, [
|
|
7869
|
+
N.isInternal && (u = N.isOpen, N.isOpen && N.close());
|
|
7870
|
+
}, S = (N) => {
|
|
7871
|
+
N.isInternal && u !== null && (u ? N.open() : N.close(), u = null);
|
|
7872
|
+
}, [w, L] = useAtom$1(currentAddSelection), v = () => {
|
|
7902
7873
|
var N;
|
|
7903
|
-
|
|
7904
|
-
},
|
|
7905
|
-
|
|
7906
|
-
},
|
|
7907
|
-
|
|
7874
|
+
y(), o.parent.isSelected || L((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
|
|
7875
|
+
}, y = () => {
|
|
7876
|
+
L(null);
|
|
7877
|
+
}, E = (N) => {
|
|
7878
|
+
y(), N.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(), C(N);
|
|
7908
7879
|
};
|
|
7909
7880
|
useEffect(() => {
|
|
7910
7881
|
const N = setTimeout(() => {
|
|
7911
|
-
|
|
7882
|
+
k && !o.isOpen && !A && !i.includes(f) && o.toggle();
|
|
7912
7883
|
}, 500);
|
|
7913
7884
|
return () => clearTimeout(N);
|
|
7914
|
-
}, [
|
|
7915
|
-
const
|
|
7916
|
-
const N = Object.keys(
|
|
7917
|
-
for (let
|
|
7918
|
-
if (N[
|
|
7919
|
-
const
|
|
7920
|
-
|
|
7885
|
+
}, [k, o, A]);
|
|
7886
|
+
const T = useMemo(() => {
|
|
7887
|
+
const N = Object.keys(h), M = [];
|
|
7888
|
+
for (let D = 0; D < N.length; D++)
|
|
7889
|
+
if (N[D].endsWith("_attrs")) {
|
|
7890
|
+
const O = h[N[D]], $ = Object.keys(O).join("|");
|
|
7891
|
+
$.match(/x-data/) && M.push("data"), $.match(/x-on/) && M.push("event"), $.match(/x-show|x-if/) && M.push("show");
|
|
7921
7892
|
}
|
|
7922
|
-
return
|
|
7923
|
-
}, [
|
|
7924
|
-
const
|
|
7925
|
-
|
|
7926
|
-
const
|
|
7927
|
-
|
|
7928
|
-
},
|
|
7929
|
-
|
|
7930
|
-
const
|
|
7931
|
-
|
|
7893
|
+
return M;
|
|
7894
|
+
}, [h]), I = (N, M) => {
|
|
7895
|
+
const D = d.contentDocument || d.contentWindow.document, O = D.querySelector(`[data-block-id=${N}]`);
|
|
7896
|
+
O && O.setAttribute("data-drop", M);
|
|
7897
|
+
const $ = O.getBoundingClientRect(), H = d.getBoundingClientRect();
|
|
7898
|
+
$.top >= H.top && $.left >= H.left && $.bottom <= H.bottom && $.right <= H.right || (D.documentElement.scrollTop = O.offsetTop - H.top);
|
|
7899
|
+
}, R = (N) => {
|
|
7900
|
+
y();
|
|
7901
|
+
const M = get(o, "parent.id");
|
|
7902
|
+
M !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: M, position: N }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: N });
|
|
7932
7903
|
};
|
|
7933
|
-
return
|
|
7904
|
+
return f === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
|
|
7934
7905
|
/* @__PURE__ */ jsx("br", {}),
|
|
7935
|
-
/* @__PURE__ */ jsx(
|
|
7906
|
+
p(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
|
|
7936
7907
|
"div",
|
|
7937
7908
|
{
|
|
7938
|
-
|
|
7909
|
+
role: "button",
|
|
7910
|
+
onClick: () => R(-1),
|
|
7939
7911
|
className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
|
|
7940
7912
|
children: /* @__PURE__ */ jsxs("div", { className: "absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-purple-500 px-3 py-1 text-[9px] leading-tight text-white hover:bg-purple-500", children: [
|
|
7941
7913
|
/* @__PURE__ */ jsx(PlusIcon$1, { className: "h-2 w-2 stroke-[3]" }),
|
|
@@ -7948,32 +7920,32 @@ const selectParent = (o, n) => {
|
|
|
7948
7920
|
] }) : /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
|
|
7949
7921
|
"div",
|
|
7950
7922
|
{
|
|
7951
|
-
onMouseEnter: () =>
|
|
7952
|
-
onMouseLeave: () =>
|
|
7953
|
-
onClick:
|
|
7923
|
+
onMouseEnter: () => m(f),
|
|
7924
|
+
onMouseLeave: () => x(),
|
|
7925
|
+
onClick: E,
|
|
7954
7926
|
style: n,
|
|
7955
|
-
"data-node-id":
|
|
7956
|
-
ref: i.includes(
|
|
7927
|
+
"data-node-id": f,
|
|
7928
|
+
ref: i.includes(f) ? null : r,
|
|
7957
7929
|
onDragStart: () => _(o),
|
|
7958
|
-
onDragEnd: () =>
|
|
7930
|
+
onDragEnd: () => S(o),
|
|
7959
7931
|
onDragOver: (N) => {
|
|
7960
|
-
N.preventDefault(),
|
|
7932
|
+
N.preventDefault(), I(f, "yes");
|
|
7961
7933
|
},
|
|
7962
7934
|
onDragLeave: (N) => {
|
|
7963
|
-
N.preventDefault(),
|
|
7935
|
+
N.preventDefault(), I(f, "no");
|
|
7964
7936
|
},
|
|
7965
7937
|
onDrop: (N) => {
|
|
7966
|
-
N.preventDefault(),
|
|
7938
|
+
N.preventDefault(), I(f, "no");
|
|
7967
7939
|
},
|
|
7968
7940
|
children: [
|
|
7969
|
-
(o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((P = o == null ? void 0 : o.parent) == null ? void 0 : P.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
|
|
7941
|
+
p(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((P = o == null ? void 0 : o.parent) == null ? void 0 : P.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
|
|
7970
7942
|
"div",
|
|
7971
7943
|
{
|
|
7972
7944
|
onClick: (N) => {
|
|
7973
|
-
N.stopPropagation(),
|
|
7945
|
+
N.stopPropagation(), R(o.childIndex);
|
|
7974
7946
|
},
|
|
7975
|
-
onMouseEnter:
|
|
7976
|
-
onMouseLeave:
|
|
7947
|
+
onMouseEnter: v,
|
|
7948
|
+
onMouseLeave: y,
|
|
7977
7949
|
className: "absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",
|
|
7978
7950
|
children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500", children: /* @__PURE__ */ jsx(PlusIcon$1, { className: "h-3 w-3 stroke-[4] text-white" }) })
|
|
7979
7951
|
}
|
|
@@ -7983,11 +7955,11 @@ const selectParent = (o, n) => {
|
|
|
7983
7955
|
{
|
|
7984
7956
|
className: cn$1(
|
|
7985
7957
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
|
|
7986
|
-
|
|
7987
|
-
|
|
7988
|
-
(o == null ? void 0 : o.id) ===
|
|
7989
|
-
|
|
7990
|
-
i.includes(
|
|
7958
|
+
b ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
|
|
7959
|
+
k && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
|
|
7960
|
+
(o == null ? void 0 : o.id) === w ? "bg-purple-100" : "",
|
|
7961
|
+
A && "opacity-20",
|
|
7962
|
+
i.includes(f) ? "opacity-50" : ""
|
|
7991
7963
|
),
|
|
7992
7964
|
children: [
|
|
7993
7965
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -7995,11 +7967,11 @@ const selectParent = (o, n) => {
|
|
|
7995
7967
|
"div",
|
|
7996
7968
|
{
|
|
7997
7969
|
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
7998
|
-
children:
|
|
7970
|
+
children: g && /* @__PURE__ */ jsx("button", { onClick: j, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${b ? "text-slate-200" : "text-slate-400"}` }) })
|
|
7999
7971
|
}
|
|
8000
7972
|
),
|
|
8001
7973
|
/* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
|
|
8002
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
7974
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
|
|
8003
7975
|
B ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
|
|
8004
7976
|
"div",
|
|
8005
7977
|
{
|
|
@@ -8008,32 +7980,32 @@ const selectParent = (o, n) => {
|
|
|
8008
7980
|
N.stopPropagation(), o.edit(), o.deselect();
|
|
8009
7981
|
},
|
|
8010
7982
|
children: [
|
|
8011
|
-
/* @__PURE__ */ jsx("span", { children: (
|
|
8012
|
-
|
|
8013
|
-
|
|
8014
|
-
|
|
7983
|
+
/* @__PURE__ */ jsx("span", { children: (h == null ? void 0 : h._name) || (h == null ? void 0 : h._type.split("/").pop()) }),
|
|
7984
|
+
T.includes("data") && /* @__PURE__ */ jsx(FileJson, { className: "h-3 w-3 text-orange-600" }),
|
|
7985
|
+
T.includes("event") && /* @__PURE__ */ jsx(Zap, { className: "h-3 w-3 text-yellow-500" }),
|
|
7986
|
+
T.includes("show") && /* @__PURE__ */ jsx(EyeOff, { className: "h-3 w-3 text-orange-600" })
|
|
8015
7987
|
]
|
|
8016
7988
|
}
|
|
8017
7989
|
)
|
|
8018
7990
|
] })
|
|
8019
7991
|
] }),
|
|
8020
7992
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
8021
|
-
!i.includes(
|
|
7993
|
+
!i.includes(f) && a.map((N) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8022
7994
|
/* @__PURE__ */ jsx(
|
|
8023
7995
|
TooltipTrigger,
|
|
8024
7996
|
{
|
|
8025
7997
|
className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
|
|
8026
7998
|
asChild: !0,
|
|
8027
|
-
children: React__default.createElement(N.item, { blockId:
|
|
7999
|
+
children: React__default.createElement(N.item, { blockId: f })
|
|
8028
8000
|
}
|
|
8029
8001
|
),
|
|
8030
8002
|
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: N.tooltip })
|
|
8031
8003
|
] })),
|
|
8032
|
-
canAddChildBlock(
|
|
8004
|
+
canAddChildBlock(h == null ? void 0 : h._type) && !i.includes(f) && p(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8033
8005
|
/* @__PURE__ */ jsx(
|
|
8034
8006
|
TooltipTrigger,
|
|
8035
8007
|
{
|
|
8036
|
-
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id:
|
|
8008
|
+
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: f }),
|
|
8037
8009
|
className: "cursor-pointer rounded bg-transparent hover:text-black",
|
|
8038
8010
|
asChild: !0,
|
|
8039
8011
|
children: /* @__PURE__ */ jsx(PlusIcon$1, { size: "15" })
|
|
@@ -8046,7 +8018,7 @@ const selectParent = (o, n) => {
|
|
|
8046
8018
|
TooltipTrigger,
|
|
8047
8019
|
{
|
|
8048
8020
|
onClick: (N) => {
|
|
8049
|
-
N.stopPropagation(), c(
|
|
8021
|
+
N.stopPropagation(), c(f), o.isOpen && o.toggle();
|
|
8050
8022
|
},
|
|
8051
8023
|
className: "cursor-pointer rounded bg-transparent hover:text-black",
|
|
8052
8024
|
asChild: !0,
|
|
@@ -8055,7 +8027,7 @@ const selectParent = (o, n) => {
|
|
|
8055
8027
|
),
|
|
8056
8028
|
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999]", side: "left", children: l("Hide block") })
|
|
8057
8029
|
] }),
|
|
8058
|
-
/* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id:
|
|
8030
|
+
/* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: f, children: /* @__PURE__ */ jsx(MoreVertical, { size: "15" }) })
|
|
8059
8031
|
] })
|
|
8060
8032
|
]
|
|
8061
8033
|
}
|
|
@@ -8152,21 +8124,32 @@ const selectParent = (o, n) => {
|
|
|
8152
8124
|
break;
|
|
8153
8125
|
}
|
|
8154
8126
|
};
|
|
8155
|
-
|
|
8127
|
+
useEffect(() => {
|
|
8156
8128
|
const o = () => {
|
|
8157
8129
|
treeRef.current && setTreeRef(treeRef.current);
|
|
8158
8130
|
};
|
|
8159
8131
|
o();
|
|
8160
8132
|
const n = new MutationObserver(o);
|
|
8161
8133
|
return n.observe(document.body, { childList: !0, subtree: !0 }), () => n.disconnect();
|
|
8162
|
-
}, [setTreeRef])
|
|
8134
|
+
}, [setTreeRef]);
|
|
8135
|
+
const { hasPermission } = usePermissions();
|
|
8136
|
+
return isEmpty(treeData) ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { className: "mt-10 flex h-full w-full items-center justify-center p-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "mb-1.5 text-sm text-gray-400", children: [
|
|
8163
8137
|
t("This page is empty"),
|
|
8164
8138
|
/* @__PURE__ */ jsx("br", {}),
|
|
8165
8139
|
/* @__PURE__ */ jsx("br", {}),
|
|
8166
|
-
/* @__PURE__ */ jsxs(
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8140
|
+
hasPermission(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsxs(
|
|
8141
|
+
Button,
|
|
8142
|
+
{
|
|
8143
|
+
disabled: !hasPermission(PERMISSIONS.ADD_BLOCK),
|
|
8144
|
+
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK),
|
|
8145
|
+
variant: "default",
|
|
8146
|
+
size: "sm",
|
|
8147
|
+
children: [
|
|
8148
|
+
"+ ",
|
|
8149
|
+
t("Add Block")
|
|
8150
|
+
]
|
|
8151
|
+
}
|
|
8152
|
+
)
|
|
8170
8153
|
] }) }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
8171
8154
|
/* @__PURE__ */ jsx("div", { className: cn$1("flex h-full select-none flex-col space-y-1"), onClick: () => clearSelection(), children: /* @__PURE__ */ jsxs(
|
|
8172
8155
|
"div",
|
|
@@ -8704,14 +8687,14 @@ function QuickPrompts({ onClick: o }) {
|
|
|
8704
8687
|
) }) });
|
|
8705
8688
|
}
|
|
8706
8689
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
8707
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null),
|
|
8690
|
+
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null), x = useRef(null);
|
|
8708
8691
|
useEffect(() => {
|
|
8709
|
-
var
|
|
8710
|
-
(
|
|
8692
|
+
var h;
|
|
8693
|
+
(h = m.current) == null || h.focus();
|
|
8711
8694
|
}, []);
|
|
8712
|
-
const f = (
|
|
8713
|
-
const { usage: b } =
|
|
8714
|
-
!l && b && g(b),
|
|
8695
|
+
const f = (h) => {
|
|
8696
|
+
const { usage: b } = h || {};
|
|
8697
|
+
!l && b && g(b), x.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
8715
8698
|
};
|
|
8716
8699
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
8717
8700
|
/* @__PURE__ */ jsxs(
|
|
@@ -8731,12 +8714,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8731
8714
|
{
|
|
8732
8715
|
ref: m,
|
|
8733
8716
|
value: i,
|
|
8734
|
-
onChange: (
|
|
8717
|
+
onChange: (h) => c(h.target.value),
|
|
8735
8718
|
placeholder: n("Ask AI to edit content"),
|
|
8736
8719
|
className: "w-full",
|
|
8737
8720
|
rows: 3,
|
|
8738
|
-
onKeyDown: (
|
|
8739
|
-
|
|
8721
|
+
onKeyDown: (h) => {
|
|
8722
|
+
h.key === "Enter" && (h.preventDefault(), x.current && clearTimeout(x.current), g(void 0), r("content", o, i, f));
|
|
8740
8723
|
}
|
|
8741
8724
|
}
|
|
8742
8725
|
),
|
|
@@ -8746,7 +8729,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8746
8729
|
{
|
|
8747
8730
|
disabled: i.trim().length < 5 || a,
|
|
8748
8731
|
onClick: () => {
|
|
8749
|
-
|
|
8732
|
+
x.current && clearTimeout(x.current), g(void 0), r("content", o, i, f);
|
|
8750
8733
|
},
|
|
8751
8734
|
variant: "default",
|
|
8752
8735
|
className: "w-fit",
|
|
@@ -8778,8 +8761,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8778
8761
|
/* @__PURE__ */ jsx(
|
|
8779
8762
|
QuickPrompts,
|
|
8780
8763
|
{
|
|
8781
|
-
onClick: (
|
|
8782
|
-
|
|
8764
|
+
onClick: (h) => {
|
|
8765
|
+
x.current && clearTimeout(x.current), g(void 0), r("content", o, h, f);
|
|
8783
8766
|
}
|
|
8784
8767
|
}
|
|
8785
8768
|
)
|
|
@@ -8793,7 +8776,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8793
8776
|
useEffect(() => {
|
|
8794
8777
|
n && a(n);
|
|
8795
8778
|
}, [n]);
|
|
8796
|
-
const
|
|
8779
|
+
const x = async () => {
|
|
8797
8780
|
try {
|
|
8798
8781
|
d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
|
|
8799
8782
|
} catch (f) {
|
|
@@ -8823,7 +8806,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8823
8806
|
className: "mt-1 w-full",
|
|
8824
8807
|
rows: 10,
|
|
8825
8808
|
onKeyDown: (f) => {
|
|
8826
|
-
f.key === "Enter" && (f.preventDefault(),
|
|
8809
|
+
f.key === "Enter" && (f.preventDefault(), x());
|
|
8827
8810
|
}
|
|
8828
8811
|
}
|
|
8829
8812
|
),
|
|
@@ -8835,7 +8818,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8835
8818
|
Button,
|
|
8836
8819
|
{
|
|
8837
8820
|
disabled: r.trim().length < 5,
|
|
8838
|
-
onClick: () =>
|
|
8821
|
+
onClick: () => x(),
|
|
8839
8822
|
variant: "default",
|
|
8840
8823
|
className: "w-fit",
|
|
8841
8824
|
size: "sm",
|
|
@@ -8864,7 +8847,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8864
8847
|
AlertDialogAction,
|
|
8865
8848
|
{
|
|
8866
8849
|
onClick: () => {
|
|
8867
|
-
a(""),
|
|
8850
|
+
a(""), x();
|
|
8868
8851
|
},
|
|
8869
8852
|
children: o("Yes, Delete")
|
|
8870
8853
|
}
|
|
@@ -8945,8 +8928,8 @@ function usePubSub(o, n) {
|
|
|
8945
8928
|
}, [o, n]);
|
|
8946
8929
|
}
|
|
8947
8930
|
const AiAssistant = () => {
|
|
8948
|
-
const o = useAiAssistant(), [n] = useRightPanel(), r = useBuilderProp("askAiCallBack", null), { t: a } = useTranslation();
|
|
8949
|
-
return r ? /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
8931
|
+
const o = useAiAssistant(), [n] = useRightPanel(), r = useBuilderProp("askAiCallBack", null), { t: a } = useTranslation(), { hasPermission: l } = usePermissions();
|
|
8932
|
+
return !r || !l(PERMISSIONS.EDIT_BLOCK) ? null : /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
8950
8933
|
/* @__PURE__ */ jsxs(Label, { htmlFor: "ai-assistant", className: "flex items-center gap-x-1 text-sm text-yellow-600", children: [
|
|
8951
8934
|
/* @__PURE__ */ jsx(SparklesIcon, { className: "w-4" }),
|
|
8952
8935
|
a("AI Assistant")
|
|
@@ -8956,13 +8939,13 @@ const AiAssistant = () => {
|
|
|
8956
8939
|
{
|
|
8957
8940
|
className: "scale-90",
|
|
8958
8941
|
checked: n === "ai",
|
|
8959
|
-
onCheckedChange: (
|
|
8960
|
-
o(
|
|
8942
|
+
onCheckedChange: (i) => {
|
|
8943
|
+
o(i);
|
|
8961
8944
|
},
|
|
8962
8945
|
id: "ai-assistant"
|
|
8963
8946
|
}
|
|
8964
8947
|
)
|
|
8965
|
-
] })
|
|
8948
|
+
] });
|
|
8966
8949
|
}, ClearCanvas = () => {
|
|
8967
8950
|
const { t: o } = useTranslation(), { setNewBlocks: n } = useBlocksStoreUndoableActions(), [, r] = useSelectedBlockIds(), [, a] = useSelectedStylingBlocks(), l = useCallback(() => {
|
|
8968
8951
|
n([]), r([]), a([]);
|
|
@@ -9021,54 +9004,54 @@ const AiAssistant = () => {
|
|
|
9021
9004
|
preloadedAttributes: n = [],
|
|
9022
9005
|
onAttributesChange: r
|
|
9023
9006
|
}) {
|
|
9024
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m,
|
|
9007
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, x] = useState(""), f = useRef(null), h = useRef(null), b = usePageExternalData();
|
|
9025
9008
|
useEffect(() => {
|
|
9026
9009
|
l(n);
|
|
9027
9010
|
}, [n]);
|
|
9028
|
-
const
|
|
9011
|
+
const k = () => {
|
|
9029
9012
|
if (i.startsWith("@")) {
|
|
9030
|
-
|
|
9013
|
+
x("Attribute keys cannot start with '@'");
|
|
9031
9014
|
return;
|
|
9032
9015
|
}
|
|
9033
9016
|
if (i) {
|
|
9034
9017
|
const S = [...a, { key: i, value: d }];
|
|
9035
|
-
r(S), l(a), c(""), p(""),
|
|
9018
|
+
r(S), l(a), c(""), p(""), x("");
|
|
9036
9019
|
}
|
|
9020
|
+
}, A = (S) => {
|
|
9021
|
+
const w = a.filter((L, v) => v !== S);
|
|
9022
|
+
r(w), l(w);
|
|
9037
9023
|
}, B = (S) => {
|
|
9038
|
-
const C = a.filter((L, v) => v !== S);
|
|
9039
|
-
r(C), l(C);
|
|
9040
|
-
}, E = (S) => {
|
|
9041
9024
|
g(S), c(a[S].key), p(a[S].value);
|
|
9042
|
-
},
|
|
9025
|
+
}, C = () => {
|
|
9043
9026
|
if (i.startsWith("@")) {
|
|
9044
|
-
|
|
9027
|
+
x("Attribute keys cannot start with '@'");
|
|
9045
9028
|
return;
|
|
9046
9029
|
}
|
|
9047
9030
|
if (u !== null && i) {
|
|
9048
9031
|
const S = [...a];
|
|
9049
|
-
S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""),
|
|
9032
|
+
S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), x("");
|
|
9050
9033
|
}
|
|
9051
|
-
},
|
|
9052
|
-
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ?
|
|
9053
|
-
},
|
|
9054
|
-
const
|
|
9055
|
-
let I = "",
|
|
9056
|
-
const
|
|
9057
|
-
return
|
|
9058
|
-
text: I + T +
|
|
9034
|
+
}, j = (S) => {
|
|
9035
|
+
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? C() : k());
|
|
9036
|
+
}, _ = useCallback((S) => {
|
|
9037
|
+
const w = (y) => /[.,!?;:]/.test(y), L = (y, E, T) => {
|
|
9038
|
+
let I = "", R = "";
|
|
9039
|
+
const P = E > 0 ? y[E - 1] : "", N = E < y.length ? y[E] : "";
|
|
9040
|
+
return E > 0 && (P === "." || !w(P) && P !== " ") && (I = " "), E < y.length && !w(N) && N !== " " && (R = " "), {
|
|
9041
|
+
text: I + T + R,
|
|
9059
9042
|
prefixLength: I.length,
|
|
9060
|
-
suffixLength:
|
|
9043
|
+
suffixLength: R.length
|
|
9061
9044
|
};
|
|
9062
|
-
}, v =
|
|
9045
|
+
}, v = h.current;
|
|
9063
9046
|
if (v) {
|
|
9064
|
-
const
|
|
9065
|
-
if (T >
|
|
9066
|
-
const
|
|
9047
|
+
const y = v.selectionStart || 0, E = v.value || "", T = v.selectionEnd || y;
|
|
9048
|
+
if (T > y) {
|
|
9049
|
+
const M = `{{${S}}}`, { text: D } = L(E, y, M), O = E.slice(0, y) + D + E.slice(T);
|
|
9067
9050
|
p(O);
|
|
9068
9051
|
return;
|
|
9069
9052
|
}
|
|
9070
|
-
const
|
|
9071
|
-
p(
|
|
9053
|
+
const R = `{{${S}}}`, { text: P } = L(E, y, R), N = E.slice(0, y) + P + E.slice(y);
|
|
9054
|
+
p(N);
|
|
9072
9055
|
}
|
|
9073
9056
|
}, []);
|
|
9074
9057
|
return /* @__PURE__ */ jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
|
|
@@ -9076,7 +9059,7 @@ const AiAssistant = () => {
|
|
|
9076
9059
|
"form",
|
|
9077
9060
|
{
|
|
9078
9061
|
onSubmit: (S) => {
|
|
9079
|
-
S.preventDefault(), u !== null ?
|
|
9062
|
+
S.preventDefault(), u !== null ? C() : k();
|
|
9080
9063
|
},
|
|
9081
9064
|
className: "space-y-3",
|
|
9082
9065
|
children: [
|
|
@@ -9101,7 +9084,7 @@ const AiAssistant = () => {
|
|
|
9101
9084
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
9102
9085
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
9103
9086
|
/* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
|
|
9104
|
-
!isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect:
|
|
9087
|
+
!isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: _ })
|
|
9105
9088
|
] }),
|
|
9106
9089
|
/* @__PURE__ */ jsx(
|
|
9107
9090
|
Textarea,
|
|
@@ -9111,10 +9094,10 @@ const AiAssistant = () => {
|
|
|
9111
9094
|
spellCheck: "false",
|
|
9112
9095
|
id: "attrValue",
|
|
9113
9096
|
rows: 2,
|
|
9114
|
-
ref:
|
|
9097
|
+
ref: h,
|
|
9115
9098
|
value: d,
|
|
9116
9099
|
onChange: (S) => p(S.target.value),
|
|
9117
|
-
onKeyDown:
|
|
9100
|
+
onKeyDown: j,
|
|
9118
9101
|
placeholder: "Enter Value",
|
|
9119
9102
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9120
9103
|
}
|
|
@@ -9126,16 +9109,16 @@ const AiAssistant = () => {
|
|
|
9126
9109
|
]
|
|
9127
9110
|
}
|
|
9128
9111
|
),
|
|
9129
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S,
|
|
9112
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, w) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
|
|
9130
9113
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
9131
9114
|
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
|
|
9132
9115
|
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: S.value.toString() })
|
|
9133
9116
|
] }),
|
|
9134
9117
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
9135
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
9136
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
9118
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(w), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
|
|
9119
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(w), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
|
|
9137
9120
|
] })
|
|
9138
|
-
] },
|
|
9121
|
+
] }, w)) })
|
|
9139
9122
|
] });
|
|
9140
9123
|
}), BlockAttributesEditor = React.memo(() => {
|
|
9141
9124
|
const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
|
|
@@ -9172,10 +9155,26 @@ function BlockAttributesToggle() {
|
|
|
9172
9155
|
] });
|
|
9173
9156
|
}
|
|
9174
9157
|
const SettingsPanel = () => {
|
|
9175
|
-
const o = useSelectedBlock(), { t: n } = useTranslation(), r = useBuilderProp("onError", noop);
|
|
9176
|
-
|
|
9158
|
+
const o = useSelectedBlock(), { t: n } = useTranslation(), r = useBuilderProp("onError", noop), { hasPermission: a } = usePermissions();
|
|
9159
|
+
let l = !a(PERMISSIONS.EDIT_BLOCK);
|
|
9160
|
+
const i = !a(PERMISSIONS.EDIT_STYLES), c = a("!" + PERMISSIONS.EDIT_BLOCK + "_" + (o == null ? void 0 : o._type));
|
|
9161
|
+
return l = l || c, isNull(o) ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 rounded-xl p-4 text-muted-foreground", children: [
|
|
9177
9162
|
/* @__PURE__ */ jsx(MixerHorizontalIcon, { className: "mx-auto text-3xl" }),
|
|
9178
9163
|
/* @__PURE__ */ jsx("h1", { children: n("Please select a block to edit settings or styles") })
|
|
9164
|
+
] }) }) : l && i ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 rounded-xl p-4 text-muted-foreground", children: [
|
|
9165
|
+
/* @__PURE__ */ jsx(MixerHorizontalIcon, { className: "mx-auto text-3xl" }),
|
|
9166
|
+
/* @__PURE__ */ jsx("h1", { children: n("You don't have permission to edit settings or styles") }),
|
|
9167
|
+
/* @__PURE__ */ jsx("p", { children: n("Please contact your administrator to get access") })
|
|
9168
|
+
] }) }) : i ? /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs("div", { className: "no-scrollbar h-full max-h-min w-full overflow-y-auto", children: [
|
|
9169
|
+
/* @__PURE__ */ jsx(BlockSettings, {}),
|
|
9170
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
9171
|
+
/* @__PURE__ */ jsx("br", {})
|
|
9172
|
+
] }) }) : l ? /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs("div", { className: "no-scrollbar h-full max-h-min w-full overflow-y-auto overflow-x-hidden", children: [
|
|
9173
|
+
/* @__PURE__ */ jsx(BlockStyling, {}),
|
|
9174
|
+
/* @__PURE__ */ jsx(BlockAttributesToggle, {}),
|
|
9175
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
9176
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
9177
|
+
/* @__PURE__ */ jsx("br", {})
|
|
9179
9178
|
] }) }) : /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs(Tabs, { defaultValue: "settings", className: "flex flex-1 flex-col", children: [
|
|
9180
9179
|
/* @__PURE__ */ jsxs(TabsList, { className: "grid h-auto w-full grid-cols-2 p-1 py-1", children: [
|
|
9181
9180
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "settings", className: "text-xs", children: "Settings" }),
|
|
@@ -9329,11 +9328,11 @@ const RootLayout = () => {
|
|
|
9329
9328
|
usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
|
|
9330
9329
|
n(1);
|
|
9331
9330
|
});
|
|
9332
|
-
const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (
|
|
9333
|
-
|
|
9334
|
-
}, u = (
|
|
9335
|
-
n(o ===
|
|
9336
|
-
}, g = useSidebarMenuItems(), { t: m } = useTranslation(),
|
|
9331
|
+
const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (h) => {
|
|
9332
|
+
h.preventDefault();
|
|
9333
|
+
}, u = (h) => {
|
|
9334
|
+
n(o === h ? null : h);
|
|
9335
|
+
}, g = useSidebarMenuItems(), { t: m } = useTranslation(), x = [...g, ...c], f = useBuilderProp("htmlDir", "ltr");
|
|
9337
9336
|
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: [
|
|
9338
9337
|
/* @__PURE__ */ jsxs(
|
|
9339
9338
|
"div",
|
|
@@ -9344,21 +9343,21 @@ const RootLayout = () => {
|
|
|
9344
9343
|
/* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
|
|
9345
9344
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
9346
9345
|
/* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
9347
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children:
|
|
9346
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: x.map((h, b) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9348
9347
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
9349
9348
|
Button,
|
|
9350
9349
|
{
|
|
9351
9350
|
variant: o === b ? "default" : "ghost",
|
|
9352
9351
|
className: "mb-2 rounded-lg p-2 transition-colors",
|
|
9353
9352
|
onClick: () => u(b),
|
|
9354
|
-
children: get(
|
|
9353
|
+
children: get(h, "icon", null)
|
|
9355
9354
|
},
|
|
9356
9355
|
b
|
|
9357
9356
|
) }),
|
|
9358
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(
|
|
9357
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(h.label) }) })
|
|
9359
9358
|
] }, "button" + b)) }),
|
|
9360
9359
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
9361
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((
|
|
9360
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((h, b) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(h, {}) }, `sidebar-component-${b}`)) })
|
|
9362
9361
|
] }),
|
|
9363
9362
|
/* @__PURE__ */ jsx(
|
|
9364
9363
|
motion.div,
|
|
@@ -9371,14 +9370,14 @@ const RootLayout = () => {
|
|
|
9371
9370
|
/* @__PURE__ */ jsxs(
|
|
9372
9371
|
"div",
|
|
9373
9372
|
{
|
|
9374
|
-
className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(
|
|
9373
|
+
className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(x, `${o}.isInternal`, !1) ? "" : "w-64"}`,
|
|
9375
9374
|
children: [
|
|
9376
|
-
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(
|
|
9377
|
-
/* @__PURE__ */ jsx("span", { children: m(
|
|
9375
|
+
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(x, `${o}.icon`, null) }),
|
|
9376
|
+
/* @__PURE__ */ jsx("span", { children: m(x[o].label) })
|
|
9378
9377
|
]
|
|
9379
9378
|
}
|
|
9380
9379
|
),
|
|
9381
|
-
/* @__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(
|
|
9380
|
+
/* @__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(x, `${o}.component`, null), {}) }) })
|
|
9382
9381
|
] })
|
|
9383
9382
|
}
|
|
9384
9383
|
),
|
|
@@ -9516,6 +9515,7 @@ export {
|
|
|
9516
9515
|
DefaultChaiBlocks,
|
|
9517
9516
|
ImportHTML,
|
|
9518
9517
|
ListTree as Outline,
|
|
9518
|
+
PERMISSIONS,
|
|
9519
9519
|
Breakpoints$1 as ScreenSizes,
|
|
9520
9520
|
ThemeConfigPanel as ThemeOptions,
|
|
9521
9521
|
UILibrariesPanel as UILibraries,
|
|
@@ -9551,6 +9551,7 @@ export {
|
|
|
9551
9551
|
usePartailBlocksStore,
|
|
9552
9552
|
usePartialBlocksList,
|
|
9553
9553
|
usePasteBlocks,
|
|
9554
|
+
usePermissions,
|
|
9554
9555
|
usePreviewMode,
|
|
9555
9556
|
useRemoveBlocks,
|
|
9556
9557
|
useRemoveClassesFromBlocks,
|