@chaibuilder/sdk 2.0.6 → 2.0.8
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/{CodeEditor-SZJ1H4vl.cjs → CodeEditor-BVHvdz8H.cjs} +1 -1
- package/dist/{CodeEditor-C-jeR5bt.js → CodeEditor-ZtRSywKI.js} +1 -1
- package/dist/{Topbar-DZ2jHLv7.js → Topbar-CX5hnmQJ.js} +1 -1
- package/dist/{Topbar-DSfx67NF.cjs → Topbar-D7QTF9G-.cjs} +1 -1
- package/dist/core.cjs +5 -5
- package/dist/core.js +1059 -909
- package/dist/tooltip-BMhhYJb6.cjs +1 -0
- package/dist/{tooltip-PKiP886L.js → tooltip-VMv3Eoxb.js} +243 -219
- package/dist/ui.cjs +1 -1
- package/dist/ui.d.ts +10 -0
- package/dist/ui.js +200 -182
- package/package.json +5 -1
- package/dist/tooltip-1Uu2avkZ.cjs +0 -1
package/dist/core.js
CHANGED
|
@@ -4,7 +4,7 @@ var V = (o, n, r) => K(o, typeof n != "symbol" ? n + "" : n, r);
|
|
|
4
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, useRef, useState, Suspense, createElement, memo, lazy } from "react";
|
|
7
|
-
import {
|
|
7
|
+
import { R as DropdownMenu, T as DropdownMenuTrigger, U as DropdownMenuContent, V as DropdownMenuItem, S as Skeleton, B as Button, K as Dialog, L as DialogTrigger, M as DialogContent, aa as Popover, an as Tooltip, ao as TooltipTrigger, ab as PopoverTrigger, ap as TooltipContent, ac as PopoverContent, y as Command, D as CommandInput, E as CommandList, F as CommandEmpty, G as CommandGroup, H as CommandItem, N as DialogHeader, P as DialogTitle, q as Badge, Y as DropdownMenuLabel, Z as DropdownMenuSeparator, W as DropdownMenuCheckboxItem, a5 as HoverCard, a6 as HoverCardTrigger, a7 as HoverCardContent, am as Textarea, a8 as Input$1, ar as TooltipPortal, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, A as Accordion, C as Card, t as CardHeader, w as CardDescription, x as CardContent, a9 as Label, u as CardFooter, ad as ScrollArea, ai as Tabs, aj as TabsList, ak as TabsTrigger, al 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, ah as Switch, n as Avatar, af as Separator, aq as TooltipProvider, ag as Toaster } from "./tooltip-VMv3Eoxb.js";
|
|
8
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
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, split, take, startCase, debounce, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, capitalize, groupBy, uniq, flatMapDeep, some, reject, sortBy, round } from "lodash-es";
|
|
10
10
|
import { Provider as Provider$1 } from "react-wrap-balancer";
|
|
@@ -19,7 +19,7 @@ import { useFeature, FlagsProvider } from "flagged";
|
|
|
19
19
|
import { getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredChaiBlocks, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
|
|
20
20
|
import { registerChaiBlock as Ue } from "@chaibuilder/runtime";
|
|
21
21
|
import { e as getDefaultExportFromCjs, d as defaultThemeOptions, g as getChaiThemeOptions, p as plugin, a as getChaiThemeCssVariables, c as getThemeFontsLinkMarkup } from "./ChaiThemeFn-Cort9tch.js";
|
|
22
|
-
import { PlusIcon as PlusIcon$1, ChevronRight, DatabaseIcon, ChevronLeft, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, X, Plus, PlusCircle, ChevronDown, Loader, SparklesIcon, Globe, PencilIcon, FileJson, Zap, EyeOff, MoreVertical, Eye, ChevronsDown, ChevronsUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, Moon, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
|
|
22
|
+
import { PlusIcon as PlusIcon$1, ChevronRight, DatabaseIcon, ChevronLeft, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, X, Plus, PlusCircle, ChevronDown, Loader, SparklesIcon, Globe, PencilIcon, FileJson, Zap, EyeOff, MoreVertical, Eye, ChevronsDown, ChevronsUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
|
|
23
23
|
import RjForm from "@rjsf/core";
|
|
24
24
|
import validator from "@rjsf/validator-ajv8";
|
|
25
25
|
import Link from "@tiptap/extension-link";
|
|
@@ -93,83 +93,83 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
93
93
|
for (const i of n.p)
|
|
94
94
|
l.add(i);
|
|
95
95
|
return l;
|
|
96
|
-
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (
|
|
97
|
-
var
|
|
98
|
-
return (
|
|
99
|
-
}, g = (
|
|
100
|
-
var
|
|
101
|
-
return (
|
|
96
|
+
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (h, ...f) => h.read(...f), p = (h, ...f) => h.write(...f), u = (h, f) => {
|
|
97
|
+
var x;
|
|
98
|
+
return (x = h.unstable_onInit) == null ? void 0 : x.call(h, f);
|
|
99
|
+
}, g = (h, f) => {
|
|
100
|
+
var x;
|
|
101
|
+
return (x = h.onMount) == null ? void 0 : x.call(h, f);
|
|
102
102
|
}, ...m) => {
|
|
103
|
-
const
|
|
104
|
-
let L = o.get(
|
|
105
|
-
return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(
|
|
103
|
+
const h = m[0] || ((A) => {
|
|
104
|
+
let L = o.get(A);
|
|
105
|
+
return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(A, L), u == null || u(A, w)), L;
|
|
106
106
|
}), f = m[1] || (() => {
|
|
107
|
-
let
|
|
108
|
-
const
|
|
107
|
+
let A, L;
|
|
108
|
+
const C = (k) => {
|
|
109
109
|
try {
|
|
110
|
-
|
|
111
|
-
} catch (
|
|
112
|
-
|
|
110
|
+
k();
|
|
111
|
+
} catch (_) {
|
|
112
|
+
A || (A = !0, L = _);
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
do {
|
|
116
|
-
c.f &&
|
|
117
|
-
const
|
|
116
|
+
c.f && C(c.f);
|
|
117
|
+
const k = /* @__PURE__ */ new Set(), _ = k.add.bind(k);
|
|
118
118
|
a.forEach((T) => {
|
|
119
119
|
var I;
|
|
120
|
-
return (I = n.get(T)) == null ? void 0 : I.l.forEach(
|
|
121
|
-
}), a.clear(), i.forEach(
|
|
120
|
+
return (I = n.get(T)) == null ? void 0 : I.l.forEach(_);
|
|
121
|
+
}), a.clear(), i.forEach(_), i.clear(), l.forEach(_), l.clear(), k.forEach(C), a.size && x();
|
|
122
122
|
} while (a.size || i.size || l.size);
|
|
123
|
-
if (
|
|
123
|
+
if (A)
|
|
124
124
|
throw L;
|
|
125
|
-
}),
|
|
126
|
-
const
|
|
127
|
-
for (;
|
|
128
|
-
const
|
|
129
|
-
if (
|
|
130
|
-
|
|
125
|
+
}), x = m[2] || (() => {
|
|
126
|
+
const A = [], L = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
|
|
127
|
+
for (; k.length; ) {
|
|
128
|
+
const _ = k[k.length - 1], T = h(_);
|
|
129
|
+
if (C.has(_)) {
|
|
130
|
+
k.pop();
|
|
131
131
|
continue;
|
|
132
132
|
}
|
|
133
|
-
if (L.has(
|
|
134
|
-
r.get(
|
|
133
|
+
if (L.has(_)) {
|
|
134
|
+
r.get(_) === T.n && A.push([_, T]), C.add(_), k.pop();
|
|
135
135
|
continue;
|
|
136
136
|
}
|
|
137
|
-
L.add(
|
|
138
|
-
for (const I of getMountedOrPendingDependents(
|
|
139
|
-
L.has(I) ||
|
|
137
|
+
L.add(_);
|
|
138
|
+
for (const I of getMountedOrPendingDependents(_, T, n))
|
|
139
|
+
L.has(I) || k.push(I);
|
|
140
140
|
}
|
|
141
|
-
for (let
|
|
142
|
-
const [T, I] =
|
|
141
|
+
for (let _ = A.length - 1; _ >= 0; --_) {
|
|
142
|
+
const [T, I] = A[_];
|
|
143
143
|
let R = !1;
|
|
144
144
|
for (const P of I.d.keys())
|
|
145
145
|
if (P !== T && a.has(P)) {
|
|
146
146
|
R = !0;
|
|
147
147
|
break;
|
|
148
148
|
}
|
|
149
|
-
R && (b(T),
|
|
149
|
+
R && (b(T), S(T)), r.delete(T);
|
|
150
150
|
}
|
|
151
|
-
}), b = m[3] || ((
|
|
152
|
-
var L,
|
|
153
|
-
const
|
|
154
|
-
if (isAtomStateInitialized(
|
|
151
|
+
}), b = m[3] || ((A) => {
|
|
152
|
+
var L, C;
|
|
153
|
+
const k = h(A);
|
|
154
|
+
if (isAtomStateInitialized(k) && (n.has(A) && r.get(A) !== k.n || Array.from(k.d).every(
|
|
155
155
|
([D, O]) => (
|
|
156
156
|
// Recursively, read the atom state of the dependency, and
|
|
157
157
|
// check if the atom epoch number is unchanged
|
|
158
158
|
b(D).n === O
|
|
159
159
|
)
|
|
160
160
|
)))
|
|
161
|
-
return
|
|
162
|
-
|
|
163
|
-
let
|
|
161
|
+
return k;
|
|
162
|
+
k.d.clear();
|
|
163
|
+
let _ = !0;
|
|
164
164
|
const T = () => {
|
|
165
|
-
n.has(
|
|
165
|
+
n.has(A) && (S(A), x(), f());
|
|
166
166
|
}, I = (D) => {
|
|
167
167
|
var O;
|
|
168
|
-
if (isSelfAtom(
|
|
169
|
-
const H =
|
|
168
|
+
if (isSelfAtom(A, D)) {
|
|
169
|
+
const H = h(D);
|
|
170
170
|
if (!isAtomStateInitialized(H))
|
|
171
171
|
if (hasInitialValue(D))
|
|
172
|
-
setAtomStateValueOrPromise(D, D.init,
|
|
172
|
+
setAtomStateValueOrPromise(D, D.init, h);
|
|
173
173
|
else
|
|
174
174
|
throw new Error("no atom init");
|
|
175
175
|
return returnAtomValue(H);
|
|
@@ -178,7 +178,7 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
178
178
|
try {
|
|
179
179
|
return returnAtomValue($);
|
|
180
180
|
} finally {
|
|
181
|
-
|
|
181
|
+
k.d.set(D, $.n), isPendingPromise(k.v) && addPendingPromiseToDependency(A, k.v, $), (O = n.get(D)) == null || O.t.add(A), _ || T();
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
184
|
let R, P;
|
|
@@ -187,100 +187,100 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
187
187
|
return R || (R = new AbortController()), R.signal;
|
|
188
188
|
},
|
|
189
189
|
get setSelf() {
|
|
190
|
-
return !P && isActuallyWritableAtom(
|
|
191
|
-
if (!
|
|
190
|
+
return !P && isActuallyWritableAtom(A) && (P = (...D) => {
|
|
191
|
+
if (!_)
|
|
192
192
|
try {
|
|
193
|
-
return A
|
|
193
|
+
return v(A, ...D);
|
|
194
194
|
} finally {
|
|
195
|
-
|
|
195
|
+
x(), f();
|
|
196
196
|
}
|
|
197
197
|
}), P;
|
|
198
198
|
}
|
|
199
|
-
}, M =
|
|
199
|
+
}, M = k.n;
|
|
200
200
|
try {
|
|
201
|
-
const D = d(
|
|
202
|
-
return setAtomStateValueOrPromise(
|
|
201
|
+
const D = d(A, I, N);
|
|
202
|
+
return setAtomStateValueOrPromise(A, D, h), isPromiseLike$2(D) && ((L = D.onCancel) == null || L.call(D, () => R == null ? void 0 : R.abort()), D.then(
|
|
203
203
|
T,
|
|
204
204
|
T
|
|
205
|
-
)),
|
|
205
|
+
)), k;
|
|
206
206
|
} catch (D) {
|
|
207
|
-
return delete
|
|
207
|
+
return delete k.v, k.e = D, ++k.n, k;
|
|
208
208
|
} finally {
|
|
209
|
-
|
|
209
|
+
_ = !1, M !== k.n && r.get(A) === M && (r.set(A, k.n), a.add(A), (C = c.c) == null || C.call(c, A));
|
|
210
210
|
}
|
|
211
|
-
}),
|
|
212
|
-
const L = [
|
|
211
|
+
}), y = m[4] || ((A) => {
|
|
212
|
+
const L = [A];
|
|
213
213
|
for (; L.length; ) {
|
|
214
|
-
const
|
|
215
|
-
for (const
|
|
216
|
-
const T =
|
|
217
|
-
r.set(
|
|
214
|
+
const C = L.pop(), k = h(C);
|
|
215
|
+
for (const _ of getMountedOrPendingDependents(C, k, n)) {
|
|
216
|
+
const T = h(_);
|
|
217
|
+
r.set(_, T.n), L.push(_);
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
}),
|
|
221
|
-
let
|
|
222
|
-
const
|
|
220
|
+
}), v = m[5] || ((A, ...L) => {
|
|
221
|
+
let C = !0;
|
|
222
|
+
const k = (T) => returnAtomValue(b(T)), _ = (T, ...I) => {
|
|
223
223
|
var R;
|
|
224
|
-
const P =
|
|
224
|
+
const P = h(T);
|
|
225
225
|
try {
|
|
226
|
-
if (isSelfAtom(
|
|
226
|
+
if (isSelfAtom(A, T)) {
|
|
227
227
|
if (!hasInitialValue(T))
|
|
228
228
|
throw new Error("atom not writable");
|
|
229
229
|
const N = P.n, M = I[0];
|
|
230
|
-
setAtomStateValueOrPromise(T, M,
|
|
230
|
+
setAtomStateValueOrPromise(T, M, h), S(T), N !== P.n && (a.add(T), (R = c.c) == null || R.call(c, T), y(T));
|
|
231
231
|
return;
|
|
232
232
|
} else
|
|
233
|
-
return
|
|
233
|
+
return v(T, ...I);
|
|
234
234
|
} finally {
|
|
235
|
-
|
|
235
|
+
C || (x(), f());
|
|
236
236
|
}
|
|
237
237
|
};
|
|
238
238
|
try {
|
|
239
|
-
return p(
|
|
239
|
+
return p(A, k, _, ...L);
|
|
240
240
|
} finally {
|
|
241
|
-
|
|
241
|
+
C = !1;
|
|
242
242
|
}
|
|
243
|
-
}),
|
|
243
|
+
}), S = m[6] || ((A) => {
|
|
244
244
|
var L;
|
|
245
|
-
const
|
|
246
|
-
if (
|
|
247
|
-
for (const [
|
|
248
|
-
if (!
|
|
249
|
-
const I =
|
|
250
|
-
|
|
245
|
+
const C = h(A), k = n.get(A);
|
|
246
|
+
if (k && !isPendingPromise(C.v)) {
|
|
247
|
+
for (const [_, T] of C.d)
|
|
248
|
+
if (!k.d.has(_)) {
|
|
249
|
+
const I = h(_);
|
|
250
|
+
B(_).t.add(A), k.d.add(_), T !== I.n && (a.add(_), (L = c.c) == null || L.call(c, _), y(_));
|
|
251
251
|
}
|
|
252
|
-
for (const
|
|
253
|
-
if (!
|
|
254
|
-
|
|
255
|
-
const T =
|
|
256
|
-
T == null || T.t.delete(
|
|
252
|
+
for (const _ of k.d || [])
|
|
253
|
+
if (!C.d.has(_)) {
|
|
254
|
+
k.d.delete(_);
|
|
255
|
+
const T = E(_);
|
|
256
|
+
T == null || T.t.delete(A);
|
|
257
257
|
}
|
|
258
258
|
}
|
|
259
|
-
}),
|
|
259
|
+
}), B = m[7] || ((A) => {
|
|
260
260
|
var L;
|
|
261
|
-
const
|
|
262
|
-
let
|
|
263
|
-
if (!
|
|
264
|
-
b(
|
|
265
|
-
for (const
|
|
266
|
-
|
|
267
|
-
if (
|
|
261
|
+
const C = h(A);
|
|
262
|
+
let k = n.get(A);
|
|
263
|
+
if (!k) {
|
|
264
|
+
b(A);
|
|
265
|
+
for (const _ of C.d.keys())
|
|
266
|
+
B(_).t.add(A);
|
|
267
|
+
if (k = {
|
|
268
268
|
l: /* @__PURE__ */ new Set(),
|
|
269
|
-
d: new Set(
|
|
269
|
+
d: new Set(C.d.keys()),
|
|
270
270
|
t: /* @__PURE__ */ new Set()
|
|
271
|
-
}, n.set(
|
|
272
|
-
const
|
|
271
|
+
}, n.set(A, k), (L = c.m) == null || L.call(c, A), isActuallyWritableAtom(A)) {
|
|
272
|
+
const _ = () => {
|
|
273
273
|
let T = !0;
|
|
274
274
|
const I = (...R) => {
|
|
275
275
|
try {
|
|
276
|
-
return A
|
|
276
|
+
return v(A, ...R);
|
|
277
277
|
} finally {
|
|
278
|
-
T || (
|
|
278
|
+
T || (x(), f());
|
|
279
279
|
}
|
|
280
280
|
};
|
|
281
281
|
try {
|
|
282
|
-
const R = g(
|
|
283
|
-
R && (
|
|
282
|
+
const R = g(A, I);
|
|
283
|
+
R && (k.u = () => {
|
|
284
284
|
T = !0;
|
|
285
285
|
try {
|
|
286
286
|
R();
|
|
@@ -292,27 +292,27 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
292
292
|
T = !1;
|
|
293
293
|
}
|
|
294
294
|
};
|
|
295
|
-
l.add(
|
|
295
|
+
l.add(_);
|
|
296
296
|
}
|
|
297
297
|
}
|
|
298
|
-
return
|
|
299
|
-
}),
|
|
298
|
+
return k;
|
|
299
|
+
}), E = m[8] || ((A) => {
|
|
300
300
|
var L;
|
|
301
|
-
const
|
|
302
|
-
let
|
|
303
|
-
if (
|
|
301
|
+
const C = h(A);
|
|
302
|
+
let k = n.get(A);
|
|
303
|
+
if (k && !k.l.size && !Array.from(k.t).some((_) => {
|
|
304
304
|
var T;
|
|
305
|
-
return (T = n.get(
|
|
305
|
+
return (T = n.get(_)) == null ? void 0 : T.d.has(A);
|
|
306
306
|
})) {
|
|
307
|
-
|
|
308
|
-
for (const
|
|
309
|
-
const T =
|
|
310
|
-
T == null || T.t.delete(
|
|
307
|
+
k.u && i.add(k.u), k = void 0, n.delete(A), (L = c.u) == null || L.call(c, A);
|
|
308
|
+
for (const _ of C.d.keys()) {
|
|
309
|
+
const T = E(_);
|
|
310
|
+
T == null || T.t.delete(A);
|
|
311
311
|
}
|
|
312
312
|
return;
|
|
313
313
|
}
|
|
314
|
-
return
|
|
315
|
-
}),
|
|
314
|
+
return k;
|
|
315
|
+
}), j = [
|
|
316
316
|
// store state
|
|
317
317
|
o,
|
|
318
318
|
n,
|
|
@@ -327,32 +327,32 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
327
327
|
u,
|
|
328
328
|
g,
|
|
329
329
|
// building-block functions
|
|
330
|
-
x,
|
|
331
|
-
f,
|
|
332
330
|
h,
|
|
331
|
+
f,
|
|
332
|
+
x,
|
|
333
333
|
b,
|
|
334
|
-
|
|
335
|
-
|
|
334
|
+
y,
|
|
335
|
+
v,
|
|
336
|
+
S,
|
|
336
337
|
B,
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
set: (w, ...L) => {
|
|
338
|
+
E
|
|
339
|
+
], w = {
|
|
340
|
+
get: (A) => returnAtomValue(b(A)),
|
|
341
|
+
set: (A, ...L) => {
|
|
342
342
|
try {
|
|
343
|
-
return A
|
|
343
|
+
return v(A, ...L);
|
|
344
344
|
} finally {
|
|
345
|
-
|
|
345
|
+
x(), f();
|
|
346
346
|
}
|
|
347
347
|
},
|
|
348
|
-
sub: (
|
|
349
|
-
const
|
|
350
|
-
return
|
|
351
|
-
|
|
348
|
+
sub: (A, L) => {
|
|
349
|
+
const k = B(A).l;
|
|
350
|
+
return k.add(L), f(), () => {
|
|
351
|
+
k.delete(L), E(A), f();
|
|
352
352
|
};
|
|
353
353
|
}
|
|
354
354
|
};
|
|
355
|
-
return Object.defineProperty(
|
|
355
|
+
return Object.defineProperty(w, BUILDING_BLOCKS, { value: j }), w;
|
|
356
356
|
}, INTERNAL_buildStoreRev1 = buildStore;
|
|
357
357
|
let keyCount = 0;
|
|
358
358
|
function atom(o, n) {
|
|
@@ -388,36 +388,36 @@ function splitAtom(o, n) {
|
|
|
388
388
|
if (p)
|
|
389
389
|
return p;
|
|
390
390
|
const u = d && r.get(d), g = [], m = [];
|
|
391
|
-
return c.forEach((
|
|
392
|
-
const
|
|
393
|
-
m[f] =
|
|
394
|
-
const b = u && u.atomList[u.keyList.indexOf(
|
|
391
|
+
return c.forEach((h, f) => {
|
|
392
|
+
const x = f;
|
|
393
|
+
m[f] = x;
|
|
394
|
+
const b = u && u.atomList[u.keyList.indexOf(x)];
|
|
395
395
|
if (b) {
|
|
396
396
|
g[f] = b;
|
|
397
397
|
return;
|
|
398
398
|
}
|
|
399
|
-
const
|
|
400
|
-
const
|
|
401
|
-
if (
|
|
402
|
-
const
|
|
403
|
-
if (
|
|
404
|
-
return
|
|
399
|
+
const y = (S) => {
|
|
400
|
+
const B = S(l), E = S(o), w = a(E, B == null ? void 0 : B.arr).keyList.indexOf(x);
|
|
401
|
+
if (w < 0 || w >= E.length) {
|
|
402
|
+
const A = c[a(c).keyList.indexOf(x)];
|
|
403
|
+
if (A)
|
|
404
|
+
return A;
|
|
405
405
|
throw new Error("splitAtom: index out of bounds for read");
|
|
406
406
|
}
|
|
407
|
-
return
|
|
408
|
-
},
|
|
409
|
-
const
|
|
410
|
-
if (L < 0 || L >=
|
|
407
|
+
return E[w];
|
|
408
|
+
}, v = (S, B, E) => {
|
|
409
|
+
const j = S(l), w = S(o), L = a(w, j == null ? void 0 : j.arr).keyList.indexOf(x);
|
|
410
|
+
if (L < 0 || L >= w.length)
|
|
411
411
|
throw new Error("splitAtom: index out of bounds for write");
|
|
412
|
-
const
|
|
413
|
-
Object.is(
|
|
414
|
-
...
|
|
415
|
-
|
|
416
|
-
...
|
|
412
|
+
const C = isFunction(E) ? E(w[L]) : E;
|
|
413
|
+
Object.is(w[L], C) || B(o, [
|
|
414
|
+
...w.slice(0, L),
|
|
415
|
+
C,
|
|
416
|
+
...w.slice(L + 1)
|
|
417
417
|
]);
|
|
418
418
|
};
|
|
419
|
-
g[f] = isWritable(o) ? atom(
|
|
420
|
-
}), u && u.keyList.length === m.length && u.keyList.every((
|
|
419
|
+
g[f] = isWritable(o) ? atom(y, v) : atom(y);
|
|
420
|
+
}), u && u.keyList.length === m.length && u.keyList.every((h, f) => h === m[f]) ? p = u : p = { arr: c, atomList: g, keyList: m }, r.set(c, p), p;
|
|
421
421
|
}, l = atom((c) => {
|
|
422
422
|
const d = c(l), p = c(o);
|
|
423
423
|
return a(p, d == null ? void 0 : d.arr);
|
|
@@ -490,18 +490,18 @@ function createJSONStorage(o = () => {
|
|
|
490
490
|
const i = {
|
|
491
491
|
getItem: (p, u) => {
|
|
492
492
|
var g, m;
|
|
493
|
-
const
|
|
494
|
-
if (
|
|
493
|
+
const h = (x) => {
|
|
494
|
+
if (x = x || "", a !== x) {
|
|
495
495
|
try {
|
|
496
|
-
l = JSON.parse(
|
|
496
|
+
l = JSON.parse(x, n == null ? void 0 : n.reviver);
|
|
497
497
|
} catch {
|
|
498
498
|
return u;
|
|
499
499
|
}
|
|
500
|
-
a =
|
|
500
|
+
a = x;
|
|
501
501
|
}
|
|
502
502
|
return l;
|
|
503
503
|
}, f = (m = (g = o()) == null ? void 0 : g.getItem(p)) != null ? m : null;
|
|
504
|
-
return isPromiseLike$1(f) ? f.then(
|
|
504
|
+
return isPromiseLike$1(f) ? f.then(h) : h(f);
|
|
505
505
|
},
|
|
506
506
|
setItem: (p, u) => {
|
|
507
507
|
var g;
|
|
@@ -514,10 +514,10 @@ function createJSONStorage(o = () => {
|
|
|
514
514
|
var u;
|
|
515
515
|
return (u = o()) == null ? void 0 : u.removeItem(p);
|
|
516
516
|
}
|
|
517
|
-
}, c = (p) => (u, g, m) => p(u, (
|
|
517
|
+
}, c = (p) => (u, g, m) => p(u, (h) => {
|
|
518
518
|
let f;
|
|
519
519
|
try {
|
|
520
|
-
f = JSON.parse(
|
|
520
|
+
f = JSON.parse(h || "");
|
|
521
521
|
} catch {
|
|
522
522
|
f = m;
|
|
523
523
|
}
|
|
@@ -672,10 +672,8 @@ const selectedLibraryAtom = atomWithStorage("_selectedLibrary", null);
|
|
|
672
672
|
selectedLibraryAtom.debugLabel = "selectedLibraryAtom";
|
|
673
673
|
const dataBindingActiveAtom = atom$1(!0);
|
|
674
674
|
dataBindingActiveAtom.debugLabel = "dataBindingActiveAtom";
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
typeof window < "u" && (win = window);
|
|
678
|
-
const FrameContext = React__default.createContext({ document: doc, window: win }), useFrame = () => React__default.useContext(FrameContext), { Provider: FrameContextProvider, Consumer: FrameContextConsumer } = FrameContext;
|
|
675
|
+
const sidebarActivePanelAtom = atom$1("outline");
|
|
676
|
+
sidebarActivePanelAtom.debugLabel = "sidebarActivePanelAtom";
|
|
679
677
|
class Content extends Component {
|
|
680
678
|
componentDidMount() {
|
|
681
679
|
this.props.contentDidMount();
|
|
@@ -687,6 +685,10 @@ class Content extends Component {
|
|
|
687
685
|
return Children.only(this.props.children);
|
|
688
686
|
}
|
|
689
687
|
}
|
|
688
|
+
let doc, win;
|
|
689
|
+
typeof document < "u" && (doc = document);
|
|
690
|
+
typeof window < "u" && (win = window);
|
|
691
|
+
const FrameContext = React__default.createContext({ document: doc, window: win }), useFrame = () => React__default.useContext(FrameContext), { Provider: FrameContextProvider, Consumer: FrameContextConsumer } = FrameContext;
|
|
690
692
|
class Frame extends Component {
|
|
691
693
|
constructor(r, a) {
|
|
692
694
|
super(r, a);
|
|
@@ -1157,15 +1159,15 @@ const useSelectedBlocksDisplayChild = () => ({
|
|
|
1157
1159
|
if (!p || !p._parent) return;
|
|
1158
1160
|
const u = p._parent, g = r.filter((m) => m._parent === u);
|
|
1159
1161
|
if (g.length === 2) {
|
|
1160
|
-
const m = g.find((
|
|
1162
|
+
const m = g.find((h) => h._id !== d);
|
|
1161
1163
|
if (m && m._type === "Text") {
|
|
1162
|
-
const
|
|
1163
|
-
|
|
1164
|
+
const h = r.find((f) => f._id === u);
|
|
1165
|
+
h && "content" in h && (r = r.map((f) => {
|
|
1164
1166
|
if (f._id === u) {
|
|
1165
|
-
const
|
|
1167
|
+
const x = { ...f, content: m.content };
|
|
1166
1168
|
return Object.keys(m).forEach((b) => {
|
|
1167
|
-
b.startsWith("content-") && (
|
|
1168
|
-
}),
|
|
1169
|
+
b.startsWith("content-") && (x[b] = m[b]);
|
|
1170
|
+
}), x;
|
|
1169
1171
|
}
|
|
1170
1172
|
return f;
|
|
1171
1173
|
}), a.push(m._id));
|
|
@@ -1233,20 +1235,20 @@ function insertBlocksAtPosition(o, n, r, a) {
|
|
|
1233
1235
|
if (r) {
|
|
1234
1236
|
const u = o.find((g) => g._id === r);
|
|
1235
1237
|
if (u && u.content !== void 0 && u.content !== "" && !o.some((m) => m._parent === r)) {
|
|
1236
|
-
const
|
|
1238
|
+
const h = {
|
|
1237
1239
|
_id: generateUUID(),
|
|
1238
1240
|
_parent: r,
|
|
1239
1241
|
_type: "Text",
|
|
1240
1242
|
content: u.content
|
|
1241
1243
|
};
|
|
1242
1244
|
Object.keys(u).forEach((f) => {
|
|
1243
|
-
f.startsWith("content-") && (
|
|
1244
|
-
}), l.unshift(
|
|
1245
|
+
f.startsWith("content-") && (h[f] = u[f]);
|
|
1246
|
+
}), l.unshift(h), i = i.map((f) => {
|
|
1245
1247
|
if (f._id === r) {
|
|
1246
|
-
const
|
|
1247
|
-
return Object.keys(
|
|
1248
|
-
b.startsWith("content-") && (
|
|
1249
|
-
}),
|
|
1248
|
+
const x = { ...f, content: "" };
|
|
1249
|
+
return Object.keys(x).forEach((b) => {
|
|
1250
|
+
b.startsWith("content-") && (x[b] = "");
|
|
1251
|
+
}), x;
|
|
1250
1252
|
}
|
|
1251
1253
|
return f;
|
|
1252
1254
|
});
|
|
@@ -1396,65 +1398,65 @@ const useBlocksStoreManager = () => {
|
|
|
1396
1398
|
updateBlocksProps: c
|
|
1397
1399
|
} = useBlocksStoreManager();
|
|
1398
1400
|
return {
|
|
1399
|
-
moveBlocks: (
|
|
1400
|
-
const
|
|
1401
|
-
const
|
|
1402
|
-
return { _id:
|
|
1403
|
-
}),
|
|
1404
|
-
|
|
1405
|
-
undo: () => each(
|
|
1406
|
-
i([
|
|
1401
|
+
moveBlocks: (x, b, y) => {
|
|
1402
|
+
const v = map(x, (B) => {
|
|
1403
|
+
const j = n.find((L) => L._id === B)._parent || null, A = n.filter((L) => j ? L._parent === j : !L._parent).map((L) => L._id).indexOf(B);
|
|
1404
|
+
return { _id: B, oldParent: j, oldPosition: A };
|
|
1405
|
+
}), S = v.find(({ _id: B }) => B === x[0]);
|
|
1406
|
+
S && S.oldParent === b && S.oldPosition === y || (i(x, b, y), o({
|
|
1407
|
+
undo: () => each(v, ({ _id: B, oldParent: E, oldPosition: j }) => {
|
|
1408
|
+
i([B], E, j);
|
|
1407
1409
|
}),
|
|
1408
|
-
redo: () => i(
|
|
1410
|
+
redo: () => i(x, b, y)
|
|
1409
1411
|
}));
|
|
1410
1412
|
},
|
|
1411
|
-
addBlocks: (
|
|
1412
|
-
a(
|
|
1413
|
-
undo: () => l(map(
|
|
1414
|
-
redo: () => a(
|
|
1413
|
+
addBlocks: (x, b, y) => {
|
|
1414
|
+
a(x, b, y), o({
|
|
1415
|
+
undo: () => l(map(x, "_id")),
|
|
1416
|
+
redo: () => a(x, b, y)
|
|
1415
1417
|
});
|
|
1416
1418
|
},
|
|
1417
|
-
removeBlocks: (
|
|
1418
|
-
var
|
|
1419
|
-
const b = (
|
|
1420
|
-
l(map(
|
|
1421
|
-
undo: () => a(
|
|
1422
|
-
redo: () => l(map(
|
|
1419
|
+
removeBlocks: (x) => {
|
|
1420
|
+
var S;
|
|
1421
|
+
const b = (S = first(x)) == null ? void 0 : S._parent, v = n.filter((B) => b ? B._parent === b : !B._parent).indexOf(first(x));
|
|
1422
|
+
l(map(x, "_id")), o({
|
|
1423
|
+
undo: () => a(x, b, v),
|
|
1424
|
+
redo: () => l(map(x, "_id"))
|
|
1423
1425
|
});
|
|
1424
1426
|
},
|
|
1425
|
-
updateBlocks: (
|
|
1426
|
-
let
|
|
1427
|
-
if (
|
|
1428
|
-
|
|
1427
|
+
updateBlocks: (x, b, y) => {
|
|
1428
|
+
let v = [];
|
|
1429
|
+
if (y)
|
|
1430
|
+
v = map(x, (S) => ({ _id: S, ...y }));
|
|
1429
1431
|
else {
|
|
1430
|
-
const
|
|
1431
|
-
|
|
1432
|
-
const
|
|
1433
|
-
return each(
|
|
1432
|
+
const S = keys(b);
|
|
1433
|
+
v = map(x, (B) => {
|
|
1434
|
+
const E = n.find((w) => w._id === B), j = { _id: B };
|
|
1435
|
+
return each(S, (w) => j[w] = E[w]), j;
|
|
1434
1436
|
});
|
|
1435
1437
|
}
|
|
1436
|
-
c(map(
|
|
1437
|
-
undo: () => c(
|
|
1438
|
-
redo: () => c(map(
|
|
1438
|
+
c(map(x, (S) => ({ _id: S, ...b }))), o({
|
|
1439
|
+
undo: () => c(v),
|
|
1440
|
+
redo: () => c(map(x, (S) => ({ _id: S, ...b })))
|
|
1439
1441
|
});
|
|
1440
1442
|
},
|
|
1441
|
-
updateBlocksRuntime: (
|
|
1442
|
-
c(map(
|
|
1443
|
+
updateBlocksRuntime: (x, b) => {
|
|
1444
|
+
c(map(x, (y) => ({ _id: y, ...b })));
|
|
1443
1445
|
},
|
|
1444
|
-
setNewBlocks: (
|
|
1445
|
-
r(
|
|
1446
|
+
setNewBlocks: (x) => {
|
|
1447
|
+
r(x), o({
|
|
1446
1448
|
undo: () => r(n),
|
|
1447
|
-
redo: () => r(
|
|
1449
|
+
redo: () => r(x)
|
|
1448
1450
|
});
|
|
1449
1451
|
},
|
|
1450
|
-
updateMultipleBlocksProps: (
|
|
1452
|
+
updateMultipleBlocksProps: (x) => {
|
|
1451
1453
|
let b = [];
|
|
1452
|
-
b = map(
|
|
1453
|
-
const
|
|
1454
|
-
return each(
|
|
1455
|
-
}), c(
|
|
1454
|
+
b = map(x, (y) => {
|
|
1455
|
+
const v = keys(y), S = n.find((E) => E._id === y._id), B = {};
|
|
1456
|
+
return each(v, (E) => B[E] = S[E]), B;
|
|
1457
|
+
}), c(x), o({
|
|
1456
1458
|
undo: () => c(b),
|
|
1457
|
-
redo: () => c(
|
|
1459
|
+
redo: () => c(x)
|
|
1458
1460
|
});
|
|
1459
1461
|
}
|
|
1460
1462
|
};
|
|
@@ -1506,17 +1508,17 @@ import.meta.vitest && describe("canDropBlock Function", () => {
|
|
|
1506
1508
|
const useAddBlock = () => {
|
|
1507
1509
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
1508
1510
|
(i, c, d) => {
|
|
1509
|
-
var
|
|
1511
|
+
var h;
|
|
1510
1512
|
for (let f = 0; f < i.length; f++) {
|
|
1511
|
-
const { _id:
|
|
1513
|
+
const { _id: x } = i[f];
|
|
1512
1514
|
i[f]._id = generateUUID();
|
|
1513
|
-
const b = filter(i, { _parent:
|
|
1514
|
-
for (let
|
|
1515
|
-
b[
|
|
1515
|
+
const b = filter(i, { _parent: x });
|
|
1516
|
+
for (let y = 0; y < b.length; y++)
|
|
1517
|
+
b[y]._parent = i[f]._id;
|
|
1516
1518
|
}
|
|
1517
1519
|
const p = first(i);
|
|
1518
1520
|
let u, g;
|
|
1519
|
-
return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(
|
|
1521
|
+
return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(h = first(i)) == null ? void 0 : h._id]), first(i);
|
|
1520
1522
|
},
|
|
1521
1523
|
[r, o, n]
|
|
1522
1524
|
);
|
|
@@ -1533,8 +1535,8 @@ const useAddBlock = () => {
|
|
|
1533
1535
|
...has(i, "_name") && { _name: i._name },
|
|
1534
1536
|
...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
|
|
1535
1537
|
};
|
|
1536
|
-
let m,
|
|
1537
|
-
return c && (m = find(o, { _id: c }), g._parent = c,
|
|
1538
|
+
let m, h;
|
|
1539
|
+
return c && (m = find(o, { _id: c }), g._parent = c, h = c), !canAcceptChildBlock(m == null ? void 0 : m._type, g._type) && m && (g._parent = m._parent, h = m._parent), r([g], h, d), n([g._id]), g;
|
|
1538
1540
|
},
|
|
1539
1541
|
[r, a, o, n]
|
|
1540
1542
|
), addPredefinedBlock: a };
|
|
@@ -2980,41 +2982,41 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2980
2982
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
2981
2983
|
})
|
|
2982
2984
|
), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
|
|
2983
|
-
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (
|
|
2984
|
-
const
|
|
2985
|
-
for (const b in
|
|
2986
|
-
const
|
|
2987
|
-
if (typeof
|
|
2988
|
-
const { baseClasses:
|
|
2989
|
-
|
|
2985
|
+
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (h, f) => {
|
|
2986
|
+
const x = cloneDeep(f.find((b) => b._id === h));
|
|
2987
|
+
for (const b in x) {
|
|
2988
|
+
const y = x[b];
|
|
2989
|
+
if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
|
|
2990
|
+
const { baseClasses: v, classes: S } = getSplitChaiClasses(y);
|
|
2991
|
+
x[b] = compact(flattenDeep([v, S])).join(" ");
|
|
2990
2992
|
} else
|
|
2991
|
-
b !== "_id" && delete
|
|
2993
|
+
b !== "_id" && delete x[b];
|
|
2992
2994
|
}
|
|
2993
|
-
return
|
|
2995
|
+
return x;
|
|
2994
2996
|
};
|
|
2995
2997
|
return {
|
|
2996
2998
|
askAi: useCallback(
|
|
2997
|
-
async (
|
|
2999
|
+
async (h, f, x, b) => {
|
|
2998
3000
|
if (l) {
|
|
2999
3001
|
n(!0), a(null);
|
|
3000
3002
|
try {
|
|
3001
|
-
const
|
|
3002
|
-
if (
|
|
3003
|
-
a(
|
|
3003
|
+
const y = p === u ? "" : p, v = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [m(f, d)], S = await l(h, addLangToPrompt(x, g, h), v, y), { blocks: B, error: E } = S;
|
|
3004
|
+
if (E) {
|
|
3005
|
+
a(E);
|
|
3004
3006
|
return;
|
|
3005
3007
|
}
|
|
3006
|
-
if (
|
|
3007
|
-
const
|
|
3008
|
-
for (const
|
|
3009
|
-
|
|
3010
|
-
return
|
|
3008
|
+
if (h === "styles") {
|
|
3009
|
+
const j = B.map((w) => {
|
|
3010
|
+
for (const A in w)
|
|
3011
|
+
A !== "_id" && (w[A] = `${STYLES_KEY},${w[A]}`);
|
|
3012
|
+
return w;
|
|
3011
3013
|
});
|
|
3012
|
-
c(
|
|
3014
|
+
c(j);
|
|
3013
3015
|
} else
|
|
3014
|
-
i(
|
|
3015
|
-
b && b(
|
|
3016
|
-
} catch (
|
|
3017
|
-
a(
|
|
3016
|
+
i(B);
|
|
3017
|
+
b && b(S);
|
|
3018
|
+
} catch (y) {
|
|
3019
|
+
a(y);
|
|
3018
3020
|
} finally {
|
|
3019
3021
|
n(!1), b && b();
|
|
3020
3022
|
}
|
|
@@ -3153,11 +3155,11 @@ const useBlockHighlight = () => {
|
|
|
3153
3155
|
(a, l = null) => {
|
|
3154
3156
|
const i = [];
|
|
3155
3157
|
each(a, (c) => {
|
|
3156
|
-
const d = o.find((
|
|
3158
|
+
const d = o.find((h) => h._id === c);
|
|
3157
3159
|
l ? l === "root" && (l = null) : l = d._parent;
|
|
3158
3160
|
const g = filter(
|
|
3159
3161
|
o,
|
|
3160
|
-
(
|
|
3162
|
+
(h) => isString(l) ? h._parent === l : !h._parent
|
|
3161
3163
|
).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
|
|
3162
3164
|
r(m, l, g), i.push(get(m, "0._id", ""));
|
|
3163
3165
|
}), n(i);
|
|
@@ -3253,12 +3255,12 @@ const useBlockHighlight = () => {
|
|
|
3253
3255
|
const d = o(c), p = a;
|
|
3254
3256
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
3255
3257
|
return each(p, (m) => {
|
|
3256
|
-
const
|
|
3258
|
+
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
3257
3259
|
u = u.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
3258
|
-
const
|
|
3259
|
-
includes(["2xl", "xl", "lg", "md", "sm"],
|
|
3260
|
+
const x = first(m.split(":"));
|
|
3261
|
+
includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(m.split(":").pop().trim());
|
|
3260
3262
|
}), each(p, (m) => {
|
|
3261
|
-
const
|
|
3263
|
+
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
3262
3264
|
g = g.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
3263
3265
|
}), {
|
|
3264
3266
|
ids: [d._id],
|
|
@@ -3377,21 +3379,21 @@ const CONTROLS = [
|
|
|
3377
3379
|
return "VERTICAL";
|
|
3378
3380
|
}
|
|
3379
3381
|
}, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
|
|
3380
|
-
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (
|
|
3381
|
-
(
|
|
3382
|
-
isDisabledControl(g, m,
|
|
3382
|
+
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, m = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, i, a), f = useCallback(
|
|
3383
|
+
(x) => {
|
|
3384
|
+
isDisabledControl(g, m, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), n());
|
|
3383
3385
|
},
|
|
3384
3386
|
[g, m, p, u, i, c, n]
|
|
3385
3387
|
);
|
|
3386
3388
|
return useHotkeys(
|
|
3387
3389
|
"shift+up, shift+down, shift+left, shift+right",
|
|
3388
|
-
({ key:
|
|
3390
|
+
({ key: x }) => {
|
|
3389
3391
|
var b;
|
|
3390
|
-
f((b =
|
|
3392
|
+
f((b = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : b.toUpperCase());
|
|
3391
3393
|
},
|
|
3392
3394
|
{ document: a == null ? void 0 : a.contentDocument },
|
|
3393
3395
|
[f]
|
|
3394
|
-
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: f, orientation:
|
|
3396
|
+
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: f, orientation: h };
|
|
3395
3397
|
}, BlockController = ({ block: o, updateFloatingBar: n }) => {
|
|
3396
3398
|
const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
|
|
3397
3399
|
o,
|
|
@@ -3430,8 +3432,8 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
|
3430
3432
|
if (m === "CHILD")
|
|
3431
3433
|
pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
|
|
3432
3434
|
else {
|
|
3433
|
-
const
|
|
3434
|
-
m === "BEFORE" ?
|
|
3435
|
+
const h = { _id: c || "", position: d == null ? void 0 : d.length };
|
|
3436
|
+
m === "BEFORE" ? h.position = Math.max(u, 0) : m === "AFTER" && (h.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, h);
|
|
3435
3437
|
}
|
|
3436
3438
|
};
|
|
3437
3439
|
return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
@@ -3461,15 +3463,15 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
|
3461
3463
|
}
|
|
3462
3464
|
);
|
|
3463
3465
|
}, BlockFloatingSelector = ({ selectedBlockElement: o, block: n }) => {
|
|
3464
|
-
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: g, refs: m, update:
|
|
3466
|
+
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: g, refs: m, update: h } = useFloating({
|
|
3465
3467
|
placement: "top-start",
|
|
3466
3468
|
middleware: [shift(), flip()],
|
|
3467
3469
|
elements: {
|
|
3468
3470
|
reference: o
|
|
3469
3471
|
}
|
|
3470
3472
|
});
|
|
3471
|
-
useResizeObserver(o, () =>
|
|
3472
|
-
const f = get(n, "_parent", null),
|
|
3473
|
+
useResizeObserver(o, () => h(), o !== null), useResizeObserver(u == null ? void 0 : u.body, () => h(), (u == null ? void 0 : u.body) !== null);
|
|
3474
|
+
const f = get(n, "_parent", null), x = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
|
|
3473
3475
|
return !o || !n || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
3474
3476
|
"div",
|
|
3475
3477
|
{
|
|
@@ -3495,12 +3497,12 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
|
3495
3497
|
}
|
|
3496
3498
|
}
|
|
3497
3499
|
),
|
|
3498
|
-
/* @__PURE__ */ jsx(BlockActionLabel, { label:
|
|
3500
|
+
/* @__PURE__ */ jsx(BlockActionLabel, { label: x, block: n }),
|
|
3499
3501
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
|
|
3500
3502
|
/* @__PURE__ */ jsx(AddBlockDropdown, { block: n, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
|
|
3501
3503
|
canDuplicateBlock(get(n, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([n == null ? void 0 : n._id]) }) : null,
|
|
3502
3504
|
canDeleteBlock(get(n, "_type", "")) && d(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([n == null ? void 0 : n._id]) }) : null,
|
|
3503
|
-
d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar:
|
|
3505
|
+
d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar: h })
|
|
3504
3506
|
] })
|
|
3505
3507
|
]
|
|
3506
3508
|
}
|
|
@@ -3561,15 +3563,15 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
|
3561
3563
|
<div class="frame-root h-full"></div>
|
|
3562
3564
|
</body>
|
|
3563
3565
|
</html>`, useKeyEventWatcher = (o) => {
|
|
3564
|
-
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(),
|
|
3566
|
+
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), h = o ? { document: o } : {};
|
|
3565
3567
|
useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys("ctrl+c,command+c", () => u(n), {}, [n, u]), useHotkeys(
|
|
3566
3568
|
"ctrl+v,command+v",
|
|
3567
3569
|
() => {
|
|
3568
3570
|
g(n[0]) && m(n);
|
|
3569
3571
|
},
|
|
3570
|
-
{ ...
|
|
3572
|
+
{ ...h, preventDefault: !0 },
|
|
3571
3573
|
[n, g, m]
|
|
3572
|
-
), useHotkeys("esc", () => r([]),
|
|
3574
|
+
), useHotkeys("esc", () => r([]), h, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...h, preventDefault: !0 }, [
|
|
3573
3575
|
n,
|
|
3574
3576
|
i
|
|
3575
3577
|
]), useHotkeys(
|
|
@@ -3577,7 +3579,7 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
|
3577
3579
|
(f) => {
|
|
3578
3580
|
f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
|
|
3579
3581
|
},
|
|
3580
|
-
|
|
3582
|
+
h,
|
|
3581
3583
|
[n, l]
|
|
3582
3584
|
);
|
|
3583
3585
|
}, KeyboardHandler = () => {
|
|
@@ -3657,33 +3659,33 @@ const useDnd = () => {
|
|
|
3657
3659
|
};
|
|
3658
3660
|
return iframeDocument = o, {
|
|
3659
3661
|
isDragging: n,
|
|
3660
|
-
onDragOver: (
|
|
3661
|
-
|
|
3662
|
+
onDragOver: (h) => {
|
|
3663
|
+
h.preventDefault(), h.stopPropagation(), throttledDragOver(h);
|
|
3662
3664
|
},
|
|
3663
|
-
onDrop: (
|
|
3664
|
-
var
|
|
3665
|
-
const f = dropTarget, b = getOrientation(f) === "vertical" ?
|
|
3665
|
+
onDrop: (h) => {
|
|
3666
|
+
var E;
|
|
3667
|
+
const f = dropTarget, b = getOrientation(f) === "vertical" ? h.clientY + ((E = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : E.scrollY) : h.clientX;
|
|
3666
3668
|
dropIndex = calculateDropIndex(b, possiblePositions);
|
|
3667
|
-
const
|
|
3668
|
-
if ((
|
|
3669
|
+
const y = d, v = f.getAttribute("data-block-id"), S = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
|
|
3670
|
+
if ((y == null ? void 0 : y._id) === v || !S) {
|
|
3669
3671
|
m();
|
|
3670
3672
|
return;
|
|
3671
3673
|
}
|
|
3672
|
-
if (!has(
|
|
3673
|
-
a(
|
|
3674
|
+
if (!has(y, "_id")) {
|
|
3675
|
+
a(y, v === "canvas" ? null : v, dropIndex), setTimeout(m, 300);
|
|
3674
3676
|
return;
|
|
3675
3677
|
}
|
|
3676
|
-
let
|
|
3677
|
-
|
|
3678
|
+
let B = f.getAttribute("data-block-id");
|
|
3679
|
+
B === null && (B = h.target.parentElement.getAttribute("data-block-id")), c([y._id], B === "canvas" ? null : B, dropIndex), m(), setTimeout(removePlaceholder, 300);
|
|
3678
3680
|
},
|
|
3679
|
-
onDragEnter: (
|
|
3680
|
-
const f =
|
|
3681
|
-
dropTarget =
|
|
3682
|
-
const b =
|
|
3683
|
-
u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [],
|
|
3681
|
+
onDragEnter: (h) => {
|
|
3682
|
+
const f = h, x = f.target;
|
|
3683
|
+
dropTarget = x;
|
|
3684
|
+
const b = x.getAttribute("data-block-id"), y = x.getAttribute("data-dnd-dragged") !== "yes";
|
|
3685
|
+
u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(x), r(!0), l(""), i([]);
|
|
3684
3686
|
},
|
|
3685
|
-
onDragLeave: (
|
|
3686
|
-
|
|
3687
|
+
onDragLeave: (h) => {
|
|
3688
|
+
h.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
|
|
3687
3689
|
}
|
|
3688
3690
|
};
|
|
3689
3691
|
};
|
|
@@ -3714,8 +3716,8 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3714
3716
|
const f = o.getHTML();
|
|
3715
3717
|
a([m], { content: f }), n.style.display = "none", u.style.visibility = "visible";
|
|
3716
3718
|
}), i(m);
|
|
3717
|
-
const
|
|
3718
|
-
o.commands.setContent(
|
|
3719
|
+
const h = d(m).content;
|
|
3720
|
+
o.commands.setContent(h), n.style.display = "block", u.style.visibility = "hidden", n.style.position = "absolute", n.style.top = `${u.offsetTop}px`, n.style.left = `${u.offsetLeft}px`, n.style.width = `${u.offsetWidth}px`, n.style.height = `${u.offsetHeight}px`, n.classList.add(...u.classList);
|
|
3719
3721
|
},
|
|
3720
3722
|
[l, c, d, i, a, o, n]
|
|
3721
3723
|
);
|
|
@@ -3756,17 +3758,17 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3756
3758
|
return;
|
|
3757
3759
|
const f = getElementByDataBlockId(n, first(r));
|
|
3758
3760
|
if (f) {
|
|
3759
|
-
const
|
|
3760
|
-
if (
|
|
3761
|
-
const b = f.getAttribute("data-style-id"),
|
|
3762
|
-
l([{ id: b, prop:
|
|
3761
|
+
const x = f.getAttribute("data-style-prop");
|
|
3762
|
+
if (x) {
|
|
3763
|
+
const b = f.getAttribute("data-style-id"), y = f.getAttribute("data-block-parent");
|
|
3764
|
+
l([{ id: b, prop: x, blockId: y }]);
|
|
3763
3765
|
}
|
|
3764
3766
|
}
|
|
3765
3767
|
}, 100);
|
|
3766
3768
|
}, [n, r, l, a]);
|
|
3767
3769
|
const c = useEditor({
|
|
3768
3770
|
extensions: [StarterKit]
|
|
3769
|
-
}), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(),
|
|
3771
|
+
}), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(), h = useDnd();
|
|
3770
3772
|
return /* @__PURE__ */ jsx(
|
|
3771
3773
|
"div",
|
|
3772
3774
|
{
|
|
@@ -3776,8 +3778,8 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3776
3778
|
onDoubleClick: p,
|
|
3777
3779
|
onMouseMove: g,
|
|
3778
3780
|
onMouseLeave: m,
|
|
3779
|
-
...omit(
|
|
3780
|
-
className: "relative h-full max-w-full p-px " + (
|
|
3781
|
+
...omit(h, "isDragging"),
|
|
3782
|
+
className: "relative h-full max-w-full p-px " + (h.isDragging ? "dragging" : ""),
|
|
3781
3783
|
children: o
|
|
3782
3784
|
}
|
|
3783
3785
|
);
|
|
@@ -3786,7 +3788,7 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3786
3788
|
d == null ? void 0 : d.getElementById("selected-block")
|
|
3787
3789
|
), [m] = useState(
|
|
3788
3790
|
d == null ? void 0 : d.getElementById("selected-styling-block")
|
|
3789
|
-
), [
|
|
3791
|
+
), [h] = useState(
|
|
3790
3792
|
d == null ? void 0 : d.getElementById("dragged-block")
|
|
3791
3793
|
);
|
|
3792
3794
|
useEffect(() => {
|
|
@@ -3811,15 +3813,15 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3811
3813
|
forms,
|
|
3812
3814
|
aspectRatio,
|
|
3813
3815
|
containerQueries,
|
|
3814
|
-
plugin(function({ addBase: b, theme:
|
|
3816
|
+
plugin(function({ addBase: b, theme: y }) {
|
|
3815
3817
|
b({
|
|
3816
3818
|
"h1,h2,h3,h4,h5,h6": {
|
|
3817
|
-
fontFamily:
|
|
3819
|
+
fontFamily: y("fontFamily.heading")
|
|
3818
3820
|
},
|
|
3819
3821
|
body: {
|
|
3820
|
-
fontFamily:
|
|
3821
|
-
color:
|
|
3822
|
-
backgroundColor:
|
|
3822
|
+
fontFamily: y("fontFamily.body"),
|
|
3823
|
+
color: y("colors.foreground"),
|
|
3824
|
+
backgroundColor: y("colors.background")
|
|
3823
3825
|
}
|
|
3824
3826
|
});
|
|
3825
3827
|
})
|
|
@@ -3830,8 +3832,8 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3830
3832
|
outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
|
|
3831
3833
|
}`);
|
|
3832
3834
|
}, [r, g]), useEffect(() => {
|
|
3833
|
-
|
|
3834
|
-
}, [i,
|
|
3835
|
+
h.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
|
|
3836
|
+
}, [i, h]), useEffect(() => {
|
|
3835
3837
|
u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
|
|
3836
3838
|
}, [u]), useEffect(() => {
|
|
3837
3839
|
m && (m.textContent = `${map(l, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
|
|
@@ -3843,10 +3845,10 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3843
3845
|
const f = useMemo(
|
|
3844
3846
|
() => getChaiThemeCssVariables(o),
|
|
3845
3847
|
[o]
|
|
3846
|
-
),
|
|
3848
|
+
), x = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
|
|
3847
3849
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3848
3850
|
/* @__PURE__ */ jsx("style", { id: "chai-theme", children: f }),
|
|
3849
|
-
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html:
|
|
3851
|
+
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: x } })
|
|
3850
3852
|
] });
|
|
3851
3853
|
}, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
|
|
3852
3854
|
const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), c = useDebouncedCallback(
|
|
@@ -3926,10 +3928,10 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3926
3928
|
const [r] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), m = useMemo(
|
|
3927
3929
|
() => u ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
|
|
3928
3930
|
[r, l, a, d, u]
|
|
3929
|
-
),
|
|
3931
|
+
), h = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), f = useMemo(
|
|
3930
3932
|
() => c(r._id, getBlockRuntimeProps(r._type)),
|
|
3931
3933
|
[r._id, r._type, c, getBlockRuntimeProps]
|
|
3932
|
-
),
|
|
3934
|
+
), x = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), b = useMemo(
|
|
3933
3935
|
() => ({
|
|
3934
3936
|
blockProps: {
|
|
3935
3937
|
"data-block-id": r._id,
|
|
@@ -3938,9 +3940,9 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3938
3940
|
inBuilder: !0,
|
|
3939
3941
|
lang: l || i,
|
|
3940
3942
|
...m,
|
|
3941
|
-
...
|
|
3943
|
+
...h,
|
|
3942
3944
|
...f,
|
|
3943
|
-
...
|
|
3945
|
+
...x
|
|
3944
3946
|
}),
|
|
3945
3947
|
[
|
|
3946
3948
|
r._id,
|
|
@@ -3948,9 +3950,9 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3948
3950
|
l,
|
|
3949
3951
|
i,
|
|
3950
3952
|
m,
|
|
3951
|
-
|
|
3953
|
+
h,
|
|
3952
3954
|
f,
|
|
3953
|
-
|
|
3955
|
+
x
|
|
3954
3956
|
]
|
|
3955
3957
|
);
|
|
3956
3958
|
return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...b, children: n }) });
|
|
@@ -3982,11 +3984,11 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3982
3984
|
if (d < n) {
|
|
3983
3985
|
const u = parseFloat((d / n).toFixed(2).toString());
|
|
3984
3986
|
let g = {};
|
|
3985
|
-
const m = p * u,
|
|
3987
|
+
const m = p * u, h = d * u;
|
|
3986
3988
|
p && (g = {
|
|
3987
3989
|
// Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
|
|
3988
3990
|
height: 100 + (p - m) / m * 100 + "%",
|
|
3989
|
-
width: 100 + (d -
|
|
3991
|
+
width: 100 + (d - h) / h * 100 + "%"
|
|
3990
3992
|
}), i({
|
|
3991
3993
|
position: "relative",
|
|
3992
3994
|
top: 0,
|
|
@@ -4003,39 +4005,39 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4003
4005
|
c();
|
|
4004
4006
|
}, [n, o, r, c]), l;
|
|
4005
4007
|
}, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
|
|
4006
|
-
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, m] = useState([]), [,
|
|
4007
|
-
p((
|
|
4008
|
+
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, m] = useState([]), [, h] = useState([]), [, f] = useAtom$1(canvasIframeAtom), [x, b] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), v = useBuilderProp("htmlDir", "ltr"), S = (j) => {
|
|
4009
|
+
p((w) => ({ ...w, width: j }));
|
|
4008
4010
|
};
|
|
4009
4011
|
useEffect(() => {
|
|
4010
4012
|
if (!c.current) return;
|
|
4011
|
-
const { clientWidth:
|
|
4012
|
-
p({ width:
|
|
4013
|
+
const { clientWidth: j, clientHeight: w } = c.current;
|
|
4014
|
+
p({ width: j, height: w });
|
|
4013
4015
|
}, [c, n]);
|
|
4014
|
-
const
|
|
4015
|
-
const { top:
|
|
4016
|
-
return
|
|
4016
|
+
const B = (j, w = 0) => {
|
|
4017
|
+
const { top: A } = j.getBoundingClientRect();
|
|
4018
|
+
return A + w >= 0 && A - w <= window.innerHeight;
|
|
4017
4019
|
};
|
|
4018
4020
|
useEffect(() => {
|
|
4019
|
-
var
|
|
4021
|
+
var j, w;
|
|
4020
4022
|
if (a && a.type !== "Multiple" && i.current) {
|
|
4021
|
-
const
|
|
4022
|
-
|
|
4023
|
+
const A = getElementByDataBlockId(i.current.contentDocument, a._id);
|
|
4024
|
+
A && (B(A) || (w = (j = i.current) == null ? void 0 : j.contentWindow) == null || w.scrollTo({ top: A.offsetTop, behavior: "smooth" }), m([A]));
|
|
4023
4025
|
}
|
|
4024
4026
|
}, [a]), useEffect(() => {
|
|
4025
|
-
if (!isEmpty(
|
|
4026
|
-
const
|
|
4027
|
+
if (!isEmpty(x) && i.current) {
|
|
4028
|
+
const j = getElementByStyleId(
|
|
4027
4029
|
i.current.contentDocument,
|
|
4028
|
-
first(
|
|
4030
|
+
first(x).id
|
|
4029
4031
|
);
|
|
4030
|
-
|
|
4032
|
+
h(j ? [j] : [null]);
|
|
4031
4033
|
} else
|
|
4032
|
-
|
|
4033
|
-
}, [
|
|
4034
|
-
const
|
|
4035
|
-
let
|
|
4036
|
-
return
|
|
4037
|
-
}, [o,
|
|
4038
|
-
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount:
|
|
4034
|
+
h([null]);
|
|
4035
|
+
}, [x]);
|
|
4036
|
+
const E = useMemo(() => {
|
|
4037
|
+
let j = IframeInitialContent;
|
|
4038
|
+
return j = j.replace("__HTML_DIR__", v), o === "offline" && (j = j.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), j;
|
|
4039
|
+
}, [o, v]);
|
|
4040
|
+
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: S, onResize: S, children: /* @__PURE__ */ jsx(
|
|
4039
4041
|
"div",
|
|
4040
4042
|
{
|
|
4041
4043
|
onClick: () => {
|
|
@@ -4052,7 +4054,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4052
4054
|
id: "canvas-iframe",
|
|
4053
4055
|
style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
|
|
4054
4056
|
className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
|
|
4055
|
-
initialContent:
|
|
4057
|
+
initialContent: E,
|
|
4056
4058
|
children: [
|
|
4057
4059
|
/* @__PURE__ */ jsx(KeyboardHandler, {}),
|
|
4058
4060
|
/* @__PURE__ */ jsx(
|
|
@@ -4064,7 +4066,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4064
4066
|
),
|
|
4065
4067
|
/* @__PURE__ */ jsx(HeadTags, {}),
|
|
4066
4068
|
/* @__PURE__ */ jsx(Provider$1, { children: /* @__PURE__ */ jsxs(Canvas, { children: [
|
|
4067
|
-
|
|
4069
|
+
y ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
|
|
4068
4070
|
/* @__PURE__ */ jsx(AddBlockAtBottom, {}),
|
|
4069
4071
|
/* @__PURE__ */ jsx("br", {}),
|
|
4070
4072
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -4114,7 +4116,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4114
4116
|
l !== o.length - 1 && /* @__PURE__ */ jsx(ChevronRight, { className: "rtl:rotate-180", size: 16 })
|
|
4115
4117
|
] }, l))
|
|
4116
4118
|
] }) });
|
|
4117
|
-
}, CodeEditor$1 = React__default.lazy(() => import("./CodeEditor-
|
|
4119
|
+
}, CodeEditor$1 = React__default.lazy(() => import("./CodeEditor-ZtRSywKI.js")), CanvasArea = () => {
|
|
4118
4120
|
const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
|
|
4119
4121
|
return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2", children: [
|
|
4120
4122
|
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
|
|
@@ -4204,19 +4206,19 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4204
4206
|
}, [a, o]);
|
|
4205
4207
|
const u = (f) => Array.isArray(f) ? "array" : typeof f == "object" && f !== null ? "object" : "value", g = React.useCallback(
|
|
4206
4208
|
(f) => {
|
|
4207
|
-
const
|
|
4208
|
-
f.type === "object" ? (c((b) => [...b, f.key]), p(f.value)) :
|
|
4209
|
+
const x = (b) => r === "value" ? b === "value" || b === "object" : r === "array" ? b === "array" : b === r;
|
|
4210
|
+
f.type === "object" ? (c((b) => [...b, f.key]), p(f.value)) : x(f.type) && (n([...i, f.key].join(".")), l(!1));
|
|
4209
4211
|
},
|
|
4210
4212
|
[i, n, r]
|
|
4211
4213
|
), m = React.useCallback(() => {
|
|
4212
4214
|
if (i.length > 0) {
|
|
4213
4215
|
const f = i.slice(0, -1);
|
|
4214
|
-
c(f), p(f.reduce((
|
|
4216
|
+
c(f), p(f.reduce((x, b) => x[b], o));
|
|
4215
4217
|
}
|
|
4216
|
-
}, [i, o]),
|
|
4218
|
+
}, [i, o]), h = React.useMemo(() => Object.entries(d).map(([f, x]) => ({
|
|
4217
4219
|
key: f,
|
|
4218
|
-
value:
|
|
4219
|
-
type: u(
|
|
4220
|
+
value: x,
|
|
4221
|
+
type: u(x)
|
|
4220
4222
|
})).filter((f) => r === "value" ? f.type === "value" || f.type === "object" : r === "array" ? f.type === "array" || f.type === "object" : r === "object" ? f.type === "object" : !0), [d, r]);
|
|
4221
4223
|
return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
|
|
4222
4224
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
@@ -4242,7 +4244,7 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4242
4244
|
/* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
|
|
4243
4245
|
"Back"
|
|
4244
4246
|
] }),
|
|
4245
|
-
|
|
4247
|
+
h.map((f) => /* @__PURE__ */ jsxs(
|
|
4246
4248
|
CommandItem,
|
|
4247
4249
|
{
|
|
4248
4250
|
value: f.key,
|
|
@@ -4258,8 +4260,8 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4258
4260
|
size: "sm",
|
|
4259
4261
|
variant: "ghost",
|
|
4260
4262
|
className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
|
|
4261
|
-
onClick: (
|
|
4262
|
-
|
|
4263
|
+
onClick: (x) => {
|
|
4264
|
+
x.stopPropagation(), n([...i, f.key].join(".")), l(!1);
|
|
4263
4265
|
},
|
|
4264
4266
|
children: "Select"
|
|
4265
4267
|
}
|
|
@@ -4435,8 +4437,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4435
4437
|
z-index: 9999 !important;
|
|
4436
4438
|
}
|
|
4437
4439
|
`, document.head.appendChild(m), () => {
|
|
4438
|
-
const
|
|
4439
|
-
|
|
4440
|
+
const h = document.getElementById("rte-modal-styles");
|
|
4441
|
+
h && h.remove();
|
|
4440
4442
|
};
|
|
4441
4443
|
}
|
|
4442
4444
|
}, [o]);
|
|
@@ -4458,12 +4460,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4458
4460
|
],
|
|
4459
4461
|
content: a || "",
|
|
4460
4462
|
onUpdate: ({ editor: m }) => {
|
|
4461
|
-
const
|
|
4462
|
-
l(
|
|
4463
|
+
const h = m.getHTML();
|
|
4464
|
+
l(h);
|
|
4463
4465
|
},
|
|
4464
4466
|
onBlur: ({ editor: m }) => {
|
|
4465
|
-
const
|
|
4466
|
-
i(r,
|
|
4467
|
+
const h = m.getHTML();
|
|
4468
|
+
i(r, h);
|
|
4467
4469
|
},
|
|
4468
4470
|
editorProps: {
|
|
4469
4471
|
attributes: {
|
|
@@ -4480,17 +4482,17 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4480
4482
|
}, [u, o]);
|
|
4481
4483
|
const g = (m) => {
|
|
4482
4484
|
if (!u) return;
|
|
4483
|
-
const
|
|
4485
|
+
const h = `{{${m}}}`;
|
|
4484
4486
|
u.commands.focus();
|
|
4485
|
-
const { from: f, to:
|
|
4486
|
-
if (f !==
|
|
4487
|
-
u.chain().deleteSelection().insertContent(
|
|
4487
|
+
const { from: f, to: x } = u.state.selection;
|
|
4488
|
+
if (f !== x)
|
|
4489
|
+
u.chain().deleteSelection().insertContent(h).run();
|
|
4488
4490
|
else {
|
|
4489
|
-
const { state:
|
|
4491
|
+
const { state: y } = u, v = y.selection.from, S = y.doc.textBetween(Math.max(0, v - 1), v), B = y.doc.textBetween(v, Math.min(v + 1, y.doc.content.size));
|
|
4492
|
+
let E = "";
|
|
4493
|
+
v > 0 && S !== " " && !/[.,!?;:]/.test(S) && (E = " ");
|
|
4490
4494
|
let j = "";
|
|
4491
|
-
|
|
4492
|
-
let _ = "";
|
|
4493
|
-
C && C !== " " && !/[.,!?;:]/.test(C) && (_ = " "), u.chain().insertContent(j + x + _).run();
|
|
4495
|
+
B && B !== " " && !/[.,!?;:]/.test(B) && (j = " "), u.chain().insertContent(E + h + j).run();
|
|
4494
4496
|
}
|
|
4495
4497
|
};
|
|
4496
4498
|
return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (m) => !m && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
|
|
@@ -4526,12 +4528,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4526
4528
|
],
|
|
4527
4529
|
content: r || "",
|
|
4528
4530
|
onUpdate: ({ editor: f }) => {
|
|
4529
|
-
const
|
|
4530
|
-
a(
|
|
4531
|
+
const x = f.getHTML();
|
|
4532
|
+
a(x), c || u(x);
|
|
4531
4533
|
},
|
|
4532
4534
|
onBlur: ({ editor: f }) => {
|
|
4533
|
-
const
|
|
4534
|
-
l(o,
|
|
4535
|
+
const x = f.getHTML();
|
|
4536
|
+
l(o, x);
|
|
4535
4537
|
},
|
|
4536
4538
|
editorProps: {
|
|
4537
4539
|
attributes: {
|
|
@@ -4546,7 +4548,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4546
4548
|
}, [r]);
|
|
4547
4549
|
const m = (f) => {
|
|
4548
4550
|
a(f);
|
|
4549
|
-
},
|
|
4551
|
+
}, h = () => {
|
|
4550
4552
|
d(!1), g && g.commands.setContent(p);
|
|
4551
4553
|
};
|
|
4552
4554
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -4558,7 +4560,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4558
4560
|
RTEModal,
|
|
4559
4561
|
{
|
|
4560
4562
|
isOpen: c,
|
|
4561
|
-
onClose:
|
|
4563
|
+
onClose: h,
|
|
4562
4564
|
id: o,
|
|
4563
4565
|
value: p,
|
|
4564
4566
|
onChange: m,
|
|
@@ -4572,73 +4574,73 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4572
4574
|
onChange: r
|
|
4573
4575
|
}) => {
|
|
4574
4576
|
var L;
|
|
4575
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (
|
|
4577
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [f, x] = useState([]), [b, y] = useState(-1), v = useRef(null), S = (L = n == null ? void 0 : n.find((C) => C.key === u)) == null ? void 0 : L.name;
|
|
4576
4578
|
useEffect(() => {
|
|
4577
|
-
if (
|
|
4578
|
-
const
|
|
4579
|
-
g(
|
|
4580
|
-
const
|
|
4581
|
-
|
|
4579
|
+
if (h(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4580
|
+
const C = split(o, ":"), k = get(C, 1, "page") || "page";
|
|
4581
|
+
g(k), (async () => {
|
|
4582
|
+
const _ = await l(k, [get(C, 2, "page")]);
|
|
4583
|
+
_ && Array.isArray(_) && h(get(_, [0, "name"], ""));
|
|
4582
4584
|
})();
|
|
4583
4585
|
}, [o]);
|
|
4584
|
-
const
|
|
4585
|
-
async (
|
|
4586
|
-
if (isEmpty(
|
|
4587
|
-
|
|
4586
|
+
const B = useDebouncedCallback(
|
|
4587
|
+
async (C) => {
|
|
4588
|
+
if (isEmpty(C))
|
|
4589
|
+
x([]);
|
|
4588
4590
|
else {
|
|
4589
|
-
const
|
|
4590
|
-
|
|
4591
|
+
const k = await l(u, C);
|
|
4592
|
+
x(k);
|
|
4591
4593
|
}
|
|
4592
|
-
c(!1),
|
|
4594
|
+
c(!1), y(-1);
|
|
4593
4595
|
},
|
|
4594
4596
|
[u],
|
|
4595
4597
|
300
|
|
4596
|
-
),
|
|
4597
|
-
const
|
|
4598
|
-
|
|
4599
|
-
},
|
|
4600
|
-
switch (
|
|
4598
|
+
), E = (C) => {
|
|
4599
|
+
const k = ["pageType", u, C.id];
|
|
4600
|
+
k[1] && (r(k.join(":")), h(C.name), p(!1), x([]), y(-1));
|
|
4601
|
+
}, j = (C) => {
|
|
4602
|
+
switch (C.key) {
|
|
4601
4603
|
case "ArrowDown":
|
|
4602
|
-
|
|
4604
|
+
C.preventDefault(), y((k) => k < f.length - 1 ? k + 1 : k);
|
|
4603
4605
|
break;
|
|
4604
4606
|
case "ArrowUp":
|
|
4605
|
-
|
|
4607
|
+
C.preventDefault(), y((k) => k > 0 ? k - 1 : k);
|
|
4606
4608
|
break;
|
|
4607
4609
|
case "Enter":
|
|
4608
|
-
if (
|
|
4609
|
-
b >= 0 &&
|
|
4610
|
+
if (C.preventDefault(), f.length === 0) return;
|
|
4611
|
+
b >= 0 && E(f[b]);
|
|
4610
4612
|
break;
|
|
4611
4613
|
case "Escape":
|
|
4612
|
-
|
|
4614
|
+
C.preventDefault(), w();
|
|
4613
4615
|
break;
|
|
4614
4616
|
}
|
|
4615
4617
|
};
|
|
4616
4618
|
useEffect(() => {
|
|
4617
|
-
if (b >= 0 &&
|
|
4618
|
-
const
|
|
4619
|
-
|
|
4619
|
+
if (b >= 0 && v.current) {
|
|
4620
|
+
const C = v.current.children[b];
|
|
4621
|
+
C == null || C.scrollIntoView({ block: "nearest" });
|
|
4620
4622
|
}
|
|
4621
4623
|
}, [b]);
|
|
4622
|
-
const
|
|
4623
|
-
|
|
4624
|
-
},
|
|
4625
|
-
|
|
4624
|
+
const w = () => {
|
|
4625
|
+
h(""), x([]), y(-1), p(!1), r("");
|
|
4626
|
+
}, A = (C) => {
|
|
4627
|
+
h(C), p(!isEmpty(C)), c(!0), B(C);
|
|
4626
4628
|
};
|
|
4627
4629
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4628
|
-
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (
|
|
4630
|
+
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (C) => g(C.target.value), children: map(n, (C) => /* @__PURE__ */ jsx("option", { value: C.key, children: C.name }, C.key)) }),
|
|
4629
4631
|
u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
|
|
4630
4632
|
/* @__PURE__ */ jsx(
|
|
4631
4633
|
"input",
|
|
4632
4634
|
{
|
|
4633
4635
|
type: "text",
|
|
4634
4636
|
value: m,
|
|
4635
|
-
onChange: (
|
|
4636
|
-
onKeyDown:
|
|
4637
|
-
placeholder: a(`Search ${
|
|
4637
|
+
onChange: (C) => A(C.target.value),
|
|
4638
|
+
onKeyDown: j,
|
|
4639
|
+
placeholder: a(`Search ${S ?? ""}`),
|
|
4638
4640
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4639
4641
|
}
|
|
4640
4642
|
),
|
|
4641
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick:
|
|
4643
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: w, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
|
|
4642
4644
|
] }),
|
|
4643
4645
|
(i || !isEmpty(f) || d && isEmpty(f)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
4644
4646
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
@@ -4648,22 +4650,22 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4648
4650
|
' "',
|
|
4649
4651
|
m,
|
|
4650
4652
|
'"'
|
|
4651
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref:
|
|
4653
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(f == null ? void 0 : f.slice(0, 20), (C, k) => /* @__PURE__ */ jsxs(
|
|
4652
4654
|
"li",
|
|
4653
4655
|
{
|
|
4654
|
-
onClick: () =>
|
|
4655
|
-
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(
|
|
4656
|
+
onClick: () => E(C),
|
|
4657
|
+
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(C.id) ? "bg-blue-200" : k === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
4656
4658
|
children: [
|
|
4657
|
-
|
|
4659
|
+
C.name,
|
|
4658
4660
|
" ",
|
|
4659
|
-
|
|
4661
|
+
C.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
|
|
4660
4662
|
"( ",
|
|
4661
|
-
|
|
4663
|
+
C.slug,
|
|
4662
4664
|
" )"
|
|
4663
4665
|
] })
|
|
4664
4666
|
]
|
|
4665
4667
|
},
|
|
4666
|
-
|
|
4668
|
+
C.id
|
|
4667
4669
|
)) }) })
|
|
4668
4670
|
] });
|
|
4669
4671
|
}, LinkField = ({ schema: o, formData: n, onChange: r }) => {
|
|
@@ -4746,29 +4748,29 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4746
4748
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
|
|
4747
4749
|
}, [o, u]);
|
|
4748
4750
|
const m = () => {
|
|
4749
|
-
const
|
|
4750
|
-
if (
|
|
4751
|
-
const b = (
|
|
4752
|
-
if (!
|
|
4753
|
-
n({ ...o, currentSlide:
|
|
4751
|
+
const x = findIndex(u, { _id: g });
|
|
4752
|
+
if (x > -1) {
|
|
4753
|
+
const b = (x + 1) % u.length, y = get(u, [b, "_id"]);
|
|
4754
|
+
if (!y) return;
|
|
4755
|
+
n({ ...o, currentSlide: y }), c([y]);
|
|
4754
4756
|
}
|
|
4755
|
-
},
|
|
4756
|
-
const
|
|
4757
|
-
if (
|
|
4758
|
-
const b = (
|
|
4759
|
-
if (!
|
|
4760
|
-
n({ ...o, currentSlide:
|
|
4757
|
+
}, h = () => {
|
|
4758
|
+
const x = findIndex(u, { _id: g });
|
|
4759
|
+
if (x > -1) {
|
|
4760
|
+
const b = (x - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
|
|
4761
|
+
if (!y) return;
|
|
4762
|
+
n({ ...o, currentSlide: y }), c([y]);
|
|
4761
4763
|
}
|
|
4762
4764
|
}, f = () => {
|
|
4763
|
-
const
|
|
4765
|
+
const x = i(
|
|
4764
4766
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4765
4767
|
p == null ? void 0 : p._id
|
|
4766
|
-
), b =
|
|
4768
|
+
), b = x == null ? void 0 : x._id;
|
|
4767
4769
|
b && (n({ ...o, currentSlide: b }), c([b]));
|
|
4768
4770
|
};
|
|
4769
4771
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4770
4772
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
4771
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
4773
|
+
/* @__PURE__ */ jsx("button", { onClick: h, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
|
|
4772
4774
|
/* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
|
|
4773
4775
|
/* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
|
|
4774
4776
|
" ",
|
|
@@ -4842,8 +4844,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4842
4844
|
value: o == null ? void 0 : o.autoplayInterval,
|
|
4843
4845
|
className: "text-xs",
|
|
4844
4846
|
pattern: "[0-9]*",
|
|
4845
|
-
onChange: (
|
|
4846
|
-
let b =
|
|
4847
|
+
onChange: (x) => {
|
|
4848
|
+
let b = x.target.value;
|
|
4847
4849
|
b.length && (b = b.replace("-", "")), n({ ...o, autoplayInterval: b });
|
|
4848
4850
|
}
|
|
4849
4851
|
}
|
|
@@ -4883,12 +4885,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4883
4885
|
formData: g,
|
|
4884
4886
|
onChange: m
|
|
4885
4887
|
}) => {
|
|
4886
|
-
const { selectedLang:
|
|
4887
|
-
(
|
|
4888
|
-
const
|
|
4888
|
+
const { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), b = isEmpty(x) ? "" : isEmpty(h) ? f : h, y = get(LANGUAGES, b, b), v = usePageExternalData(), S = useSelectedBlock(), B = useRegisteredChaiBlocks(), E = get(B, [S == null ? void 0 : S._type, "i18nProps"], []) || [], [j, w] = useState(null), A = useCallback(
|
|
4889
|
+
(k) => {
|
|
4890
|
+
const _ = (P) => /[.,!?;:]/.test(P), T = (P, N, M) => {
|
|
4889
4891
|
let D = "", O = "";
|
|
4890
4892
|
const $ = N > 0 ? P[N - 1] : "", H = N < P.length ? P[N] : "";
|
|
4891
|
-
return N > 0 && ($ === "." || !
|
|
4893
|
+
return N > 0 && ($ === "." || !_($) && $ !== " ") && (D = " "), N < P.length && !_(H) && H !== " " && (O = " "), {
|
|
4892
4894
|
text: D + M + O,
|
|
4893
4895
|
prefixLength: D.length,
|
|
4894
4896
|
suffixLength: O.length
|
|
@@ -4899,7 +4901,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4899
4901
|
if (R && (R.querySelector(".ProseMirror") || R.__chaiRTE)) {
|
|
4900
4902
|
const P = R.__chaiRTE;
|
|
4901
4903
|
if (P) {
|
|
4902
|
-
const N = `{{${
|
|
4904
|
+
const N = `{{${k}}}`;
|
|
4903
4905
|
P.commands.focus();
|
|
4904
4906
|
const { from: M, to: D } = P.state.selection;
|
|
4905
4907
|
if (M !== D)
|
|
@@ -4907,9 +4909,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4907
4909
|
else {
|
|
4908
4910
|
const { state: $ } = P, H = $.selection.from, U = $.doc.textBetween(Math.max(0, H - 1), H), F = $.doc.textBetween(H, Math.min(H + 1, $.doc.content.size));
|
|
4909
4911
|
let z = "";
|
|
4910
|
-
H > 0 && U !== " " && !
|
|
4912
|
+
H > 0 && U !== " " && !_(U) && (z = " ");
|
|
4911
4913
|
let W = "";
|
|
4912
|
-
F && F !== " " && !
|
|
4914
|
+
F && F !== " " && !_(F) && (W = " "), P.chain().insertContent(z + N + W).run();
|
|
4913
4915
|
}
|
|
4914
4916
|
setTimeout(() => m(P.getHTML(), {}, o), 100);
|
|
4915
4917
|
return;
|
|
@@ -4917,31 +4919,31 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4917
4919
|
} else {
|
|
4918
4920
|
const P = I, N = P.selectionStart || 0, M = P.value || "", D = P.selectionEnd || N;
|
|
4919
4921
|
if (D > N) {
|
|
4920
|
-
const F = `{{${
|
|
4922
|
+
const F = `{{${k}}}`, { text: z } = T(M, N, F), W = M.slice(0, N) + z + M.slice(D);
|
|
4921
4923
|
m(W, {}, o);
|
|
4922
4924
|
return;
|
|
4923
4925
|
}
|
|
4924
|
-
const $ = `{{${
|
|
4926
|
+
const $ = `{{${k}}}`, { text: H } = T(M, N, $), U = M.slice(0, N) + H + M.slice(N);
|
|
4925
4927
|
m(U, {}, o);
|
|
4926
4928
|
}
|
|
4927
4929
|
},
|
|
4928
|
-
[o, m, g,
|
|
4930
|
+
[o, m, g, S == null ? void 0 : S._id]
|
|
4929
4931
|
);
|
|
4930
4932
|
if (d)
|
|
4931
4933
|
return null;
|
|
4932
4934
|
if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
|
|
4933
|
-
const
|
|
4935
|
+
const C = E == null ? void 0 : E.includes(o.replace("root.", ""));
|
|
4934
4936
|
if (u.type === "array") {
|
|
4935
|
-
const
|
|
4937
|
+
const k = j === o;
|
|
4936
4938
|
return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
|
|
4937
4939
|
u.title && /* @__PURE__ */ jsxs(
|
|
4938
4940
|
"label",
|
|
4939
4941
|
{
|
|
4940
4942
|
htmlFor: o,
|
|
4941
|
-
onClick: () =>
|
|
4943
|
+
onClick: () => w(k ? null : o),
|
|
4942
4944
|
className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
|
|
4943
4945
|
children: [
|
|
4944
|
-
|
|
4946
|
+
k ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
|
|
4945
4947
|
/* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
|
|
4946
4948
|
/* @__PURE__ */ jsx("span", { className: "leading-tight", children: r }),
|
|
4947
4949
|
" ",
|
|
@@ -4949,7 +4951,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4949
4951
|
]
|
|
4950
4952
|
}
|
|
4951
4953
|
),
|
|
4952
|
-
(g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${
|
|
4954
|
+
(g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${k ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
|
|
4953
4955
|
c,
|
|
4954
4956
|
a,
|
|
4955
4957
|
l,
|
|
@@ -4962,13 +4964,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4962
4964
|
/* @__PURE__ */ jsxs("label", { htmlFor: o, className: u.type === "object" ? "pb-2" : "", children: [
|
|
4963
4965
|
r,
|
|
4964
4966
|
" ",
|
|
4965
|
-
|
|
4967
|
+
C && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
|
|
4966
4968
|
" ",
|
|
4967
|
-
|
|
4969
|
+
y
|
|
4968
4970
|
] }),
|
|
4969
4971
|
p && u.type !== "object" ? " *" : null
|
|
4970
4972
|
] }),
|
|
4971
|
-
u.type === "string" && !u.enum && !u.oneOf &&
|
|
4973
|
+
u.type === "string" && !u.enum && !u.oneOf && v && /* @__PURE__ */ jsx(NestedPathSelector, { data: v, onSelect: A, dataType: "value" })
|
|
4972
4974
|
] }),
|
|
4973
4975
|
c,
|
|
4974
4976
|
a,
|
|
@@ -5023,8 +5025,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5023
5025
|
formData: a,
|
|
5024
5026
|
onChange: ({ formData: g }, m) => {
|
|
5025
5027
|
if (!m || o !== (g == null ? void 0 : g._id)) return;
|
|
5026
|
-
const
|
|
5027
|
-
u({ formData: g },
|
|
5028
|
+
const h = take(m.split("."), 2).join(".").replace("root.", "");
|
|
5029
|
+
u({ formData: g }, h);
|
|
5028
5030
|
}
|
|
5029
5031
|
},
|
|
5030
5032
|
i
|
|
@@ -5067,35 +5069,35 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5067
5069
|
}), a;
|
|
5068
5070
|
};
|
|
5069
5071
|
function BlockSettings() {
|
|
5070
|
-
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type),
|
|
5071
|
-
|
|
5072
|
-
},
|
|
5073
|
-
debounce(({ formData:
|
|
5074
|
-
f({ formData:
|
|
5072
|
+
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), f = ({ formData: j }, w, A) => {
|
|
5073
|
+
w && (c == null ? void 0 : c._id) === n._id && a([n._id], { [w]: get(j, w) }, A);
|
|
5074
|
+
}, x = useCallback(
|
|
5075
|
+
debounce(({ formData: j }, w, A) => {
|
|
5076
|
+
f({ formData: j }, w, A), d(j);
|
|
5075
5077
|
}, 1500),
|
|
5076
5078
|
[n == null ? void 0 : n._id, o]
|
|
5077
|
-
), b = ({ formData:
|
|
5078
|
-
|
|
5079
|
-
},
|
|
5080
|
-
|
|
5079
|
+
), b = ({ formData: j }, w) => {
|
|
5080
|
+
w && (r([n._id], { [w]: get(j, w) }), x({ formData: j }, w, { [w]: get(c, w) }));
|
|
5081
|
+
}, y = ({ formData: j }, w) => {
|
|
5082
|
+
w && (r([g._id], { [w]: get(j, w) }), x({ formData: j }, w, { [w]: get(c, w) }));
|
|
5081
5083
|
};
|
|
5082
5084
|
keys(get(i, "_bindings", {}));
|
|
5083
|
-
const { schema:
|
|
5084
|
-
const
|
|
5085
|
-
if (
|
|
5086
|
-
return getBlockFormSchemas(
|
|
5087
|
-
}, [n]), { wrapperSchema:
|
|
5085
|
+
const { schema: v, uiSchema: S } = useMemo(() => {
|
|
5086
|
+
const j = n == null ? void 0 : n._type;
|
|
5087
|
+
if (j)
|
|
5088
|
+
return getBlockFormSchemas(j);
|
|
5089
|
+
}, [n]), { wrapperSchema: B, wrapperUiSchema: E } = useMemo(() => {
|
|
5088
5090
|
if (!g || !(g != null && g._type))
|
|
5089
5091
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5090
|
-
const
|
|
5091
|
-
return { wrapperSchema:
|
|
5092
|
+
const j = g == null ? void 0 : g._type, { schema: w = {}, uiSchema: A = {} } = getBlockFormSchemas(j);
|
|
5093
|
+
return { wrapperSchema: w, wrapperUiSchema: A };
|
|
5092
5094
|
}, [g]);
|
|
5093
5095
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5094
5096
|
!isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
5095
5097
|
/* @__PURE__ */ jsxs(
|
|
5096
5098
|
"div",
|
|
5097
5099
|
{
|
|
5098
|
-
onClick: () => u((
|
|
5100
|
+
onClick: () => u((j) => !j),
|
|
5099
5101
|
className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
|
|
5100
5102
|
children: [
|
|
5101
5103
|
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" }),
|
|
@@ -5114,21 +5116,21 @@ function BlockSettings() {
|
|
|
5114
5116
|
JSONForm,
|
|
5115
5117
|
{
|
|
5116
5118
|
blockId: g == null ? void 0 : g._id,
|
|
5117
|
-
onChange:
|
|
5118
|
-
formData:
|
|
5119
|
-
schema:
|
|
5120
|
-
uiSchema:
|
|
5119
|
+
onChange: y,
|
|
5120
|
+
formData: h,
|
|
5121
|
+
schema: B,
|
|
5122
|
+
uiSchema: E
|
|
5121
5123
|
}
|
|
5122
5124
|
) })
|
|
5123
5125
|
] }),
|
|
5124
|
-
isEmpty(
|
|
5126
|
+
isEmpty(v) ? null : /* @__PURE__ */ jsx(
|
|
5125
5127
|
JSONForm,
|
|
5126
5128
|
{
|
|
5127
5129
|
blockId: n == null ? void 0 : n._id,
|
|
5128
5130
|
onChange: b,
|
|
5129
5131
|
formData: i,
|
|
5130
|
-
schema:
|
|
5131
|
-
uiSchema:
|
|
5132
|
+
schema: v,
|
|
5133
|
+
uiSchema: S
|
|
5132
5134
|
}
|
|
5133
5135
|
),
|
|
5134
5136
|
(n == null ? void 0 : n._type) === "GlobalBlock" ? /* @__PURE__ */ jsx(GlobalBlockSettings, {}) : null
|
|
@@ -5233,32 +5235,32 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5233
5235
|
canvas: n = !1,
|
|
5234
5236
|
tooltip: r = !0
|
|
5235
5237
|
}) => {
|
|
5236
|
-
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(),
|
|
5237
|
-
u.includes(
|
|
5238
|
-
},
|
|
5239
|
-
n || l(
|
|
5238
|
+
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (y) => {
|
|
5239
|
+
u.includes(y) ? u.length > 2 && g(u.filter((v) => v !== y)) : g((v) => [...v, y]);
|
|
5240
|
+
}, x = (y) => {
|
|
5241
|
+
n || l(y), c(y);
|
|
5240
5242
|
}, b = getBreakpointValue(n ? i : a).toLowerCase();
|
|
5241
|
-
return
|
|
5243
|
+
return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (y) => /* @__PURE__ */ createElement(
|
|
5242
5244
|
BreakpointCard,
|
|
5243
5245
|
{
|
|
5244
5246
|
canvas: n,
|
|
5245
|
-
...
|
|
5246
|
-
onClick:
|
|
5247
|
-
key:
|
|
5247
|
+
...y,
|
|
5248
|
+
onClick: x,
|
|
5249
|
+
key: y.breakpoint,
|
|
5248
5250
|
currentBreakpoint: b
|
|
5249
5251
|
}
|
|
5250
5252
|
)) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
|
|
5251
5253
|
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
|
|
5252
|
-
|
|
5253
|
-
(
|
|
5254
|
+
h.filter((y) => includes(u, toUpper(y.breakpoint))),
|
|
5255
|
+
(y) => /* @__PURE__ */ createElement(
|
|
5254
5256
|
BreakpointCard,
|
|
5255
5257
|
{
|
|
5256
5258
|
canvas: n,
|
|
5257
5259
|
openDelay: o,
|
|
5258
5260
|
tooltip: r,
|
|
5259
|
-
...
|
|
5260
|
-
onClick:
|
|
5261
|
-
key:
|
|
5261
|
+
...y,
|
|
5262
|
+
onClick: x,
|
|
5263
|
+
key: y.breakpoint,
|
|
5262
5264
|
currentBreakpoint: b
|
|
5263
5265
|
}
|
|
5264
5266
|
)
|
|
@@ -5268,15 +5270,15 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5268
5270
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
|
|
5269
5271
|
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: m("Screen sizes") }),
|
|
5270
5272
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
5271
|
-
map(
|
|
5273
|
+
map(h, (y) => /* @__PURE__ */ jsx(
|
|
5272
5274
|
DropdownMenuCheckboxItem,
|
|
5273
5275
|
{
|
|
5274
|
-
disabled:
|
|
5275
|
-
onCheckedChange: () => f(toUpper(
|
|
5276
|
-
checked: includes(u, toUpper(
|
|
5277
|
-
children: m(
|
|
5276
|
+
disabled: y.breakpoint === "xs",
|
|
5277
|
+
onCheckedChange: () => f(toUpper(y.breakpoint)),
|
|
5278
|
+
checked: includes(u, toUpper(y.breakpoint)),
|
|
5279
|
+
children: m(y.title)
|
|
5278
5280
|
},
|
|
5279
|
-
|
|
5281
|
+
y.breakpoint
|
|
5280
5282
|
))
|
|
5281
5283
|
] })
|
|
5282
5284
|
] })
|
|
@@ -5353,11 +5355,11 @@ function Countdown() {
|
|
|
5353
5355
|
const AskAIStyles = ({ blockId: o }) => {
|
|
5354
5356
|
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
|
|
5355
5357
|
useEffect(() => {
|
|
5356
|
-
var
|
|
5357
|
-
(
|
|
5358
|
+
var h;
|
|
5359
|
+
(h = d.current) == null || h.focus();
|
|
5358
5360
|
}, []);
|
|
5359
|
-
const m = (
|
|
5360
|
-
const { usage: f } =
|
|
5361
|
+
const m = (h) => {
|
|
5362
|
+
const { usage: f } = h || {};
|
|
5361
5363
|
!l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
5362
5364
|
};
|
|
5363
5365
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
@@ -5367,12 +5369,12 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5367
5369
|
{
|
|
5368
5370
|
ref: d,
|
|
5369
5371
|
value: i,
|
|
5370
|
-
onChange: (
|
|
5372
|
+
onChange: (h) => c(h.target.value),
|
|
5371
5373
|
placeholder: n("Ask AI to edit styles"),
|
|
5372
5374
|
className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
|
|
5373
5375
|
rows: 4,
|
|
5374
|
-
onKeyDown: (
|
|
5375
|
-
|
|
5376
|
+
onKeyDown: (h) => {
|
|
5377
|
+
h.key === "Enter" && (h.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
|
|
5376
5378
|
}
|
|
5377
5379
|
}
|
|
5378
5380
|
),
|
|
@@ -5414,10 +5416,10 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5414
5416
|
};
|
|
5415
5417
|
function ManualClasses() {
|
|
5416
5418
|
var T;
|
|
5417
|
-
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(),
|
|
5419
|
+
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), b = (T = first(d)) == null ? void 0 : T.prop, { classes: y } = getSplitChaiClasses(get(p, b, "")), v = y.split(" ").filter((I) => !isEmpty(I)), S = () => {
|
|
5418
5420
|
const I = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5419
|
-
u(m, I, !0),
|
|
5420
|
-
}, [
|
|
5421
|
+
u(m, I, !0), x("");
|
|
5422
|
+
}, [B, E] = useState([]), j = ({ value: I }) => {
|
|
5421
5423
|
const R = I.trim().toLowerCase(), P = R.match(/.+:/g);
|
|
5422
5424
|
let N = [];
|
|
5423
5425
|
if (P && P.length > 0) {
|
|
@@ -5428,10 +5430,10 @@ function ManualClasses() {
|
|
|
5428
5430
|
}));
|
|
5429
5431
|
} else
|
|
5430
5432
|
N = i.search(R);
|
|
5431
|
-
return
|
|
5432
|
-
},
|
|
5433
|
-
|
|
5434
|
-
},
|
|
5433
|
+
return E(map(N, "item"));
|
|
5434
|
+
}, w = () => {
|
|
5435
|
+
E([]);
|
|
5436
|
+
}, A = (I) => I.name, L = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), C = useMemo(
|
|
5435
5437
|
() => ({
|
|
5436
5438
|
ref: o,
|
|
5437
5439
|
autoComplete: "off",
|
|
@@ -5441,33 +5443,33 @@ function ManualClasses() {
|
|
|
5441
5443
|
placeholder: c("Enter classes separated by space"),
|
|
5442
5444
|
value: f,
|
|
5443
5445
|
onKeyDown: (I) => {
|
|
5444
|
-
I.key === "Enter" && f.trim() !== "" &&
|
|
5446
|
+
I.key === "Enter" && f.trim() !== "" && S();
|
|
5445
5447
|
},
|
|
5446
|
-
onChange: (I, { newValue: R }) =>
|
|
5448
|
+
onChange: (I, { newValue: R }) => x(R),
|
|
5447
5449
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
5448
5450
|
}),
|
|
5449
5451
|
[f, c, o]
|
|
5450
|
-
),
|
|
5452
|
+
), k = (I) => {
|
|
5451
5453
|
debugger;
|
|
5452
5454
|
const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5453
5455
|
g(m, [I]), u(m, R, !0), r(""), l(-1);
|
|
5454
|
-
},
|
|
5456
|
+
}, _ = () => {
|
|
5455
5457
|
if (navigator.clipboard === void 0) {
|
|
5456
5458
|
toast.error(c("Clipboard not supported"));
|
|
5457
5459
|
return;
|
|
5458
5460
|
}
|
|
5459
|
-
navigator.clipboard.writeText(
|
|
5461
|
+
navigator.clipboard.writeText(v.join(" ")), toast.success(c("Classes copied to clipboard"));
|
|
5460
5462
|
};
|
|
5461
5463
|
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
|
|
5462
5464
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
|
|
5463
5465
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
|
|
5464
5466
|
/* @__PURE__ */ jsx("span", { children: c("Classes") }),
|
|
5465
5467
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5466
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick:
|
|
5468
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: _, className: "cursor-pointer" }) }),
|
|
5467
5469
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
|
|
5468
5470
|
] })
|
|
5469
5471
|
] }),
|
|
5470
|
-
|
|
5472
|
+
h ? /* @__PURE__ */ jsxs(Popover, { children: [
|
|
5471
5473
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
|
|
5472
5474
|
/* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4" }),
|
|
5473
5475
|
/* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
|
|
@@ -5479,12 +5481,12 @@ function ManualClasses() {
|
|
|
5479
5481
|
/* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
|
|
5480
5482
|
Autosuggest,
|
|
5481
5483
|
{
|
|
5482
|
-
suggestions:
|
|
5483
|
-
onSuggestionsFetchRequested:
|
|
5484
|
-
onSuggestionsClearRequested:
|
|
5485
|
-
getSuggestionValue:
|
|
5484
|
+
suggestions: B,
|
|
5485
|
+
onSuggestionsFetchRequested: j,
|
|
5486
|
+
onSuggestionsClearRequested: w,
|
|
5487
|
+
getSuggestionValue: A,
|
|
5486
5488
|
renderSuggestion: L,
|
|
5487
|
-
inputProps:
|
|
5489
|
+
inputProps: C,
|
|
5488
5490
|
containerProps: {
|
|
5489
5491
|
className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
|
|
5490
5492
|
},
|
|
@@ -5500,14 +5502,14 @@ function ManualClasses() {
|
|
|
5500
5502
|
{
|
|
5501
5503
|
variant: "outline",
|
|
5502
5504
|
className: "h-6 border-border",
|
|
5503
|
-
onClick:
|
|
5505
|
+
onClick: S,
|
|
5504
5506
|
disabled: f.trim() === "",
|
|
5505
5507
|
size: "sm",
|
|
5506
5508
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
5507
5509
|
}
|
|
5508
5510
|
)
|
|
5509
5511
|
] }),
|
|
5510
|
-
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children:
|
|
5512
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: v.map(
|
|
5511
5513
|
(I, R) => a === R ? /* @__PURE__ */ jsx(
|
|
5512
5514
|
"input",
|
|
5513
5515
|
{
|
|
@@ -5515,10 +5517,10 @@ function ManualClasses() {
|
|
|
5515
5517
|
value: n,
|
|
5516
5518
|
onChange: (P) => r(P.target.value),
|
|
5517
5519
|
onBlur: () => {
|
|
5518
|
-
|
|
5520
|
+
k(I);
|
|
5519
5521
|
},
|
|
5520
5522
|
onKeyDown: (P) => {
|
|
5521
|
-
P.key === "Enter" &&
|
|
5523
|
+
P.key === "Enter" && k(I);
|
|
5522
5524
|
},
|
|
5523
5525
|
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"
|
|
5524
5526
|
},
|
|
@@ -5709,10 +5711,10 @@ const COLOR_PROP = {
|
|
|
5709
5711
|
ringColor: "ring",
|
|
5710
5712
|
ringOffsetColor: "ring-offset"
|
|
5711
5713
|
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
5712
|
-
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), m = get(u, "2", ""),
|
|
5714
|
+
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), m = get(u, "2", ""), h = useCallback(
|
|
5713
5715
|
// eslint-disable-next-line no-shadow
|
|
5714
5716
|
(b) => {
|
|
5715
|
-
["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((
|
|
5717
|
+
["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((y) => ({ ...y, color: b, shade: y.shade ? y.shade : "500" })));
|
|
5716
5718
|
},
|
|
5717
5719
|
[c, p]
|
|
5718
5720
|
);
|
|
@@ -5731,18 +5733,18 @@ const COLOR_PROP = {
|
|
|
5731
5733
|
useEffect(() => {
|
|
5732
5734
|
p({ color: "", shade: "" });
|
|
5733
5735
|
}, [r]);
|
|
5734
|
-
const { match:
|
|
5736
|
+
const { match: x } = useTailwindClassList();
|
|
5735
5737
|
return useEffect(() => {
|
|
5736
|
-
const
|
|
5737
|
-
|
|
5738
|
-
}, [
|
|
5738
|
+
const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
5739
|
+
x(o, y) && n(y, o);
|
|
5740
|
+
}, [x, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
|
|
5739
5741
|
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
5740
5742
|
DropDown,
|
|
5741
5743
|
{
|
|
5742
5744
|
disabled: !l,
|
|
5743
5745
|
rounded: !0,
|
|
5744
5746
|
selected: g,
|
|
5745
|
-
onChange:
|
|
5747
|
+
onChange: h,
|
|
5746
5748
|
options: [
|
|
5747
5749
|
"current",
|
|
5748
5750
|
"transparent",
|
|
@@ -6166,50 +6168,50 @@ const COLOR_PROP = {
|
|
|
6166
6168
|
},
|
|
6167
6169
|
a
|
|
6168
6170
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
6169
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m,
|
|
6171
|
+
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [b, y] = useState(""), [v, S] = useState(!1), [B, E] = useState(!1);
|
|
6170
6172
|
useEffect(() => {
|
|
6171
|
-
const { value:
|
|
6172
|
-
if (
|
|
6173
|
-
l(
|
|
6173
|
+
const { value: C, unit: k } = getClassValueAndUnit(i);
|
|
6174
|
+
if (k === "") {
|
|
6175
|
+
l(C), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
6174
6176
|
return;
|
|
6175
6177
|
}
|
|
6176
|
-
|
|
6178
|
+
h(k), l(k === "class" || isEmpty(C) ? "" : C);
|
|
6177
6179
|
}, [i, p, u]);
|
|
6178
|
-
const
|
|
6179
|
-
(
|
|
6180
|
-
const
|
|
6181
|
-
if (get(
|
|
6182
|
-
|
|
6180
|
+
const j = useThrottledCallback((C) => c(C), [c], THROTTLE_TIME), w = useThrottledCallback((C) => c(C, !1), [c], THROTTLE_TIME), A = useCallback(
|
|
6181
|
+
(C = !1) => {
|
|
6182
|
+
const k = getUserInputValues(`${a}`, u);
|
|
6183
|
+
if (get(k, "error", !1)) {
|
|
6184
|
+
x(!0);
|
|
6183
6185
|
return;
|
|
6184
6186
|
}
|
|
6185
|
-
const
|
|
6186
|
-
if (
|
|
6187
|
-
|
|
6187
|
+
const _ = get(k, "unit") !== "" ? get(k, "unit") : m;
|
|
6188
|
+
if (_ === "auto" || _ === "none") {
|
|
6189
|
+
j(`${d}${_}`);
|
|
6188
6190
|
return;
|
|
6189
6191
|
}
|
|
6190
|
-
if (get(
|
|
6192
|
+
if (get(k, "value") === "")
|
|
6191
6193
|
return;
|
|
6192
|
-
const I = `${get(
|
|
6193
|
-
|
|
6194
|
+
const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
|
|
6195
|
+
C ? w(I) : j(I);
|
|
6194
6196
|
},
|
|
6195
|
-
[
|
|
6197
|
+
[j, w, a, m, d, u]
|
|
6196
6198
|
), L = useCallback(
|
|
6197
|
-
(
|
|
6198
|
-
const
|
|
6199
|
-
if (get(
|
|
6200
|
-
|
|
6199
|
+
(C) => {
|
|
6200
|
+
const k = getUserInputValues(`${a}`, u);
|
|
6201
|
+
if (get(k, "error", !1)) {
|
|
6202
|
+
x(!0);
|
|
6201
6203
|
return;
|
|
6202
6204
|
}
|
|
6203
|
-
if (
|
|
6204
|
-
|
|
6205
|
+
if (C === "auto" || C === "none") {
|
|
6206
|
+
j(`${d}${C}`);
|
|
6205
6207
|
return;
|
|
6206
6208
|
}
|
|
6207
|
-
if (get(
|
|
6209
|
+
if (get(k, "value") === "")
|
|
6208
6210
|
return;
|
|
6209
|
-
const
|
|
6210
|
-
|
|
6211
|
+
const _ = get(k, "unit") !== "" ? get(k, "unit") : C, I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${_ === "-" ? "" : _}]`;
|
|
6212
|
+
j(I);
|
|
6211
6213
|
},
|
|
6212
|
-
[
|
|
6214
|
+
[j, a, d, u]
|
|
6213
6215
|
);
|
|
6214
6216
|
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: m === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6215
6217
|
/* @__PURE__ */ jsx(
|
|
@@ -6224,37 +6226,37 @@ const COLOR_PROP = {
|
|
|
6224
6226
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsx(InfoCircledIcon, {}) }) }),
|
|
6225
6227
|
/* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
|
|
6226
6228
|
] })
|
|
6227
|
-
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${
|
|
6229
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${v ? "z-auto" : ""}`, children: [
|
|
6228
6230
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
6229
6231
|
["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
|
|
6230
6232
|
"input",
|
|
6231
6233
|
{
|
|
6232
6234
|
readOnly: m === "class",
|
|
6233
|
-
onKeyPress: (
|
|
6234
|
-
|
|
6235
|
+
onKeyPress: (C) => {
|
|
6236
|
+
C.key === "Enter" && A();
|
|
6235
6237
|
},
|
|
6236
|
-
onKeyDown: (
|
|
6237
|
-
if (
|
|
6238
|
+
onKeyDown: (C) => {
|
|
6239
|
+
if (C.keyCode !== 38 && C.keyCode !== 40)
|
|
6238
6240
|
return;
|
|
6239
|
-
|
|
6240
|
-
const
|
|
6241
|
-
let
|
|
6242
|
-
|
|
6243
|
-
const T = `${
|
|
6244
|
-
|
|
6241
|
+
C.preventDefault(), E(!0);
|
|
6242
|
+
const k = parseInt$1(C.target.value);
|
|
6243
|
+
let _ = isNaN$1(k) ? 0 : k;
|
|
6244
|
+
C.keyCode === 38 && (_ += 1), C.keyCode === 40 && (_ -= 1);
|
|
6245
|
+
const T = `${_}`, R = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6246
|
+
w(R);
|
|
6245
6247
|
},
|
|
6246
|
-
onKeyUp: (
|
|
6247
|
-
|
|
6248
|
+
onKeyUp: (C) => {
|
|
6249
|
+
B && (C.preventDefault(), E(!1));
|
|
6248
6250
|
},
|
|
6249
|
-
onBlur: () =>
|
|
6250
|
-
onChange: (
|
|
6251
|
-
|
|
6251
|
+
onBlur: () => A(),
|
|
6252
|
+
onChange: (C) => {
|
|
6253
|
+
x(!1), l(C.target.value);
|
|
6252
6254
|
},
|
|
6253
|
-
onClick: (
|
|
6254
|
-
var
|
|
6255
|
-
(
|
|
6255
|
+
onClick: (C) => {
|
|
6256
|
+
var k;
|
|
6257
|
+
(k = C == null ? void 0 : C.target) == null || k.select(), r(!1);
|
|
6256
6258
|
},
|
|
6257
|
-
value:
|
|
6259
|
+
value: v ? b : a,
|
|
6258
6260
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
6259
6261
|
" ",
|
|
6260
6262
|
f ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
@@ -6279,29 +6281,29 @@ const COLOR_PROP = {
|
|
|
6279
6281
|
{
|
|
6280
6282
|
units: u,
|
|
6281
6283
|
current: m,
|
|
6282
|
-
onSelect: (
|
|
6283
|
-
r(!1),
|
|
6284
|
+
onSelect: (C) => {
|
|
6285
|
+
r(!1), h(C), L(C);
|
|
6284
6286
|
}
|
|
6285
6287
|
}
|
|
6286
6288
|
) }) })
|
|
6287
6289
|
] })
|
|
6288
6290
|
] }),
|
|
6289
|
-
["none", "auto"].indexOf(m) !== -1 ||
|
|
6291
|
+
["none", "auto"].indexOf(m) !== -1 || v ? null : /* @__PURE__ */ jsx(
|
|
6290
6292
|
DragStyleButton,
|
|
6291
6293
|
{
|
|
6292
|
-
onDragStart: () =>
|
|
6293
|
-
onDragEnd: (
|
|
6294
|
-
if (
|
|
6294
|
+
onDragStart: () => S(!0),
|
|
6295
|
+
onDragEnd: (C) => {
|
|
6296
|
+
if (y(() => ""), S(!1), isEmpty(C))
|
|
6295
6297
|
return;
|
|
6296
|
-
const
|
|
6297
|
-
|
|
6298
|
+
const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6299
|
+
j(T);
|
|
6298
6300
|
},
|
|
6299
|
-
onDrag: (
|
|
6300
|
-
if (isEmpty(
|
|
6301
|
+
onDrag: (C) => {
|
|
6302
|
+
if (isEmpty(C))
|
|
6301
6303
|
return;
|
|
6302
|
-
|
|
6303
|
-
const
|
|
6304
|
-
|
|
6304
|
+
y(C);
|
|
6305
|
+
const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6306
|
+
w(T);
|
|
6305
6307
|
},
|
|
6306
6308
|
currentValue: a,
|
|
6307
6309
|
unit: m,
|
|
@@ -6398,35 +6400,35 @@ const COLOR_PROP = {
|
|
|
6398
6400
|
"2xl": "1536px"
|
|
6399
6401
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6400
6402
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6401
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l),
|
|
6402
|
-
(
|
|
6403
|
-
const L = { dark: p, mq: g, mod: u, cls:
|
|
6403
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), y = useCallback(
|
|
6404
|
+
(w, A = !0) => {
|
|
6405
|
+
const L = { dark: p, mq: g, mod: u, cls: w, property: l, fullCls: "" };
|
|
6404
6406
|
(p || u !== "") && (L.mq = "xs");
|
|
6405
|
-
const
|
|
6406
|
-
x
|
|
6407
|
+
const C = generateFullClsName(L);
|
|
6408
|
+
h(x, [C], A);
|
|
6407
6409
|
},
|
|
6408
|
-
[
|
|
6409
|
-
),
|
|
6410
|
-
f(
|
|
6411
|
-
}, [
|
|
6410
|
+
[x, p, g, u, l, h]
|
|
6411
|
+
), v = useCallback(() => {
|
|
6412
|
+
f(x, [b], !0);
|
|
6413
|
+
}, [x, b, f]), S = useMemo(() => canChangeClass(m, g), [m, g]);
|
|
6412
6414
|
useEffect(() => {
|
|
6413
|
-
i(
|
|
6414
|
-
}, [
|
|
6415
|
-
const [, ,
|
|
6416
|
-
(
|
|
6417
|
-
|
|
6415
|
+
i(S, m);
|
|
6416
|
+
}, [S, i, m]);
|
|
6417
|
+
const [, , B] = useScreenSizeWidth(), E = useCallback(
|
|
6418
|
+
(w) => {
|
|
6419
|
+
B({
|
|
6418
6420
|
xs: 400,
|
|
6419
6421
|
sm: 640,
|
|
6420
6422
|
md: 800,
|
|
6421
6423
|
lg: 1024,
|
|
6422
6424
|
xl: 1420,
|
|
6423
6425
|
"2xl": 1920
|
|
6424
|
-
}[
|
|
6426
|
+
}[w]);
|
|
6425
6427
|
},
|
|
6426
|
-
[
|
|
6427
|
-
),
|
|
6428
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange:
|
|
6429
|
-
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !
|
|
6428
|
+
[B]
|
|
6429
|
+
), j = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
|
|
6430
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: S, canReset: m && j, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
6431
|
+
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !j ? "text-foreground" : ""}`, children: n(a) }) }),
|
|
6430
6432
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6431
6433
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
6432
6434
|
r === "arbitrary" ? /* @__PURE__ */ jsx(
|
|
@@ -6435,17 +6437,17 @@ const COLOR_PROP = {
|
|
|
6435
6437
|
currentClass: get(m, "cls", ""),
|
|
6436
6438
|
classPrefix: get(CLASS_PREFIXES, l, ""),
|
|
6437
6439
|
units: c || [],
|
|
6438
|
-
onChange:
|
|
6440
|
+
onChange: y,
|
|
6439
6441
|
negative: d,
|
|
6440
6442
|
cssProperty: l
|
|
6441
6443
|
}
|
|
6442
6444
|
) : null,
|
|
6443
|
-
r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange:
|
|
6444
|
-
r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange:
|
|
6445
|
-
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange:
|
|
6446
|
-
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange:
|
|
6445
|
+
r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange: y }),
|
|
6446
|
+
r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange: y }),
|
|
6447
|
+
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
|
|
6448
|
+
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
|
|
6447
6449
|
] }),
|
|
6448
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children:
|
|
6450
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: j ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : S && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6449
6451
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6450
6452
|
"button",
|
|
6451
6453
|
{
|
|
@@ -6465,7 +6467,7 @@ const COLOR_PROP = {
|
|
|
6465
6467
|
"button",
|
|
6466
6468
|
{
|
|
6467
6469
|
type: "button",
|
|
6468
|
-
onClick: () =>
|
|
6470
|
+
onClick: () => E(get(m, "mq")),
|
|
6469
6471
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
6470
6472
|
children: [
|
|
6471
6473
|
"Switch to ",
|
|
@@ -6486,7 +6488,7 @@ const COLOR_PROP = {
|
|
|
6486
6488
|
units: i = basicUnits,
|
|
6487
6489
|
negative: c = !1
|
|
6488
6490
|
}) => {
|
|
6489
|
-
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((
|
|
6491
|
+
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((h) => map(g, "property").includes(h), [g]);
|
|
6490
6492
|
return /* @__PURE__ */ jsxs(
|
|
6491
6493
|
"div",
|
|
6492
6494
|
{
|
|
@@ -6494,7 +6496,7 @@ const COLOR_PROP = {
|
|
|
6494
6496
|
children: [
|
|
6495
6497
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6496
6498
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6497
|
-
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label:
|
|
6499
|
+
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: h, key: f }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6498
6500
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6499
6501
|
"button",
|
|
6500
6502
|
{
|
|
@@ -6509,8 +6511,8 @@ const COLOR_PROP = {
|
|
|
6509
6511
|
]
|
|
6510
6512
|
}
|
|
6511
6513
|
) }),
|
|
6512
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(
|
|
6513
|
-
] }) }, `option-${
|
|
6514
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(h)) })
|
|
6515
|
+
] }) }, `option-${x}`)) })
|
|
6514
6516
|
] }),
|
|
6515
6517
|
/* @__PURE__ */ jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsx(
|
|
6516
6518
|
BlockStyle,
|
|
@@ -6591,11 +6593,11 @@ function BlockStyling() {
|
|
|
6591
6593
|
}), d = useThrottledCallback(
|
|
6592
6594
|
(u) => {
|
|
6593
6595
|
const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
|
|
6594
|
-
let
|
|
6595
|
-
|
|
6596
|
+
let h = parseFloat(i.dragStartValue);
|
|
6597
|
+
h = isNaN(h) ? 0 : h;
|
|
6596
6598
|
let f = MAPPER[i.dragUnit];
|
|
6597
6599
|
(startsWith(m, "scale") || m === "opacity") && (f = 10);
|
|
6598
|
-
let b = (i.dragStartY - u.pageY) / f +
|
|
6600
|
+
let b = (i.dragStartY - u.pageY) / f + h;
|
|
6599
6601
|
g && b < 0 && (b = 0), m === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
|
|
6600
6602
|
},
|
|
6601
6603
|
[i],
|
|
@@ -6641,20 +6643,20 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
6641
6643
|
parentId: r,
|
|
6642
6644
|
position: a
|
|
6643
6645
|
}) => {
|
|
6644
|
-
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(),
|
|
6646
|
+
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), h = () => {
|
|
6645
6647
|
if (console.log("addBlockToPage", o), has(o, "blocks")) {
|
|
6646
6648
|
const b = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
|
|
6647
6649
|
u(syncBlocksWithDefaults(b), r || null, a);
|
|
6648
6650
|
} else
|
|
6649
6651
|
p(o, r || null, a);
|
|
6650
6652
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6651
|
-
}, f = useFeature("dnd"), { t:
|
|
6653
|
+
}, f = useFeature("dnd"), { t: x } = useTranslation();
|
|
6652
6654
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6653
6655
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6654
6656
|
"button",
|
|
6655
6657
|
{
|
|
6656
6658
|
disabled: n,
|
|
6657
|
-
onClick:
|
|
6659
|
+
onClick: h,
|
|
6658
6660
|
type: "button",
|
|
6659
6661
|
onDragStart: (b) => {
|
|
6660
6662
|
b.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), b.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
@@ -6665,11 +6667,11 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
6665
6667
|
className: "cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",
|
|
6666
6668
|
children: [
|
|
6667
6669
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
6668
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(
|
|
6670
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(d || i)) })
|
|
6669
6671
|
]
|
|
6670
6672
|
}
|
|
6671
6673
|
) }),
|
|
6672
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
6674
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(d || i) }) })
|
|
6673
6675
|
] }) });
|
|
6674
6676
|
}, DefaultChaiBlocks = ({
|
|
6675
6677
|
parentId: o,
|
|
@@ -6857,22 +6859,22 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
6857
6859
|
}
|
|
6858
6860
|
}
|
|
6859
6861
|
}, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
|
|
6860
|
-
var m,
|
|
6862
|
+
var m, h, f, x, b, y, v, S;
|
|
6861
6863
|
if (r.type === "comment") return [];
|
|
6862
6864
|
console.log("node ===>", r);
|
|
6863
6865
|
let a = { _id: generateUUID() };
|
|
6864
6866
|
if (n && (a._parent = n.block._id), r.type === "text")
|
|
6865
6867
|
return isEmpty(get(r, "content", "")) ? [] : n && shouldAddText(n.node, n.block) ? (set(n, "block.content", get(r, "content", "")), []) : { ...a, _type: "Text", content: get(r, "content", "") };
|
|
6866
6868
|
const l = get(r, "attributes", []), i = l.find(
|
|
6867
|
-
(
|
|
6869
|
+
(B) => B.key === "data-chai-richtext" || B.key === "chai-richtext"
|
|
6868
6870
|
), c = l.find(
|
|
6869
|
-
(
|
|
6871
|
+
(B) => B.key === "data-chai-lightbox" || B.key === "chai-lightbox"
|
|
6870
6872
|
), d = l.find(
|
|
6871
|
-
(
|
|
6873
|
+
(B) => B.key === "data-chai-dropdown" || B.key === "chai-dropdown"
|
|
6872
6874
|
), p = l.find(
|
|
6873
|
-
(
|
|
6875
|
+
(B) => B.key === "data-chai-dropdown-button" || B.key === "chai-dropdown-button"
|
|
6874
6876
|
), u = l.find(
|
|
6875
|
-
(
|
|
6877
|
+
(B) => B.key === "data-chai-dropdown-content" || B.key === "chai-dropdown-content"
|
|
6876
6878
|
);
|
|
6877
6879
|
if (a = {
|
|
6878
6880
|
...a,
|
|
@@ -6880,13 +6882,13 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
6880
6882
|
...getAttrs(r),
|
|
6881
6883
|
...getStyles(r)
|
|
6882
6884
|
}, r.attributes) {
|
|
6883
|
-
const
|
|
6884
|
-
|
|
6885
|
+
const B = r.attributes.find((E) => includes(NAME_ATTRIBUTES, E.key));
|
|
6886
|
+
B && (a._name = B.value);
|
|
6885
6887
|
}
|
|
6886
6888
|
if (i)
|
|
6887
6889
|
return a.content = stringify(r.children), has(a, "styles_attrs.data-chai-richtext") && delete a.styles_attrs["data-chai-richtext"], has(a, "styles_attrs.chai-richtext") && delete a.styles_attrs["chai-richtext"], [a];
|
|
6888
6890
|
if (c) {
|
|
6889
|
-
const
|
|
6891
|
+
const B = [
|
|
6890
6892
|
"data-chai-lightbox",
|
|
6891
6893
|
"chai-lightbox",
|
|
6892
6894
|
"data-vbtype",
|
|
@@ -6898,44 +6900,44 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
6898
6900
|
];
|
|
6899
6901
|
a = {
|
|
6900
6902
|
...a,
|
|
6901
|
-
href: ((m = l.find((
|
|
6902
|
-
hrefType: ((
|
|
6903
|
-
autoplay: ((f = l.find((
|
|
6904
|
-
maxWidth: ((b = (
|
|
6905
|
-
backdropColor: ((
|
|
6906
|
-
galleryName: ((
|
|
6907
|
-
}, forEach(
|
|
6908
|
-
has(a, `styles_attrs.${
|
|
6903
|
+
href: ((m = l.find((E) => E.key === "href")) == null ? void 0 : m.value) || "",
|
|
6904
|
+
hrefType: ((h = l.find((E) => E.key === "data-vbtype")) == null ? void 0 : h.value) || "video",
|
|
6905
|
+
autoplay: ((f = l.find((E) => E.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
|
|
6906
|
+
maxWidth: ((b = (x = l.find((E) => E.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : b.replace("px", "")) || "",
|
|
6907
|
+
backdropColor: ((y = l.find((E) => E.key === "data-overlay")) == null ? void 0 : y.value) || "",
|
|
6908
|
+
galleryName: ((v = l.find((E) => E.key === "data-gall")) == null ? void 0 : v.value) || ""
|
|
6909
|
+
}, forEach(B, (E) => {
|
|
6910
|
+
has(a, `styles_attrs.${E}`) && delete a.styles_attrs[E];
|
|
6909
6911
|
});
|
|
6910
6912
|
}
|
|
6911
6913
|
if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
|
|
6912
6914
|
delete a.styles_attrs;
|
|
6913
|
-
const
|
|
6914
|
-
a.content = getTextContent(
|
|
6915
|
-
const
|
|
6915
|
+
const B = filter(r.children || [], (j) => (j == null ? void 0 : j.tagName) !== "span");
|
|
6916
|
+
a.content = getTextContent(B);
|
|
6917
|
+
const E = find(
|
|
6916
6918
|
r.children || [],
|
|
6917
|
-
(
|
|
6919
|
+
(j) => (j == null ? void 0 : j.tagName) === "span" && some(j.children || [], (w) => (w == null ? void 0 : w.tagName) === "svg")
|
|
6918
6920
|
);
|
|
6919
|
-
if (
|
|
6920
|
-
const
|
|
6921
|
-
if (
|
|
6922
|
-
a.icon = stringify([
|
|
6923
|
-
const { height:
|
|
6924
|
-
a.iconHeight =
|
|
6921
|
+
if (E) {
|
|
6922
|
+
const j = find(E.children || [], (w) => (w == null ? void 0 : w.tagName) === "svg");
|
|
6923
|
+
if (j) {
|
|
6924
|
+
a.icon = stringify([j]);
|
|
6925
|
+
const { height: w, width: A } = getSvgDimensions(j, "16px", "16px");
|
|
6926
|
+
a.iconHeight = w, a.iconWidth = A;
|
|
6925
6927
|
}
|
|
6926
6928
|
}
|
|
6927
6929
|
return [a];
|
|
6928
6930
|
}
|
|
6929
6931
|
if (a._type === "Input") {
|
|
6930
|
-
const
|
|
6931
|
-
|
|
6932
|
+
const B = a.inputType || "text";
|
|
6933
|
+
B === "checkbox" ? set(a, "_type", "Checkbox") : B === "radio" && set(a, "_type", "Radio");
|
|
6932
6934
|
} else if (r.tagName === "video" || r.tagName === "iframe") {
|
|
6933
|
-
const
|
|
6934
|
-
return hasVideoEmbed(
|
|
6935
|
+
const B = stringify([r]);
|
|
6936
|
+
return hasVideoEmbed(B) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(B)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = B, [a];
|
|
6935
6937
|
} else if (r.tagName === "svg") {
|
|
6936
|
-
const
|
|
6937
|
-
return a.styles = `${STYLES_KEY}, ${cn$1(`w-${
|
|
6938
|
-
} else if (r.tagName == "option" && n && ((
|
|
6938
|
+
const B = find(r.attributes, { key: "height" }), E = find(r.attributes, { key: "width" }), j = get(B, "value") ? `[${get(B, "value")}px]` : "24px", w = get(E, "value") ? `[${get(E, "value")}px]` : "24px", A = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
|
|
6939
|
+
return a.styles = `${STYLES_KEY}, ${cn$1(`w-${w} h-${j}`, A)}`.trim(), r.attributes = filter(r.attributes, (L) => !includes(["style", "width", "height", "class"], L.key)), a.icon = stringify([r]), [a];
|
|
6940
|
+
} else if (r.tagName == "option" && n && ((S = n.block) == null ? void 0 : S._type) === "Select")
|
|
6939
6941
|
return n.block.options.push({
|
|
6940
6942
|
label: getTextContent(r.children),
|
|
6941
6943
|
...getAttrs(r)
|
|
@@ -7008,29 +7010,29 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7008
7010
|
error: c
|
|
7009
7011
|
}), g(!0);
|
|
7010
7012
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7011
|
-
const
|
|
7012
|
-
const
|
|
7013
|
+
const h = Object.entries(a).map(([x, b]) => {
|
|
7014
|
+
const y = b, v = y.type || "partial", S = formatReadableName(v);
|
|
7013
7015
|
return {
|
|
7014
7016
|
type: "PartialBlock",
|
|
7015
7017
|
// Set the type to PartialBlock
|
|
7016
|
-
label: formatReadableName(
|
|
7017
|
-
description:
|
|
7018
|
+
label: formatReadableName(y.name || x),
|
|
7019
|
+
description: y.description || "",
|
|
7018
7020
|
icon: Globe,
|
|
7019
|
-
group:
|
|
7021
|
+
group: S,
|
|
7020
7022
|
// Use formatted type as group
|
|
7021
7023
|
category: "partial",
|
|
7022
|
-
partialBlockId:
|
|
7024
|
+
partialBlockId: x,
|
|
7023
7025
|
// Store the original ID as partialBlockId
|
|
7024
|
-
_name:
|
|
7026
|
+
_name: y.name
|
|
7025
7027
|
};
|
|
7026
|
-
}), f = uniq(map(
|
|
7028
|
+
}), f = uniq(map(h, "group"));
|
|
7027
7029
|
p({
|
|
7028
|
-
blocks:
|
|
7030
|
+
blocks: h,
|
|
7029
7031
|
groups: f,
|
|
7030
7032
|
isLoading: !1,
|
|
7031
7033
|
error: null
|
|
7032
7034
|
}), g(!0);
|
|
7033
|
-
} else l ? p((
|
|
7035
|
+
} else l ? p((h) => ({ ...h, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
|
|
7034
7036
|
blocks: [],
|
|
7035
7037
|
groups: [],
|
|
7036
7038
|
isLoading: !1,
|
|
@@ -7046,7 +7048,7 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7046
7048
|
c
|
|
7047
7049
|
]);
|
|
7048
7050
|
const m = () => {
|
|
7049
|
-
p((
|
|
7051
|
+
p((h) => ({ ...h, isLoading: !0, error: null })), g(!1), i();
|
|
7050
7052
|
};
|
|
7051
7053
|
return d.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : d.error || d.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
|
|
7052
7054
|
/* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
|
|
@@ -7069,44 +7071,44 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7069
7071
|
}
|
|
7070
7072
|
);
|
|
7071
7073
|
}, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
7072
|
-
var
|
|
7073
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (
|
|
7074
|
+
var C;
|
|
7075
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (C = find(c, (k) => k._id === r)) == null ? void 0 : C._type, [h, f] = useState("all"), [x, b] = useState(null), y = useRef(null);
|
|
7074
7076
|
useEffect(() => {
|
|
7075
|
-
const
|
|
7076
|
-
var
|
|
7077
|
-
(
|
|
7077
|
+
const k = setTimeout(() => {
|
|
7078
|
+
var _;
|
|
7079
|
+
(_ = u.current) == null || _.focus();
|
|
7078
7080
|
}, 0);
|
|
7079
|
-
return () => clearTimeout(
|
|
7081
|
+
return () => clearTimeout(k);
|
|
7080
7082
|
}, [g]), useEffect(() => {
|
|
7081
7083
|
d && (f("all"), b(null));
|
|
7082
|
-
}, [d]), useEffect(() => (
|
|
7083
|
-
f(
|
|
7084
|
+
}, [d]), useEffect(() => (y.current = debounce((k) => {
|
|
7085
|
+
f(k);
|
|
7084
7086
|
}, 500), () => {
|
|
7085
|
-
|
|
7087
|
+
y.current && y.current.cancel();
|
|
7086
7088
|
}), []);
|
|
7087
|
-
const
|
|
7088
|
-
b(
|
|
7089
|
-
}, []),
|
|
7090
|
-
b(null),
|
|
7091
|
-
}, []),
|
|
7092
|
-
|
|
7093
|
-
}, []),
|
|
7089
|
+
const v = useCallback((k) => {
|
|
7090
|
+
b(k), y.current && y.current(k);
|
|
7091
|
+
}, []), S = useCallback(() => {
|
|
7092
|
+
b(null), y.current && y.current.cancel();
|
|
7093
|
+
}, []), B = useCallback((k) => {
|
|
7094
|
+
y.current && y.current.cancel(), f(k), b(null);
|
|
7095
|
+
}, []), E = useMemo(
|
|
7094
7096
|
() => d ? values(n).filter(
|
|
7095
|
-
(
|
|
7096
|
-
var
|
|
7097
|
-
return (((
|
|
7097
|
+
(k) => {
|
|
7098
|
+
var _, T;
|
|
7099
|
+
return (((_ = k.label) == null ? void 0 : _.toLowerCase()) + " " + ((T = k.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
|
|
7098
7100
|
}
|
|
7099
7101
|
) : n,
|
|
7100
7102
|
[n, d]
|
|
7101
|
-
),
|
|
7103
|
+
), j = useMemo(
|
|
7102
7104
|
() => d ? o.filter(
|
|
7103
|
-
(
|
|
7104
|
-
) : o.filter((
|
|
7105
|
-
[n,
|
|
7106
|
-
),
|
|
7107
|
-
() => sortBy(
|
|
7108
|
-
[
|
|
7109
|
-
),
|
|
7105
|
+
(k) => reject(filter(values(E), { group: k }), { hidden: !0 }).length > 0
|
|
7106
|
+
) : o.filter((k) => reject(filter(values(n), { group: k }), { hidden: !0 }).length > 0),
|
|
7107
|
+
[n, E, o, d]
|
|
7108
|
+
), w = useMemo(
|
|
7109
|
+
() => sortBy(j, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
|
|
7110
|
+
[j]
|
|
7111
|
+
), A = useMemo(() => h === "all" ? E : filter(values(E), { group: h }), [E, h]), L = useMemo(() => h === "all" ? w : [h], [w, h]);
|
|
7110
7112
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7111
7113
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7112
7114
|
Input$1,
|
|
@@ -7116,55 +7118,55 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7116
7118
|
placeholder: i("Search blocks..."),
|
|
7117
7119
|
value: d,
|
|
7118
7120
|
className: "-ml-2",
|
|
7119
|
-
onChange: (
|
|
7121
|
+
onChange: (k) => p(k.target.value)
|
|
7120
7122
|
}
|
|
7121
7123
|
) }),
|
|
7122
7124
|
/* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
|
|
7123
|
-
|
|
7125
|
+
w.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
7124
7126
|
/* @__PURE__ */ jsx(
|
|
7125
7127
|
"button",
|
|
7126
7128
|
{
|
|
7127
|
-
onClick: () =>
|
|
7128
|
-
onMouseEnter: () =>
|
|
7129
|
-
onMouseLeave:
|
|
7130
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${
|
|
7129
|
+
onClick: () => B("all"),
|
|
7130
|
+
onMouseEnter: () => v("all"),
|
|
7131
|
+
onMouseLeave: S,
|
|
7132
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" || x === "all" ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
|
|
7131
7133
|
children: i("All")
|
|
7132
7134
|
},
|
|
7133
7135
|
"sidebar-all"
|
|
7134
7136
|
),
|
|
7135
|
-
|
|
7137
|
+
w.map((k) => /* @__PURE__ */ jsx(
|
|
7136
7138
|
"button",
|
|
7137
7139
|
{
|
|
7138
|
-
onClick: () =>
|
|
7139
|
-
onMouseEnter: () =>
|
|
7140
|
-
onMouseLeave:
|
|
7141
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${
|
|
7142
|
-
children: capitalize(i(
|
|
7140
|
+
onClick: () => B(k),
|
|
7141
|
+
onMouseEnter: () => v(k),
|
|
7142
|
+
onMouseLeave: S,
|
|
7143
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === k || x === k ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
|
|
7144
|
+
children: capitalize(i(k.toLowerCase()))
|
|
7143
7145
|
},
|
|
7144
|
-
`sidebar-${
|
|
7146
|
+
`sidebar-${k}`
|
|
7145
7147
|
))
|
|
7146
7148
|
] }) }) }),
|
|
7147
|
-
/* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children:
|
|
7149
|
+
/* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children: j.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
|
|
7148
7150
|
i("No blocks found matching"),
|
|
7149
7151
|
' "',
|
|
7150
7152
|
d,
|
|
7151
7153
|
'"'
|
|
7152
|
-
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((
|
|
7153
|
-
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(
|
|
7154
|
+
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7155
|
+
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
|
|
7154
7156
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
|
|
7155
|
-
|
|
7157
|
+
h === "all" ? filter(values(A), { group: k }) : values(A),
|
|
7156
7158
|
{ hidden: !0 }
|
|
7157
|
-
).map((
|
|
7159
|
+
).map((_) => /* @__PURE__ */ jsx(
|
|
7158
7160
|
CoreBlock,
|
|
7159
7161
|
{
|
|
7160
7162
|
parentId: r,
|
|
7161
7163
|
position: a,
|
|
7162
|
-
block:
|
|
7163
|
-
disabled: !canAcceptChildBlock(m,
|
|
7164
|
+
block: _,
|
|
7165
|
+
disabled: !canAcceptChildBlock(m, _.type) || !canBeNestedInside(m, _.type)
|
|
7164
7166
|
},
|
|
7165
|
-
|
|
7167
|
+
_.type
|
|
7166
7168
|
)) })
|
|
7167
|
-
] },
|
|
7169
|
+
] }, k)) }) }) })
|
|
7168
7170
|
] })
|
|
7169
7171
|
] });
|
|
7170
7172
|
}, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
|
|
@@ -7173,13 +7175,13 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7173
7175
|
parentId: r = void 0,
|
|
7174
7176
|
position: a = -1
|
|
7175
7177
|
}) => {
|
|
7176
|
-
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(), m = Object.keys(g || {}).length > 0, { hasPermission:
|
|
7178
|
+
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(), m = Object.keys(g || {}).length > 0, { hasPermission: h } = usePermissions();
|
|
7177
7179
|
useEffect(() => {
|
|
7178
7180
|
i === "partials" && !m && c("library");
|
|
7179
7181
|
}, [i, m, c]);
|
|
7180
7182
|
const f = useCallback(() => {
|
|
7181
7183
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7182
|
-
}, []),
|
|
7184
|
+
}, []), x = p && h(PERMISSIONS.IMPORT_HTML);
|
|
7183
7185
|
return /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
7184
7186
|
n ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
|
|
7185
7187
|
/* @__PURE__ */ jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: l("Add block") }),
|
|
@@ -7198,13 +7200,13 @@ const CHAI_BUILDER_EVENTS = {
|
|
|
7198
7200
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
7199
7201
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
7200
7202
|
m && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
|
|
7201
|
-
|
|
7203
|
+
x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
7202
7204
|
map(u, (b) => /* @__PURE__ */ jsx(TabsTrigger, { value: b.key, children: React__default.createElement(b.tab) }))
|
|
7203
7205
|
] }),
|
|
7204
7206
|
/* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
|
|
7205
7207
|
/* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
|
|
7206
7208
|
m && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
|
|
7207
|
-
|
|
7209
|
+
x ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
|
|
7208
7210
|
map(u, (b) => /* @__PURE__ */ jsx(TabsContent, { value: b.key, children: React__default.createElement(b.tabContent, { close: f, parentId: r, position: a }) }))
|
|
7209
7211
|
]
|
|
7210
7212
|
}
|
|
@@ -7262,18 +7264,18 @@ const BlockCard = ({
|
|
|
7262
7264
|
parentId: r = void 0,
|
|
7263
7265
|
position: a = -1
|
|
7264
7266
|
}) => {
|
|
7265
|
-
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")),
|
|
7266
|
-
const
|
|
7267
|
-
return
|
|
7267
|
+
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), x = (v) => {
|
|
7268
|
+
const S = has(v, "styles_attrs.data-page-section");
|
|
7269
|
+
return v._type === "Box" && S;
|
|
7268
7270
|
}, b = useCallback(
|
|
7269
|
-
async (
|
|
7270
|
-
if (
|
|
7271
|
+
async (v) => {
|
|
7272
|
+
if (v.stopPropagation(), has(o, "component")) {
|
|
7271
7273
|
d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7272
7274
|
return;
|
|
7273
7275
|
}
|
|
7274
7276
|
i(!0);
|
|
7275
|
-
const
|
|
7276
|
-
isEmpty(
|
|
7277
|
+
const S = await c(n, o);
|
|
7278
|
+
isEmpty(S) || p(syncBlocksWithDefaults(S), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7277
7279
|
},
|
|
7278
7280
|
[d, p, o, c, n, r, a]
|
|
7279
7281
|
);
|
|
@@ -7283,20 +7285,20 @@ const BlockCard = ({
|
|
|
7283
7285
|
{
|
|
7284
7286
|
onClick: l ? () => {
|
|
7285
7287
|
} : b,
|
|
7286
|
-
draggable:
|
|
7287
|
-
onDragStart: async (
|
|
7288
|
-
const
|
|
7289
|
-
let
|
|
7290
|
-
if (
|
|
7291
|
-
const
|
|
7292
|
-
if (
|
|
7293
|
-
const
|
|
7294
|
-
|
|
7295
|
-
|
|
7288
|
+
draggable: h ? "true" : "false",
|
|
7289
|
+
onDragStart: async (v) => {
|
|
7290
|
+
const S = await c(n, o);
|
|
7291
|
+
let B = r;
|
|
7292
|
+
if (x(first(S)) && (B = null), !isEmpty(S)) {
|
|
7293
|
+
const E = { blocks: S, uiLibrary: !0, parent: B };
|
|
7294
|
+
if (v.dataTransfer.setData("text/plain", JSON.stringify(E)), o.preview) {
|
|
7295
|
+
const j = new Image();
|
|
7296
|
+
j.src = o.preview, j.onload = () => {
|
|
7297
|
+
v.dataTransfer.setDragImage(j, 0, 0);
|
|
7296
7298
|
};
|
|
7297
7299
|
} else
|
|
7298
|
-
|
|
7299
|
-
f(
|
|
7300
|
+
v.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7301
|
+
f(E), setTimeout(() => {
|
|
7300
7302
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7301
7303
|
}, 200);
|
|
7302
7304
|
}
|
|
@@ -7316,39 +7318,43 @@ const BlockCard = ({
|
|
|
7316
7318
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: m }) })
|
|
7317
7319
|
] });
|
|
7318
7320
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
7319
|
-
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i =
|
|
7321
|
+
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = l.find((v) => v.id === r) || first(l), { data: c, isLoading: d } = useLibraryBlocks(i), p = groupBy([...c], "group"), [u, g] = useState(null);
|
|
7322
|
+
useEffect(() => {
|
|
7323
|
+
u || g(first(keys(p)));
|
|
7324
|
+
}, [p, u]);
|
|
7325
|
+
const m = get(p, u, []), h = useRef(null), { t: f } = useTranslation(), x = (v) => {
|
|
7320
7326
|
h.current && (clearTimeout(h.current), h.current = null), h.current = setTimeout(() => {
|
|
7321
|
-
h.current &&
|
|
7327
|
+
h.current && g(v);
|
|
7322
7328
|
}, 300);
|
|
7323
7329
|
};
|
|
7324
|
-
if (
|
|
7330
|
+
if (d)
|
|
7325
7331
|
return /* @__PURE__ */ jsxs("div", { className: "mt-4 grid h-full w-full grid-cols-12 gap-2", children: [
|
|
7326
7332
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7327
7333
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7328
7334
|
] });
|
|
7329
|
-
const
|
|
7335
|
+
const b = filter(m, (v, S) => S % 2 === 0), y = filter(m, (v, S) => S % 2 === 1);
|
|
7330
7336
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { className: "relative mt-2 flex h-full max-h-full overflow-hidden bg-background", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full pt-2", children: [
|
|
7331
7337
|
/* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
7332
|
-
/* @__PURE__ */ jsx(UILibrariesSelect, { library:
|
|
7338
|
+
/* @__PURE__ */ jsx(UILibrariesSelect, { library: i == null ? void 0 : i.id, setLibrary: a, uiLibraries: l }),
|
|
7333
7339
|
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
|
|
7334
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children:
|
|
7340
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: f("Groups") }),
|
|
7335
7341
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7336
|
-
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: map(
|
|
7342
|
+
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: map(p, (v, S) => /* @__PURE__ */ jsxs(
|
|
7337
7343
|
"div",
|
|
7338
7344
|
{
|
|
7339
|
-
onMouseEnter: () =>
|
|
7345
|
+
onMouseEnter: () => x(S),
|
|
7340
7346
|
onMouseLeave: () => clearTimeout(h.current),
|
|
7341
|
-
onClick: () =>
|
|
7347
|
+
onClick: () => g(S),
|
|
7342
7348
|
className: cn$1(
|
|
7343
7349
|
"flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",
|
|
7344
|
-
|
|
7350
|
+
S === u ? "bg-blue-500 text-white hover:bg-blue-600" : ""
|
|
7345
7351
|
),
|
|
7346
7352
|
children: [
|
|
7347
|
-
/* @__PURE__ */ jsx("span", { children: capitalize(
|
|
7353
|
+
/* @__PURE__ */ jsx("span", { children: capitalize(f(S.toLowerCase())) }),
|
|
7348
7354
|
/* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
|
|
7349
7355
|
]
|
|
7350
7356
|
},
|
|
7351
|
-
|
|
7357
|
+
S
|
|
7352
7358
|
)) })
|
|
7353
7359
|
] })
|
|
7354
7360
|
] }),
|
|
@@ -7359,25 +7365,25 @@ const BlockCard = ({
|
|
|
7359
7365
|
className: "z-10 -mt-2 flex h-full max-h-full w-full flex-col gap-2 border-l border-border transition-all ease-linear",
|
|
7360
7366
|
children: [
|
|
7361
7367
|
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
|
|
7362
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children:
|
|
7368
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: b.map((v, S) => /* @__PURE__ */ jsx(
|
|
7363
7369
|
BlockCard,
|
|
7364
7370
|
{
|
|
7365
7371
|
parentId: o,
|
|
7366
7372
|
position: n,
|
|
7367
|
-
block:
|
|
7368
|
-
library:
|
|
7373
|
+
block: v,
|
|
7374
|
+
library: i
|
|
7369
7375
|
},
|
|
7370
|
-
`block-${
|
|
7376
|
+
`block-${S}`
|
|
7371
7377
|
)) }),
|
|
7372
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children:
|
|
7378
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: y.map((v, S) => /* @__PURE__ */ jsx(
|
|
7373
7379
|
BlockCard,
|
|
7374
7380
|
{
|
|
7375
7381
|
parentId: o,
|
|
7376
7382
|
position: n,
|
|
7377
|
-
block:
|
|
7378
|
-
library:
|
|
7383
|
+
block: v,
|
|
7384
|
+
library: i
|
|
7379
7385
|
},
|
|
7380
|
-
`block-${
|
|
7386
|
+
`block-${S}`
|
|
7381
7387
|
)) })
|
|
7382
7388
|
] }),
|
|
7383
7389
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -7621,41 +7627,41 @@ const selectParent = (o, n) => {
|
|
|
7621
7627
|
var P;
|
|
7622
7628
|
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom), { hasPermission: p } = usePermissions();
|
|
7623
7629
|
let u = null;
|
|
7624
|
-
const g = o.children.length > 0, { highlightBlock: m, clearHighlight:
|
|
7630
|
+
const g = o.children.length > 0, { highlightBlock: m, clearHighlight: h } = useBlockHighlight(), { id: f, data: x, isSelected: b, willReceiveDrop: y, isDragging: v, isEditing: S, handleClick: B } = o, E = (N) => {
|
|
7625
7631
|
N.stopPropagation(), !i.includes(f) && o.toggle();
|
|
7626
|
-
},
|
|
7632
|
+
}, j = (N) => {
|
|
7627
7633
|
N.isInternal && (u = N.isOpen, N.isOpen && N.close());
|
|
7628
|
-
},
|
|
7634
|
+
}, w = (N) => {
|
|
7629
7635
|
N.isInternal && u !== null && (u ? N.open() : N.close(), u = null);
|
|
7630
|
-
}, [
|
|
7636
|
+
}, [A, L] = useAtom$1(currentAddSelection), C = () => {
|
|
7631
7637
|
var N;
|
|
7632
|
-
|
|
7633
|
-
},
|
|
7638
|
+
k(), o.parent.isSelected || L((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
|
|
7639
|
+
}, k = () => {
|
|
7634
7640
|
L(null);
|
|
7635
|
-
},
|
|
7636
|
-
|
|
7641
|
+
}, _ = (N) => {
|
|
7642
|
+
k(), N.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(), B(N);
|
|
7637
7643
|
};
|
|
7638
7644
|
useEffect(() => {
|
|
7639
7645
|
const N = setTimeout(() => {
|
|
7640
|
-
|
|
7646
|
+
y && !o.isOpen && !v && !i.includes(f) && o.toggle();
|
|
7641
7647
|
}, 500);
|
|
7642
7648
|
return () => clearTimeout(N);
|
|
7643
|
-
}, [
|
|
7649
|
+
}, [y, o, v]);
|
|
7644
7650
|
const T = useMemo(() => {
|
|
7645
|
-
const N = Object.keys(
|
|
7651
|
+
const N = Object.keys(x), M = [];
|
|
7646
7652
|
for (let D = 0; D < N.length; D++)
|
|
7647
7653
|
if (N[D].endsWith("_attrs")) {
|
|
7648
|
-
const O =
|
|
7654
|
+
const O = x[N[D]], $ = Object.keys(O).join("|");
|
|
7649
7655
|
$.match(/x-data/) && M.push("data"), $.match(/x-on/) && M.push("event"), $.match(/x-show|x-if/) && M.push("show");
|
|
7650
7656
|
}
|
|
7651
7657
|
return M;
|
|
7652
|
-
}, [
|
|
7658
|
+
}, [x]), I = (N, M) => {
|
|
7653
7659
|
const D = d.contentDocument || d.contentWindow.document, O = D.querySelector(`[data-block-id=${N}]`);
|
|
7654
7660
|
O && O.setAttribute("data-drop", M);
|
|
7655
7661
|
const $ = O.getBoundingClientRect(), H = d.getBoundingClientRect();
|
|
7656
7662
|
$.top >= H.top && $.left >= H.left && $.bottom <= H.bottom && $.right <= H.right || (D.documentElement.scrollTop = O.offsetTop - H.top);
|
|
7657
7663
|
}, R = (N) => {
|
|
7658
|
-
|
|
7664
|
+
k();
|
|
7659
7665
|
const M = get(o, "parent.id");
|
|
7660
7666
|
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 });
|
|
7661
7667
|
};
|
|
@@ -7679,13 +7685,13 @@ const selectParent = (o, n) => {
|
|
|
7679
7685
|
"div",
|
|
7680
7686
|
{
|
|
7681
7687
|
onMouseEnter: () => m(f),
|
|
7682
|
-
onMouseLeave: () =>
|
|
7683
|
-
onClick:
|
|
7688
|
+
onMouseLeave: () => h(),
|
|
7689
|
+
onClick: _,
|
|
7684
7690
|
style: n,
|
|
7685
7691
|
"data-node-id": f,
|
|
7686
7692
|
ref: i.includes(f) ? null : r,
|
|
7687
|
-
onDragStart: () =>
|
|
7688
|
-
onDragEnd: () =>
|
|
7693
|
+
onDragStart: () => j(o),
|
|
7694
|
+
onDragEnd: () => w(o),
|
|
7689
7695
|
onDragOver: (N) => {
|
|
7690
7696
|
N.preventDefault(), I(f, "yes");
|
|
7691
7697
|
},
|
|
@@ -7702,8 +7708,8 @@ const selectParent = (o, n) => {
|
|
|
7702
7708
|
onClick: (N) => {
|
|
7703
7709
|
N.stopPropagation(), R(o.childIndex);
|
|
7704
7710
|
},
|
|
7705
|
-
onMouseEnter:
|
|
7706
|
-
onMouseLeave:
|
|
7711
|
+
onMouseEnter: C,
|
|
7712
|
+
onMouseLeave: k,
|
|
7707
7713
|
className: "absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",
|
|
7708
7714
|
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" }) })
|
|
7709
7715
|
}
|
|
@@ -7714,9 +7720,9 @@ const selectParent = (o, n) => {
|
|
|
7714
7720
|
className: cn$1(
|
|
7715
7721
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
|
|
7716
7722
|
b ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
|
|
7717
|
-
|
|
7718
|
-
(o == null ? void 0 : o.id) ===
|
|
7719
|
-
|
|
7723
|
+
y && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
|
|
7724
|
+
(o == null ? void 0 : o.id) === A ? "bg-purple-100" : "",
|
|
7725
|
+
v && "opacity-20",
|
|
7720
7726
|
i.includes(f) ? "opacity-50" : ""
|
|
7721
7727
|
),
|
|
7722
7728
|
children: [
|
|
@@ -7725,12 +7731,12 @@ const selectParent = (o, n) => {
|
|
|
7725
7731
|
"div",
|
|
7726
7732
|
{
|
|
7727
7733
|
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
7728
|
-
children: g && /* @__PURE__ */ jsx("button", { onClick:
|
|
7734
|
+
children: g && /* @__PURE__ */ jsx("button", { onClick: E, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${b ? "text-slate-200" : "text-slate-400"}` }) })
|
|
7729
7735
|
}
|
|
7730
7736
|
),
|
|
7731
7737
|
/* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
|
|
7732
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
7733
|
-
|
|
7738
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: x == null ? void 0 : x._type }),
|
|
7739
|
+
S ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
|
|
7734
7740
|
"div",
|
|
7735
7741
|
{
|
|
7736
7742
|
className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
|
|
@@ -7738,7 +7744,7 @@ const selectParent = (o, n) => {
|
|
|
7738
7744
|
N.stopPropagation(), o.edit(), o.deselect();
|
|
7739
7745
|
},
|
|
7740
7746
|
children: [
|
|
7741
|
-
/* @__PURE__ */ jsx("span", { children: (
|
|
7747
|
+
/* @__PURE__ */ jsx("span", { children: (x == null ? void 0 : x._name) || (x == null ? void 0 : x._type.split("/").pop()) }),
|
|
7742
7748
|
T.includes("data") && /* @__PURE__ */ jsx(FileJson, { className: "h-3 w-3 text-orange-600" }),
|
|
7743
7749
|
T.includes("event") && /* @__PURE__ */ jsx(Zap, { className: "h-3 w-3 text-yellow-500" }),
|
|
7744
7750
|
T.includes("show") && /* @__PURE__ */ jsx(EyeOff, { className: "h-3 w-3 text-orange-600" })
|
|
@@ -7759,7 +7765,7 @@ const selectParent = (o, n) => {
|
|
|
7759
7765
|
),
|
|
7760
7766
|
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: N.tooltip })
|
|
7761
7767
|
] })),
|
|
7762
|
-
canAddChildBlock(
|
|
7768
|
+
canAddChildBlock(x == null ? void 0 : x._type) && !i.includes(f) && p(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7763
7769
|
/* @__PURE__ */ jsx(
|
|
7764
7770
|
TooltipTrigger,
|
|
7765
7771
|
{
|
|
@@ -8089,63 +8095,63 @@ const selectParent = (o, n) => {
|
|
|
8089
8095
|
}
|
|
8090
8096
|
);
|
|
8091
8097
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
8092
|
-
const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), m = (
|
|
8093
|
-
a(
|
|
8094
|
-
},
|
|
8095
|
-
const
|
|
8096
|
-
if (
|
|
8097
|
-
const
|
|
8098
|
-
|
|
8098
|
+
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 = (v) => {
|
|
8099
|
+
a(v);
|
|
8100
|
+
}, h = () => {
|
|
8101
|
+
const v = l.find((S) => Object.keys(S)[0] === r);
|
|
8102
|
+
if (v) {
|
|
8103
|
+
const S = Object.values(v)[0];
|
|
8104
|
+
S && typeof S == "object" && "fontFamily" in S && "borderRadius" in S && "colors" in S ? p(S) : console.error("Invalid preset structure:", S);
|
|
8099
8105
|
} else
|
|
8100
8106
|
console.error("Preset not found:", r);
|
|
8101
8107
|
}, f = useDebouncedCallback(
|
|
8102
|
-
(
|
|
8108
|
+
(v, S) => {
|
|
8103
8109
|
p(() => ({
|
|
8104
8110
|
...d,
|
|
8105
8111
|
fontFamily: {
|
|
8106
8112
|
...d.fontFamily,
|
|
8107
|
-
[
|
|
8113
|
+
[v.replace(/font-/g, "")]: S
|
|
8108
8114
|
}
|
|
8109
8115
|
}));
|
|
8110
8116
|
},
|
|
8111
8117
|
[d],
|
|
8112
8118
|
200
|
|
8113
|
-
),
|
|
8114
|
-
(
|
|
8119
|
+
), x = useDebouncedCallback(
|
|
8120
|
+
(v) => {
|
|
8115
8121
|
p(() => ({
|
|
8116
8122
|
...d,
|
|
8117
|
-
borderRadius: `${
|
|
8123
|
+
borderRadius: `${v}px`
|
|
8118
8124
|
}));
|
|
8119
8125
|
},
|
|
8120
8126
|
[d],
|
|
8121
8127
|
200
|
|
8122
8128
|
), b = useDebouncedCallback(
|
|
8123
|
-
(
|
|
8129
|
+
(v, S) => {
|
|
8124
8130
|
p(() => {
|
|
8125
|
-
const
|
|
8126
|
-
return n ? set(
|
|
8131
|
+
const B = get(d, `colors.${v}`);
|
|
8132
|
+
return n ? set(B, 1, S) : set(B, 0, S), {
|
|
8127
8133
|
...d,
|
|
8128
8134
|
colors: {
|
|
8129
8135
|
...d.colors,
|
|
8130
|
-
[
|
|
8136
|
+
[v]: B
|
|
8131
8137
|
}
|
|
8132
8138
|
};
|
|
8133
8139
|
});
|
|
8134
8140
|
},
|
|
8135
8141
|
[d],
|
|
8136
8142
|
200
|
|
8137
|
-
),
|
|
8138
|
-
const
|
|
8143
|
+
), y = (v) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(v.items).map(([S]) => {
|
|
8144
|
+
const B = get(d, `colors.${S}.${n ? 1 : 0}`);
|
|
8139
8145
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
8140
8146
|
/* @__PURE__ */ jsx(
|
|
8141
8147
|
ColorPickerInput,
|
|
8142
8148
|
{
|
|
8143
|
-
value:
|
|
8144
|
-
onChange: (
|
|
8149
|
+
value: B,
|
|
8150
|
+
onChange: (E) => b(S, E)
|
|
8145
8151
|
}
|
|
8146
8152
|
),
|
|
8147
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children:
|
|
8148
|
-
] },
|
|
8153
|
+
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: S.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((E) => E.charAt(0).toUpperCase() + E.slice(1)).join(" ") + (!S.toLowerCase().includes("foreground") && !S.toLowerCase().includes("border") && !S.toLowerCase().includes("input") && !S.toLowerCase().includes("ring") && !S.toLowerCase().includes("background") ? " Background" : "") })
|
|
8154
|
+
] }, S);
|
|
8149
8155
|
}) });
|
|
8150
8156
|
return c("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
8151
8157
|
/* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
@@ -8156,11 +8162,11 @@ const selectParent = (o, n) => {
|
|
|
8156
8162
|
"select",
|
|
8157
8163
|
{
|
|
8158
8164
|
value: r,
|
|
8159
|
-
onChange: (
|
|
8165
|
+
onChange: (v) => m(v.target.value),
|
|
8160
8166
|
className: "w-full space-y-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
8161
8167
|
children: [
|
|
8162
8168
|
/* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
|
|
8163
|
-
Array.isArray(l) && l.map((
|
|
8169
|
+
Array.isArray(l) && l.map((v) => /* @__PURE__ */ jsx("option", { value: Object.keys(v)[0], children: capitalize(Object.keys(v)[0]) }, Object.keys(v)[0]))
|
|
8164
8170
|
]
|
|
8165
8171
|
}
|
|
8166
8172
|
)
|
|
@@ -8171,31 +8177,31 @@ const selectParent = (o, n) => {
|
|
|
8171
8177
|
className: "w-full text-sm",
|
|
8172
8178
|
disabled: r === "",
|
|
8173
8179
|
variant: "default",
|
|
8174
|
-
onClick:
|
|
8180
|
+
onClick: h,
|
|
8175
8181
|
children: g("Apply")
|
|
8176
8182
|
}
|
|
8177
8183
|
) })
|
|
8178
8184
|
] }),
|
|
8179
8185
|
/* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
|
|
8180
|
-
(u == null ? void 0 : u.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(u.fontFamily).map(([
|
|
8186
|
+
(u == null ? void 0 : u.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(u.fontFamily).map(([v, S]) => /* @__PURE__ */ jsx(
|
|
8181
8187
|
FontSelector,
|
|
8182
8188
|
{
|
|
8183
|
-
label:
|
|
8184
|
-
value: d.fontFamily[
|
|
8185
|
-
onChange: (
|
|
8189
|
+
label: v,
|
|
8190
|
+
value: d.fontFamily[v.replace(/font-/g, "")] || S[Object.keys(S)[0]],
|
|
8191
|
+
onChange: (B) => f(v, B)
|
|
8186
8192
|
},
|
|
8187
|
-
|
|
8193
|
+
v
|
|
8188
8194
|
)) }),
|
|
8189
8195
|
(u == null ? void 0 : u.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
|
|
8190
8196
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Border Radius") }),
|
|
8191
8197
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
|
|
8192
|
-
/* @__PURE__ */ jsx(BorderRadiusInput, { value: d.borderRadius, onChange:
|
|
8198
|
+
/* @__PURE__ */ jsx(BorderRadiusInput, { value: d.borderRadius, onChange: x }),
|
|
8193
8199
|
/* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: d.borderRadius })
|
|
8194
8200
|
] })
|
|
8195
8201
|
] }),
|
|
8196
8202
|
(u == null ? void 0 : u.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
|
|
8197
8203
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Colors") }),
|
|
8198
|
-
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: u.colors.map((
|
|
8204
|
+
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: u.colors.map((v) => y(v)) }, n ? "dark" : "light")
|
|
8199
8205
|
] })
|
|
8200
8206
|
] }),
|
|
8201
8207
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -8665,14 +8671,14 @@ function QuickPrompts({ onClick: o }) {
|
|
|
8665
8671
|
) }) });
|
|
8666
8672
|
}
|
|
8667
8673
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
8668
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null),
|
|
8674
|
+
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null), h = useRef(null);
|
|
8669
8675
|
useEffect(() => {
|
|
8670
|
-
var
|
|
8671
|
-
(
|
|
8676
|
+
var x;
|
|
8677
|
+
(x = m.current) == null || x.focus();
|
|
8672
8678
|
}, []);
|
|
8673
|
-
const f = (
|
|
8674
|
-
const { usage: b } =
|
|
8675
|
-
!l && b && g(b),
|
|
8679
|
+
const f = (x) => {
|
|
8680
|
+
const { usage: b } = x || {};
|
|
8681
|
+
!l && b && g(b), h.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
8676
8682
|
};
|
|
8677
8683
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
8678
8684
|
/* @__PURE__ */ jsxs(
|
|
@@ -8692,12 +8698,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8692
8698
|
{
|
|
8693
8699
|
ref: m,
|
|
8694
8700
|
value: i,
|
|
8695
|
-
onChange: (
|
|
8701
|
+
onChange: (x) => c(x.target.value),
|
|
8696
8702
|
placeholder: n("Ask AI to edit content"),
|
|
8697
8703
|
className: "w-full",
|
|
8698
8704
|
rows: 3,
|
|
8699
|
-
onKeyDown: (
|
|
8700
|
-
|
|
8705
|
+
onKeyDown: (x) => {
|
|
8706
|
+
x.key === "Enter" && (x.preventDefault(), h.current && clearTimeout(h.current), g(void 0), r("content", o, i, f));
|
|
8701
8707
|
}
|
|
8702
8708
|
}
|
|
8703
8709
|
),
|
|
@@ -8707,7 +8713,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8707
8713
|
{
|
|
8708
8714
|
disabled: i.trim().length < 5 || a,
|
|
8709
8715
|
onClick: () => {
|
|
8710
|
-
|
|
8716
|
+
h.current && clearTimeout(h.current), g(void 0), r("content", o, i, f);
|
|
8711
8717
|
},
|
|
8712
8718
|
variant: "default",
|
|
8713
8719
|
className: "w-fit",
|
|
@@ -8739,8 +8745,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8739
8745
|
/* @__PURE__ */ jsx(
|
|
8740
8746
|
QuickPrompts,
|
|
8741
8747
|
{
|
|
8742
|
-
onClick: (
|
|
8743
|
-
|
|
8748
|
+
onClick: (x) => {
|
|
8749
|
+
h.current && clearTimeout(h.current), g(void 0), r("content", o, x, f);
|
|
8744
8750
|
}
|
|
8745
8751
|
}
|
|
8746
8752
|
)
|
|
@@ -8754,7 +8760,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8754
8760
|
useEffect(() => {
|
|
8755
8761
|
n && a(n);
|
|
8756
8762
|
}, [n]);
|
|
8757
|
-
const
|
|
8763
|
+
const h = async () => {
|
|
8758
8764
|
try {
|
|
8759
8765
|
d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
|
|
8760
8766
|
} catch (f) {
|
|
@@ -8784,7 +8790,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8784
8790
|
className: "mt-1 w-full",
|
|
8785
8791
|
rows: 10,
|
|
8786
8792
|
onKeyDown: (f) => {
|
|
8787
|
-
f.key === "Enter" && (f.preventDefault(),
|
|
8793
|
+
f.key === "Enter" && (f.preventDefault(), h());
|
|
8788
8794
|
}
|
|
8789
8795
|
}
|
|
8790
8796
|
),
|
|
@@ -8796,7 +8802,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8796
8802
|
Button,
|
|
8797
8803
|
{
|
|
8798
8804
|
disabled: r.trim().length < 5,
|
|
8799
|
-
onClick: () =>
|
|
8805
|
+
onClick: () => h(),
|
|
8800
8806
|
variant: "default",
|
|
8801
8807
|
className: "w-fit",
|
|
8802
8808
|
size: "sm",
|
|
@@ -8825,7 +8831,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8825
8831
|
AlertDialogAction,
|
|
8826
8832
|
{
|
|
8827
8833
|
onClick: () => {
|
|
8828
|
-
a(""),
|
|
8834
|
+
a(""), h();
|
|
8829
8835
|
},
|
|
8830
8836
|
children: o("Yes, Delete")
|
|
8831
8837
|
}
|
|
@@ -8883,7 +8889,8 @@ function getFromQueryParams(o) {
|
|
|
8883
8889
|
return (r = new URLSearchParams(window.location.search).get("flags")) == null ? void 0 : r.includes(o);
|
|
8884
8890
|
}
|
|
8885
8891
|
const FEATURE_TOGGLES = {
|
|
8886
|
-
dnd: getFromQueryParams("dnd")
|
|
8892
|
+
dnd: getFromQueryParams("dnd"),
|
|
8893
|
+
aiChat: getFromQueryParams("ai-chat")
|
|
8887
8894
|
}, setDebugLogs = (o) => {
|
|
8888
8895
|
}, getParentNodeIds = (o, n) => {
|
|
8889
8896
|
const r = [];
|
|
@@ -8905,6 +8912,138 @@ function usePubSub(o, n) {
|
|
|
8905
8912
|
return () => r();
|
|
8906
8913
|
}, [o, n]);
|
|
8907
8914
|
}
|
|
8915
|
+
function AIChatPanel() {
|
|
8916
|
+
const [o, n] = useState([]), [r, a] = useState(""), [l, i] = useState(!1), [c, d] = useState(null), p = useRef(null), u = useRef(null), g = useRef(null);
|
|
8917
|
+
useEffect(() => {
|
|
8918
|
+
var y;
|
|
8919
|
+
(y = u.current) == null || y.scrollIntoView({ behavior: "smooth" });
|
|
8920
|
+
}, [o]), useEffect(() => {
|
|
8921
|
+
g.current && (g.current.style.height = "auto", g.current.style.height = `${Math.min(g.current.scrollHeight, 120)}px`);
|
|
8922
|
+
}, [r]);
|
|
8923
|
+
const m = async () => {
|
|
8924
|
+
if (!r.trim() && !c) return;
|
|
8925
|
+
const y = {
|
|
8926
|
+
id: Date.now().toString(),
|
|
8927
|
+
role: "user",
|
|
8928
|
+
content: r,
|
|
8929
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
8930
|
+
};
|
|
8931
|
+
n((v) => [...v, y]), a(""), i(!0), setTimeout(() => {
|
|
8932
|
+
const v = {
|
|
8933
|
+
id: (Date.now() + 1).toString(),
|
|
8934
|
+
role: "assistant",
|
|
8935
|
+
content: "This is a sample response from the AI assistant. In a real implementation, this would be replaced with an actual response from the AI model.",
|
|
8936
|
+
timestamp: /* @__PURE__ */ new Date()
|
|
8937
|
+
};
|
|
8938
|
+
n((S) => [...S, v]), i(!1), d(null);
|
|
8939
|
+
}, 1500);
|
|
8940
|
+
}, h = (y) => {
|
|
8941
|
+
y.key === "Enter" && !y.shiftKey && (y.preventDefault(), m());
|
|
8942
|
+
}, f = (y) => {
|
|
8943
|
+
var S;
|
|
8944
|
+
const v = (S = y.target.files) == null ? void 0 : S[0];
|
|
8945
|
+
if (v) {
|
|
8946
|
+
const B = new FileReader();
|
|
8947
|
+
B.onload = (E) => {
|
|
8948
|
+
var j;
|
|
8949
|
+
d((j = E.target) == null ? void 0 : j.result);
|
|
8950
|
+
}, B.readAsDataURL(v);
|
|
8951
|
+
}
|
|
8952
|
+
}, x = () => {
|
|
8953
|
+
var y;
|
|
8954
|
+
(y = p.current) == null || y.click();
|
|
8955
|
+
}, b = () => {
|
|
8956
|
+
d(null), p.current && (p.current.value = "");
|
|
8957
|
+
};
|
|
8958
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
|
|
8959
|
+
/* @__PURE__ */ jsx(ScrollArea, { className: "flex-1 p-3", children: o.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "mt-10 flex h-full flex-col items-center justify-center p-4 text-center text-muted-foreground", children: [
|
|
8960
|
+
/* @__PURE__ */ jsx(Sparkles, { className: "mb-2 h-8 w-8 text-primary/50" }),
|
|
8961
|
+
/* @__PURE__ */ jsx("p", { className: "text-sm", children: "Ask me anything to get started" })
|
|
8962
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
|
|
8963
|
+
o.map((y) => /* @__PURE__ */ jsxs(
|
|
8964
|
+
"div",
|
|
8965
|
+
{
|
|
8966
|
+
className: cn(
|
|
8967
|
+
"flex max-w-full gap-2",
|
|
8968
|
+
y.role === "assistant" ? "items-start" : "items-start justify-end"
|
|
8969
|
+
),
|
|
8970
|
+
children: [
|
|
8971
|
+
y.role === "assistant" && /* @__PURE__ */ jsx(Avatar, { className: "h-6 w-6 bg-primary/10", children: /* @__PURE__ */ jsx(Sparkles, { className: "h-3 w-3 text-primary" }) }),
|
|
8972
|
+
/* @__PURE__ */ jsx(
|
|
8973
|
+
"div",
|
|
8974
|
+
{
|
|
8975
|
+
className: cn(
|
|
8976
|
+
"rounded-lg px-3 py-2 text-sm",
|
|
8977
|
+
y.role === "assistant" ? "bg-muted text-foreground" : "bg-primary text-primary-foreground"
|
|
8978
|
+
),
|
|
8979
|
+
children: y.content
|
|
8980
|
+
}
|
|
8981
|
+
),
|
|
8982
|
+
y.role === "user" && /* @__PURE__ */ jsx(Avatar, { className: "h-6 w-6 bg-primary", children: /* @__PURE__ */ jsx("span", { className: "text-xs text-primary-foreground", children: "You" }) })
|
|
8983
|
+
]
|
|
8984
|
+
},
|
|
8985
|
+
y.id
|
|
8986
|
+
)),
|
|
8987
|
+
l && /* @__PURE__ */ jsxs("div", { className: "flex items-start gap-2", children: [
|
|
8988
|
+
/* @__PURE__ */ jsx(Avatar, { className: "h-6 w-6 bg-primary/10", children: /* @__PURE__ */ jsx(Sparkles, { className: "h-3 w-3 text-primary" }) }),
|
|
8989
|
+
/* @__PURE__ */ jsx("div", { className: "rounded-lg bg-muted px-3 py-2", children: /* @__PURE__ */ jsx(Loader2, { className: "h-4 w-4 animate-spin text-muted-foreground" }) })
|
|
8990
|
+
] }),
|
|
8991
|
+
/* @__PURE__ */ jsx("div", { ref: u })
|
|
8992
|
+
] }) }),
|
|
8993
|
+
c && /* @__PURE__ */ jsx("div", { className: "px-3 pt-2", children: /* @__PURE__ */ jsxs("div", { className: "relative h-20 w-20 overflow-hidden rounded-md", children: [
|
|
8994
|
+
/* @__PURE__ */ jsx("img", { src: c || "/placeholder.svg", alt: "Attachment", className: "h-full w-full object-cover" }),
|
|
8995
|
+
/* @__PURE__ */ jsx(
|
|
8996
|
+
Button,
|
|
8997
|
+
{
|
|
8998
|
+
size: "icon",
|
|
8999
|
+
variant: "destructive",
|
|
9000
|
+
className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
|
|
9001
|
+
onClick: b,
|
|
9002
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
9003
|
+
}
|
|
9004
|
+
)
|
|
9005
|
+
] }) }),
|
|
9006
|
+
/* @__PURE__ */ jsx("div", { className: "mt-auto p-3", children: /* @__PURE__ */ jsxs("div", { className: "flex items-end gap-2", children: [
|
|
9007
|
+
/* @__PURE__ */ jsxs("div", { className: "relative flex-1", children: [
|
|
9008
|
+
/* @__PURE__ */ jsx(
|
|
9009
|
+
Textarea,
|
|
9010
|
+
{
|
|
9011
|
+
ref: g,
|
|
9012
|
+
value: r,
|
|
9013
|
+
onChange: (y) => a(y.target.value),
|
|
9014
|
+
onKeyDown: h,
|
|
9015
|
+
placeholder: "Ask something...",
|
|
9016
|
+
className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
|
|
9017
|
+
}
|
|
9018
|
+
),
|
|
9019
|
+
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: f, accept: "image/*", className: "hidden" }),
|
|
9020
|
+
/* @__PURE__ */ jsx(
|
|
9021
|
+
Button,
|
|
9022
|
+
{
|
|
9023
|
+
size: "icon",
|
|
9024
|
+
variant: "ghost",
|
|
9025
|
+
className: "absolute bottom-2 right-2 h-6 w-6",
|
|
9026
|
+
onClick: x,
|
|
9027
|
+
children: /* @__PURE__ */ jsx(Image$1, { className: "h-4 w-4 text-muted-foreground" })
|
|
9028
|
+
}
|
|
9029
|
+
)
|
|
9030
|
+
] }),
|
|
9031
|
+
/* @__PURE__ */ jsxs(
|
|
9032
|
+
Button,
|
|
9033
|
+
{
|
|
9034
|
+
size: "sm",
|
|
9035
|
+
className: "h-10 px-3",
|
|
9036
|
+
onClick: m,
|
|
9037
|
+
disabled: l || !r.trim() && !c,
|
|
9038
|
+
children: [
|
|
9039
|
+
/* @__PURE__ */ jsx(Send, { className: "mr-1 h-4 w-4" }),
|
|
9040
|
+
"Send"
|
|
9041
|
+
]
|
|
9042
|
+
}
|
|
9043
|
+
)
|
|
9044
|
+
] }) })
|
|
9045
|
+
] });
|
|
9046
|
+
}
|
|
8908
9047
|
const AiAssistant = () => {
|
|
8909
9048
|
const o = useAiAssistant(), [n] = useRightPanel(), r = useBuilderProp("askAiCallBack", null), { t: a } = useTranslation(), { hasPermission: l } = usePermissions();
|
|
8910
9049
|
return !r || !l(PERMISSIONS.EDIT_BLOCK) ? null : /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
@@ -8952,7 +9091,7 @@ const AiAssistant = () => {
|
|
|
8952
9091
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: a("Toggle Data Binding") }) })
|
|
8953
9092
|
] }) });
|
|
8954
9093
|
}, CanvasTopBar = () => {
|
|
8955
|
-
const o = useBuilderProp("darkMode", !0), [
|
|
9094
|
+
const o = useBuilderProp("darkMode", !0), n = useFeature("aiChat"), [r] = useCanvasZoom();
|
|
8956
9095
|
return /* @__PURE__ */ jsxs("div", { className: "flex h-10 items-center justify-between border-b border-border bg-background/70 px-2", children: [
|
|
8957
9096
|
/* @__PURE__ */ jsxs("div", { className: "flex h-full space-x-2", children: [
|
|
8958
9097
|
/* @__PURE__ */ jsx(Breakpoints$1, { canvas: !0, openDelay: 400 }),
|
|
@@ -8965,7 +9104,7 @@ const AiAssistant = () => {
|
|
|
8965
9104
|
/* @__PURE__ */ jsx(ZoomInIcon, { className: "h-3.5 w-3.5 flex-shrink-0" }),
|
|
8966
9105
|
" ",
|
|
8967
9106
|
/* @__PURE__ */ jsxs("div", { className: "text-xs leading-3", children: [
|
|
8968
|
-
round(
|
|
9107
|
+
round(r, 0),
|
|
8969
9108
|
"%"
|
|
8970
9109
|
] })
|
|
8971
9110
|
] }),
|
|
@@ -8975,60 +9114,60 @@ const AiAssistant = () => {
|
|
|
8975
9114
|
] }),
|
|
8976
9115
|
/* @__PURE__ */ jsxs("div", { className: "flex h-full items-center space-x-2", children: [
|
|
8977
9116
|
/* @__PURE__ */ jsx(ClearCanvas, {}),
|
|
8978
|
-
/* @__PURE__ */ jsx(AiAssistant, {})
|
|
9117
|
+
n ? null : /* @__PURE__ */ jsx(AiAssistant, {})
|
|
8979
9118
|
] })
|
|
8980
9119
|
] });
|
|
8981
9120
|
}, AttrsEditor = React__default.memo(function o({
|
|
8982
9121
|
preloadedAttributes: n = [],
|
|
8983
9122
|
onAttributesChange: r
|
|
8984
9123
|
}) {
|
|
8985
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m,
|
|
9124
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""), f = useRef(null), x = useRef(null), b = usePageExternalData();
|
|
8986
9125
|
useEffect(() => {
|
|
8987
9126
|
l(n);
|
|
8988
9127
|
}, [n]);
|
|
8989
|
-
const
|
|
9128
|
+
const y = () => {
|
|
8990
9129
|
if (i.startsWith("@")) {
|
|
8991
|
-
|
|
9130
|
+
h("Attribute keys cannot start with '@'");
|
|
8992
9131
|
return;
|
|
8993
9132
|
}
|
|
8994
9133
|
if (i) {
|
|
8995
|
-
const
|
|
8996
|
-
r(
|
|
9134
|
+
const w = [...a, { key: i, value: d }];
|
|
9135
|
+
r(w), l(a), c(""), p(""), h("");
|
|
8997
9136
|
}
|
|
8998
|
-
},
|
|
8999
|
-
const
|
|
9000
|
-
r(
|
|
9001
|
-
},
|
|
9002
|
-
g(
|
|
9003
|
-
},
|
|
9137
|
+
}, v = (w) => {
|
|
9138
|
+
const A = a.filter((L, C) => C !== w);
|
|
9139
|
+
r(A), l(A);
|
|
9140
|
+
}, S = (w) => {
|
|
9141
|
+
g(w), c(a[w].key), p(a[w].value);
|
|
9142
|
+
}, B = () => {
|
|
9004
9143
|
if (i.startsWith("@")) {
|
|
9005
|
-
|
|
9144
|
+
h("Attribute keys cannot start with '@'");
|
|
9006
9145
|
return;
|
|
9007
9146
|
}
|
|
9008
9147
|
if (u !== null && i) {
|
|
9009
|
-
const
|
|
9010
|
-
|
|
9148
|
+
const w = [...a];
|
|
9149
|
+
w[u] = { key: i, value: d }, r(w), l(w), g(null), c(""), p(""), h("");
|
|
9011
9150
|
}
|
|
9012
|
-
},
|
|
9013
|
-
|
|
9014
|
-
},
|
|
9015
|
-
const
|
|
9151
|
+
}, E = (w) => {
|
|
9152
|
+
w.key === "Enter" && !w.shiftKey && (w.preventDefault(), u !== null ? B() : y());
|
|
9153
|
+
}, j = useCallback((w) => {
|
|
9154
|
+
const A = (k) => /[.,!?;:]/.test(k), L = (k, _, T) => {
|
|
9016
9155
|
let I = "", R = "";
|
|
9017
|
-
const P =
|
|
9018
|
-
return
|
|
9156
|
+
const P = _ > 0 ? k[_ - 1] : "", N = _ < k.length ? k[_] : "";
|
|
9157
|
+
return _ > 0 && (P === "." || !A(P) && P !== " ") && (I = " "), _ < k.length && !A(N) && N !== " " && (R = " "), {
|
|
9019
9158
|
text: I + T + R,
|
|
9020
9159
|
prefixLength: I.length,
|
|
9021
9160
|
suffixLength: R.length
|
|
9022
9161
|
};
|
|
9023
|
-
},
|
|
9024
|
-
if (
|
|
9025
|
-
const
|
|
9026
|
-
if (T >
|
|
9027
|
-
const M = `{{${
|
|
9162
|
+
}, C = x.current;
|
|
9163
|
+
if (C) {
|
|
9164
|
+
const k = C.selectionStart || 0, _ = C.value || "", T = C.selectionEnd || k;
|
|
9165
|
+
if (T > k) {
|
|
9166
|
+
const M = `{{${w}}}`, { text: D } = L(_, k, M), O = _.slice(0, k) + D + _.slice(T);
|
|
9028
9167
|
p(O);
|
|
9029
9168
|
return;
|
|
9030
9169
|
}
|
|
9031
|
-
const R = `{{${
|
|
9170
|
+
const R = `{{${w}}}`, { text: P } = L(_, k, R), N = _.slice(0, k) + P + _.slice(k);
|
|
9032
9171
|
p(N);
|
|
9033
9172
|
}
|
|
9034
9173
|
}, []);
|
|
@@ -9036,8 +9175,8 @@ const AiAssistant = () => {
|
|
|
9036
9175
|
/* @__PURE__ */ jsxs(
|
|
9037
9176
|
"form",
|
|
9038
9177
|
{
|
|
9039
|
-
onSubmit: (
|
|
9040
|
-
|
|
9178
|
+
onSubmit: (w) => {
|
|
9179
|
+
w.preventDefault(), u !== null ? B() : y();
|
|
9041
9180
|
},
|
|
9042
9181
|
className: "space-y-3",
|
|
9043
9182
|
children: [
|
|
@@ -9053,7 +9192,7 @@ const AiAssistant = () => {
|
|
|
9053
9192
|
id: "attrKey",
|
|
9054
9193
|
ref: f,
|
|
9055
9194
|
value: i,
|
|
9056
|
-
onChange: (
|
|
9195
|
+
onChange: (w) => c(w.target.value),
|
|
9057
9196
|
placeholder: "Enter Key",
|
|
9058
9197
|
className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9059
9198
|
}
|
|
@@ -9062,7 +9201,7 @@ const AiAssistant = () => {
|
|
|
9062
9201
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
9063
9202
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
9064
9203
|
/* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
|
|
9065
|
-
!isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect:
|
|
9204
|
+
!isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: j })
|
|
9066
9205
|
] }),
|
|
9067
9206
|
/* @__PURE__ */ jsx(
|
|
9068
9207
|
Textarea,
|
|
@@ -9072,10 +9211,10 @@ const AiAssistant = () => {
|
|
|
9072
9211
|
spellCheck: "false",
|
|
9073
9212
|
id: "attrValue",
|
|
9074
9213
|
rows: 2,
|
|
9075
|
-
ref:
|
|
9214
|
+
ref: x,
|
|
9076
9215
|
value: d,
|
|
9077
|
-
onChange: (
|
|
9078
|
-
onKeyDown:
|
|
9216
|
+
onChange: (w) => p(w.target.value),
|
|
9217
|
+
onKeyDown: E,
|
|
9079
9218
|
placeholder: "Enter Value",
|
|
9080
9219
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9081
9220
|
}
|
|
@@ -9087,16 +9226,16 @@ const AiAssistant = () => {
|
|
|
9087
9226
|
]
|
|
9088
9227
|
}
|
|
9089
9228
|
),
|
|
9090
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((
|
|
9229
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((w, A) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
|
|
9091
9230
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
9092
|
-
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children:
|
|
9093
|
-
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children:
|
|
9231
|
+
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: w.key }),
|
|
9232
|
+
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: w.value.toString() })
|
|
9094
9233
|
] }),
|
|
9095
9234
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
9096
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
9097
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A
|
|
9235
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => S(A), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
|
|
9236
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => v(A), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
|
|
9098
9237
|
] })
|
|
9099
|
-
] },
|
|
9238
|
+
] }, A)) })
|
|
9100
9239
|
] });
|
|
9101
9240
|
}), BlockAttributesEditor = React.memo(() => {
|
|
9102
9241
|
const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
|
|
@@ -9290,27 +9429,38 @@ const ChooseLayout = ({ open: o, close: n }) => {
|
|
|
9290
9429
|
)
|
|
9291
9430
|
] }) })
|
|
9292
9431
|
] }) });
|
|
9293
|
-
}, TopBar = lazy(() => import("./Topbar-
|
|
9432
|
+
}, TopBar = lazy(() => import("./Topbar-CX5hnmQJ.js")), DEFAULT_PANEL_WIDTH = 280;
|
|
9294
9433
|
function useSidebarMenuItems() {
|
|
9295
|
-
|
|
9296
|
-
|
|
9434
|
+
const o = useBuilderProp("askAiCallBack", null), n = useFeature("aiChat");
|
|
9435
|
+
return useMemo(() => {
|
|
9436
|
+
const r = [];
|
|
9437
|
+
return r.push({
|
|
9438
|
+
id: "outline",
|
|
9297
9439
|
icon: /* @__PURE__ */ jsx(Layers, { size: 20 }),
|
|
9298
9440
|
label: "Outline",
|
|
9299
9441
|
isInternal: !0,
|
|
9442
|
+
width: DEFAULT_PANEL_WIDTH,
|
|
9300
9443
|
component: () => /* @__PURE__ */ jsx("div", { className: "-mt-8", children: /* @__PURE__ */ jsx(ListTree, {}) })
|
|
9301
|
-
}
|
|
9302
|
-
|
|
9444
|
+
}), o && n && r.unshift({
|
|
9445
|
+
id: "ai",
|
|
9446
|
+
icon: /* @__PURE__ */ jsx(SparklesIcon, { size: 20 }),
|
|
9447
|
+
label: "AI Assistant",
|
|
9448
|
+
isInternal: !0,
|
|
9449
|
+
width: 450,
|
|
9450
|
+
component: () => /* @__PURE__ */ jsx("div", { className: "-mt-8 h-full max-h-full", children: /* @__PURE__ */ jsx(AIChatPanel, {}) })
|
|
9451
|
+
}), compact(r);
|
|
9452
|
+
}, [o, n]);
|
|
9303
9453
|
}
|
|
9304
9454
|
const RootLayout = () => {
|
|
9305
|
-
const [o, n] =
|
|
9455
|
+
const [o, n] = useAtom$1(sidebarActivePanelAtom), [r, a] = useState(!1), [l, i] = useRightPanel();
|
|
9306
9456
|
usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
|
|
9307
|
-
n(
|
|
9457
|
+
n("outline");
|
|
9308
9458
|
});
|
|
9309
|
-
const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (
|
|
9310
|
-
|
|
9311
|
-
}, u = (
|
|
9312
|
-
n(o ===
|
|
9313
|
-
}, g = useSidebarMenuItems(), { t: m } = useTranslation(),
|
|
9459
|
+
const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (y) => {
|
|
9460
|
+
y.preventDefault();
|
|
9461
|
+
}, u = (y) => {
|
|
9462
|
+
n(o === y ? null : y);
|
|
9463
|
+
}, g = useSidebarMenuItems(), { t: m } = useTranslation(), h = useMemo(() => [...g, ...c], [g, c]), f = useBuilderProp("htmlDir", "ltr"), x = find(h, { id: o }), b = get(x, "width", DEFAULT_PANEL_WIDTH);
|
|
9314
9464
|
return /* @__PURE__ */ jsx("div", { dir: f, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
|
|
9315
9465
|
/* @__PURE__ */ jsxs(
|
|
9316
9466
|
"div",
|
|
@@ -9320,42 +9470,42 @@ const RootLayout = () => {
|
|
|
9320
9470
|
children: [
|
|
9321
9471
|
/* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
|
|
9322
9472
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
9323
|
-
/* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
9324
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children:
|
|
9473
|
+
/* @__PURE__ */ jsxs("div", { className: "flex h-full w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
9474
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: h.map((y, v) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9325
9475
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
9326
9476
|
Button,
|
|
9327
9477
|
{
|
|
9328
|
-
variant: o ===
|
|
9478
|
+
variant: o === y.id ? "default" : "ghost",
|
|
9329
9479
|
className: "mb-2 rounded-lg p-2 transition-colors",
|
|
9330
|
-
onClick: () => u(
|
|
9331
|
-
children: get(
|
|
9480
|
+
onClick: () => u(y.id),
|
|
9481
|
+
children: get(y, "icon", null)
|
|
9332
9482
|
},
|
|
9333
|
-
|
|
9483
|
+
v
|
|
9334
9484
|
) }),
|
|
9335
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(
|
|
9336
|
-
] }, "button" +
|
|
9485
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(y.label) }) })
|
|
9486
|
+
] }, "button" + v)) }),
|
|
9337
9487
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
9338
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((
|
|
9488
|
+
/* @__PURE__ */ jsx("div", { className: "flex h-full flex-col", children: d == null ? void 0 : d.map((y, v) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(y, {}) }, `sidebar-component-${v}`)) })
|
|
9339
9489
|
] }),
|
|
9340
9490
|
/* @__PURE__ */ jsx(
|
|
9341
9491
|
motion.div,
|
|
9342
9492
|
{
|
|
9343
9493
|
className: "h-full max-h-full border-r border-border",
|
|
9344
|
-
initial: { width:
|
|
9345
|
-
animate: { width: o !== null ?
|
|
9494
|
+
initial: { width: b },
|
|
9495
|
+
animate: { width: o !== null ? b : 0 },
|
|
9346
9496
|
transition: { duration: 0.3, ease: "easeInOut" },
|
|
9347
9497
|
children: o !== null && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
|
|
9348
9498
|
/* @__PURE__ */ jsxs(
|
|
9349
9499
|
"div",
|
|
9350
9500
|
{
|
|
9351
|
-
className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(x,
|
|
9501
|
+
className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(x, "isInternal", !1) ? "" : "w-64"}`,
|
|
9352
9502
|
children: [
|
|
9353
|
-
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(x,
|
|
9354
|
-
/* @__PURE__ */ jsx("span", { children: m(x
|
|
9503
|
+
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(x, "icon", null) }),
|
|
9504
|
+
/* @__PURE__ */ jsx("span", { children: m(x == null ? void 0 : x.label) })
|
|
9355
9505
|
]
|
|
9356
9506
|
}
|
|
9357
9507
|
),
|
|
9358
|
-
/* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(x,
|
|
9508
|
+
/* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(x, "component", null), {}) }) })
|
|
9359
9509
|
] })
|
|
9360
9510
|
}
|
|
9361
9511
|
),
|
|
@@ -9367,8 +9517,8 @@ const RootLayout = () => {
|
|
|
9367
9517
|
motion.div,
|
|
9368
9518
|
{
|
|
9369
9519
|
className: "h-full max-h-full border-l border-border",
|
|
9370
|
-
initial: { width:
|
|
9371
|
-
animate: { width:
|
|
9520
|
+
initial: { width: o === "ai" ? 0 : DEFAULT_PANEL_WIDTH },
|
|
9521
|
+
animate: { width: o === "ai" ? 0 : DEFAULT_PANEL_WIDTH },
|
|
9372
9522
|
transition: { duration: 0.3, ease: "easeInOut" },
|
|
9373
9523
|
children: /* @__PURE__ */ jsx("div", { className: "no-scrollbar overflow h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col overflow-hidden p-3", children: [
|
|
9374
9524
|
/* @__PURE__ */ jsx("h2", { className: "-mt-1 flex items-center space-x-1 text-base font-bold", children: /* @__PURE__ */ jsx("div", { className: "flex grow items-center gap-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between gap-2", children: l === "ai" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
@@ -9391,7 +9541,7 @@ const RootLayout = () => {
|
|
|
9391
9541
|
}
|
|
9392
9542
|
)
|
|
9393
9543
|
] }) : null }) }) }),
|
|
9394
|
-
/* @__PURE__ */ jsx("div", { className: "flex max-h-full w-full", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: l === "ai" ? /* @__PURE__ */ jsx(AskAI, {}) : l === "theme" ? /* @__PURE__ */ jsx(ThemeConfigPanel, {}) : /* @__PURE__ */ jsx(SettingsPanel, {}) }) })
|
|
9544
|
+
/* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: l === "ai" ? /* @__PURE__ */ jsx(AskAI, {}) : l === "theme" ? /* @__PURE__ */ jsx(ThemeConfigPanel, {}) : /* @__PURE__ */ jsx(SettingsPanel, {}) }) })
|
|
9395
9545
|
] }) })
|
|
9396
9546
|
}
|
|
9397
9547
|
)
|