@chaibuilder/sdk 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +5 -5
- package/dist/core.d.ts +8 -0
- package/dist/core.js +902 -784
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +1 -3
- package/dist/render.js +107 -112
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
var G = Object.defineProperty;
|
|
2
2
|
var K = (o, n, r) => n in o ? G(o, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[n] = r;
|
|
3
3
|
var V = (o, n, r) => K(o, typeof n != "symbol" ? n + "" : n, r);
|
|
4
|
-
import { jsx,
|
|
4
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import React__default, { createContext, useReducer, useEffect, useDebugValue, useCallback, useContext, useMemo, Component, Children, useState, useRef, Suspense, createElement, memo, lazy } from "react";
|
|
7
|
-
import { S as Skeleton, B as Button, a6 as Label, H as Dialog, I as DialogTrigger, J as DialogContent, a7 as Popover, ak as Tooltip, al as TooltipTrigger, a8 as PopoverTrigger, am as TooltipContent, a9 as PopoverContent, v as Command, x as CommandInput, y as CommandList, z as CommandEmpty, D as CommandGroup, E as CommandItem, K as DialogHeader, M as DialogTitle, n as Badge,
|
|
7
|
+
import { O as DropdownMenu, P as DropdownMenuTrigger, Q as DropdownMenuContent, R as DropdownMenuItem, S as Skeleton, B as Button, a6 as Label, H as Dialog, I as DialogTrigger, J as DialogContent, a7 as Popover, ak as Tooltip, al as TooltipTrigger, a8 as PopoverTrigger, am as TooltipContent, a9 as PopoverContent, v as Command, x as CommandInput, y as CommandList, z as CommandEmpty, D as CommandGroup, E as CommandItem, K as DialogHeader, M as DialogTitle, n as Badge, V as DropdownMenuLabel, W as DropdownMenuSeparator, T as DropdownMenuCheckboxItem, a2 as HoverCard, a3 as HoverCardTrigger, a4 as HoverCardContent, aj as Textarea, a5 as Input$1, ao as TooltipPortal, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, aa as ScrollArea, Y as DropdownMenuGroup, X as DropdownMenuShortcut, A as Accordion, C as Card, q as CardHeader, t as CardDescription, u as CardContent, r as CardFooter, af as Tabs, ag as TabsList, ah as TabsTrigger, ai as TabsContent, e as AlertDialog, f as AlertDialogTrigger, g as AlertDialogContent, h as AlertDialogHeader, j as AlertDialogTitle, k as AlertDialogDescription, i as AlertDialogFooter, m as AlertDialogCancel, l as AlertDialogAction, ae as Switch, ac as Separator, an as TooltipProvider, ad as Toaster } from "./tooltip-PKiP886L.js";
|
|
8
8
|
import { atom as atom$1, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
|
|
9
|
-
import { find, filter, flatten, map, omit, isString, has, isObject, memoize, get, compact, isEmpty, noop, includes, without, each, first, keys, range, values, flattenDeep, set, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, throttle, isFunction as isFunction$1, reverse, startCase, debounce, capitalize, split,
|
|
9
|
+
import { find, filter, flatten, map, omit, isString, has, isObject, memoize, get, compact, isEmpty, noop, includes, without, each, first, keys, range, values, flattenDeep, set, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, findIndex, throttle, isFunction as isFunction$1, reverse, startCase, debounce, capitalize, split, take, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, uniq, flatMapDeep, some, reject, sortBy, round } from "lodash-es";
|
|
10
10
|
import { Provider as Provider$1 } from "react-wrap-balancer";
|
|
11
11
|
import { useTranslation, initReactI18next } from "react-i18next";
|
|
12
|
-
import { useTranslation as
|
|
12
|
+
import { useTranslation as Ve } from "react-i18next";
|
|
13
13
|
import { g as generateUUID, a as getBreakpointValue, c as cn$1 } from "./Functions-BGzDsf1z.js";
|
|
14
14
|
import { flip } from "@floating-ui/dom";
|
|
15
15
|
import { useFloating, shift } from "@floating-ui/react-dom";
|
|
16
|
-
import { ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, BoxModelIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, Cross2Icon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, FontItalicIcon, UnderlineIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross1Icon, InfoCircledIcon, BoxIcon, MinusIcon, TriangleDownIcon, RowSpacingIcon, CrossCircledIcon, CaretDownIcon, CaretRightIcon, CardStackIcon, CardStackPlusIcon, ScissorsIcon, CheckIcon, SunIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
|
|
16
|
+
import { PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, BoxModelIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, Cross2Icon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, FontItalicIcon, UnderlineIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross1Icon, InfoCircledIcon, BoxIcon, MinusIcon, TriangleDownIcon, RowSpacingIcon, CrossCircledIcon, CaretDownIcon, CaretRightIcon, CardStackIcon, CardStackPlusIcon, ScissorsIcon, CheckIcon, SunIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
|
|
17
17
|
import { useThrottledCallback, useDebouncedCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
|
|
18
18
|
import { useFeature, FlagsProvider } from "flagged";
|
|
19
19
|
import { getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredChaiBlocks, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
|
|
20
|
-
import { registerChaiBlock as
|
|
20
|
+
import { registerChaiBlock as Fe } 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
22
|
import TreeModel from "tree-model";
|
|
23
23
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
@@ -36,6 +36,7 @@ import { ErrorBoundary } from "react-error-boundary";
|
|
|
36
36
|
import { Resizable } from "re-resizable";
|
|
37
37
|
import RjForm from "@rjsf/core";
|
|
38
38
|
import validator from "@rjsf/validator-ajv8";
|
|
39
|
+
import { isEmpty as isEmpty$1, get as get$1 } from "lodash";
|
|
39
40
|
import Link from "@tiptap/extension-link";
|
|
40
41
|
import TextAlign from "@tiptap/extension-text-align";
|
|
41
42
|
import Underline from "@tiptap/extension-underline";
|
|
@@ -45,7 +46,7 @@ import Fuse from "fuse.js";
|
|
|
45
46
|
import { parse, stringify } from "himalaya";
|
|
46
47
|
import { Tree } from "react-arborist";
|
|
47
48
|
import i18n from "i18next";
|
|
48
|
-
import { default as
|
|
49
|
+
import { default as We } from "i18next";
|
|
49
50
|
import { motion } from "framer-motion";
|
|
50
51
|
const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.write, isAtomStateInitialized = (o) => "v" in o || "e" in o, returnAtomValue = (o) => {
|
|
51
52
|
if ("e" in o)
|
|
@@ -93,92 +94,92 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
93
94
|
for (const i of n.p)
|
|
94
95
|
l.add(i);
|
|
95
96
|
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
|
+
}, 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
98
|
var x;
|
|
98
|
-
return (x =
|
|
99
|
-
}, g = (
|
|
99
|
+
return (x = h.unstable_onInit) == null ? void 0 : x.call(h, f);
|
|
100
|
+
}, g = (h, f) => {
|
|
100
101
|
var x;
|
|
101
|
-
return (x =
|
|
102
|
-
}, ...
|
|
103
|
-
const
|
|
102
|
+
return (x = h.onMount) == null ? void 0 : x.call(h, f);
|
|
103
|
+
}, ...m) => {
|
|
104
|
+
const h = m[0] || ((C) => {
|
|
104
105
|
let L = o.get(C);
|
|
105
106
|
return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(C, L), u == null || u(C, S)), L;
|
|
106
|
-
}),
|
|
107
|
+
}), f = m[1] || (() => {
|
|
107
108
|
let C, L;
|
|
108
109
|
const v = (k) => {
|
|
109
110
|
try {
|
|
110
111
|
k();
|
|
111
|
-
} catch (
|
|
112
|
-
C || (C = !0, L =
|
|
112
|
+
} catch (A) {
|
|
113
|
+
C || (C = !0, L = A);
|
|
113
114
|
}
|
|
114
115
|
};
|
|
115
116
|
do {
|
|
116
117
|
c.f && v(c.f);
|
|
117
|
-
const k = /* @__PURE__ */ new Set(),
|
|
118
|
+
const k = /* @__PURE__ */ new Set(), A = k.add.bind(k);
|
|
118
119
|
a.forEach((T) => {
|
|
119
120
|
var I;
|
|
120
|
-
return (I = n.get(T)) == null ? void 0 : I.l.forEach(
|
|
121
|
-
}), a.clear(), i.forEach(
|
|
121
|
+
return (I = n.get(T)) == null ? void 0 : I.l.forEach(A);
|
|
122
|
+
}), a.clear(), i.forEach(A), i.clear(), l.forEach(A), l.clear(), k.forEach(v), a.size && x();
|
|
122
123
|
} while (a.size || i.size || l.size);
|
|
123
124
|
if (C)
|
|
124
125
|
throw L;
|
|
125
|
-
}), x =
|
|
126
|
+
}), x = m[2] || (() => {
|
|
126
127
|
const C = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
|
|
127
128
|
for (; k.length; ) {
|
|
128
|
-
const
|
|
129
|
-
if (v.has(
|
|
129
|
+
const A = k[k.length - 1], T = h(A);
|
|
130
|
+
if (v.has(A)) {
|
|
130
131
|
k.pop();
|
|
131
132
|
continue;
|
|
132
133
|
}
|
|
133
|
-
if (L.has(
|
|
134
|
-
r.get(
|
|
134
|
+
if (L.has(A)) {
|
|
135
|
+
r.get(A) === T.n && C.push([A, T]), v.add(A), k.pop();
|
|
135
136
|
continue;
|
|
136
137
|
}
|
|
137
|
-
L.add(
|
|
138
|
-
for (const I of getMountedOrPendingDependents(
|
|
138
|
+
L.add(A);
|
|
139
|
+
for (const I of getMountedOrPendingDependents(A, T, n))
|
|
139
140
|
L.has(I) || k.push(I);
|
|
140
141
|
}
|
|
141
|
-
for (let
|
|
142
|
-
const [T, I] = C[
|
|
142
|
+
for (let A = C.length - 1; A >= 0; --A) {
|
|
143
|
+
const [T, I] = C[A];
|
|
143
144
|
let P = !1;
|
|
144
145
|
for (const N of I.d.keys())
|
|
145
146
|
if (N !== T && a.has(N)) {
|
|
146
147
|
P = !0;
|
|
147
148
|
break;
|
|
148
149
|
}
|
|
149
|
-
P && (
|
|
150
|
+
P && (b(T), E(T)), r.delete(T);
|
|
150
151
|
}
|
|
151
|
-
}),
|
|
152
|
+
}), b = m[3] || ((C) => {
|
|
152
153
|
var L, v;
|
|
153
|
-
const k =
|
|
154
|
+
const k = h(C);
|
|
154
155
|
if (isAtomStateInitialized(k) && (n.has(C) && r.get(C) !== k.n || Array.from(k.d).every(
|
|
155
156
|
([R, O]) => (
|
|
156
157
|
// Recursively, read the atom state of the dependency, and
|
|
157
158
|
// check if the atom epoch number is unchanged
|
|
158
|
-
|
|
159
|
+
b(R).n === O
|
|
159
160
|
)
|
|
160
161
|
)))
|
|
161
162
|
return k;
|
|
162
163
|
k.d.clear();
|
|
163
|
-
let
|
|
164
|
+
let A = !0;
|
|
164
165
|
const T = () => {
|
|
165
|
-
n.has(C) && (E(C), x(),
|
|
166
|
+
n.has(C) && (E(C), x(), f());
|
|
166
167
|
}, I = (R) => {
|
|
167
168
|
var O;
|
|
168
169
|
if (isSelfAtom(C, R)) {
|
|
169
|
-
const H =
|
|
170
|
+
const H = h(R);
|
|
170
171
|
if (!isAtomStateInitialized(H))
|
|
171
172
|
if (hasInitialValue(R))
|
|
172
|
-
setAtomStateValueOrPromise(R, R.init,
|
|
173
|
+
setAtomStateValueOrPromise(R, R.init, h);
|
|
173
174
|
else
|
|
174
175
|
throw new Error("no atom init");
|
|
175
176
|
return returnAtomValue(H);
|
|
176
177
|
}
|
|
177
|
-
const M =
|
|
178
|
+
const M = b(R);
|
|
178
179
|
try {
|
|
179
180
|
return returnAtomValue(M);
|
|
180
181
|
} finally {
|
|
181
|
-
k.d.set(R, M.n), isPendingPromise(k.v) && addPendingPromiseToDependency(C, k.v, M), (O = n.get(R)) == null || O.t.add(C),
|
|
182
|
+
k.d.set(R, M.n), isPendingPromise(k.v) && addPendingPromiseToDependency(C, k.v, M), (O = n.get(R)) == null || O.t.add(C), A || T();
|
|
182
183
|
}
|
|
183
184
|
};
|
|
184
185
|
let P, N;
|
|
@@ -188,94 +189,94 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
188
189
|
},
|
|
189
190
|
get setSelf() {
|
|
190
191
|
return !N && isActuallyWritableAtom(C) && (N = (...R) => {
|
|
191
|
-
if (!
|
|
192
|
+
if (!A)
|
|
192
193
|
try {
|
|
193
|
-
return
|
|
194
|
+
return B(C, ...R);
|
|
194
195
|
} finally {
|
|
195
|
-
x(),
|
|
196
|
+
x(), f();
|
|
196
197
|
}
|
|
197
198
|
}), N;
|
|
198
199
|
}
|
|
199
200
|
}, $ = k.n;
|
|
200
201
|
try {
|
|
201
202
|
const R = d(C, I, D);
|
|
202
|
-
return setAtomStateValueOrPromise(C, R,
|
|
203
|
+
return setAtomStateValueOrPromise(C, R, h), isPromiseLike$2(R) && ((L = R.onCancel) == null || L.call(R, () => P == null ? void 0 : P.abort()), R.then(
|
|
203
204
|
T,
|
|
204
205
|
T
|
|
205
206
|
)), k;
|
|
206
207
|
} catch (R) {
|
|
207
208
|
return delete k.v, k.e = R, ++k.n, k;
|
|
208
209
|
} finally {
|
|
209
|
-
|
|
210
|
+
A = !1, $ !== k.n && r.get(C) === $ && (r.set(C, k.n), a.add(C), (v = c.c) == null || v.call(c, C));
|
|
210
211
|
}
|
|
211
|
-
}),
|
|
212
|
+
}), y = m[4] || ((C) => {
|
|
212
213
|
const L = [C];
|
|
213
214
|
for (; L.length; ) {
|
|
214
|
-
const v = L.pop(), k =
|
|
215
|
-
for (const
|
|
216
|
-
const T =
|
|
217
|
-
r.set(
|
|
215
|
+
const v = L.pop(), k = h(v);
|
|
216
|
+
for (const A of getMountedOrPendingDependents(v, k, n)) {
|
|
217
|
+
const T = h(A);
|
|
218
|
+
r.set(A, T.n), L.push(A);
|
|
218
219
|
}
|
|
219
220
|
}
|
|
220
|
-
}),
|
|
221
|
+
}), B = m[5] || ((C, ...L) => {
|
|
221
222
|
let v = !0;
|
|
222
|
-
const k = (T) => returnAtomValue(
|
|
223
|
+
const k = (T) => returnAtomValue(b(T)), A = (T, ...I) => {
|
|
223
224
|
var P;
|
|
224
|
-
const N =
|
|
225
|
+
const N = h(T);
|
|
225
226
|
try {
|
|
226
227
|
if (isSelfAtom(C, T)) {
|
|
227
228
|
if (!hasInitialValue(T))
|
|
228
229
|
throw new Error("atom not writable");
|
|
229
230
|
const D = N.n, $ = I[0];
|
|
230
|
-
setAtomStateValueOrPromise(T, $,
|
|
231
|
+
setAtomStateValueOrPromise(T, $, h), E(T), D !== N.n && (a.add(T), (P = c.c) == null || P.call(c, T), y(T));
|
|
231
232
|
return;
|
|
232
233
|
} else
|
|
233
|
-
return
|
|
234
|
+
return B(T, ...I);
|
|
234
235
|
} finally {
|
|
235
|
-
v || (x(),
|
|
236
|
+
v || (x(), f());
|
|
236
237
|
}
|
|
237
238
|
};
|
|
238
239
|
try {
|
|
239
|
-
return p(C, k,
|
|
240
|
+
return p(C, k, A, ...L);
|
|
240
241
|
} finally {
|
|
241
242
|
v = !1;
|
|
242
243
|
}
|
|
243
|
-
}), E =
|
|
244
|
+
}), E = m[6] || ((C) => {
|
|
244
245
|
var L;
|
|
245
|
-
const v =
|
|
246
|
+
const v = h(C), k = n.get(C);
|
|
246
247
|
if (k && !isPendingPromise(v.v)) {
|
|
247
|
-
for (const [
|
|
248
|
-
if (!k.d.has(
|
|
249
|
-
const I =
|
|
250
|
-
w(
|
|
248
|
+
for (const [A, T] of v.d)
|
|
249
|
+
if (!k.d.has(A)) {
|
|
250
|
+
const I = h(A);
|
|
251
|
+
w(A).t.add(C), k.d.add(A), T !== I.n && (a.add(A), (L = c.c) == null || L.call(c, A), y(A));
|
|
251
252
|
}
|
|
252
|
-
for (const
|
|
253
|
-
if (!v.d.has(
|
|
254
|
-
k.d.delete(
|
|
255
|
-
const T = _(
|
|
253
|
+
for (const A of k.d || [])
|
|
254
|
+
if (!v.d.has(A)) {
|
|
255
|
+
k.d.delete(A);
|
|
256
|
+
const T = _(A);
|
|
256
257
|
T == null || T.t.delete(C);
|
|
257
258
|
}
|
|
258
259
|
}
|
|
259
|
-
}), w =
|
|
260
|
+
}), w = m[7] || ((C) => {
|
|
260
261
|
var L;
|
|
261
|
-
const v =
|
|
262
|
+
const v = h(C);
|
|
262
263
|
let k = n.get(C);
|
|
263
264
|
if (!k) {
|
|
264
|
-
|
|
265
|
-
for (const
|
|
266
|
-
w(
|
|
265
|
+
b(C);
|
|
266
|
+
for (const A of v.d.keys())
|
|
267
|
+
w(A).t.add(C);
|
|
267
268
|
if (k = {
|
|
268
269
|
l: /* @__PURE__ */ new Set(),
|
|
269
270
|
d: new Set(v.d.keys()),
|
|
270
271
|
t: /* @__PURE__ */ new Set()
|
|
271
272
|
}, n.set(C, k), (L = c.m) == null || L.call(c, C), isActuallyWritableAtom(C)) {
|
|
272
|
-
const
|
|
273
|
+
const A = () => {
|
|
273
274
|
let T = !0;
|
|
274
275
|
const I = (...P) => {
|
|
275
276
|
try {
|
|
276
|
-
return
|
|
277
|
+
return B(C, ...P);
|
|
277
278
|
} finally {
|
|
278
|
-
T || (x(),
|
|
279
|
+
T || (x(), f());
|
|
279
280
|
}
|
|
280
281
|
};
|
|
281
282
|
try {
|
|
@@ -292,21 +293,21 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
292
293
|
T = !1;
|
|
293
294
|
}
|
|
294
295
|
};
|
|
295
|
-
l.add(
|
|
296
|
+
l.add(A);
|
|
296
297
|
}
|
|
297
298
|
}
|
|
298
299
|
return k;
|
|
299
|
-
}), _ =
|
|
300
|
+
}), _ = m[8] || ((C) => {
|
|
300
301
|
var L;
|
|
301
|
-
const v =
|
|
302
|
+
const v = h(C);
|
|
302
303
|
let k = n.get(C);
|
|
303
|
-
if (k && !k.l.size && !Array.from(k.t).some((
|
|
304
|
+
if (k && !k.l.size && !Array.from(k.t).some((A) => {
|
|
304
305
|
var T;
|
|
305
|
-
return (T = n.get(
|
|
306
|
+
return (T = n.get(A)) == null ? void 0 : T.d.has(C);
|
|
306
307
|
})) {
|
|
307
308
|
k.u && i.add(k.u), k = void 0, n.delete(C), (L = c.u) == null || L.call(c, C);
|
|
308
|
-
for (const
|
|
309
|
-
const T = _(
|
|
309
|
+
for (const A of v.d.keys()) {
|
|
310
|
+
const T = _(A);
|
|
310
311
|
T == null || T.t.delete(C);
|
|
311
312
|
}
|
|
312
313
|
return;
|
|
@@ -327,28 +328,28 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
327
328
|
u,
|
|
328
329
|
g,
|
|
329
330
|
// building-block functions
|
|
330
|
-
m,
|
|
331
331
|
h,
|
|
332
|
+
f,
|
|
332
333
|
x,
|
|
333
|
-
y,
|
|
334
334
|
b,
|
|
335
|
-
|
|
335
|
+
y,
|
|
336
|
+
B,
|
|
336
337
|
E,
|
|
337
338
|
w,
|
|
338
339
|
_
|
|
339
340
|
], S = {
|
|
340
|
-
get: (C) => returnAtomValue(
|
|
341
|
+
get: (C) => returnAtomValue(b(C)),
|
|
341
342
|
set: (C, ...L) => {
|
|
342
343
|
try {
|
|
343
|
-
return
|
|
344
|
+
return B(C, ...L);
|
|
344
345
|
} finally {
|
|
345
|
-
x(),
|
|
346
|
+
x(), f();
|
|
346
347
|
}
|
|
347
348
|
},
|
|
348
349
|
sub: (C, L) => {
|
|
349
350
|
const k = w(C).l;
|
|
350
|
-
return k.add(L),
|
|
351
|
-
k.delete(L), _(C),
|
|
351
|
+
return k.add(L), f(), () => {
|
|
352
|
+
k.delete(L), _(C), f();
|
|
352
353
|
};
|
|
353
354
|
}
|
|
354
355
|
};
|
|
@@ -387,16 +388,16 @@ function splitAtom(o, n) {
|
|
|
387
388
|
let p = r.get(c);
|
|
388
389
|
if (p)
|
|
389
390
|
return p;
|
|
390
|
-
const u = d && r.get(d), g = [],
|
|
391
|
-
return c.forEach((
|
|
392
|
-
const x =
|
|
393
|
-
f
|
|
394
|
-
const
|
|
395
|
-
if (
|
|
396
|
-
g[
|
|
391
|
+
const u = d && r.get(d), g = [], m = [];
|
|
392
|
+
return c.forEach((h, f) => {
|
|
393
|
+
const x = f;
|
|
394
|
+
m[f] = x;
|
|
395
|
+
const b = u && u.atomList[u.keyList.indexOf(x)];
|
|
396
|
+
if (b) {
|
|
397
|
+
g[f] = b;
|
|
397
398
|
return;
|
|
398
399
|
}
|
|
399
|
-
const
|
|
400
|
+
const y = (E) => {
|
|
400
401
|
const w = E(l), _ = E(o), S = a(_, w == null ? void 0 : w.arr).keyList.indexOf(x);
|
|
401
402
|
if (S < 0 || S >= _.length) {
|
|
402
403
|
const C = c[a(c).keyList.indexOf(x)];
|
|
@@ -405,7 +406,7 @@ function splitAtom(o, n) {
|
|
|
405
406
|
throw new Error("splitAtom: index out of bounds for read");
|
|
406
407
|
}
|
|
407
408
|
return _[S];
|
|
408
|
-
},
|
|
409
|
+
}, B = (E, w, _) => {
|
|
409
410
|
const j = E(l), S = E(o), L = a(S, j == null ? void 0 : j.arr).keyList.indexOf(x);
|
|
410
411
|
if (L < 0 || L >= S.length)
|
|
411
412
|
throw new Error("splitAtom: index out of bounds for write");
|
|
@@ -416,8 +417,8 @@ function splitAtom(o, n) {
|
|
|
416
417
|
...S.slice(L + 1)
|
|
417
418
|
]);
|
|
418
419
|
};
|
|
419
|
-
g[
|
|
420
|
-
}), u && u.keyList.length ===
|
|
420
|
+
g[f] = isWritable(o) ? atom(y, B) : atom(y);
|
|
421
|
+
}), 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
422
|
}, l = atom((c) => {
|
|
422
423
|
const d = c(l), p = c(o);
|
|
423
424
|
return a(p, d == null ? void 0 : d.arr);
|
|
@@ -453,17 +454,17 @@ function splitAtom(o, n) {
|
|
|
453
454
|
case "move": {
|
|
454
455
|
const u = c(i).indexOf(p.atom), g = p.before ? c(i).indexOf(p.before) : c(i).length;
|
|
455
456
|
if (u >= 0 && g >= 0) {
|
|
456
|
-
const
|
|
457
|
+
const m = c(o);
|
|
457
458
|
u < g ? d(o, [
|
|
458
|
-
...
|
|
459
|
-
...
|
|
460
|
-
|
|
461
|
-
...
|
|
459
|
+
...m.slice(0, u),
|
|
460
|
+
...m.slice(u + 1, g),
|
|
461
|
+
m[u],
|
|
462
|
+
...m.slice(g)
|
|
462
463
|
]) : d(o, [
|
|
463
|
-
...
|
|
464
|
-
|
|
465
|
-
...
|
|
466
|
-
...
|
|
464
|
+
...m.slice(0, g),
|
|
465
|
+
m[u],
|
|
466
|
+
...m.slice(g, u),
|
|
467
|
+
...m.slice(u + 1)
|
|
467
468
|
]);
|
|
468
469
|
}
|
|
469
470
|
break;
|
|
@@ -489,8 +490,8 @@ function createJSONStorage(o = () => {
|
|
|
489
490
|
let a, l;
|
|
490
491
|
const i = {
|
|
491
492
|
getItem: (p, u) => {
|
|
492
|
-
var g,
|
|
493
|
-
const
|
|
493
|
+
var g, m;
|
|
494
|
+
const h = (x) => {
|
|
494
495
|
if (x = x || "", a !== x) {
|
|
495
496
|
try {
|
|
496
497
|
l = JSON.parse(x, n == null ? void 0 : n.reviver);
|
|
@@ -500,8 +501,8 @@ function createJSONStorage(o = () => {
|
|
|
500
501
|
a = x;
|
|
501
502
|
}
|
|
502
503
|
return l;
|
|
503
|
-
},
|
|
504
|
-
return isPromiseLike$1(
|
|
504
|
+
}, f = (m = (g = o()) == null ? void 0 : g.getItem(p)) != null ? m : null;
|
|
505
|
+
return isPromiseLike$1(f) ? f.then(h) : h(f);
|
|
505
506
|
},
|
|
506
507
|
setItem: (p, u) => {
|
|
507
508
|
var g;
|
|
@@ -514,14 +515,14 @@ function createJSONStorage(o = () => {
|
|
|
514
515
|
var u;
|
|
515
516
|
return (u = o()) == null ? void 0 : u.removeItem(p);
|
|
516
517
|
}
|
|
517
|
-
}, c = (p) => (u, g,
|
|
518
|
-
let
|
|
518
|
+
}, c = (p) => (u, g, m) => p(u, (h) => {
|
|
519
|
+
let f;
|
|
519
520
|
try {
|
|
520
|
-
|
|
521
|
+
f = JSON.parse(h || "");
|
|
521
522
|
} catch {
|
|
522
|
-
|
|
523
|
+
f = m;
|
|
523
524
|
}
|
|
524
|
-
g(
|
|
525
|
+
g(f);
|
|
525
526
|
});
|
|
526
527
|
let d;
|
|
527
528
|
try {
|
|
@@ -532,8 +533,8 @@ function createJSONStorage(o = () => {
|
|
|
532
533
|
if (!(o() instanceof window.Storage))
|
|
533
534
|
return () => {
|
|
534
535
|
};
|
|
535
|
-
const g = (
|
|
536
|
-
|
|
536
|
+
const g = (m) => {
|
|
537
|
+
m.storageArea === o() && m.key === p && u(m.newValue);
|
|
537
538
|
};
|
|
538
539
|
return window.addEventListener("storage", g), () => {
|
|
539
540
|
window.removeEventListener("storage", g);
|
|
@@ -1147,22 +1148,22 @@ const useSelectedBlocksDisplayChild = () => ({
|
|
|
1147
1148
|
}, removeNestedBlocks = (o, n) => {
|
|
1148
1149
|
let r = [...o], a = [];
|
|
1149
1150
|
n.forEach((d) => {
|
|
1150
|
-
const p = r.find((
|
|
1151
|
+
const p = r.find((m) => m._id === d);
|
|
1151
1152
|
if (!p || !p._parent) return;
|
|
1152
|
-
const u = p._parent, g = r.filter((
|
|
1153
|
+
const u = p._parent, g = r.filter((m) => m._parent === u);
|
|
1153
1154
|
if (g.length === 2) {
|
|
1154
|
-
const
|
|
1155
|
-
if (
|
|
1156
|
-
const
|
|
1157
|
-
|
|
1158
|
-
if (
|
|
1159
|
-
const x = { ...
|
|
1160
|
-
return Object.keys(
|
|
1161
|
-
|
|
1155
|
+
const m = g.find((h) => h._id !== d);
|
|
1156
|
+
if (m && m._type === "Text") {
|
|
1157
|
+
const h = r.find((f) => f._id === u);
|
|
1158
|
+
h && "content" in h && (r = r.map((f) => {
|
|
1159
|
+
if (f._id === u) {
|
|
1160
|
+
const x = { ...f, content: m.content };
|
|
1161
|
+
return Object.keys(m).forEach((b) => {
|
|
1162
|
+
b.startsWith("content-") && (x[b] = m[b]);
|
|
1162
1163
|
}), x;
|
|
1163
1164
|
}
|
|
1164
|
-
return
|
|
1165
|
-
}), a.push(
|
|
1165
|
+
return f;
|
|
1166
|
+
}), a.push(m._id));
|
|
1166
1167
|
}
|
|
1167
1168
|
}
|
|
1168
1169
|
});
|
|
@@ -1225,23 +1226,23 @@ function insertBlocksAtPosition(o, n, r, a) {
|
|
|
1225
1226
|
let i = [...o];
|
|
1226
1227
|
if (r) {
|
|
1227
1228
|
const u = o.find((g) => g._id === r);
|
|
1228
|
-
if (u && u.content !== void 0 && u.content !== "" && !o.some((
|
|
1229
|
-
const
|
|
1229
|
+
if (u && u.content !== void 0 && u.content !== "" && !o.some((m) => m._parent === r)) {
|
|
1230
|
+
const h = {
|
|
1230
1231
|
_id: generateUUID(),
|
|
1231
1232
|
_parent: r,
|
|
1232
1233
|
_type: "Text",
|
|
1233
1234
|
content: u.content
|
|
1234
1235
|
};
|
|
1235
|
-
Object.keys(u).forEach((
|
|
1236
|
-
|
|
1237
|
-
}), l.unshift(
|
|
1238
|
-
if (
|
|
1239
|
-
const x = { ...
|
|
1240
|
-
return Object.keys(x).forEach((
|
|
1241
|
-
|
|
1236
|
+
Object.keys(u).forEach((f) => {
|
|
1237
|
+
f.startsWith("content-") && (h[f] = u[f]);
|
|
1238
|
+
}), l.unshift(h), i = i.map((f) => {
|
|
1239
|
+
if (f._id === r) {
|
|
1240
|
+
const x = { ...f, content: "" };
|
|
1241
|
+
return Object.keys(x).forEach((b) => {
|
|
1242
|
+
b.startsWith("content-") && (x[b] = "");
|
|
1242
1243
|
}), x;
|
|
1243
1244
|
}
|
|
1244
|
-
return
|
|
1245
|
+
return f;
|
|
1245
1246
|
});
|
|
1246
1247
|
}
|
|
1247
1248
|
}
|
|
@@ -1250,7 +1251,7 @@ function insertBlocksAtPosition(o, n, r, a) {
|
|
|
1250
1251
|
const d = !isNaN(a) || a > -1 ? Math.min(a, c.length) : c.length;
|
|
1251
1252
|
let p = i.length;
|
|
1252
1253
|
for (let u = 0, g = 0; u < i.length; u++)
|
|
1253
|
-
if (i[u]._parent === r) {
|
|
1254
|
+
if (r !== void 0 ? i[u]._parent === r : !i[u]._parent) {
|
|
1254
1255
|
if (g === d) {
|
|
1255
1256
|
p = u;
|
|
1256
1257
|
break;
|
|
@@ -1270,17 +1271,19 @@ function findNodeById(o, n) {
|
|
|
1270
1271
|
return o.first((r) => r.model._id === n) || null;
|
|
1271
1272
|
}
|
|
1272
1273
|
function moveNode(o, n, r, a) {
|
|
1274
|
+
var u, g;
|
|
1273
1275
|
const l = findNodeById(o, n), i = findNodeById(o, r);
|
|
1274
|
-
if (l
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1276
|
+
if (!l || !i) return !1;
|
|
1277
|
+
i.children || (i.model.children = []);
|
|
1278
|
+
let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((m) => m.model._id === n);
|
|
1279
|
+
l.drop(), c = Math.max(c, 0);
|
|
1280
|
+
const p = (((g = l == null ? void 0 : l.model) == null ? void 0 : g._parent) || "root") === r && c <= a ? a - 1 : a;
|
|
1281
|
+
try {
|
|
1282
|
+
i.addChildAtIndex(l, p);
|
|
1283
|
+
} catch (m) {
|
|
1284
|
+
return console.error("Error adding child to parent:", m), !1;
|
|
1282
1285
|
}
|
|
1283
|
-
return !
|
|
1286
|
+
return !0;
|
|
1284
1287
|
}
|
|
1285
1288
|
function handleOldParentTextBlock(o, n) {
|
|
1286
1289
|
if (!n || !n._parent) return o;
|
|
@@ -1319,8 +1322,8 @@ function handleNewParentTextBlock(o, n, r) {
|
|
|
1319
1322
|
const d = o.map((u) => {
|
|
1320
1323
|
if (u._id === r) {
|
|
1321
1324
|
const g = { ...u, content: "" };
|
|
1322
|
-
return Object.keys(g).forEach((
|
|
1323
|
-
|
|
1325
|
+
return Object.keys(g).forEach((m) => {
|
|
1326
|
+
m.startsWith("content-") && (g[m] = "");
|
|
1324
1327
|
}), g;
|
|
1325
1328
|
}
|
|
1326
1329
|
return u;
|
|
@@ -1337,7 +1340,7 @@ function moveBlocksWithChildren(o, n, r, a) {
|
|
|
1337
1340
|
const c = r || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
|
|
1338
1341
|
if (moveNode(p, n, c, a)) {
|
|
1339
1342
|
let u = flattenTree(p);
|
|
1340
|
-
const g = u.find((
|
|
1343
|
+
const g = u.find((m) => m._id === n);
|
|
1341
1344
|
return g && (g._parent = c === "root" ? null : c), u.shift(), r && (u = handleNewParentTextBlock(u, l, r)), u;
|
|
1342
1345
|
}
|
|
1343
1346
|
return i;
|
|
@@ -1387,50 +1390,50 @@ const useBlocksStoreManager = () => {
|
|
|
1387
1390
|
updateBlocksProps: c
|
|
1388
1391
|
} = useBlocksStoreManager();
|
|
1389
1392
|
return {
|
|
1390
|
-
moveBlocks: (x,
|
|
1391
|
-
const
|
|
1393
|
+
moveBlocks: (x, b, y) => {
|
|
1394
|
+
const B = map(x, (w) => {
|
|
1392
1395
|
const j = n.find((L) => L._id === w)._parent || null, C = n.filter((L) => j ? L._parent === j : !L._parent).map((L) => L._id).indexOf(w);
|
|
1393
1396
|
return { _id: w, oldParent: j, oldPosition: C };
|
|
1394
|
-
}), E =
|
|
1395
|
-
E && E.oldParent ===
|
|
1396
|
-
undo: () => each(
|
|
1397
|
+
}), E = B.find(({ _id: w }) => w === x[0]);
|
|
1398
|
+
E && E.oldParent === b && E.oldPosition === y || (i(x, b, y), o({
|
|
1399
|
+
undo: () => each(B, ({ _id: w, oldParent: _, oldPosition: j }) => {
|
|
1397
1400
|
i([w], _, j);
|
|
1398
1401
|
}),
|
|
1399
|
-
redo: () => i(x,
|
|
1402
|
+
redo: () => i(x, b, y)
|
|
1400
1403
|
}));
|
|
1401
1404
|
},
|
|
1402
|
-
addBlocks: (x,
|
|
1403
|
-
a(x,
|
|
1405
|
+
addBlocks: (x, b, y) => {
|
|
1406
|
+
a(x, b, y), o({
|
|
1404
1407
|
undo: () => l(map(x, "_id")),
|
|
1405
|
-
redo: () => a(x,
|
|
1408
|
+
redo: () => a(x, b, y)
|
|
1406
1409
|
});
|
|
1407
1410
|
},
|
|
1408
1411
|
removeBlocks: (x) => {
|
|
1409
1412
|
var E;
|
|
1410
|
-
const
|
|
1413
|
+
const b = (E = first(x)) == null ? void 0 : E._parent, B = n.filter((w) => b ? w._parent === b : !w._parent).indexOf(first(x));
|
|
1411
1414
|
l(map(x, "_id")), o({
|
|
1412
|
-
undo: () => a(x,
|
|
1415
|
+
undo: () => a(x, b, B),
|
|
1413
1416
|
redo: () => l(map(x, "_id"))
|
|
1414
1417
|
});
|
|
1415
1418
|
},
|
|
1416
|
-
updateBlocks: (x,
|
|
1417
|
-
let
|
|
1418
|
-
if (
|
|
1419
|
-
|
|
1419
|
+
updateBlocks: (x, b, y) => {
|
|
1420
|
+
let B = [];
|
|
1421
|
+
if (y)
|
|
1422
|
+
B = map(x, (E) => ({ _id: E, ...y }));
|
|
1420
1423
|
else {
|
|
1421
|
-
const E = keys(
|
|
1422
|
-
|
|
1424
|
+
const E = keys(b);
|
|
1425
|
+
B = map(x, (w) => {
|
|
1423
1426
|
const _ = n.find((S) => S._id === w), j = { _id: w };
|
|
1424
1427
|
return each(E, (S) => j[S] = _[S]), j;
|
|
1425
1428
|
});
|
|
1426
1429
|
}
|
|
1427
|
-
c(map(x, (E) => ({ _id: E, ...
|
|
1428
|
-
undo: () => c(
|
|
1429
|
-
redo: () => c(map(x, (E) => ({ _id: E, ...
|
|
1430
|
+
c(map(x, (E) => ({ _id: E, ...b }))), o({
|
|
1431
|
+
undo: () => c(B),
|
|
1432
|
+
redo: () => c(map(x, (E) => ({ _id: E, ...b })))
|
|
1430
1433
|
});
|
|
1431
1434
|
},
|
|
1432
|
-
updateBlocksRuntime: (x,
|
|
1433
|
-
c(map(x, (
|
|
1435
|
+
updateBlocksRuntime: (x, b) => {
|
|
1436
|
+
c(map(x, (y) => ({ _id: y, ...b })));
|
|
1434
1437
|
},
|
|
1435
1438
|
setNewBlocks: (x) => {
|
|
1436
1439
|
r(x), o({
|
|
@@ -1439,12 +1442,12 @@ const useBlocksStoreManager = () => {
|
|
|
1439
1442
|
});
|
|
1440
1443
|
},
|
|
1441
1444
|
updateMultipleBlocksProps: (x) => {
|
|
1442
|
-
let
|
|
1443
|
-
|
|
1444
|
-
const
|
|
1445
|
-
return each(
|
|
1445
|
+
let b = [];
|
|
1446
|
+
b = map(x, (y) => {
|
|
1447
|
+
const B = keys(y), E = n.find((_) => _._id === y._id), w = {};
|
|
1448
|
+
return each(B, (_) => w[_] = E[_]), w;
|
|
1446
1449
|
}), c(x), o({
|
|
1447
|
-
undo: () => c(
|
|
1450
|
+
undo: () => c(b),
|
|
1448
1451
|
redo: () => c(x)
|
|
1449
1452
|
});
|
|
1450
1453
|
}
|
|
@@ -1481,25 +1484,25 @@ import.meta.vitest && describe("canDropBlock Function", () => {
|
|
|
1481
1484
|
const useAddBlock = () => {
|
|
1482
1485
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
1483
1486
|
(i, c, d) => {
|
|
1484
|
-
var
|
|
1485
|
-
for (let
|
|
1486
|
-
const { _id: x } = i[
|
|
1487
|
-
i[
|
|
1488
|
-
const
|
|
1489
|
-
for (let
|
|
1490
|
-
y
|
|
1487
|
+
var h;
|
|
1488
|
+
for (let f = 0; f < i.length; f++) {
|
|
1489
|
+
const { _id: x } = i[f];
|
|
1490
|
+
i[f]._id = generateUUID();
|
|
1491
|
+
const b = filter(i, { _parent: x });
|
|
1492
|
+
for (let y = 0; y < b.length; y++)
|
|
1493
|
+
b[y]._parent = i[f]._id;
|
|
1491
1494
|
}
|
|
1492
1495
|
const p = first(i);
|
|
1493
1496
|
let u, g;
|
|
1494
|
-
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([(
|
|
1497
|
+
return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(h = first(i)) == null ? void 0 : h._id]), first(i);
|
|
1495
1498
|
},
|
|
1496
1499
|
[r, o, n]
|
|
1497
1500
|
);
|
|
1498
1501
|
return { addCoreBlock: useCallback(
|
|
1499
1502
|
(i, c, d) => {
|
|
1500
1503
|
if (has(i, "blocks")) {
|
|
1501
|
-
const
|
|
1502
|
-
return a(
|
|
1504
|
+
const b = i.blocks;
|
|
1505
|
+
return a(b, c, d);
|
|
1503
1506
|
}
|
|
1504
1507
|
const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
|
|
1505
1508
|
_type: i.type,
|
|
@@ -1508,8 +1511,8 @@ const useAddBlock = () => {
|
|
|
1508
1511
|
...has(i, "_name") && { _name: i._name },
|
|
1509
1512
|
...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
|
|
1510
1513
|
};
|
|
1511
|
-
let
|
|
1512
|
-
return c && (
|
|
1514
|
+
let m, h;
|
|
1515
|
+
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;
|
|
1513
1516
|
},
|
|
1514
1517
|
[r, a, o, n]
|
|
1515
1518
|
), addPredefinedBlock: a };
|
|
@@ -2955,30 +2958,30 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2955
2958
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
2956
2959
|
})
|
|
2957
2960
|
), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
|
|
2958
|
-
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,
|
|
2959
|
-
const x = cloneDeep(
|
|
2960
|
-
for (const
|
|
2961
|
-
const
|
|
2962
|
-
if (typeof
|
|
2963
|
-
const { baseClasses:
|
|
2964
|
-
x[
|
|
2961
|
+
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (h, f) => {
|
|
2962
|
+
const x = cloneDeep(f.find((b) => b._id === h));
|
|
2963
|
+
for (const b in x) {
|
|
2964
|
+
const y = x[b];
|
|
2965
|
+
if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
|
|
2966
|
+
const { baseClasses: B, classes: E } = getSplitChaiClasses(y);
|
|
2967
|
+
x[b] = compact(flattenDeep([B, E])).join(" ");
|
|
2965
2968
|
} else
|
|
2966
|
-
|
|
2969
|
+
b !== "_id" && delete x[b];
|
|
2967
2970
|
}
|
|
2968
2971
|
return x;
|
|
2969
2972
|
};
|
|
2970
2973
|
return {
|
|
2971
2974
|
askAi: useCallback(
|
|
2972
|
-
async (
|
|
2975
|
+
async (h, f, x, b) => {
|
|
2973
2976
|
if (l) {
|
|
2974
2977
|
n(!0), a(null);
|
|
2975
2978
|
try {
|
|
2976
|
-
const
|
|
2979
|
+
const y = p === u ? "" : p, B = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [m(f, d)], E = await l(h, addLangToPrompt(x, g, h), B, y), { blocks: w, error: _ } = E;
|
|
2977
2980
|
if (_) {
|
|
2978
2981
|
a(_);
|
|
2979
2982
|
return;
|
|
2980
2983
|
}
|
|
2981
|
-
if (
|
|
2984
|
+
if (h === "styles") {
|
|
2982
2985
|
const j = w.map((S) => {
|
|
2983
2986
|
for (const C in S)
|
|
2984
2987
|
C !== "_id" && (S[C] = `${STYLES_KEY},${S[C]}`);
|
|
@@ -2987,11 +2990,11 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2987
2990
|
c(j);
|
|
2988
2991
|
} else
|
|
2989
2992
|
i(w);
|
|
2990
|
-
|
|
2991
|
-
} catch (
|
|
2992
|
-
a(
|
|
2993
|
+
b && b(E);
|
|
2994
|
+
} catch (y) {
|
|
2995
|
+
a(y);
|
|
2993
2996
|
} finally {
|
|
2994
|
-
n(!1),
|
|
2997
|
+
n(!1), b && b();
|
|
2995
2998
|
}
|
|
2996
2999
|
}
|
|
2997
3000
|
},
|
|
@@ -3128,13 +3131,13 @@ const useBlockHighlight = () => {
|
|
|
3128
3131
|
(a, l = null) => {
|
|
3129
3132
|
const i = [];
|
|
3130
3133
|
each(a, (c) => {
|
|
3131
|
-
const d = o.find((
|
|
3134
|
+
const d = o.find((h) => h._id === c);
|
|
3132
3135
|
l ? l === "root" && (l = null) : l = d._parent;
|
|
3133
3136
|
const g = filter(
|
|
3134
3137
|
o,
|
|
3135
|
-
(
|
|
3136
|
-
).indexOf(d) + 1,
|
|
3137
|
-
r(
|
|
3138
|
+
(h) => isString(l) ? h._parent === l : !h._parent
|
|
3139
|
+
).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
|
|
3140
|
+
r(m, l, g), i.push(get(m, "0._id", ""));
|
|
3138
3141
|
}), n(i);
|
|
3139
3142
|
},
|
|
3140
3143
|
[o, n]
|
|
@@ -3227,14 +3230,14 @@ const useBlockHighlight = () => {
|
|
|
3227
3230
|
return map(i, (c) => {
|
|
3228
3231
|
const d = o(c), p = a;
|
|
3229
3232
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
3230
|
-
return each(p, (
|
|
3231
|
-
const
|
|
3232
|
-
u = u.replace(
|
|
3233
|
-
const x = first(
|
|
3234
|
-
includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(
|
|
3235
|
-
}), each(p, (
|
|
3236
|
-
const
|
|
3237
|
-
g = g.replace(
|
|
3233
|
+
return each(p, (m) => {
|
|
3234
|
+
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
3235
|
+
u = u.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
3236
|
+
const x = first(m.split(":"));
|
|
3237
|
+
includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(m.split(":").pop().trim());
|
|
3238
|
+
}), each(p, (m) => {
|
|
3239
|
+
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
3240
|
+
g = g.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
3238
3241
|
}), {
|
|
3239
3242
|
ids: [d._id],
|
|
3240
3243
|
props: {
|
|
@@ -3320,11 +3323,7 @@ wrapperBlockAtom.debugLabel = "wrapperBlockAtom";
|
|
|
3320
3323
|
const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), layoutVariantAtom = atomWithStorage("_layout_variant_mode", "DUAL_SIDE_PANEL"), useLayoutVariant = () => {
|
|
3321
3324
|
const [o, n] = useAtom$1(layoutVariantAtom), r = useBuilderProp("layoutVariant", "DUAL_SIDE_PANEL");
|
|
3322
3325
|
return [o || r, n];
|
|
3323
|
-
},
|
|
3324
|
-
OPEN_ADD_BLOCK: "OPEN_ADD_BLOCK",
|
|
3325
|
-
CLOSE_ADD_BLOCK: "CLOSE_ADD_BLOCK",
|
|
3326
|
-
SHOW_BLOCK_SETTINGS: "SHOW_BLOCK_SETTINGS"
|
|
3327
|
-
};
|
|
3326
|
+
}, draggedBlockAtom = atom$1(null), dropTargetBlockIdAtom = atom$1(null);
|
|
3328
3327
|
class PubSub {
|
|
3329
3328
|
constructor() {
|
|
3330
3329
|
V(this, "subscribers", /* @__PURE__ */ new Map());
|
|
@@ -3340,7 +3339,138 @@ class PubSub {
|
|
|
3340
3339
|
a && a.forEach((l) => l(r));
|
|
3341
3340
|
}
|
|
3342
3341
|
}
|
|
3343
|
-
const pubsub = new PubSub(),
|
|
3342
|
+
const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
3343
|
+
const { t: r } = useTranslation(), [a] = useBlocksStore(), l = get(o, "_id"), i = get(o, "_parent"), c = filter(a, (g) => i ? get(g, "_parent") === i : !get(g, "_parent")), d = canAddChildBlock(get(o, "_type", "")), p = findIndex(c, { _id: l }), u = (g) => {
|
|
3344
|
+
if (g === "CHILD")
|
|
3345
|
+
pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
|
|
3346
|
+
else {
|
|
3347
|
+
const m = { _id: i || "", position: c == null ? void 0 : c.length };
|
|
3348
|
+
g === "BEFORE" ? m.position = Math.max(p, 0) : g === "AFTER" && (m.position = p + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, m);
|
|
3349
|
+
}
|
|
3350
|
+
};
|
|
3351
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
3352
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { children: n }),
|
|
3353
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "border border-blue-500 bg-blue-500 text-white shadow-2xl", children: [
|
|
3354
|
+
d && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => u("CHILD"), children: r("Add inside") }),
|
|
3355
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => u("BEFORE"), children: r("Add before") }),
|
|
3356
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => u("AFTER"), children: r("Add after") })
|
|
3357
|
+
] })
|
|
3358
|
+
] });
|
|
3359
|
+
};
|
|
3360
|
+
function getOrientation(o) {
|
|
3361
|
+
const n = window.getComputedStyle(o), r = n.display;
|
|
3362
|
+
if (r === "flex" || r === "inline-flex") {
|
|
3363
|
+
const a = n.flexDirection;
|
|
3364
|
+
return a === "column" || a === "column-reverse" ? "vertical" : "horizontal";
|
|
3365
|
+
} else if (r === "grid") {
|
|
3366
|
+
const a = n.gridAutoFlow, l = n.gridTemplateColumns;
|
|
3367
|
+
return a.includes("column") || l && l !== "none" && l !== "" && !l.includes("calc") && // Handle calc expressions
|
|
3368
|
+
l.split(" ").length <= 1 ? "vertical" : "horizontal";
|
|
3369
|
+
} else if (r === "block" || r === "inline-block")
|
|
3370
|
+
return "vertical";
|
|
3371
|
+
return "horizontal";
|
|
3372
|
+
}
|
|
3373
|
+
if (import.meta.vitest) {
|
|
3374
|
+
const { test: o, expect: n } = import.meta.vitest;
|
|
3375
|
+
o("getOrientation default div should be vertical", () => {
|
|
3376
|
+
n(getOrientation(document.createElement("div"))).toBe("vertical");
|
|
3377
|
+
}), o("getOrientation flex with default direction should be horizontal", () => {
|
|
3378
|
+
const r = document.createElement("div");
|
|
3379
|
+
r.style.display = "flex", n(getOrientation(r)).toBe("horizontal");
|
|
3380
|
+
}), o("getOrientation inline-flex with default direction should be horizontal", () => {
|
|
3381
|
+
const r = document.createElement("div");
|
|
3382
|
+
r.style.display = "inline-flex", n(getOrientation(r)).toBe("horizontal");
|
|
3383
|
+
}), o("getOrientation flex with row direction should be horizontal", () => {
|
|
3384
|
+
const r = document.createElement("div");
|
|
3385
|
+
r.style.display = "flex", r.style.flexDirection = "row", n(getOrientation(r)).toBe("horizontal");
|
|
3386
|
+
}), o("getOrientation flex with row-reverse direction should be horizontal", () => {
|
|
3387
|
+
const r = document.createElement("div");
|
|
3388
|
+
r.style.display = "flex", r.style.flexDirection = "row-reverse", n(getOrientation(r)).toBe("horizontal");
|
|
3389
|
+
}), o("getOrientation flex with column direction should be vertical", () => {
|
|
3390
|
+
const r = document.createElement("div");
|
|
3391
|
+
r.style.display = "flex", r.style.flexDirection = "column", n(getOrientation(r)).toBe("vertical");
|
|
3392
|
+
}), o("getOrientation flex with column-reverse direction should be vertical", () => {
|
|
3393
|
+
const r = document.createElement("div");
|
|
3394
|
+
r.style.display = "flex", r.style.flexDirection = "column-reverse", n(getOrientation(r)).toBe("vertical");
|
|
3395
|
+
}), o("getOrientation grid with default settings should be horizontal", () => {
|
|
3396
|
+
const r = document.createElement("div");
|
|
3397
|
+
r.style.display = "grid", n(getOrientation(r)).toBe("horizontal");
|
|
3398
|
+
}), o("getOrientation grid with row auto-flow should be horizontal", () => {
|
|
3399
|
+
const r = document.createElement("div");
|
|
3400
|
+
r.style.display = "grid", r.style.gridAutoFlow = "row", n(getOrientation(r)).toBe("horizontal");
|
|
3401
|
+
}), o("getOrientation grid with column auto-flow should be vertical", () => {
|
|
3402
|
+
const r = document.createElement("div");
|
|
3403
|
+
r.style.display = "grid", r.style.gridAutoFlow = "column", n(getOrientation(r)).toBe("vertical");
|
|
3404
|
+
}), o("getOrientation grid with dense column auto-flow should be vertical", () => {
|
|
3405
|
+
const r = document.createElement("div");
|
|
3406
|
+
r.style.display = "grid", r.style.gridAutoFlow = "column dense", n(getOrientation(r)).toBe("vertical");
|
|
3407
|
+
}), o("getOrientation grid with single column should be vertical", () => {
|
|
3408
|
+
const r = document.createElement("div");
|
|
3409
|
+
r.style.display = "grid", r.style.gridTemplateColumns = "1fr", n(getOrientation(r)).toBe("vertical");
|
|
3410
|
+
}), o("getOrientation grid with multiple columns should be horizontal", () => {
|
|
3411
|
+
const r = document.createElement("div");
|
|
3412
|
+
r.style.display = "grid", r.style.gridTemplateColumns = "1fr 1fr", n(getOrientation(r)).toBe("horizontal");
|
|
3413
|
+
}), o("getOrientation block should be vertical", () => {
|
|
3414
|
+
const r = document.createElement("div");
|
|
3415
|
+
r.style.display = "block", n(getOrientation(r)).toBe("vertical");
|
|
3416
|
+
}), o("getOrientation inline-block should be vertical", () => {
|
|
3417
|
+
const r = document.createElement("div");
|
|
3418
|
+
r.style.display = "inline-block", n(getOrientation(r)).toBe("vertical");
|
|
3419
|
+
}), o("getOrientation inline should be horizontal", () => {
|
|
3420
|
+
const r = document.createElement("div");
|
|
3421
|
+
r.style.display = "inline", n(getOrientation(r)).toBe("horizontal");
|
|
3422
|
+
}), o("getOrientation table should be horizontal", () => {
|
|
3423
|
+
const r = document.createElement("div");
|
|
3424
|
+
r.style.display = "table", n(getOrientation(r)).toBe("horizontal");
|
|
3425
|
+
});
|
|
3426
|
+
}
|
|
3427
|
+
const CONTROLS = [
|
|
3428
|
+
{ ControlIcon: PinTopIcon, dir: "VERTICAL", key: "UP" },
|
|
3429
|
+
{ ControlIcon: PinBottomIcon, dir: "VERTICAL", key: "DOWN" },
|
|
3430
|
+
{ ControlIcon: PinLeftIcon, dir: "HORIZONTAL", key: "LEFT" },
|
|
3431
|
+
{ ControlIcon: PinRightIcon, dir: "HORIZONTAL", key: "RIGHT" }
|
|
3432
|
+
], getParentBlockOrientation = (o, n) => {
|
|
3433
|
+
try {
|
|
3434
|
+
if (!o || !n) return "VERTICAL";
|
|
3435
|
+
const r = `[data-block-id='${o}']`, a = n == null ? void 0 : n.querySelector(r);
|
|
3436
|
+
return a ? getOrientation(a).toUpperCase() : "VERTICAL";
|
|
3437
|
+
} catch {
|
|
3438
|
+
return "VERTICAL";
|
|
3439
|
+
}
|
|
3440
|
+
}, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
|
|
3441
|
+
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (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, a), f = useCallback(
|
|
3442
|
+
(x) => {
|
|
3443
|
+
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());
|
|
3444
|
+
},
|
|
3445
|
+
[g, m, p, u, i, c, n]
|
|
3446
|
+
);
|
|
3447
|
+
return useHotkeys(
|
|
3448
|
+
"shift+up, shift+down, shift+left, shift+right",
|
|
3449
|
+
({ key: x }) => {
|
|
3450
|
+
var b;
|
|
3451
|
+
f((b = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : b.toUpperCase());
|
|
3452
|
+
},
|
|
3453
|
+
{ document: a == null ? void 0 : a.contentDocument },
|
|
3454
|
+
[f]
|
|
3455
|
+
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: f, orientation: h };
|
|
3456
|
+
}, BlockController = ({ block: o, updateFloatingBar: n }) => {
|
|
3457
|
+
const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
|
|
3458
|
+
o,
|
|
3459
|
+
n
|
|
3460
|
+
);
|
|
3461
|
+
return r ? null : /* @__PURE__ */ jsx(Fragment, { children: CONTROLS.map(({ ControlIcon: d, dir: p, key: u }) => {
|
|
3462
|
+
if (c !== p) return null;
|
|
3463
|
+
const g = isDisabledControl(a, l, u);
|
|
3464
|
+
return g ? null : /* @__PURE__ */ jsx(
|
|
3465
|
+
d,
|
|
3466
|
+
{
|
|
3467
|
+
onClick: () => i(u),
|
|
3468
|
+
className: `${g ? "pointer-events-none cursor-not-allowed opacity-50" : "duration-300 hover:scale-95 hover:opacity-80"}`
|
|
3469
|
+
},
|
|
3470
|
+
u
|
|
3471
|
+
);
|
|
3472
|
+
}) });
|
|
3473
|
+
}, BlockActionLabel = ({ block: o, label: n }) => {
|
|
3344
3474
|
const [, r] = useSelectedBlockIds(), [, a] = useHighlightBlockId(), [, l] = useAtom$1(draggedBlockAtom), i = useFeature("dnd");
|
|
3345
3475
|
return /* @__PURE__ */ jsxs(
|
|
3346
3476
|
"div",
|
|
@@ -3359,51 +3489,46 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3359
3489
|
}
|
|
3360
3490
|
);
|
|
3361
3491
|
}, BlockFloatingSelector = ({ selectedBlockElement: o, block: n }) => {
|
|
3362
|
-
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), [d] = useAtom$1(inlineEditingActiveAtom), {
|
|
3492
|
+
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), [d] = useAtom$1(inlineEditingActiveAtom), { document: p } = useFrame(), { floatingStyles: u, refs: g, update: m } = useFloating({
|
|
3363
3493
|
placement: "top-start",
|
|
3364
3494
|
middleware: [shift(), flip()],
|
|
3365
3495
|
elements: {
|
|
3366
3496
|
reference: o
|
|
3367
3497
|
}
|
|
3368
3498
|
});
|
|
3369
|
-
useResizeObserver(o, () =>
|
|
3370
|
-
const
|
|
3499
|
+
useResizeObserver(o, () => m(), o !== null), useResizeObserver(p == null ? void 0 : p.body, () => m(), (p == null ? void 0 : p.body) !== null);
|
|
3500
|
+
const h = get(n, "_parent", null), f = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
|
|
3371
3501
|
return !o || !n || d ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
3372
3502
|
"div",
|
|
3373
3503
|
{
|
|
3374
3504
|
role: "button",
|
|
3375
3505
|
tabIndex: 0,
|
|
3376
|
-
ref:
|
|
3377
|
-
style:
|
|
3378
|
-
onClick: (
|
|
3379
|
-
|
|
3506
|
+
ref: g.setFloating,
|
|
3507
|
+
style: u,
|
|
3508
|
+
onClick: (x) => {
|
|
3509
|
+
x.stopPropagation(), x.preventDefault();
|
|
3380
3510
|
},
|
|
3381
|
-
onMouseEnter: (
|
|
3382
|
-
|
|
3511
|
+
onMouseEnter: (x) => {
|
|
3512
|
+
x.stopPropagation(), i(null);
|
|
3383
3513
|
},
|
|
3384
|
-
onKeyDown: (
|
|
3514
|
+
onKeyDown: (x) => x.stopPropagation(),
|
|
3385
3515
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3386
3516
|
children: [
|
|
3387
|
-
|
|
3517
|
+
h && /* @__PURE__ */ jsx(
|
|
3388
3518
|
ArrowUpIcon,
|
|
3389
3519
|
{
|
|
3390
3520
|
className: "hover:scale-105",
|
|
3391
3521
|
onClick: () => {
|
|
3392
|
-
c([]), l([
|
|
3522
|
+
c([]), l([h]);
|
|
3393
3523
|
}
|
|
3394
3524
|
}
|
|
3395
3525
|
),
|
|
3396
|
-
/* @__PURE__ */ jsx(BlockActionLabel, { label:
|
|
3397
|
-
/* @__PURE__ */ jsxs("div", { className: "flex gap-2
|
|
3398
|
-
|
|
3399
|
-
PlusIcon,
|
|
3400
|
-
{
|
|
3401
|
-
className: "hover:scale-105",
|
|
3402
|
-
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, n)
|
|
3403
|
-
}
|
|
3404
|
-
),
|
|
3526
|
+
/* @__PURE__ */ jsx(BlockActionLabel, { label: f, block: n }),
|
|
3527
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
|
|
3528
|
+
/* @__PURE__ */ jsx(AddBlockDropdown, { block: n, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
|
|
3405
3529
|
canDuplicateBlock(get(n, "_type", "")) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([n == null ? void 0 : n._id]) }) : null,
|
|
3406
|
-
canDeleteBlock(get(n, "_type", "")) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([n == null ? void 0 : n._id]) }) : null
|
|
3530
|
+
canDeleteBlock(get(n, "_type", "")) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([n == null ? void 0 : n._id]) }) : null,
|
|
3531
|
+
/* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar: m })
|
|
3407
3532
|
] })
|
|
3408
3533
|
]
|
|
3409
3534
|
}
|
|
@@ -3464,28 +3589,32 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3464
3589
|
<div class="frame-root h-full"></div>
|
|
3465
3590
|
</body>
|
|
3466
3591
|
</html>`, useKeyEventWatcher = (o) => {
|
|
3467
|
-
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks:
|
|
3592
|
+
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), h = o ? { document: o } : {};
|
|
3468
3593
|
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(
|
|
3469
3594
|
"ctrl+v,command+v",
|
|
3470
3595
|
() => {
|
|
3471
|
-
g(n[0]) &&
|
|
3596
|
+
g(n[0]) && m(n);
|
|
3472
3597
|
},
|
|
3473
|
-
{ ...
|
|
3474
|
-
[n, g,
|
|
3475
|
-
), useHotkeys("esc", () => r([]),
|
|
3598
|
+
{ ...h, preventDefault: !0 },
|
|
3599
|
+
[n, g, m]
|
|
3600
|
+
), useHotkeys("esc", () => r([]), h, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...h, preventDefault: !0 }, [
|
|
3476
3601
|
n,
|
|
3477
3602
|
i
|
|
3478
3603
|
]), useHotkeys(
|
|
3479
3604
|
"del, backspace",
|
|
3480
|
-
(
|
|
3481
|
-
|
|
3605
|
+
(f) => {
|
|
3606
|
+
f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
|
|
3482
3607
|
},
|
|
3483
|
-
|
|
3608
|
+
h,
|
|
3484
3609
|
[n, l]
|
|
3485
3610
|
);
|
|
3486
3611
|
}, KeyboardHandler = () => {
|
|
3487
3612
|
const { document: o } = useFrame();
|
|
3488
3613
|
return useKeyEventWatcher(o), null;
|
|
3614
|
+
}, CHAI_BUILDER_EVENTS = {
|
|
3615
|
+
OPEN_ADD_BLOCK: "OPEN_ADD_BLOCK",
|
|
3616
|
+
CLOSE_ADD_BLOCK: "CLOSE_ADD_BLOCK",
|
|
3617
|
+
SHOW_BLOCK_SETTINGS: "SHOW_BLOCK_SETTINGS"
|
|
3489
3618
|
}, AddBlockAtBottom = () => {
|
|
3490
3619
|
const { t: o } = useTranslation();
|
|
3491
3620
|
return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer py-2", children: [
|
|
@@ -3505,18 +3634,6 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3505
3634
|
/* @__PURE__ */ jsx("br", {})
|
|
3506
3635
|
] });
|
|
3507
3636
|
};
|
|
3508
|
-
function getOrientation(o) {
|
|
3509
|
-
const n = window.getComputedStyle(o), r = n.display;
|
|
3510
|
-
if (r === "flex" || r === "inline-flex") {
|
|
3511
|
-
const a = n.flexDirection;
|
|
3512
|
-
return a === "column" || a === "column-reverse" ? "vertical" : "horizontal";
|
|
3513
|
-
} else if (r === "grid") {
|
|
3514
|
-
const a = n.gridAutoFlow, l = n.gridTemplateRows, i = n.gridTemplateColumns;
|
|
3515
|
-
return a.includes("column") || l.split(" ").length > i.split(" ").length ? "vertical" : "horizontal";
|
|
3516
|
-
} else if (r === "block" || r === "inline-block")
|
|
3517
|
-
return "vertical";
|
|
3518
|
-
return "horizontal";
|
|
3519
|
-
}
|
|
3520
3637
|
let iframeDocument = null, possiblePositions = [], dropTarget = null, dropIndex = null;
|
|
3521
3638
|
const positionPlaceholder = (o, n, r) => {
|
|
3522
3639
|
if (!iframeDocument || !o) return;
|
|
@@ -3566,38 +3683,38 @@ function removeDataDrop() {
|
|
|
3566
3683
|
const useDnd = () => {
|
|
3567
3684
|
const { document: o } = useFrame(), [n, r] = useAtom$1(draggingFlagAtom), { addCoreBlock: a } = useAddBlock(), [, l] = useHighlightBlockId(), [, i] = useSelectedBlockIds(), { moveBlocks: c } = useBlocksStoreUndoableActions(), [d, p] = useAtom$1(draggedBlockAtom), [, u] = useAtom$1(dropTargetBlockIdAtom);
|
|
3568
3685
|
if (!useFeature("dnd")) return {};
|
|
3569
|
-
const
|
|
3686
|
+
const m = () => {
|
|
3570
3687
|
removePlaceholder(), r(!1), p(null), u(null), possiblePositions = [];
|
|
3571
3688
|
};
|
|
3572
3689
|
return iframeDocument = o, {
|
|
3573
3690
|
isDragging: n,
|
|
3574
|
-
onDragOver: (
|
|
3575
|
-
|
|
3691
|
+
onDragOver: (h) => {
|
|
3692
|
+
h.preventDefault(), h.stopPropagation(), throttledDragOver(h);
|
|
3576
3693
|
},
|
|
3577
|
-
onDrop: (
|
|
3694
|
+
onDrop: (h) => {
|
|
3578
3695
|
var _;
|
|
3579
|
-
const
|
|
3580
|
-
dropIndex = calculateDropIndex(
|
|
3581
|
-
const
|
|
3582
|
-
if ((
|
|
3583
|
-
|
|
3696
|
+
const f = dropTarget, b = getOrientation(f) === "vertical" ? h.clientY + ((_ = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : _.scrollY) : h.clientX;
|
|
3697
|
+
dropIndex = calculateDropIndex(b, possiblePositions);
|
|
3698
|
+
const y = d, B = f.getAttribute("data-block-id"), E = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
|
|
3699
|
+
if ((y == null ? void 0 : y._id) === B || !E) {
|
|
3700
|
+
m();
|
|
3584
3701
|
return;
|
|
3585
3702
|
}
|
|
3586
|
-
if (!has(
|
|
3587
|
-
a(
|
|
3703
|
+
if (!has(y, "_id")) {
|
|
3704
|
+
a(y, B === "canvas" ? null : B, dropIndex), setTimeout(m, 300);
|
|
3588
3705
|
return;
|
|
3589
3706
|
}
|
|
3590
|
-
let w =
|
|
3591
|
-
w === null && (w =
|
|
3707
|
+
let w = f.getAttribute("data-block-id");
|
|
3708
|
+
w === null && (w = h.target.parentElement.getAttribute("data-block-id")), c([y._id], w === "canvas" ? null : w, dropIndex), m(), setTimeout(removePlaceholder, 300);
|
|
3592
3709
|
},
|
|
3593
|
-
onDragEnter: (
|
|
3594
|
-
const
|
|
3710
|
+
onDragEnter: (h) => {
|
|
3711
|
+
const f = h, x = f.target;
|
|
3595
3712
|
dropTarget = x;
|
|
3596
|
-
const
|
|
3597
|
-
u(
|
|
3713
|
+
const b = x.getAttribute("data-block-id"), y = x.getAttribute("data-dnd-dragged") !== "yes";
|
|
3714
|
+
u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(x), r(!0), l(""), i([]);
|
|
3598
3715
|
},
|
|
3599
|
-
onDragLeave: (
|
|
3600
|
-
|
|
3716
|
+
onDragLeave: (h) => {
|
|
3717
|
+
h.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
|
|
3601
3718
|
}
|
|
3602
3719
|
};
|
|
3603
3720
|
};
|
|
@@ -3619,17 +3736,17 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3619
3736
|
const g = u.getAttribute("data-block-type");
|
|
3620
3737
|
if (!g || !r.includes(g))
|
|
3621
3738
|
return;
|
|
3622
|
-
const
|
|
3623
|
-
if (!
|
|
3624
|
-
o.on("update", ({ editor:
|
|
3625
|
-
console.log(
|
|
3739
|
+
const m = u.getAttribute("data-block-id");
|
|
3740
|
+
if (!m) return;
|
|
3741
|
+
o.on("update", ({ editor: f }) => {
|
|
3742
|
+
console.log(f.getHTML());
|
|
3626
3743
|
}), o.on("blur", () => {
|
|
3627
3744
|
console.log("blur");
|
|
3628
|
-
const
|
|
3629
|
-
a([
|
|
3630
|
-
}), i(
|
|
3631
|
-
const
|
|
3632
|
-
o.commands.setContent(
|
|
3745
|
+
const f = o.getHTML();
|
|
3746
|
+
a([m], { content: f }), n.style.display = "none", u.style.visibility = "visible";
|
|
3747
|
+
}), i(m);
|
|
3748
|
+
const h = d(m).content;
|
|
3749
|
+
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);
|
|
3633
3750
|
},
|
|
3634
3751
|
[l, c, d, i, a, o, n]
|
|
3635
3752
|
);
|
|
@@ -3668,19 +3785,19 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3668
3785
|
setTimeout(() => {
|
|
3669
3786
|
if (!isEmpty(a))
|
|
3670
3787
|
return;
|
|
3671
|
-
const
|
|
3672
|
-
if (
|
|
3673
|
-
const x =
|
|
3788
|
+
const f = getElementByDataBlockId(n, first(r));
|
|
3789
|
+
if (f) {
|
|
3790
|
+
const x = f.getAttribute("data-style-prop");
|
|
3674
3791
|
if (x) {
|
|
3675
|
-
const
|
|
3676
|
-
l([{ id:
|
|
3792
|
+
const b = f.getAttribute("data-style-id"), y = f.getAttribute("data-block-parent");
|
|
3793
|
+
l([{ id: b, prop: x, blockId: y }]);
|
|
3677
3794
|
}
|
|
3678
3795
|
}
|
|
3679
3796
|
}, 100);
|
|
3680
3797
|
}, [n, r, l, a]);
|
|
3681
3798
|
const c = useEditor({
|
|
3682
3799
|
extensions: [StarterKit]
|
|
3683
|
-
}), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(),
|
|
3800
|
+
}), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(), h = useDnd();
|
|
3684
3801
|
return /* @__PURE__ */ jsx(
|
|
3685
3802
|
"div",
|
|
3686
3803
|
{
|
|
@@ -3689,18 +3806,18 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3689
3806
|
onClick: u,
|
|
3690
3807
|
onDoubleClick: p,
|
|
3691
3808
|
onMouseMove: g,
|
|
3692
|
-
onMouseLeave:
|
|
3693
|
-
...omit(
|
|
3694
|
-
className: "relative h-full max-w-full p-px " + (
|
|
3809
|
+
onMouseLeave: m,
|
|
3810
|
+
...omit(h, "isDragging"),
|
|
3811
|
+
className: "relative h-full max-w-full p-px " + (h.isDragging ? "dragging" : ""),
|
|
3695
3812
|
children: o
|
|
3696
3813
|
}
|
|
3697
3814
|
);
|
|
3698
3815
|
}, getElementByDataBlockId = (o, n) => o.querySelector(`[data-block-id="${n}"]`), HeadTags = () => {
|
|
3699
3816
|
const [o] = useTheme(), n = useThemeOptions(), [r] = useSelectedBlockIds(), [a] = useDarkMode(), [l] = useSelectedStylingBlocks(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), { document: d, window: p } = useFrame(), [u] = useState(d == null ? void 0 : d.getElementById("highlighted-block")), [g] = useState(
|
|
3700
3817
|
d == null ? void 0 : d.getElementById("selected-block")
|
|
3701
|
-
), [f] = useState(
|
|
3702
|
-
d == null ? void 0 : d.getElementById("selected-styling-block")
|
|
3703
3818
|
), [m] = useState(
|
|
3819
|
+
d == null ? void 0 : d.getElementById("selected-styling-block")
|
|
3820
|
+
), [h] = useState(
|
|
3704
3821
|
d == null ? void 0 : d.getElementById("dragged-block")
|
|
3705
3822
|
);
|
|
3706
3823
|
useEffect(() => {
|
|
@@ -3725,41 +3842,41 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3725
3842
|
forms,
|
|
3726
3843
|
aspectRatio,
|
|
3727
3844
|
containerQueries,
|
|
3728
|
-
plugin(function({ addBase:
|
|
3729
|
-
|
|
3845
|
+
plugin(function({ addBase: b, theme: y }) {
|
|
3846
|
+
b({
|
|
3730
3847
|
"h1,h2,h3,h4,h5,h6": {
|
|
3731
|
-
fontFamily:
|
|
3848
|
+
fontFamily: y("fontFamily.heading")
|
|
3732
3849
|
},
|
|
3733
3850
|
body: {
|
|
3734
|
-
fontFamily:
|
|
3735
|
-
color:
|
|
3736
|
-
backgroundColor:
|
|
3851
|
+
fontFamily: y("fontFamily.body"),
|
|
3852
|
+
color: y("colors.foreground"),
|
|
3853
|
+
backgroundColor: y("colors.background")
|
|
3737
3854
|
}
|
|
3738
3855
|
});
|
|
3739
3856
|
})
|
|
3740
3857
|
]
|
|
3741
3858
|
});
|
|
3742
3859
|
}, [o, n, p]), useEffect(() => {
|
|
3743
|
-
g && (g.textContent = `${map(r, (
|
|
3860
|
+
g && (g.textContent = `${map(r, (b) => `[data-block-id="${b}"]`).join(",")}{
|
|
3744
3861
|
outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
|
|
3745
3862
|
}`);
|
|
3746
3863
|
}, [r, g]), useEffect(() => {
|
|
3747
|
-
|
|
3748
|
-
}, [i,
|
|
3864
|
+
h.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
|
|
3865
|
+
}, [i, h]), useEffect(() => {
|
|
3749
3866
|
u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
|
|
3750
3867
|
}, [u]), useEffect(() => {
|
|
3751
|
-
|
|
3868
|
+
m && (m.textContent = `${map(l, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
|
|
3752
3869
|
outline: 1px solid orange !important; outline-offset: -1px;
|
|
3753
3870
|
}`);
|
|
3754
|
-
}, [l,
|
|
3871
|
+
}, [l, m]), useEffect(() => {
|
|
3755
3872
|
d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
|
|
3756
3873
|
}, [c, d]);
|
|
3757
|
-
const
|
|
3874
|
+
const f = useMemo(
|
|
3758
3875
|
() => getChaiThemeCssVariables(o),
|
|
3759
3876
|
[o]
|
|
3760
3877
|
), x = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
|
|
3761
3878
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3762
|
-
/* @__PURE__ */ jsx("style", { id: "chai-theme", children:
|
|
3879
|
+
/* @__PURE__ */ jsx("style", { id: "chai-theme", children: f }),
|
|
3763
3880
|
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: x } })
|
|
3764
3881
|
] });
|
|
3765
3882
|
}, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
|
|
@@ -3837,13 +3954,13 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3837
3954
|
[o]
|
|
3838
3955
|
);
|
|
3839
3956
|
}, BlockRenderer = ({ blockAtom: o, children: n }) => {
|
|
3840
|
-
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),
|
|
3957
|
+
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(
|
|
3841
3958
|
() => u ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
|
|
3842
3959
|
[r, l, a, d, u]
|
|
3843
|
-
),
|
|
3960
|
+
), h = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), f = useMemo(
|
|
3844
3961
|
() => c(r._id, getBlockRuntimeProps(r._type)),
|
|
3845
3962
|
[r._id, r._type, c, getBlockRuntimeProps]
|
|
3846
|
-
), x = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]),
|
|
3963
|
+
), x = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), b = useMemo(
|
|
3847
3964
|
() => ({
|
|
3848
3965
|
blockProps: {
|
|
3849
3966
|
"data-block-id": r._id,
|
|
@@ -3851,9 +3968,9 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3851
3968
|
},
|
|
3852
3969
|
inBuilder: !0,
|
|
3853
3970
|
lang: l || i,
|
|
3854
|
-
...f,
|
|
3855
3971
|
...m,
|
|
3856
3972
|
...h,
|
|
3973
|
+
...f,
|
|
3857
3974
|
...x
|
|
3858
3975
|
}),
|
|
3859
3976
|
[
|
|
@@ -3861,13 +3978,13 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3861
3978
|
r._type,
|
|
3862
3979
|
l,
|
|
3863
3980
|
i,
|
|
3864
|
-
f,
|
|
3865
3981
|
m,
|
|
3866
3982
|
h,
|
|
3983
|
+
f,
|
|
3867
3984
|
x
|
|
3868
3985
|
]
|
|
3869
3986
|
);
|
|
3870
|
-
return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...
|
|
3987
|
+
return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...b, children: n }) });
|
|
3871
3988
|
}, PartialBlocksRenderer = ({ partialBlockId: o }) => {
|
|
3872
3989
|
const { getPartailBlocks: n } = usePartailBlocksStore(), r = useMemo(() => n(o), [n, o]), a = useMemo(() => splitAtom(atom$1(r)), [r]);
|
|
3873
3990
|
return isEmpty(r) ? null : /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: r });
|
|
@@ -3896,11 +4013,11 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3896
4013
|
if (d < n) {
|
|
3897
4014
|
const u = parseFloat((d / n).toFixed(2).toString());
|
|
3898
4015
|
let g = {};
|
|
3899
|
-
const
|
|
4016
|
+
const m = p * u, h = d * u;
|
|
3900
4017
|
p && (g = {
|
|
3901
4018
|
// Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
|
|
3902
|
-
height: 100 + (p -
|
|
3903
|
-
width: 100 + (d -
|
|
4019
|
+
height: 100 + (p - m) / m * 100 + "%",
|
|
4020
|
+
width: 100 + (d - h) / h * 100 + "%"
|
|
3904
4021
|
}), i({
|
|
3905
4022
|
position: "relative",
|
|
3906
4023
|
top: 0,
|
|
@@ -3917,7 +4034,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3917
4034
|
c();
|
|
3918
4035
|
}, [n, o, r, c]), l;
|
|
3919
4036
|
}, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
|
|
3920
|
-
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,
|
|
4037
|
+
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, m] = useState([]), [, h] = useState([]), [, f] = useAtom$1(canvasIframeAtom), [x, b] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), B = useBuilderProp("htmlDir", "ltr"), E = (j) => {
|
|
3921
4038
|
p((S) => ({ ...S, width: j }));
|
|
3922
4039
|
};
|
|
3923
4040
|
useEffect(() => {
|
|
@@ -3933,7 +4050,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3933
4050
|
var j, S;
|
|
3934
4051
|
if (a && a.type !== "Multiple" && i.current) {
|
|
3935
4052
|
const C = getElementByDataBlockId(i.current.contentDocument, a._id);
|
|
3936
|
-
C && (w(C) || (S = (j = i.current) == null ? void 0 : j.contentWindow) == null || S.scrollTo({ top: C.offsetTop, behavior: "smooth" }),
|
|
4053
|
+
C && (w(C) || (S = (j = i.current) == null ? void 0 : j.contentWindow) == null || S.scrollTo({ top: C.offsetTop, behavior: "smooth" }), m([C]));
|
|
3937
4054
|
}
|
|
3938
4055
|
}, [a]), useEffect(() => {
|
|
3939
4056
|
if (!isEmpty(x) && i.current) {
|
|
@@ -3941,19 +4058,19 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3941
4058
|
i.current.contentDocument,
|
|
3942
4059
|
first(x).id
|
|
3943
4060
|
);
|
|
3944
|
-
|
|
4061
|
+
h(j ? [j] : [null]);
|
|
3945
4062
|
} else
|
|
3946
|
-
|
|
4063
|
+
h([null]);
|
|
3947
4064
|
}, [x]);
|
|
3948
4065
|
const _ = useMemo(() => {
|
|
3949
4066
|
let j = IframeInitialContent;
|
|
3950
|
-
return j = j.replace("__HTML_DIR__",
|
|
3951
|
-
}, [o,
|
|
4067
|
+
return j = j.replace("__HTML_DIR__", B), o === "offline" && (j = j.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), j;
|
|
4068
|
+
}, [o, B]);
|
|
3952
4069
|
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: E, onResize: E, children: /* @__PURE__ */ jsx(
|
|
3953
4070
|
"div",
|
|
3954
4071
|
{
|
|
3955
4072
|
onClick: () => {
|
|
3956
|
-
r([]),
|
|
4073
|
+
r([]), b([]);
|
|
3957
4074
|
},
|
|
3958
4075
|
onMouseLeave: () => setTimeout(() => l(""), 300),
|
|
3959
4076
|
className: "relative mx-auto h-full w-full overflow-hidden",
|
|
@@ -3961,7 +4078,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3961
4078
|
children: /* @__PURE__ */ jsxs(
|
|
3962
4079
|
ChaiFrame,
|
|
3963
4080
|
{
|
|
3964
|
-
contentDidMount: () =>
|
|
4081
|
+
contentDidMount: () => f(i.current),
|
|
3965
4082
|
ref: i,
|
|
3966
4083
|
id: "canvas-iframe",
|
|
3967
4084
|
style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
|
|
@@ -3978,7 +4095,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3978
4095
|
),
|
|
3979
4096
|
/* @__PURE__ */ jsx(HeadTags, {}),
|
|
3980
4097
|
/* @__PURE__ */ jsx(Provider$1, { children: /* @__PURE__ */ jsxs(Canvas, { children: [
|
|
3981
|
-
|
|
4098
|
+
y ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
|
|
3982
4099
|
/* @__PURE__ */ jsx(AddBlockAtBottom, {}),
|
|
3983
4100
|
/* @__PURE__ */ jsx("br", {}),
|
|
3984
4101
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -4139,63 +4256,63 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4139
4256
|
}
|
|
4140
4257
|
);
|
|
4141
4258
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
4142
|
-
const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), [c, d] = useTheme(), p = useThemeOptions(), { t: u } = useTranslation(), g = (
|
|
4143
|
-
a(
|
|
4144
|
-
},
|
|
4145
|
-
const
|
|
4146
|
-
if (
|
|
4147
|
-
const
|
|
4148
|
-
|
|
4259
|
+
const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), [c, d] = useTheme(), p = useThemeOptions(), { t: u } = useTranslation(), g = (y) => {
|
|
4260
|
+
a(y);
|
|
4261
|
+
}, m = () => {
|
|
4262
|
+
const y = l.find((B) => Object.keys(B)[0] === r);
|
|
4263
|
+
if (y) {
|
|
4264
|
+
const B = Object.values(y)[0];
|
|
4265
|
+
B && typeof B == "object" && "fontFamily" in B && "borderRadius" in B && "colors" in B ? d(B) : console.error("Invalid preset structure:", B);
|
|
4149
4266
|
} else
|
|
4150
4267
|
console.error("Preset not found:", r);
|
|
4151
|
-
},
|
|
4152
|
-
(
|
|
4268
|
+
}, h = useDebouncedCallback(
|
|
4269
|
+
(y, B) => {
|
|
4153
4270
|
d(() => ({
|
|
4154
4271
|
...c,
|
|
4155
4272
|
fontFamily: {
|
|
4156
4273
|
...c.fontFamily,
|
|
4157
|
-
[
|
|
4274
|
+
[y.replace(/font-/g, "")]: B
|
|
4158
4275
|
}
|
|
4159
4276
|
}));
|
|
4160
4277
|
},
|
|
4161
4278
|
[c],
|
|
4162
4279
|
200
|
|
4163
|
-
),
|
|
4164
|
-
(
|
|
4280
|
+
), f = useDebouncedCallback(
|
|
4281
|
+
(y) => {
|
|
4165
4282
|
d(() => ({
|
|
4166
4283
|
...c,
|
|
4167
|
-
borderRadius: `${
|
|
4284
|
+
borderRadius: `${y}px`
|
|
4168
4285
|
}));
|
|
4169
4286
|
},
|
|
4170
4287
|
[c],
|
|
4171
4288
|
200
|
|
4172
4289
|
), x = useDebouncedCallback(
|
|
4173
|
-
(
|
|
4290
|
+
(y, B) => {
|
|
4174
4291
|
d(() => {
|
|
4175
|
-
const E = get(c, `colors.${
|
|
4176
|
-
return n ? set(E, 1,
|
|
4292
|
+
const E = get(c, `colors.${y}`);
|
|
4293
|
+
return n ? set(E, 1, B) : set(E, 0, B), {
|
|
4177
4294
|
...c,
|
|
4178
4295
|
colors: {
|
|
4179
4296
|
...c.colors,
|
|
4180
|
-
[
|
|
4297
|
+
[y]: E
|
|
4181
4298
|
}
|
|
4182
4299
|
};
|
|
4183
4300
|
});
|
|
4184
4301
|
},
|
|
4185
4302
|
[c],
|
|
4186
4303
|
200
|
|
4187
|
-
),
|
|
4188
|
-
const E = get(c, `colors.${
|
|
4304
|
+
), b = (y) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(y.items).map(([B]) => {
|
|
4305
|
+
const E = get(c, `colors.${B}.${n ? 1 : 0}`);
|
|
4189
4306
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
4190
4307
|
/* @__PURE__ */ jsx(
|
|
4191
4308
|
ColorPickerInput,
|
|
4192
4309
|
{
|
|
4193
4310
|
value: E,
|
|
4194
|
-
onChange: (w) => x(
|
|
4311
|
+
onChange: (w) => x(B, w)
|
|
4195
4312
|
}
|
|
4196
4313
|
),
|
|
4197
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children:
|
|
4198
|
-
] },
|
|
4314
|
+
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
|
|
4315
|
+
] }, B);
|
|
4199
4316
|
}) });
|
|
4200
4317
|
return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
4201
4318
|
/* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
@@ -4206,11 +4323,11 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4206
4323
|
"select",
|
|
4207
4324
|
{
|
|
4208
4325
|
value: r,
|
|
4209
|
-
onChange: (
|
|
4326
|
+
onChange: (y) => g(y.target.value),
|
|
4210
4327
|
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",
|
|
4211
4328
|
children: [
|
|
4212
4329
|
/* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
|
|
4213
|
-
Array.isArray(l) && l.map((
|
|
4330
|
+
Array.isArray(l) && l.map((y) => /* @__PURE__ */ jsx("option", { value: Object.keys(y)[0], children: capitalize(Object.keys(y)[0]) }, Object.keys(y)[0]))
|
|
4214
4331
|
]
|
|
4215
4332
|
}
|
|
4216
4333
|
)
|
|
@@ -4221,31 +4338,31 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4221
4338
|
className: "w-full text-sm",
|
|
4222
4339
|
disabled: r === "",
|
|
4223
4340
|
variant: "default",
|
|
4224
|
-
onClick:
|
|
4341
|
+
onClick: m,
|
|
4225
4342
|
children: u("Apply")
|
|
4226
4343
|
}
|
|
4227
4344
|
) })
|
|
4228
4345
|
] }),
|
|
4229
4346
|
/* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
|
|
4230
|
-
(p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([
|
|
4347
|
+
(p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([y, B]) => /* @__PURE__ */ jsx(
|
|
4231
4348
|
FontSelector,
|
|
4232
4349
|
{
|
|
4233
|
-
label:
|
|
4234
|
-
value: c.fontFamily[
|
|
4235
|
-
onChange: (E) =>
|
|
4350
|
+
label: y,
|
|
4351
|
+
value: c.fontFamily[y.replace(/font-/g, "")] || B[Object.keys(B)[0]],
|
|
4352
|
+
onChange: (E) => h(y, E)
|
|
4236
4353
|
},
|
|
4237
|
-
|
|
4354
|
+
y
|
|
4238
4355
|
)) }),
|
|
4239
4356
|
(p == null ? void 0 : p.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
|
|
4240
4357
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Border Radius") }),
|
|
4241
4358
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
|
|
4242
|
-
/* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange:
|
|
4359
|
+
/* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange: f }),
|
|
4243
4360
|
/* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: c.borderRadius })
|
|
4244
4361
|
] })
|
|
4245
4362
|
] }),
|
|
4246
4363
|
(p == null ? void 0 : p.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
|
|
4247
4364
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Colors") }),
|
|
4248
|
-
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((
|
|
4365
|
+
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((y) => b(y)) }, n ? "dark" : "light")
|
|
4249
4366
|
] })
|
|
4250
4367
|
] }),
|
|
4251
4368
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -4336,22 +4453,22 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4336
4453
|
useEffect(() => {
|
|
4337
4454
|
a || c([]), p(o);
|
|
4338
4455
|
}, [a, o]);
|
|
4339
|
-
const u = (
|
|
4340
|
-
(
|
|
4341
|
-
const x = (
|
|
4342
|
-
|
|
4456
|
+
const u = (f) => Array.isArray(f) ? "array" : typeof f == "object" && f !== null ? "object" : "value", g = React.useCallback(
|
|
4457
|
+
(f) => {
|
|
4458
|
+
const x = (b) => r === "value" ? b === "value" || b === "object" : r === "array" ? b === "array" : b === r;
|
|
4459
|
+
f.type === "object" ? (c((b) => [...b, f.key]), p(f.value)) : x(f.type) && (n([...i, f.key].join(".")), l(!1));
|
|
4343
4460
|
},
|
|
4344
4461
|
[i, n, r]
|
|
4345
|
-
),
|
|
4462
|
+
), m = React.useCallback(() => {
|
|
4346
4463
|
if (i.length > 0) {
|
|
4347
|
-
const
|
|
4348
|
-
c(
|
|
4464
|
+
const f = i.slice(0, -1);
|
|
4465
|
+
c(f), p(f.reduce((x, b) => x[b], o));
|
|
4349
4466
|
}
|
|
4350
|
-
}, [i, o]),
|
|
4351
|
-
key:
|
|
4467
|
+
}, [i, o]), h = React.useMemo(() => Object.entries(d).map(([f, x]) => ({
|
|
4468
|
+
key: f,
|
|
4352
4469
|
value: x,
|
|
4353
4470
|
type: u(x)
|
|
4354
|
-
})).filter((
|
|
4471
|
+
})).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]);
|
|
4355
4472
|
return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
|
|
4356
4473
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4357
4474
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
@@ -4372,37 +4489,37 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4372
4489
|
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
4373
4490
|
/* @__PURE__ */ jsx(CommandEmpty, { children: "No option found." }),
|
|
4374
4491
|
/* @__PURE__ */ jsxs(CommandGroup, { children: [
|
|
4375
|
-
i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect:
|
|
4492
|
+
i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: m, className: "flex items-center text-sm", children: [
|
|
4376
4493
|
/* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
|
|
4377
4494
|
"Back"
|
|
4378
4495
|
] }),
|
|
4379
|
-
|
|
4496
|
+
h.map((f) => /* @__PURE__ */ jsxs(
|
|
4380
4497
|
CommandItem,
|
|
4381
4498
|
{
|
|
4382
|
-
value:
|
|
4499
|
+
value: f.key,
|
|
4383
4500
|
disabled: !1,
|
|
4384
|
-
onSelect: () => g(
|
|
4501
|
+
onSelect: () => g(f),
|
|
4385
4502
|
className: "flex items-center justify-between",
|
|
4386
4503
|
children: [
|
|
4387
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
4504
|
+
/* @__PURE__ */ jsx("span", { children: f.key }),
|
|
4388
4505
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4389
|
-
r === "object" &&
|
|
4506
|
+
r === "object" && f.type === "object" && /* @__PURE__ */ jsx(
|
|
4390
4507
|
Button,
|
|
4391
4508
|
{
|
|
4392
4509
|
size: "sm",
|
|
4393
4510
|
variant: "ghost",
|
|
4394
4511
|
className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
|
|
4395
4512
|
onClick: (x) => {
|
|
4396
|
-
x.stopPropagation(), n([...i,
|
|
4513
|
+
x.stopPropagation(), n([...i, f.key].join(".")), l(!1);
|
|
4397
4514
|
},
|
|
4398
4515
|
children: "Select"
|
|
4399
4516
|
}
|
|
4400
4517
|
),
|
|
4401
|
-
(
|
|
4518
|
+
(f.type === "object" || f.type === "array") && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 opacity-50" }) })
|
|
4402
4519
|
] })
|
|
4403
4520
|
]
|
|
4404
4521
|
},
|
|
4405
|
-
|
|
4522
|
+
f.key
|
|
4406
4523
|
))
|
|
4407
4524
|
] })
|
|
4408
4525
|
] })
|
|
@@ -4561,16 +4678,16 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4561
4678
|
const c = useRef(null), d = useRef(a || ""), p = usePageExternalData();
|
|
4562
4679
|
useEffect(() => {
|
|
4563
4680
|
if (o) {
|
|
4564
|
-
const
|
|
4565
|
-
return
|
|
4681
|
+
const m = document.createElement("style");
|
|
4682
|
+
return m.id = "rte-modal-styles", m.innerHTML = `
|
|
4566
4683
|
/* Ensure the NestedPathSelector popover appears above the dialog */
|
|
4567
4684
|
.rte-path-selector + [data-radix-popper-content-wrapper],
|
|
4568
4685
|
[data-radix-popper-content-wrapper] {
|
|
4569
4686
|
z-index: 9999 !important;
|
|
4570
4687
|
}
|
|
4571
|
-
`, document.head.appendChild(
|
|
4572
|
-
const
|
|
4573
|
-
|
|
4688
|
+
`, document.head.appendChild(m), () => {
|
|
4689
|
+
const h = document.getElementById("rte-modal-styles");
|
|
4690
|
+
h && h.remove();
|
|
4574
4691
|
};
|
|
4575
4692
|
}
|
|
4576
4693
|
}, [o]);
|
|
@@ -4591,13 +4708,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4591
4708
|
Underline
|
|
4592
4709
|
],
|
|
4593
4710
|
content: a || "",
|
|
4594
|
-
onUpdate: ({ editor:
|
|
4595
|
-
const
|
|
4596
|
-
l(
|
|
4711
|
+
onUpdate: ({ editor: m }) => {
|
|
4712
|
+
const h = m.getHTML();
|
|
4713
|
+
l(h);
|
|
4597
4714
|
},
|
|
4598
|
-
onBlur: ({ editor:
|
|
4599
|
-
const
|
|
4600
|
-
i(r,
|
|
4715
|
+
onBlur: ({ editor: m }) => {
|
|
4716
|
+
const h = m.getHTML();
|
|
4717
|
+
i(r, h);
|
|
4601
4718
|
},
|
|
4602
4719
|
editorProps: {
|
|
4603
4720
|
attributes: {
|
|
@@ -4612,22 +4729,22 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4612
4729
|
}, [o, u]), useEffect(() => {
|
|
4613
4730
|
c.current && u && (c.current.__chaiRTE = u);
|
|
4614
4731
|
}, [u, o]);
|
|
4615
|
-
const g = (
|
|
4732
|
+
const g = (m) => {
|
|
4616
4733
|
if (!u) return;
|
|
4617
|
-
const
|
|
4734
|
+
const h = `{{${m}}}`;
|
|
4618
4735
|
u.commands.focus();
|
|
4619
|
-
const { from:
|
|
4620
|
-
if (
|
|
4621
|
-
u.chain().deleteSelection().insertContent(
|
|
4736
|
+
const { from: f, to: x } = u.state.selection;
|
|
4737
|
+
if (f !== x)
|
|
4738
|
+
u.chain().deleteSelection().insertContent(h).run();
|
|
4622
4739
|
else {
|
|
4623
|
-
const { state:
|
|
4740
|
+
const { state: y } = u, B = y.selection.from, E = y.doc.textBetween(Math.max(0, B - 1), B), w = y.doc.textBetween(B, Math.min(B + 1, y.doc.content.size));
|
|
4624
4741
|
let _ = "";
|
|
4625
|
-
|
|
4742
|
+
B > 0 && E !== " " && !/[.,!?;:]/.test(E) && (_ = " ");
|
|
4626
4743
|
let j = "";
|
|
4627
|
-
w && w !== " " && !/[.,!?;:]/.test(w) && (j = " "), u.chain().insertContent(_ +
|
|
4744
|
+
w && w !== " " && !/[.,!?;:]/.test(w) && (j = " "), u.chain().insertContent(_ + h + j).run();
|
|
4628
4745
|
}
|
|
4629
4746
|
};
|
|
4630
|
-
return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (
|
|
4747
|
+
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: [
|
|
4631
4748
|
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center justify-between pr-8", children: [
|
|
4632
4749
|
/* @__PURE__ */ jsx("span", { children: "Rich Text Editor" }),
|
|
4633
4750
|
p && Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -4659,12 +4776,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4659
4776
|
Underline
|
|
4660
4777
|
],
|
|
4661
4778
|
content: r || "",
|
|
4662
|
-
onUpdate: ({ editor:
|
|
4663
|
-
const x =
|
|
4779
|
+
onUpdate: ({ editor: f }) => {
|
|
4780
|
+
const x = f.getHTML();
|
|
4664
4781
|
a(x), c || u(x);
|
|
4665
4782
|
},
|
|
4666
|
-
onBlur: ({ editor:
|
|
4667
|
-
const x =
|
|
4783
|
+
onBlur: ({ editor: f }) => {
|
|
4784
|
+
const x = f.getHTML();
|
|
4668
4785
|
l(o, x);
|
|
4669
4786
|
},
|
|
4670
4787
|
editorProps: {
|
|
@@ -4678,9 +4795,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4678
4795
|
}, [g]), useEffect(() => {
|
|
4679
4796
|
u(r || "");
|
|
4680
4797
|
}, [r]);
|
|
4681
|
-
const
|
|
4682
|
-
a(
|
|
4683
|
-
},
|
|
4798
|
+
const m = (f) => {
|
|
4799
|
+
a(f);
|
|
4800
|
+
}, h = () => {
|
|
4684
4801
|
d(!1), g && g.commands.setContent(p);
|
|
4685
4802
|
};
|
|
4686
4803
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -4692,10 +4809,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4692
4809
|
RTEModal,
|
|
4693
4810
|
{
|
|
4694
4811
|
isOpen: c,
|
|
4695
|
-
onClose:
|
|
4812
|
+
onClose: h,
|
|
4696
4813
|
id: o,
|
|
4697
4814
|
value: p,
|
|
4698
|
-
onChange:
|
|
4815
|
+
onChange: m,
|
|
4699
4816
|
onBlur: l
|
|
4700
4817
|
}
|
|
4701
4818
|
)
|
|
@@ -4706,13 +4823,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4706
4823
|
onChange: r
|
|
4707
4824
|
}) => {
|
|
4708
4825
|
var L;
|
|
4709
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [
|
|
4826
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [f, x] = useState([]), [b, y] = useState(-1), B = useRef(null), E = (L = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : L.name;
|
|
4710
4827
|
useEffect(() => {
|
|
4711
|
-
if (
|
|
4828
|
+
if (h(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4712
4829
|
const v = split(o, ":"), k = get(v, 1, "page") || "page";
|
|
4713
4830
|
g(k), (async () => {
|
|
4714
|
-
const
|
|
4715
|
-
|
|
4831
|
+
const A = await l(k, [get(v, 2, "page")]);
|
|
4832
|
+
A && Array.isArray(A) && h(get(A, [0, "name"], ""));
|
|
4716
4833
|
})();
|
|
4717
4834
|
}, [o]);
|
|
4718
4835
|
const w = useDebouncedCallback(
|
|
@@ -4723,24 +4840,24 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4723
4840
|
const k = await l(u, v);
|
|
4724
4841
|
x(k);
|
|
4725
4842
|
}
|
|
4726
|
-
c(!1),
|
|
4843
|
+
c(!1), y(-1);
|
|
4727
4844
|
},
|
|
4728
4845
|
[u],
|
|
4729
4846
|
300
|
|
4730
4847
|
), _ = (v) => {
|
|
4731
4848
|
const k = ["pageType", u, v.id];
|
|
4732
|
-
k[1] && (r(k.join(":")),
|
|
4849
|
+
k[1] && (r(k.join(":")), h(v.name), p(!1), x([]), y(-1));
|
|
4733
4850
|
}, j = (v) => {
|
|
4734
4851
|
switch (v.key) {
|
|
4735
4852
|
case "ArrowDown":
|
|
4736
|
-
v.preventDefault(),
|
|
4853
|
+
v.preventDefault(), y((k) => k < f.length - 1 ? k + 1 : k);
|
|
4737
4854
|
break;
|
|
4738
4855
|
case "ArrowUp":
|
|
4739
|
-
v.preventDefault(),
|
|
4856
|
+
v.preventDefault(), y((k) => k > 0 ? k - 1 : k);
|
|
4740
4857
|
break;
|
|
4741
4858
|
case "Enter":
|
|
4742
|
-
if (v.preventDefault(),
|
|
4743
|
-
|
|
4859
|
+
if (v.preventDefault(), f.length === 0) return;
|
|
4860
|
+
b >= 0 && _(f[b]);
|
|
4744
4861
|
break;
|
|
4745
4862
|
case "Escape":
|
|
4746
4863
|
v.preventDefault(), S();
|
|
@@ -4748,15 +4865,15 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4748
4865
|
}
|
|
4749
4866
|
};
|
|
4750
4867
|
useEffect(() => {
|
|
4751
|
-
if (
|
|
4752
|
-
const v =
|
|
4868
|
+
if (b >= 0 && B.current) {
|
|
4869
|
+
const v = B.current.children[b];
|
|
4753
4870
|
v == null || v.scrollIntoView({ block: "nearest" });
|
|
4754
4871
|
}
|
|
4755
|
-
}, [
|
|
4872
|
+
}, [b]);
|
|
4756
4873
|
const S = () => {
|
|
4757
|
-
|
|
4874
|
+
h(""), x([]), y(-1), p(!1), r("");
|
|
4758
4875
|
}, C = (v) => {
|
|
4759
|
-
|
|
4876
|
+
h(v), p(!isEmpty(v)), c(!0), w(v);
|
|
4760
4877
|
};
|
|
4761
4878
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4762
4879
|
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (v) => g(v.target.value), children: map(n, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
|
|
@@ -4765,28 +4882,28 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4765
4882
|
"input",
|
|
4766
4883
|
{
|
|
4767
4884
|
type: "text",
|
|
4768
|
-
value:
|
|
4885
|
+
value: m,
|
|
4769
4886
|
onChange: (v) => C(v.target.value),
|
|
4770
4887
|
onKeyDown: j,
|
|
4771
4888
|
placeholder: a(`Search ${E ?? ""}`),
|
|
4772
4889
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4773
4890
|
}
|
|
4774
4891
|
),
|
|
4775
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children:
|
|
4892
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
|
|
4776
4893
|
] }),
|
|
4777
|
-
(i || !isEmpty(
|
|
4894
|
+
(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: [
|
|
4778
4895
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
4779
4896
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
4780
|
-
] }) : d && isEmpty(
|
|
4897
|
+
] }) : d && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4781
4898
|
a("No results found for"),
|
|
4782
4899
|
' "',
|
|
4783
|
-
|
|
4900
|
+
m,
|
|
4784
4901
|
'"'
|
|
4785
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref:
|
|
4902
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: B, children: map(f == null ? void 0 : f.slice(0, 20), (v, k) => /* @__PURE__ */ jsxs(
|
|
4786
4903
|
"li",
|
|
4787
4904
|
{
|
|
4788
4905
|
onClick: () => _(v),
|
|
4789
|
-
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : k ===
|
|
4906
|
+
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : k === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
4790
4907
|
children: [
|
|
4791
4908
|
v.name,
|
|
4792
4909
|
" ",
|
|
@@ -4879,30 +4996,30 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4879
4996
|
}, [a]), useEffect(() => {
|
|
4880
4997
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
|
|
4881
4998
|
}, [o, u]);
|
|
4882
|
-
const
|
|
4999
|
+
const m = () => {
|
|
4883
5000
|
const x = findIndex(u, { _id: g });
|
|
4884
5001
|
if (x > -1) {
|
|
4885
|
-
const
|
|
4886
|
-
if (!
|
|
4887
|
-
n({ ...o, currentSlide:
|
|
5002
|
+
const b = (x + 1) % u.length, y = get(u, [b, "_id"]);
|
|
5003
|
+
if (!y) return;
|
|
5004
|
+
n({ ...o, currentSlide: y }), c([y]);
|
|
4888
5005
|
}
|
|
4889
|
-
},
|
|
5006
|
+
}, h = () => {
|
|
4890
5007
|
const x = findIndex(u, { _id: g });
|
|
4891
5008
|
if (x > -1) {
|
|
4892
|
-
const
|
|
4893
|
-
if (!
|
|
4894
|
-
n({ ...o, currentSlide:
|
|
5009
|
+
const b = (x - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
|
|
5010
|
+
if (!y) return;
|
|
5011
|
+
n({ ...o, currentSlide: y }), c([y]);
|
|
4895
5012
|
}
|
|
4896
|
-
},
|
|
5013
|
+
}, f = () => {
|
|
4897
5014
|
const x = i(
|
|
4898
5015
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4899
5016
|
p == null ? void 0 : p._id
|
|
4900
|
-
),
|
|
4901
|
-
|
|
5017
|
+
), b = x == null ? void 0 : x._id;
|
|
5018
|
+
b && (n({ ...o, currentSlide: b }), c([b]));
|
|
4902
5019
|
};
|
|
4903
5020
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4904
5021
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
4905
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
5022
|
+
/* @__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]" }) }),
|
|
4906
5023
|
/* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
|
|
4907
5024
|
/* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
|
|
4908
5025
|
" ",
|
|
@@ -4911,11 +5028,11 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4911
5028
|
"/",
|
|
4912
5029
|
u.length
|
|
4913
5030
|
] }) : "-" }),
|
|
4914
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
5031
|
+
/* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
|
|
4915
5032
|
/* @__PURE__ */ jsxs(
|
|
4916
5033
|
"button",
|
|
4917
5034
|
{
|
|
4918
|
-
onClick:
|
|
5035
|
+
onClick: f,
|
|
4919
5036
|
className: "flex w-full items-center justify-center gap-x-1 rounded bg-gray-200 p-1.5 text-xs font-medium leading-tight hover:opacity-80",
|
|
4920
5037
|
children: [
|
|
4921
5038
|
/* @__PURE__ */ jsx(PlusCircle, { className: "h-3 w-3 stroke-[2]" }),
|
|
@@ -4977,8 +5094,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4977
5094
|
className: "text-xs",
|
|
4978
5095
|
pattern: "[0-9]*",
|
|
4979
5096
|
onChange: (x) => {
|
|
4980
|
-
let
|
|
4981
|
-
|
|
5097
|
+
let b = x.target.value;
|
|
5098
|
+
b.length && (b = b.replace("-", "")), n({ ...o, autoplayInterval: b });
|
|
4982
5099
|
}
|
|
4983
5100
|
}
|
|
4984
5101
|
)
|
|
@@ -5003,7 +5120,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5003
5120
|
),
|
|
5004
5121
|
/* @__PURE__ */ jsx(Button, { onClick: d, size: "sm", variant: "outline", className: "w-fit", children: r("Open code editor") })
|
|
5005
5122
|
] });
|
|
5006
|
-
},
|
|
5123
|
+
}, JSONFormFieldTemplate = ({
|
|
5007
5124
|
id: o,
|
|
5008
5125
|
classNames: n,
|
|
5009
5126
|
label: r,
|
|
@@ -5015,14 +5132,14 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5015
5132
|
required: p,
|
|
5016
5133
|
schema: u,
|
|
5017
5134
|
formData: g,
|
|
5018
|
-
onChange:
|
|
5135
|
+
onChange: m
|
|
5019
5136
|
}) => {
|
|
5020
|
-
const { selectedLang:
|
|
5137
|
+
const { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), b = isEmpty$1(x) ? "" : isEmpty$1(h) ? f : h, y = get$1(LANGUAGES, b, b), B = usePageExternalData(), E = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = get$1(w, [E == null ? void 0 : E._type, "i18nProps"], []) || [], [j, S] = useState(null), C = useCallback(
|
|
5021
5138
|
(k) => {
|
|
5022
|
-
const
|
|
5139
|
+
const A = (N) => /[.,!?;:]/.test(N), T = (N, D, $) => {
|
|
5023
5140
|
let R = "", O = "";
|
|
5024
5141
|
const M = D > 0 ? N[D - 1] : "", H = D < N.length ? N[D] : "";
|
|
5025
|
-
return D > 0 && (M === "." || !
|
|
5142
|
+
return D > 0 && (M === "." || !A(M) && M !== " ") && (R = " "), D < N.length && !A(H) && H !== " " && (O = " "), {
|
|
5026
5143
|
text: R + $ + O,
|
|
5027
5144
|
prefixLength: R.length,
|
|
5028
5145
|
suffixLength: O.length
|
|
@@ -5041,25 +5158,25 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5041
5158
|
else {
|
|
5042
5159
|
const { state: M } = N, H = M.selection.from, F = M.doc.textBetween(Math.max(0, H - 1), H), U = M.doc.textBetween(H, Math.min(H + 1, M.doc.content.size));
|
|
5043
5160
|
let z = "";
|
|
5044
|
-
H > 0 && F !== " " && !
|
|
5161
|
+
H > 0 && F !== " " && !A(F) && (z = " ");
|
|
5045
5162
|
let W = "";
|
|
5046
|
-
U && U !== " " && !
|
|
5163
|
+
U && U !== " " && !A(U) && (W = " "), N.chain().insertContent(z + D + W).run();
|
|
5047
5164
|
}
|
|
5048
|
-
setTimeout(() =>
|
|
5165
|
+
setTimeout(() => m(N.getHTML(), {}, o), 100);
|
|
5049
5166
|
return;
|
|
5050
5167
|
}
|
|
5051
5168
|
} else {
|
|
5052
5169
|
const N = I, D = N.selectionStart || 0, $ = N.value || "", R = N.selectionEnd || D;
|
|
5053
5170
|
if (R > D) {
|
|
5054
5171
|
const U = `{{${k}}}`, { text: z } = T($, D, U), W = $.slice(0, D) + z + $.slice(R);
|
|
5055
|
-
|
|
5172
|
+
m(W, {}, o);
|
|
5056
5173
|
return;
|
|
5057
5174
|
}
|
|
5058
5175
|
const M = `{{${k}}}`, { text: H } = T($, D, M), F = $.slice(0, D) + H + $.slice(D);
|
|
5059
|
-
|
|
5176
|
+
m(F, {}, o);
|
|
5060
5177
|
}
|
|
5061
5178
|
},
|
|
5062
|
-
[o,
|
|
5179
|
+
[o, m, g, E == null ? void 0 : E._id]
|
|
5063
5180
|
);
|
|
5064
5181
|
if (d)
|
|
5065
5182
|
return null;
|
|
@@ -5098,11 +5215,11 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5098
5215
|
" ",
|
|
5099
5216
|
v && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
|
|
5100
5217
|
" ",
|
|
5101
|
-
|
|
5218
|
+
y
|
|
5102
5219
|
] }),
|
|
5103
5220
|
p && u.type !== "object" ? " *" : null
|
|
5104
5221
|
] }),
|
|
5105
|
-
u.type === "string" && !u.enum && !u.oneOf &&
|
|
5222
|
+
u.type === "string" && !u.enum && !u.oneOf && B && /* @__PURE__ */ jsx(NestedPathSelector, { data: B, onSelect: C, dataType: "value" })
|
|
5106
5223
|
] }),
|
|
5107
5224
|
c,
|
|
5108
5225
|
a,
|
|
@@ -5115,8 +5232,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5115
5232
|
/* @__PURE__ */ jsx("span", { children: "Add" })
|
|
5116
5233
|
] }) }), JSONForm = memo(({ blockId: o, schema: n, uiSchema: r, formData: a, onChange: l }) => {
|
|
5117
5234
|
const { selectedLang: i } = useLanguages(), [c] = useAtom$1(chaiRjsfWidgetsAtom), [d] = useAtom$1(chaiRjsfFieldsAtom), [p] = useAtom$1(chaiRjsfTemplatesAtom), u = useThrottledCallback(
|
|
5118
|
-
async ({ formData: g },
|
|
5119
|
-
l({ formData: g },
|
|
5235
|
+
async ({ formData: g }, m) => {
|
|
5236
|
+
l({ formData: g }, m);
|
|
5120
5237
|
},
|
|
5121
5238
|
[l, i],
|
|
5122
5239
|
400
|
|
@@ -5140,7 +5257,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5140
5257
|
...d
|
|
5141
5258
|
},
|
|
5142
5259
|
templates: {
|
|
5143
|
-
FieldTemplate:
|
|
5260
|
+
FieldTemplate: JSONFormFieldTemplate,
|
|
5144
5261
|
ButtonTemplates: {
|
|
5145
5262
|
AddButton: CustomAddButton
|
|
5146
5263
|
},
|
|
@@ -5155,10 +5272,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5155
5272
|
uiSchema: r,
|
|
5156
5273
|
schema: n,
|
|
5157
5274
|
formData: a,
|
|
5158
|
-
onChange: ({ formData: g },
|
|
5159
|
-
if (!
|
|
5160
|
-
const
|
|
5161
|
-
u({ formData: g },
|
|
5275
|
+
onChange: ({ formData: g }, m) => {
|
|
5276
|
+
if (!m || o !== (g == null ? void 0 : g._id)) return;
|
|
5277
|
+
const h = take(m.split("."), 2).join(".").replace("root.", "");
|
|
5278
|
+
u({ formData: g }, h);
|
|
5162
5279
|
}
|
|
5163
5280
|
},
|
|
5164
5281
|
i
|
|
@@ -5201,20 +5318,20 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5201
5318
|
}), a;
|
|
5202
5319
|
};
|
|
5203
5320
|
function BlockSettings() {
|
|
5204
|
-
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(),
|
|
5321
|
+
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), f = ({ formData: j }, S, C) => {
|
|
5205
5322
|
S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(j, S) }, C);
|
|
5206
5323
|
}, x = useCallback(
|
|
5207
5324
|
debounce(({ formData: j }, S, C) => {
|
|
5208
|
-
|
|
5325
|
+
f({ formData: j }, S, C), d(j);
|
|
5209
5326
|
}, 1500),
|
|
5210
5327
|
[n == null ? void 0 : n._id, o]
|
|
5211
|
-
),
|
|
5328
|
+
), b = ({ formData: j }, S) => {
|
|
5212
5329
|
S && (r([n._id], { [S]: get(j, S) }), x({ formData: j }, S, { [S]: get(c, S) }));
|
|
5213
|
-
},
|
|
5330
|
+
}, y = ({ formData: j }, S) => {
|
|
5214
5331
|
S && (r([g._id], { [S]: get(j, S) }), x({ formData: j }, S, { [S]: get(c, S) }));
|
|
5215
5332
|
};
|
|
5216
5333
|
keys(get(i, "_bindings", {}));
|
|
5217
|
-
const { schema:
|
|
5334
|
+
const { schema: B, uiSchema: E } = useMemo(() => {
|
|
5218
5335
|
const j = n == null ? void 0 : n._type;
|
|
5219
5336
|
if (j)
|
|
5220
5337
|
return getBlockFormSchemas(j);
|
|
@@ -5248,20 +5365,20 @@ function BlockSettings() {
|
|
|
5248
5365
|
JSONForm,
|
|
5249
5366
|
{
|
|
5250
5367
|
blockId: g == null ? void 0 : g._id,
|
|
5251
|
-
onChange:
|
|
5252
|
-
formData:
|
|
5368
|
+
onChange: y,
|
|
5369
|
+
formData: h,
|
|
5253
5370
|
schema: w,
|
|
5254
5371
|
uiSchema: _
|
|
5255
5372
|
}
|
|
5256
5373
|
) })
|
|
5257
5374
|
] }),
|
|
5258
|
-
isEmpty(
|
|
5375
|
+
isEmpty(B) ? null : /* @__PURE__ */ jsx(
|
|
5259
5376
|
JSONForm,
|
|
5260
5377
|
{
|
|
5261
5378
|
blockId: n == null ? void 0 : n._id,
|
|
5262
|
-
onChange:
|
|
5379
|
+
onChange: b,
|
|
5263
5380
|
formData: i,
|
|
5264
|
-
schema:
|
|
5381
|
+
schema: B,
|
|
5265
5382
|
uiSchema: E
|
|
5266
5383
|
}
|
|
5267
5384
|
),
|
|
@@ -5367,50 +5484,50 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5367
5484
|
canvas: n = !1,
|
|
5368
5485
|
tooltip: r = !0
|
|
5369
5486
|
}) => {
|
|
5370
|
-
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t:
|
|
5371
|
-
u.includes(
|
|
5372
|
-
}, x = (
|
|
5373
|
-
n || l(
|
|
5374
|
-
},
|
|
5375
|
-
return
|
|
5487
|
+
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (y) => {
|
|
5488
|
+
u.includes(y) ? u.length > 2 && g(u.filter((B) => B !== y)) : g((B) => [...B, y]);
|
|
5489
|
+
}, x = (y) => {
|
|
5490
|
+
n || l(y), c(y);
|
|
5491
|
+
}, b = getBreakpointValue(n ? i : a).toLowerCase();
|
|
5492
|
+
return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (y) => /* @__PURE__ */ createElement(
|
|
5376
5493
|
BreakpointCard,
|
|
5377
5494
|
{
|
|
5378
5495
|
canvas: n,
|
|
5379
|
-
...
|
|
5496
|
+
...y,
|
|
5380
5497
|
onClick: x,
|
|
5381
|
-
key:
|
|
5382
|
-
currentBreakpoint:
|
|
5498
|
+
key: y.breakpoint,
|
|
5499
|
+
currentBreakpoint: b
|
|
5383
5500
|
}
|
|
5384
5501
|
)) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
|
|
5385
5502
|
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
|
|
5386
|
-
|
|
5387
|
-
(
|
|
5503
|
+
h.filter((y) => includes(u, toUpper(y.breakpoint))),
|
|
5504
|
+
(y) => /* @__PURE__ */ createElement(
|
|
5388
5505
|
BreakpointCard,
|
|
5389
5506
|
{
|
|
5390
5507
|
canvas: n,
|
|
5391
5508
|
openDelay: o,
|
|
5392
5509
|
tooltip: r,
|
|
5393
|
-
...
|
|
5510
|
+
...y,
|
|
5394
5511
|
onClick: x,
|
|
5395
|
-
key:
|
|
5396
|
-
currentBreakpoint:
|
|
5512
|
+
key: y.breakpoint,
|
|
5513
|
+
currentBreakpoint: b
|
|
5397
5514
|
}
|
|
5398
5515
|
)
|
|
5399
5516
|
) }),
|
|
5400
5517
|
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
5401
5518
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-pointer px-2.5 hover:opacity-80", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "scale-90 transform" }) }) }),
|
|
5402
5519
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
|
|
5403
|
-
/* @__PURE__ */ jsx(DropdownMenuLabel, { children:
|
|
5520
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: m("Screen sizes") }),
|
|
5404
5521
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
5405
|
-
map(
|
|
5522
|
+
map(h, (y) => /* @__PURE__ */ jsx(
|
|
5406
5523
|
DropdownMenuCheckboxItem,
|
|
5407
5524
|
{
|
|
5408
|
-
disabled:
|
|
5409
|
-
onCheckedChange: () =>
|
|
5410
|
-
checked: includes(u, toUpper(
|
|
5411
|
-
children:
|
|
5525
|
+
disabled: y.breakpoint === "xs",
|
|
5526
|
+
onCheckedChange: () => f(toUpper(y.breakpoint)),
|
|
5527
|
+
checked: includes(u, toUpper(y.breakpoint)),
|
|
5528
|
+
children: m(y.title)
|
|
5412
5529
|
},
|
|
5413
|
-
|
|
5530
|
+
y.breakpoint
|
|
5414
5531
|
))
|
|
5415
5532
|
] })
|
|
5416
5533
|
] })
|
|
@@ -5487,12 +5604,12 @@ function Countdown() {
|
|
|
5487
5604
|
const AskAIStyles = ({ blockId: o }) => {
|
|
5488
5605
|
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
|
|
5489
5606
|
useEffect(() => {
|
|
5490
|
-
var
|
|
5491
|
-
(
|
|
5607
|
+
var h;
|
|
5608
|
+
(h = d.current) == null || h.focus();
|
|
5492
5609
|
}, []);
|
|
5493
|
-
const
|
|
5494
|
-
const { usage:
|
|
5495
|
-
!l &&
|
|
5610
|
+
const m = (h) => {
|
|
5611
|
+
const { usage: f } = h || {};
|
|
5612
|
+
!l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
5496
5613
|
};
|
|
5497
5614
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
5498
5615
|
/* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: n("Ask AI") }),
|
|
@@ -5501,12 +5618,12 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5501
5618
|
{
|
|
5502
5619
|
ref: d,
|
|
5503
5620
|
value: i,
|
|
5504
|
-
onChange: (
|
|
5621
|
+
onChange: (h) => c(h.target.value),
|
|
5505
5622
|
placeholder: n("Ask AI to edit styles"),
|
|
5506
5623
|
className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
|
|
5507
5624
|
rows: 4,
|
|
5508
|
-
onKeyDown: (
|
|
5509
|
-
|
|
5625
|
+
onKeyDown: (h) => {
|
|
5626
|
+
h.key === "Enter" && (h.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
|
|
5510
5627
|
}
|
|
5511
5628
|
}
|
|
5512
5629
|
),
|
|
@@ -5516,7 +5633,7 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5516
5633
|
{
|
|
5517
5634
|
disabled: i.trim().length < 5 || a,
|
|
5518
5635
|
onClick: () => {
|
|
5519
|
-
p.current && clearTimeout(p.current), g(void 0), r("styles", o, i,
|
|
5636
|
+
p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m);
|
|
5520
5637
|
},
|
|
5521
5638
|
variant: "default",
|
|
5522
5639
|
className: "w-fit",
|
|
@@ -5548,9 +5665,9 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5548
5665
|
};
|
|
5549
5666
|
function ManualClasses() {
|
|
5550
5667
|
var T;
|
|
5551
|
-
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [
|
|
5552
|
-
const I =
|
|
5553
|
-
u(
|
|
5668
|
+
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), b = (T = first(d)) == null ? void 0 : T.prop, { classes: y } = getSplitChaiClasses(get(p, b, "")), B = y.split(" ").filter((I) => !isEmpty(I)), E = () => {
|
|
5669
|
+
const I = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5670
|
+
u(m, I, !0), x("");
|
|
5554
5671
|
}, [w, _] = useState([]), j = ({ value: I }) => {
|
|
5555
5672
|
const P = I.trim().toLowerCase(), N = P.match(/.+:/g);
|
|
5556
5673
|
let D = [];
|
|
@@ -5573,35 +5690,35 @@ function ManualClasses() {
|
|
|
5573
5690
|
autoCapitalize: "off",
|
|
5574
5691
|
spellCheck: !1,
|
|
5575
5692
|
placeholder: c("Enter classes separated by space"),
|
|
5576
|
-
value:
|
|
5693
|
+
value: f,
|
|
5577
5694
|
onKeyDown: (I) => {
|
|
5578
|
-
I.key === "Enter" &&
|
|
5695
|
+
I.key === "Enter" && f.trim() !== "" && E();
|
|
5579
5696
|
},
|
|
5580
5697
|
onChange: (I, { newValue: P }) => x(P),
|
|
5581
5698
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
5582
5699
|
}),
|
|
5583
|
-
[
|
|
5700
|
+
[f, c, o]
|
|
5584
5701
|
), k = (I) => {
|
|
5585
5702
|
debugger;
|
|
5586
5703
|
const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5587
|
-
g(
|
|
5588
|
-
},
|
|
5704
|
+
g(m, [I]), u(m, P, !0), r(""), l(-1);
|
|
5705
|
+
}, A = () => {
|
|
5589
5706
|
if (navigator.clipboard === void 0) {
|
|
5590
5707
|
toast.error(c("Clipboard not supported"));
|
|
5591
5708
|
return;
|
|
5592
5709
|
}
|
|
5593
|
-
navigator.clipboard.writeText(
|
|
5710
|
+
navigator.clipboard.writeText(B.join(" ")), toast.success(c("Classes copied to clipboard"));
|
|
5594
5711
|
};
|
|
5595
5712
|
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
|
|
5596
5713
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
|
|
5597
5714
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
|
|
5598
5715
|
/* @__PURE__ */ jsx("span", { children: c("Classes") }),
|
|
5599
5716
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5600
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick:
|
|
5717
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: A, className: "cursor-pointer" }) }),
|
|
5601
5718
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
|
|
5602
5719
|
] })
|
|
5603
5720
|
] }),
|
|
5604
|
-
|
|
5721
|
+
h ? /* @__PURE__ */ jsxs(Popover, { children: [
|
|
5605
5722
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
|
|
5606
5723
|
/* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4" }),
|
|
5607
5724
|
/* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
|
|
@@ -5635,13 +5752,13 @@ function ManualClasses() {
|
|
|
5635
5752
|
variant: "outline",
|
|
5636
5753
|
className: "h-6 border-border",
|
|
5637
5754
|
onClick: E,
|
|
5638
|
-
disabled:
|
|
5755
|
+
disabled: f.trim() === "",
|
|
5639
5756
|
size: "sm",
|
|
5640
5757
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
5641
5758
|
}
|
|
5642
5759
|
)
|
|
5643
5760
|
] }),
|
|
5644
|
-
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children:
|
|
5761
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: B.map(
|
|
5645
5762
|
(I, P) => a === P ? /* @__PURE__ */ jsx(
|
|
5646
5763
|
"input",
|
|
5647
5764
|
{
|
|
@@ -5666,7 +5783,7 @@ function ManualClasses() {
|
|
|
5666
5783
|
n !== I && /* @__PURE__ */ jsx(
|
|
5667
5784
|
Cross2Icon,
|
|
5668
5785
|
{
|
|
5669
|
-
onClick: () => g(
|
|
5786
|
+
onClick: () => g(m, [I], !0),
|
|
5670
5787
|
className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
|
|
5671
5788
|
}
|
|
5672
5789
|
)
|
|
@@ -6012,10 +6129,10 @@ const COLOR_PROP = {
|
|
|
6012
6129
|
ringColor: "ring",
|
|
6013
6130
|
ringOffsetColor: "ring-offset"
|
|
6014
6131
|
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
6015
|
-
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", ""),
|
|
6132
|
+
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), m = get(u, "2", ""), h = useCallback(
|
|
6016
6133
|
// eslint-disable-next-line no-shadow
|
|
6017
|
-
(
|
|
6018
|
-
["current", "inherit", "transparent", "black", "white"].includes(
|
|
6134
|
+
(b) => {
|
|
6135
|
+
["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((y) => ({ ...y, color: b, shade: y.shade ? y.shade : "500" })));
|
|
6019
6136
|
},
|
|
6020
6137
|
[c, p]
|
|
6021
6138
|
);
|
|
@@ -6024,10 +6141,10 @@ const COLOR_PROP = {
|
|
|
6024
6141
|
return c([]);
|
|
6025
6142
|
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
6026
6143
|
}, [g]);
|
|
6027
|
-
const
|
|
6144
|
+
const f = useCallback(
|
|
6028
6145
|
// eslint-disable-next-line no-shadow
|
|
6029
|
-
(
|
|
6030
|
-
p({ color: g, shade:
|
|
6146
|
+
(b) => {
|
|
6147
|
+
p({ color: g, shade: b });
|
|
6031
6148
|
},
|
|
6032
6149
|
[g]
|
|
6033
6150
|
);
|
|
@@ -6036,8 +6153,8 @@ const COLOR_PROP = {
|
|
|
6036
6153
|
}, [r]);
|
|
6037
6154
|
const { match: x } = useTailwindClassList();
|
|
6038
6155
|
return useEffect(() => {
|
|
6039
|
-
const
|
|
6040
|
-
x(o,
|
|
6156
|
+
const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
6157
|
+
x(o, y) && n(y, o);
|
|
6041
6158
|
}, [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: [
|
|
6042
6159
|
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
6043
6160
|
DropDown,
|
|
@@ -6045,7 +6162,7 @@ const COLOR_PROP = {
|
|
|
6045
6162
|
disabled: !l,
|
|
6046
6163
|
rounded: !0,
|
|
6047
6164
|
selected: g,
|
|
6048
|
-
onChange:
|
|
6165
|
+
onChange: h,
|
|
6049
6166
|
options: [
|
|
6050
6167
|
"current",
|
|
6051
6168
|
"transparent",
|
|
@@ -6078,7 +6195,7 @@ const COLOR_PROP = {
|
|
|
6078
6195
|
]
|
|
6079
6196
|
}
|
|
6080
6197
|
) }),
|
|
6081
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected:
|
|
6198
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: f, options: i }) })
|
|
6082
6199
|
] });
|
|
6083
6200
|
}, IconChoices = ({ property: o, onChange: n }) => {
|
|
6084
6201
|
const { getClasses: r } = useTailwindClassList(), a = r(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
|
|
@@ -6275,14 +6392,14 @@ const COLOR_PROP = {
|
|
|
6275
6392
|
},
|
|
6276
6393
|
a
|
|
6277
6394
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
6278
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [
|
|
6395
|
+
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(""), [B, E] = useState(!1), [w, _] = useState(!1);
|
|
6279
6396
|
useEffect(() => {
|
|
6280
6397
|
const { value: v, unit: k } = getClassValueAndUnit(i);
|
|
6281
6398
|
if (k === "") {
|
|
6282
|
-
l(v),
|
|
6399
|
+
l(v), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
6283
6400
|
return;
|
|
6284
6401
|
}
|
|
6285
|
-
|
|
6402
|
+
h(k), l(k === "class" || isEmpty(v) ? "" : v);
|
|
6286
6403
|
}, [i, p, u]);
|
|
6287
6404
|
const j = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), S = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), C = useCallback(
|
|
6288
6405
|
(v = !1) => {
|
|
@@ -6291,17 +6408,17 @@ const COLOR_PROP = {
|
|
|
6291
6408
|
x(!0);
|
|
6292
6409
|
return;
|
|
6293
6410
|
}
|
|
6294
|
-
const
|
|
6295
|
-
if (
|
|
6296
|
-
j(`${d}${
|
|
6411
|
+
const A = get(k, "unit") !== "" ? get(k, "unit") : m;
|
|
6412
|
+
if (A === "auto" || A === "none") {
|
|
6413
|
+
j(`${d}${A}`);
|
|
6297
6414
|
return;
|
|
6298
6415
|
}
|
|
6299
6416
|
if (get(k, "value") === "")
|
|
6300
6417
|
return;
|
|
6301
|
-
const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${
|
|
6418
|
+
const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${A === "-" ? "" : A}]`;
|
|
6302
6419
|
v ? S(I) : j(I);
|
|
6303
6420
|
},
|
|
6304
|
-
[j, S, a,
|
|
6421
|
+
[j, S, a, m, d, u]
|
|
6305
6422
|
), L = useCallback(
|
|
6306
6423
|
(v) => {
|
|
6307
6424
|
const k = getUserInputValues(`${a}`, u);
|
|
@@ -6315,12 +6432,12 @@ const COLOR_PROP = {
|
|
|
6315
6432
|
}
|
|
6316
6433
|
if (get(k, "value") === "")
|
|
6317
6434
|
return;
|
|
6318
|
-
const
|
|
6435
|
+
const A = get(k, "unit") !== "" ? get(k, "unit") : v, I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${A === "-" ? "" : A}]`;
|
|
6319
6436
|
j(I);
|
|
6320
6437
|
},
|
|
6321
6438
|
[j, a, d, u]
|
|
6322
6439
|
);
|
|
6323
|
-
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children:
|
|
6440
|
+
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: [
|
|
6324
6441
|
/* @__PURE__ */ jsx(
|
|
6325
6442
|
"input",
|
|
6326
6443
|
{
|
|
@@ -6333,12 +6450,12 @@ const COLOR_PROP = {
|
|
|
6333
6450
|
/* @__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, {}) }) }),
|
|
6334
6451
|
/* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
|
|
6335
6452
|
] })
|
|
6336
|
-
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${
|
|
6453
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${B ? "z-auto" : ""}`, children: [
|
|
6337
6454
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
6338
|
-
["none", "auto"].indexOf(
|
|
6455
|
+
["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
|
|
6339
6456
|
"input",
|
|
6340
6457
|
{
|
|
6341
|
-
readOnly:
|
|
6458
|
+
readOnly: m === "class",
|
|
6342
6459
|
onKeyPress: (v) => {
|
|
6343
6460
|
v.key === "Enter" && C();
|
|
6344
6461
|
},
|
|
@@ -6347,9 +6464,9 @@ const COLOR_PROP = {
|
|
|
6347
6464
|
return;
|
|
6348
6465
|
v.preventDefault(), _(!0);
|
|
6349
6466
|
const k = parseInt$1(v.target.value);
|
|
6350
|
-
let
|
|
6351
|
-
v.keyCode === 38 && (
|
|
6352
|
-
const T = `${
|
|
6467
|
+
let A = isNaN$1(k) ? 0 : k;
|
|
6468
|
+
v.keyCode === 38 && (A += 1), v.keyCode === 40 && (A -= 1);
|
|
6469
|
+
const T = `${A}`, P = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6353
6470
|
S(P);
|
|
6354
6471
|
},
|
|
6355
6472
|
onKeyUp: (v) => {
|
|
@@ -6363,10 +6480,10 @@ const COLOR_PROP = {
|
|
|
6363
6480
|
var k;
|
|
6364
6481
|
(k = v == null ? void 0 : v.target) == null || k.select(), r(!1);
|
|
6365
6482
|
},
|
|
6366
|
-
value:
|
|
6483
|
+
value: B ? b : a,
|
|
6367
6484
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
6368
6485
|
" ",
|
|
6369
|
-
|
|
6486
|
+
f ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
6370
6487
|
)
|
|
6371
6488
|
}
|
|
6372
6489
|
),
|
|
@@ -6378,7 +6495,7 @@ const COLOR_PROP = {
|
|
|
6378
6495
|
onClick: () => r(!n),
|
|
6379
6496
|
className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
|
|
6380
6497
|
children: [
|
|
6381
|
-
/* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children:
|
|
6498
|
+
/* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: m }),
|
|
6382
6499
|
u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
|
|
6383
6500
|
]
|
|
6384
6501
|
}
|
|
@@ -6387,33 +6504,33 @@ const COLOR_PROP = {
|
|
|
6387
6504
|
UnitSelection,
|
|
6388
6505
|
{
|
|
6389
6506
|
units: u,
|
|
6390
|
-
current:
|
|
6507
|
+
current: m,
|
|
6391
6508
|
onSelect: (v) => {
|
|
6392
|
-
r(!1),
|
|
6509
|
+
r(!1), h(v), L(v);
|
|
6393
6510
|
}
|
|
6394
6511
|
}
|
|
6395
6512
|
) }) })
|
|
6396
6513
|
] })
|
|
6397
6514
|
] }),
|
|
6398
|
-
["none", "auto"].indexOf(
|
|
6515
|
+
["none", "auto"].indexOf(m) !== -1 || B ? null : /* @__PURE__ */ jsx(
|
|
6399
6516
|
DragStyleButton,
|
|
6400
6517
|
{
|
|
6401
6518
|
onDragStart: () => E(!0),
|
|
6402
6519
|
onDragEnd: (v) => {
|
|
6403
|
-
if (
|
|
6520
|
+
if (y(() => ""), E(!1), isEmpty(v))
|
|
6404
6521
|
return;
|
|
6405
|
-
const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${
|
|
6522
|
+
const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6406
6523
|
j(T);
|
|
6407
6524
|
},
|
|
6408
6525
|
onDrag: (v) => {
|
|
6409
6526
|
if (isEmpty(v))
|
|
6410
6527
|
return;
|
|
6411
|
-
|
|
6412
|
-
const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${
|
|
6528
|
+
y(v);
|
|
6529
|
+
const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6413
6530
|
S(T);
|
|
6414
6531
|
},
|
|
6415
6532
|
currentValue: a,
|
|
6416
|
-
unit:
|
|
6533
|
+
unit: m,
|
|
6417
6534
|
negative: g,
|
|
6418
6535
|
cssProperty: p
|
|
6419
6536
|
}
|
|
@@ -6507,20 +6624,20 @@ const COLOR_PROP = {
|
|
|
6507
6624
|
"2xl": "1536px"
|
|
6508
6625
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6509
6626
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6510
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(),
|
|
6627
|
+
}, 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(
|
|
6511
6628
|
(S, C = !0) => {
|
|
6512
6629
|
const L = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
|
|
6513
6630
|
(p || u !== "") && (L.mq = "xs");
|
|
6514
6631
|
const v = generateFullClsName(L);
|
|
6515
|
-
|
|
6632
|
+
h(x, [v], C);
|
|
6516
6633
|
},
|
|
6517
|
-
[x, p, g, u, l,
|
|
6518
|
-
),
|
|
6519
|
-
|
|
6520
|
-
}, [x,
|
|
6634
|
+
[x, p, g, u, l, h]
|
|
6635
|
+
), B = useCallback(() => {
|
|
6636
|
+
f(x, [b], !0);
|
|
6637
|
+
}, [x, b, f]), E = useMemo(() => canChangeClass(m, g), [m, g]);
|
|
6521
6638
|
useEffect(() => {
|
|
6522
|
-
i(E,
|
|
6523
|
-
}, [E, i,
|
|
6639
|
+
i(E, m);
|
|
6640
|
+
}, [E, i, m]);
|
|
6524
6641
|
const [, , w] = useScreenSizeWidth(), _ = useCallback(
|
|
6525
6642
|
(S) => {
|
|
6526
6643
|
w({
|
|
@@ -6533,28 +6650,28 @@ const COLOR_PROP = {
|
|
|
6533
6650
|
}[S]);
|
|
6534
6651
|
},
|
|
6535
6652
|
[w]
|
|
6536
|
-
), j = get(
|
|
6537
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: E, canReset:
|
|
6538
|
-
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${
|
|
6653
|
+
), j = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
|
|
6654
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: E, canReset: m && j, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
6655
|
+
/* @__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) }) }),
|
|
6539
6656
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6540
6657
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
6541
6658
|
r === "arbitrary" ? /* @__PURE__ */ jsx(
|
|
6542
6659
|
AdvanceChoices,
|
|
6543
6660
|
{
|
|
6544
|
-
currentClass: get(
|
|
6661
|
+
currentClass: get(m, "cls", ""),
|
|
6545
6662
|
classPrefix: get(CLASS_PREFIXES, l, ""),
|
|
6546
6663
|
units: c || [],
|
|
6547
|
-
onChange:
|
|
6664
|
+
onChange: y,
|
|
6548
6665
|
negative: d,
|
|
6549
6666
|
cssProperty: l
|
|
6550
6667
|
}
|
|
6551
6668
|
) : null,
|
|
6552
|
-
r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange:
|
|
6553
|
-
r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange:
|
|
6554
|
-
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange:
|
|
6555
|
-
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange:
|
|
6669
|
+
r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange: y }),
|
|
6670
|
+
r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange: y }),
|
|
6671
|
+
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
|
|
6672
|
+
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
|
|
6556
6673
|
] }),
|
|
6557
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${
|
|
6674
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: j ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => B(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : E && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6558
6675
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6559
6676
|
"button",
|
|
6560
6677
|
{
|
|
@@ -6566,19 +6683,19 @@ const COLOR_PROP = {
|
|
|
6566
6683
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
6567
6684
|
"Current style is set at ",
|
|
6568
6685
|
/* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
|
|
6569
|
-
getBreakpoint(get(
|
|
6570
|
-
p && !
|
|
6686
|
+
getBreakpoint(get(m, "mq")),
|
|
6687
|
+
p && !m.dark ? "(Light mode)" : ""
|
|
6571
6688
|
] }),
|
|
6572
6689
|
/* @__PURE__ */ jsx("br", {}),
|
|
6573
6690
|
/* @__PURE__ */ jsxs(
|
|
6574
6691
|
"button",
|
|
6575
6692
|
{
|
|
6576
6693
|
type: "button",
|
|
6577
|
-
onClick: () => _(get(
|
|
6694
|
+
onClick: () => _(get(m, "mq")),
|
|
6578
6695
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
6579
6696
|
children: [
|
|
6580
6697
|
"Switch to ",
|
|
6581
|
-
get(
|
|
6698
|
+
get(m, "mq").toUpperCase()
|
|
6582
6699
|
]
|
|
6583
6700
|
}
|
|
6584
6701
|
)
|
|
@@ -6595,7 +6712,7 @@ const COLOR_PROP = {
|
|
|
6595
6712
|
units: i = basicUnits,
|
|
6596
6713
|
negative: c = !1
|
|
6597
6714
|
}) => {
|
|
6598
|
-
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(),
|
|
6715
|
+
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((h) => map(g, "property").includes(h), [g]);
|
|
6599
6716
|
return /* @__PURE__ */ jsxs(
|
|
6600
6717
|
"div",
|
|
6601
6718
|
{
|
|
@@ -6604,22 +6721,22 @@ const COLOR_PROP = {
|
|
|
6604
6721
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6605
6722
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6606
6723
|
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
|
|
6607
|
-
n.map(({ label:
|
|
6724
|
+
n.map(({ label: h, key: f }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6608
6725
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6609
6726
|
"button",
|
|
6610
6727
|
{
|
|
6611
6728
|
type: "button",
|
|
6612
|
-
onClick: () => u(
|
|
6613
|
-
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${
|
|
6729
|
+
onClick: () => u(f),
|
|
6730
|
+
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6614
6731
|
children: [
|
|
6615
6732
|
React__default.createElement("div", {
|
|
6616
|
-
className: f
|
|
6733
|
+
className: m(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6617
6734
|
}),
|
|
6618
|
-
React__default.createElement(get(EDITOR_ICONS,
|
|
6735
|
+
React__default.createElement(get(EDITOR_ICONS, f, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6619
6736
|
]
|
|
6620
6737
|
}
|
|
6621
6738
|
) }),
|
|
6622
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(
|
|
6739
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(h)) })
|
|
6623
6740
|
] }) }))
|
|
6624
6741
|
) })
|
|
6625
6742
|
] }),
|
|
@@ -6758,13 +6875,13 @@ function BlockStyling() {
|
|
|
6758
6875
|
cssProperty: ""
|
|
6759
6876
|
}), d = useThrottledCallback(
|
|
6760
6877
|
(u) => {
|
|
6761
|
-
const g = !get(i, "negative", !1),
|
|
6762
|
-
let
|
|
6763
|
-
|
|
6764
|
-
let
|
|
6765
|
-
(startsWith(
|
|
6766
|
-
let
|
|
6767
|
-
g &&
|
|
6878
|
+
const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
|
|
6879
|
+
let h = parseFloat(i.dragStartValue);
|
|
6880
|
+
h = isNaN(h) ? 0 : h;
|
|
6881
|
+
let f = MAPPER[i.dragUnit];
|
|
6882
|
+
(startsWith(m, "scale") || m === "opacity") && (f = 10);
|
|
6883
|
+
let b = (i.dragStartY - u.pageY) / f + h;
|
|
6884
|
+
g && b < 0 && (b = 0), m === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
|
|
6768
6885
|
},
|
|
6769
6886
|
[i],
|
|
6770
6887
|
50
|
|
@@ -6806,27 +6923,27 @@ const CoreBlock = ({
|
|
|
6806
6923
|
parentId: r,
|
|
6807
6924
|
position: a
|
|
6808
6925
|
}) => {
|
|
6809
|
-
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight:
|
|
6926
|
+
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), h = () => {
|
|
6810
6927
|
if (console.log("addBlockToPage", o), has(o, "blocks")) {
|
|
6811
|
-
const
|
|
6812
|
-
u(syncBlocksWithDefaults(
|
|
6928
|
+
const b = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
|
|
6929
|
+
u(syncBlocksWithDefaults(b), r || null, a);
|
|
6813
6930
|
} else
|
|
6814
6931
|
p(o, r || null, a);
|
|
6815
6932
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6816
|
-
},
|
|
6933
|
+
}, f = useFeature("dnd"), { t: x } = useTranslation();
|
|
6817
6934
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6818
6935
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6819
6936
|
"button",
|
|
6820
6937
|
{
|
|
6821
6938
|
disabled: n,
|
|
6822
|
-
onClick:
|
|
6939
|
+
onClick: h,
|
|
6823
6940
|
type: "button",
|
|
6824
|
-
onDragStart: (
|
|
6825
|
-
|
|
6826
|
-
g([]),
|
|
6941
|
+
onDragStart: (b) => {
|
|
6942
|
+
b.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), b.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
6943
|
+
g([]), m();
|
|
6827
6944
|
}, 200);
|
|
6828
6945
|
},
|
|
6829
|
-
draggable:
|
|
6946
|
+
draggable: f ? "true" : "false",
|
|
6830
6947
|
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",
|
|
6831
6948
|
children: [
|
|
6832
6949
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
@@ -7022,7 +7139,7 @@ const CoreBlock = ({
|
|
|
7022
7139
|
}
|
|
7023
7140
|
}
|
|
7024
7141
|
}, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
|
|
7025
|
-
var
|
|
7142
|
+
var m, h, f, x, b, y, B, E;
|
|
7026
7143
|
if (r.type === "comment") return [];
|
|
7027
7144
|
console.log("node ===>", r);
|
|
7028
7145
|
let a = { _id: generateUUID() };
|
|
@@ -7063,12 +7180,12 @@ const CoreBlock = ({
|
|
|
7063
7180
|
];
|
|
7064
7181
|
a = {
|
|
7065
7182
|
...a,
|
|
7066
|
-
href: ((
|
|
7067
|
-
hrefType: ((
|
|
7068
|
-
autoplay: ((
|
|
7069
|
-
maxWidth: ((
|
|
7070
|
-
backdropColor: ((
|
|
7071
|
-
galleryName: ((
|
|
7183
|
+
href: ((m = l.find((_) => _.key === "href")) == null ? void 0 : m.value) || "",
|
|
7184
|
+
hrefType: ((h = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : h.value) || "video",
|
|
7185
|
+
autoplay: ((f = l.find((_) => _.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
|
|
7186
|
+
maxWidth: ((b = (x = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : b.replace("px", "")) || "",
|
|
7187
|
+
backdropColor: ((y = l.find((_) => _.key === "data-overlay")) == null ? void 0 : y.value) || "",
|
|
7188
|
+
galleryName: ((B = l.find((_) => _.key === "data-gall")) == null ? void 0 : B.value) || ""
|
|
7072
7189
|
}, forEach(w, (_) => {
|
|
7073
7190
|
has(a, `styles_attrs.${_}`) && delete a.styles_attrs[_];
|
|
7074
7191
|
});
|
|
@@ -7173,29 +7290,29 @@ const CoreBlock = ({
|
|
|
7173
7290
|
error: c
|
|
7174
7291
|
}), g(!0);
|
|
7175
7292
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7176
|
-
const
|
|
7177
|
-
const
|
|
7293
|
+
const h = Object.entries(a).map(([x, b]) => {
|
|
7294
|
+
const y = b, B = y.type || "partial", E = formatReadableName(B);
|
|
7178
7295
|
return {
|
|
7179
7296
|
type: "PartialBlock",
|
|
7180
7297
|
// Set the type to PartialBlock
|
|
7181
|
-
label: formatReadableName(
|
|
7182
|
-
description:
|
|
7298
|
+
label: formatReadableName(y.name || x),
|
|
7299
|
+
description: y.description || "",
|
|
7183
7300
|
icon: Globe,
|
|
7184
7301
|
group: E,
|
|
7185
7302
|
// Use formatted type as group
|
|
7186
7303
|
category: "partial",
|
|
7187
7304
|
partialBlockId: x,
|
|
7188
7305
|
// Store the original ID as partialBlockId
|
|
7189
|
-
_name:
|
|
7306
|
+
_name: y.name
|
|
7190
7307
|
};
|
|
7191
|
-
}),
|
|
7308
|
+
}), f = uniq(map(h, "group"));
|
|
7192
7309
|
p({
|
|
7193
|
-
blocks:
|
|
7194
|
-
groups:
|
|
7310
|
+
blocks: h,
|
|
7311
|
+
groups: f,
|
|
7195
7312
|
isLoading: !1,
|
|
7196
7313
|
error: null
|
|
7197
7314
|
}), g(!0);
|
|
7198
|
-
} else l ? p((
|
|
7315
|
+
} else l ? p((h) => ({ ...h, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
|
|
7199
7316
|
blocks: [],
|
|
7200
7317
|
groups: [],
|
|
7201
7318
|
isLoading: !1,
|
|
@@ -7210,15 +7327,15 @@ const CoreBlock = ({
|
|
|
7210
7327
|
d.blocks,
|
|
7211
7328
|
c
|
|
7212
7329
|
]);
|
|
7213
|
-
const
|
|
7214
|
-
p((
|
|
7330
|
+
const m = () => {
|
|
7331
|
+
p((h) => ({ ...h, isLoading: !0, error: null })), g(!1), i();
|
|
7215
7332
|
};
|
|
7216
7333
|
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: [
|
|
7217
7334
|
/* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
|
|
7218
7335
|
/* @__PURE__ */ jsx(
|
|
7219
7336
|
"button",
|
|
7220
7337
|
{
|
|
7221
|
-
onClick:
|
|
7338
|
+
onClick: m,
|
|
7222
7339
|
className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
|
|
7223
7340
|
children: "Refresh"
|
|
7224
7341
|
}
|
|
@@ -7235,31 +7352,31 @@ const CoreBlock = ({
|
|
|
7235
7352
|
);
|
|
7236
7353
|
}, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
7237
7354
|
var v;
|
|
7238
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom),
|
|
7355
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (v = find(c, (k) => k._id === r)) == null ? void 0 : v._type, [h, f] = useState("all"), [x, b] = useState(null), y = useRef(null);
|
|
7239
7356
|
useEffect(() => {
|
|
7240
7357
|
const k = setTimeout(() => {
|
|
7241
|
-
var
|
|
7242
|
-
(
|
|
7358
|
+
var A;
|
|
7359
|
+
(A = u.current) == null || A.focus();
|
|
7243
7360
|
}, 0);
|
|
7244
7361
|
return () => clearTimeout(k);
|
|
7245
7362
|
}, [g]), useEffect(() => {
|
|
7246
|
-
d && (
|
|
7247
|
-
}, [d]), useEffect(() => (
|
|
7248
|
-
|
|
7363
|
+
d && (f("all"), b(null));
|
|
7364
|
+
}, [d]), useEffect(() => (y.current = debounce((k) => {
|
|
7365
|
+
f(k);
|
|
7249
7366
|
}, 500), () => {
|
|
7250
|
-
|
|
7367
|
+
y.current && y.current.cancel();
|
|
7251
7368
|
}), []);
|
|
7252
|
-
const
|
|
7253
|
-
|
|
7369
|
+
const B = useCallback((k) => {
|
|
7370
|
+
b(k), y.current && y.current(k);
|
|
7254
7371
|
}, []), E = useCallback(() => {
|
|
7255
|
-
|
|
7372
|
+
b(null), y.current && y.current.cancel();
|
|
7256
7373
|
}, []), w = useCallback((k) => {
|
|
7257
|
-
|
|
7374
|
+
y.current && y.current.cancel(), f(k), b(null);
|
|
7258
7375
|
}, []), _ = useMemo(
|
|
7259
7376
|
() => d ? values(n).filter(
|
|
7260
7377
|
(k) => {
|
|
7261
|
-
var
|
|
7262
|
-
return (((
|
|
7378
|
+
var A, T;
|
|
7379
|
+
return (((A = k.label) == null ? void 0 : A.toLowerCase()) + " " + ((T = k.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
|
|
7263
7380
|
}
|
|
7264
7381
|
) : n,
|
|
7265
7382
|
[n, d]
|
|
@@ -7271,7 +7388,7 @@ const CoreBlock = ({
|
|
|
7271
7388
|
), S = useMemo(
|
|
7272
7389
|
() => sortBy(j, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
|
|
7273
7390
|
[j]
|
|
7274
|
-
), C = useMemo(() =>
|
|
7391
|
+
), C = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), L = useMemo(() => h === "all" ? S : [h], [S, h]);
|
|
7275
7392
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7276
7393
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7277
7394
|
Input$1,
|
|
@@ -7290,9 +7407,9 @@ const CoreBlock = ({
|
|
|
7290
7407
|
"button",
|
|
7291
7408
|
{
|
|
7292
7409
|
onClick: () => w("all"),
|
|
7293
|
-
onMouseEnter: () =>
|
|
7410
|
+
onMouseEnter: () => B("all"),
|
|
7294
7411
|
onMouseLeave: E,
|
|
7295
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${
|
|
7412
|
+
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"}`,
|
|
7296
7413
|
children: i("All")
|
|
7297
7414
|
},
|
|
7298
7415
|
"sidebar-all"
|
|
@@ -7301,9 +7418,9 @@ const CoreBlock = ({
|
|
|
7301
7418
|
"button",
|
|
7302
7419
|
{
|
|
7303
7420
|
onClick: () => w(k),
|
|
7304
|
-
onMouseEnter: () =>
|
|
7421
|
+
onMouseEnter: () => B(k),
|
|
7305
7422
|
onMouseLeave: E,
|
|
7306
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${
|
|
7423
|
+
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"}`,
|
|
7307
7424
|
children: capitalize(i(k.toLowerCase()))
|
|
7308
7425
|
},
|
|
7309
7426
|
`sidebar-${k}`
|
|
@@ -7318,17 +7435,17 @@ const CoreBlock = ({
|
|
|
7318
7435
|
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
|
|
7319
7436
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: React__default.Children.toArray(
|
|
7320
7437
|
reject(
|
|
7321
|
-
|
|
7438
|
+
h === "all" ? filter(values(C), { group: k }) : values(C),
|
|
7322
7439
|
{ hidden: !0 }
|
|
7323
|
-
).map((
|
|
7440
|
+
).map((A) => /* @__PURE__ */ jsx(
|
|
7324
7441
|
CoreBlock,
|
|
7325
7442
|
{
|
|
7326
7443
|
parentId: r,
|
|
7327
7444
|
position: a,
|
|
7328
|
-
block:
|
|
7329
|
-
disabled: !canAcceptChildBlock(
|
|
7445
|
+
block: A,
|
|
7446
|
+
disabled: !canAcceptChildBlock(m, A.type) || !canBeNestedInside(m, A.type)
|
|
7330
7447
|
},
|
|
7331
|
-
|
|
7448
|
+
A.type
|
|
7332
7449
|
))
|
|
7333
7450
|
) })
|
|
7334
7451
|
] }, k)) }) }) })
|
|
@@ -7340,11 +7457,11 @@ const CoreBlock = ({
|
|
|
7340
7457
|
parentId: r = void 0,
|
|
7341
7458
|
position: a = -1
|
|
7342
7459
|
}) => {
|
|
7343
|
-
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(),
|
|
7460
|
+
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(), m = Object.keys(g || {}).length > 0;
|
|
7344
7461
|
useEffect(() => {
|
|
7345
|
-
i === "partials" && !
|
|
7346
|
-
}, [i,
|
|
7347
|
-
const
|
|
7462
|
+
i === "partials" && !m && c("library");
|
|
7463
|
+
}, [i, m, c]);
|
|
7464
|
+
const h = useCallback(() => {
|
|
7348
7465
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7349
7466
|
}, []);
|
|
7350
7467
|
return /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
@@ -7355,8 +7472,8 @@ const CoreBlock = ({
|
|
|
7355
7472
|
/* @__PURE__ */ jsxs(
|
|
7356
7473
|
Tabs,
|
|
7357
7474
|
{
|
|
7358
|
-
onValueChange: (
|
|
7359
|
-
d(""), c(
|
|
7475
|
+
onValueChange: (f) => {
|
|
7476
|
+
d(""), c(f);
|
|
7360
7477
|
},
|
|
7361
7478
|
value: i,
|
|
7362
7479
|
className: "flex h-full max-h-full flex-col overflow-hidden",
|
|
@@ -7364,15 +7481,15 @@ const CoreBlock = ({
|
|
|
7364
7481
|
/* @__PURE__ */ jsxs(TabsList, { className: "flex w-full items-center", children: [
|
|
7365
7482
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
7366
7483
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
7367
|
-
|
|
7484
|
+
m && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
|
|
7368
7485
|
p ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
7369
|
-
map(u, (
|
|
7486
|
+
map(u, (f) => /* @__PURE__ */ jsx(TabsTrigger, { value: f.key, children: React__default.createElement(f.tab) }))
|
|
7370
7487
|
] }),
|
|
7371
7488
|
/* @__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 }) }) }) }),
|
|
7372
7489
|
/* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
|
|
7373
|
-
|
|
7490
|
+
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 }) }) }) }),
|
|
7374
7491
|
p ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
|
|
7375
|
-
map(u, (
|
|
7492
|
+
map(u, (f) => /* @__PURE__ */ jsx(TabsContent, { value: f.key, children: React__default.createElement(f.tabContent, { close: h, parentId: r, position: a }) }))
|
|
7376
7493
|
]
|
|
7377
7494
|
}
|
|
7378
7495
|
)
|
|
@@ -7429,12 +7546,12 @@ const BlockCard = ({
|
|
|
7429
7546
|
parentId: r = void 0,
|
|
7430
7547
|
position: a = -1
|
|
7431
7548
|
}) => {
|
|
7432
|
-
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(),
|
|
7433
|
-
const E = has(
|
|
7434
|
-
return
|
|
7435
|
-
},
|
|
7436
|
-
async (
|
|
7437
|
-
if (
|
|
7549
|
+
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), x = (B) => {
|
|
7550
|
+
const E = has(B, "styles_attrs.data-page-section");
|
|
7551
|
+
return B._type === "Box" && E;
|
|
7552
|
+
}, b = useCallback(
|
|
7553
|
+
async (B) => {
|
|
7554
|
+
if (B.stopPropagation(), has(o, "component")) {
|
|
7438
7555
|
d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7439
7556
|
return;
|
|
7440
7557
|
}
|
|
@@ -7449,21 +7566,21 @@ const BlockCard = ({
|
|
|
7449
7566
|
"div",
|
|
7450
7567
|
{
|
|
7451
7568
|
onClick: l ? () => {
|
|
7452
|
-
} :
|
|
7453
|
-
draggable:
|
|
7454
|
-
onDragStart: async (
|
|
7569
|
+
} : b,
|
|
7570
|
+
draggable: h ? "true" : "false",
|
|
7571
|
+
onDragStart: async (B) => {
|
|
7455
7572
|
const E = await c(n, o);
|
|
7456
7573
|
let w = r;
|
|
7457
7574
|
if (x(first(E)) && (w = null), !isEmpty(E)) {
|
|
7458
7575
|
const _ = { blocks: E, uiLibrary: !0, parent: w };
|
|
7459
|
-
if (
|
|
7576
|
+
if (B.dataTransfer.setData("text/plain", JSON.stringify(_)), o.preview) {
|
|
7460
7577
|
const j = new Image();
|
|
7461
7578
|
j.src = o.preview, j.onload = () => {
|
|
7462
|
-
|
|
7579
|
+
B.dataTransfer.setDragImage(j, 0, 0);
|
|
7463
7580
|
};
|
|
7464
7581
|
} else
|
|
7465
|
-
|
|
7466
|
-
|
|
7582
|
+
B.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7583
|
+
f(_), setTimeout(() => {
|
|
7467
7584
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7468
7585
|
}, 200);
|
|
7469
7586
|
}
|
|
@@ -7476,11 +7593,11 @@ const BlockCard = ({
|
|
|
7476
7593
|
/* @__PURE__ */ jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
|
|
7477
7594
|
/* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
|
|
7478
7595
|
] }),
|
|
7479
|
-
o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt:
|
|
7596
|
+
o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: m }) : /* @__PURE__ */ jsx("div", { className: "flex h-20 items-center justify-center rounded-md border border-border bg-gray-200", children: /* @__PURE__ */ jsx("p", { className: "max-w-xs text-center text-sm text-gray-700", children: m }) })
|
|
7480
7597
|
]
|
|
7481
7598
|
}
|
|
7482
7599
|
) }),
|
|
7483
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
7600
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: m }) })
|
|
7484
7601
|
] });
|
|
7485
7602
|
}, libraryBlocksAtom = atom$1(
|
|
7486
7603
|
{}
|
|
@@ -7495,9 +7612,9 @@ const BlockCard = ({
|
|
|
7495
7612
|
})();
|
|
7496
7613
|
}, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
|
|
7497
7614
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
7498
|
-
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((w) => w.category === "custom"), d = l.find((w) => w.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [
|
|
7615
|
+
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((w) => w.category === "custom"), d = l.find((w) => w.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [m, h] = useState("Hero"), f = get(g, m, []), x = useRef(null), { t: b } = useTranslation(), y = (w) => {
|
|
7499
7616
|
x.current && (clearTimeout(x.current), x.current = null), x.current = setTimeout(() => {
|
|
7500
|
-
x.current &&
|
|
7617
|
+
x.current && h(w);
|
|
7501
7618
|
}, 300);
|
|
7502
7619
|
};
|
|
7503
7620
|
if (u)
|
|
@@ -7505,26 +7622,26 @@ const BlockCard = ({
|
|
|
7505
7622
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7506
7623
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7507
7624
|
] });
|
|
7508
|
-
const
|
|
7625
|
+
const B = filter(f, (w, _) => _ % 2 === 0), E = filter(f, (w, _) => _ % 2 === 1);
|
|
7509
7626
|
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: [
|
|
7510
7627
|
/* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
7511
7628
|
/* @__PURE__ */ jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
|
|
7512
7629
|
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
|
|
7513
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children:
|
|
7630
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: b("Groups") }),
|
|
7514
7631
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7515
7632
|
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: React__default.Children.toArray(
|
|
7516
7633
|
map(g, (w, _) => /* @__PURE__ */ jsxs(
|
|
7517
7634
|
"div",
|
|
7518
7635
|
{
|
|
7519
|
-
onMouseEnter: () =>
|
|
7636
|
+
onMouseEnter: () => y(_),
|
|
7520
7637
|
onMouseLeave: () => clearTimeout(x.current),
|
|
7521
|
-
onClick: () =>
|
|
7638
|
+
onClick: () => h(_),
|
|
7522
7639
|
className: cn$1(
|
|
7523
7640
|
"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",
|
|
7524
|
-
_ ===
|
|
7641
|
+
_ === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
|
|
7525
7642
|
),
|
|
7526
7643
|
children: [
|
|
7527
|
-
/* @__PURE__ */ jsx("span", { children: capitalize(
|
|
7644
|
+
/* @__PURE__ */ jsx("span", { children: capitalize(b(_.toLowerCase())) }),
|
|
7528
7645
|
/* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
|
|
7529
7646
|
]
|
|
7530
7647
|
},
|
|
@@ -7541,7 +7658,7 @@ const BlockCard = ({
|
|
|
7541
7658
|
children: [
|
|
7542
7659
|
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
|
|
7543
7660
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
7544
|
-
|
|
7661
|
+
B.map((w) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: w, library: d }))
|
|
7545
7662
|
) }),
|
|
7546
7663
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
7547
7664
|
E.map((w) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: w, library: d }))
|
|
@@ -7639,11 +7756,11 @@ const BlockCard = ({
|
|
|
7639
7756
|
);
|
|
7640
7757
|
}, RenameBlock = ({ node: o }) => {
|
|
7641
7758
|
const { t: n } = useTranslation();
|
|
7642
|
-
return
|
|
7759
|
+
return /* @__PURE__ */ jsxs(
|
|
7643
7760
|
DropdownMenuItem,
|
|
7644
7761
|
{
|
|
7645
7762
|
onClick: (r) => {
|
|
7646
|
-
r.stopPropagation(),
|
|
7763
|
+
r.stopPropagation(), o.edit(), o.deselect();
|
|
7647
7764
|
},
|
|
7648
7765
|
className: "flex items-center gap-x-4 text-xs",
|
|
7649
7766
|
children: [
|
|
@@ -7654,7 +7771,7 @@ const BlockCard = ({
|
|
|
7654
7771
|
}
|
|
7655
7772
|
);
|
|
7656
7773
|
}, BlockContextMenuContent = ({ node: o }) => {
|
|
7657
|
-
const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), i = useCallback(() => {
|
|
7774
|
+
const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), i = useBuilderProp("blockMoreOptions", []), c = useCallback(() => {
|
|
7658
7775
|
a(r);
|
|
7659
7776
|
}, [r, a]);
|
|
7660
7777
|
return /* @__PURE__ */ jsxs(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: [
|
|
@@ -7676,7 +7793,7 @@ const BlockCard = ({
|
|
|
7676
7793
|
{
|
|
7677
7794
|
disabled: !canDuplicateBlock(l == null ? void 0 : l._type),
|
|
7678
7795
|
className: "flex items-center gap-x-4 text-xs",
|
|
7679
|
-
onClick:
|
|
7796
|
+
onClick: c,
|
|
7680
7797
|
children: [
|
|
7681
7798
|
/* @__PURE__ */ jsx(CardStackPlusIcon, {}),
|
|
7682
7799
|
" ",
|
|
@@ -7687,7 +7804,8 @@ const BlockCard = ({
|
|
|
7687
7804
|
/* @__PURE__ */ jsx(RenameBlock, { node: o }),
|
|
7688
7805
|
/* @__PURE__ */ jsx(CutBlocks, {}),
|
|
7689
7806
|
/* @__PURE__ */ jsx(CopyPasteBlocks, {}),
|
|
7690
|
-
/* @__PURE__ */ jsx(RemoveBlocks, {})
|
|
7807
|
+
/* @__PURE__ */ jsx(RemoveBlocks, {}),
|
|
7808
|
+
i.map((d, p) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("span", { children: "Loading..." }), children: React__default.createElement(d, { block: l }) }, `more-${p}`))
|
|
7691
7809
|
] });
|
|
7692
7810
|
}, BlockMoreOptions = ({ children: o, id: n, node: r }) => {
|
|
7693
7811
|
const [, a] = useSelectedBlockIds();
|
|
@@ -7774,8 +7892,8 @@ const selectParent = (o, n) => {
|
|
|
7774
7892
|
var P;
|
|
7775
7893
|
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
|
|
7776
7894
|
let p = null;
|
|
7777
|
-
const u = o.children.length > 0, { highlightBlock: g, clearHighlight:
|
|
7778
|
-
N.stopPropagation(), !i.includes(
|
|
7895
|
+
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: h, data: f, isSelected: x, willReceiveDrop: b, isDragging: y, isEditing: B, handleClick: E } = o, w = (N) => {
|
|
7896
|
+
N.stopPropagation(), !i.includes(h) && o.toggle();
|
|
7779
7897
|
}, _ = (N) => {
|
|
7780
7898
|
N.isInternal && (p = N.isOpen, N.isOpen && N.close());
|
|
7781
7899
|
}, j = (N) => {
|
|
@@ -7786,23 +7904,23 @@ const selectParent = (o, n) => {
|
|
|
7786
7904
|
}, v = () => {
|
|
7787
7905
|
C(null);
|
|
7788
7906
|
}, k = (N) => {
|
|
7789
|
-
v(), N.stopPropagation(), !o.isOpen && !i.includes(
|
|
7907
|
+
v(), N.stopPropagation(), !o.isOpen && !i.includes(h) && o.toggle(), E(N);
|
|
7790
7908
|
};
|
|
7791
7909
|
useEffect(() => {
|
|
7792
7910
|
const N = setTimeout(() => {
|
|
7793
|
-
|
|
7911
|
+
b && !o.isOpen && !y && !i.includes(h) && o.toggle();
|
|
7794
7912
|
}, 500);
|
|
7795
7913
|
return () => clearTimeout(N);
|
|
7796
|
-
}, [
|
|
7797
|
-
const
|
|
7798
|
-
const N = Object.keys(
|
|
7914
|
+
}, [b, o, y]);
|
|
7915
|
+
const A = useMemo(() => {
|
|
7916
|
+
const N = Object.keys(f), D = [];
|
|
7799
7917
|
for (let $ = 0; $ < N.length; $++)
|
|
7800
7918
|
if (N[$].endsWith("_attrs")) {
|
|
7801
|
-
const R =
|
|
7919
|
+
const R = f[N[$]], O = Object.keys(R).join("|");
|
|
7802
7920
|
O.match(/x-data/) && D.push("data"), O.match(/x-on/) && D.push("event"), O.match(/x-show|x-if/) && D.push("show");
|
|
7803
7921
|
}
|
|
7804
7922
|
return D;
|
|
7805
|
-
}, [
|
|
7923
|
+
}, [f]), T = (N, D) => {
|
|
7806
7924
|
const $ = d.contentDocument || d.contentWindow.document, R = $.querySelector(`[data-block-id=${N}]`);
|
|
7807
7925
|
R && R.setAttribute("data-drop", D);
|
|
7808
7926
|
const O = R.getBoundingClientRect(), M = d.getBoundingClientRect();
|
|
@@ -7812,7 +7930,7 @@ const selectParent = (o, n) => {
|
|
|
7812
7930
|
const D = get(o, "parent.id");
|
|
7813
7931
|
D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: N }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: N });
|
|
7814
7932
|
};
|
|
7815
|
-
return
|
|
7933
|
+
return h === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
|
|
7816
7934
|
/* @__PURE__ */ jsx("br", {}),
|
|
7817
7935
|
/* @__PURE__ */ jsx(
|
|
7818
7936
|
"div",
|
|
@@ -7830,22 +7948,22 @@ const selectParent = (o, n) => {
|
|
|
7830
7948
|
] }) : /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
|
|
7831
7949
|
"div",
|
|
7832
7950
|
{
|
|
7833
|
-
onMouseEnter: () => g(
|
|
7834
|
-
onMouseLeave: () =>
|
|
7951
|
+
onMouseEnter: () => g(h),
|
|
7952
|
+
onMouseLeave: () => m(),
|
|
7835
7953
|
onClick: k,
|
|
7836
7954
|
style: n,
|
|
7837
|
-
"data-node-id":
|
|
7838
|
-
ref: i.includes(
|
|
7955
|
+
"data-node-id": h,
|
|
7956
|
+
ref: i.includes(h) ? null : r,
|
|
7839
7957
|
onDragStart: () => _(o),
|
|
7840
7958
|
onDragEnd: () => j(o),
|
|
7841
7959
|
onDragOver: (N) => {
|
|
7842
|
-
N.preventDefault(), T(
|
|
7960
|
+
N.preventDefault(), T(h, "yes");
|
|
7843
7961
|
},
|
|
7844
7962
|
onDragLeave: (N) => {
|
|
7845
|
-
N.preventDefault(), T(
|
|
7963
|
+
N.preventDefault(), T(h, "no");
|
|
7846
7964
|
},
|
|
7847
7965
|
onDrop: (N) => {
|
|
7848
|
-
N.preventDefault(), T(
|
|
7966
|
+
N.preventDefault(), T(h, "no");
|
|
7849
7967
|
},
|
|
7850
7968
|
children: [
|
|
7851
7969
|
(o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((P = o == null ? void 0 : o.parent) == null ? void 0 : P.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
|
|
@@ -7866,10 +7984,10 @@ const selectParent = (o, n) => {
|
|
|
7866
7984
|
className: cn$1(
|
|
7867
7985
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
|
|
7868
7986
|
x ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
|
|
7869
|
-
|
|
7987
|
+
b && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
|
|
7870
7988
|
(o == null ? void 0 : o.id) === S ? "bg-purple-100" : "",
|
|
7871
|
-
|
|
7872
|
-
i.includes(
|
|
7989
|
+
y && "opacity-20",
|
|
7990
|
+
i.includes(h) ? "opacity-50" : ""
|
|
7873
7991
|
),
|
|
7874
7992
|
children: [
|
|
7875
7993
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -7881,8 +7999,8 @@ const selectParent = (o, n) => {
|
|
|
7881
7999
|
}
|
|
7882
8000
|
),
|
|
7883
8001
|
/* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
|
|
7884
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
7885
|
-
|
|
8002
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: f == null ? void 0 : f._type }),
|
|
8003
|
+
B ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
|
|
7886
8004
|
"div",
|
|
7887
8005
|
{
|
|
7888
8006
|
className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
|
|
@@ -7890,32 +8008,32 @@ const selectParent = (o, n) => {
|
|
|
7890
8008
|
N.stopPropagation(), o.edit(), o.deselect();
|
|
7891
8009
|
},
|
|
7892
8010
|
children: [
|
|
7893
|
-
/* @__PURE__ */ jsx("span", { children: (
|
|
7894
|
-
|
|
7895
|
-
|
|
7896
|
-
|
|
8011
|
+
/* @__PURE__ */ jsx("span", { children: (f == null ? void 0 : f._name) || (f == null ? void 0 : f._type.split("/").pop()) }),
|
|
8012
|
+
A.includes("data") && /* @__PURE__ */ jsx(FileJson, { className: "h-3 w-3 text-orange-600" }),
|
|
8013
|
+
A.includes("event") && /* @__PURE__ */ jsx(Zap, { className: "h-3 w-3 text-yellow-500" }),
|
|
8014
|
+
A.includes("show") && /* @__PURE__ */ jsx(EyeOff, { className: "h-3 w-3 text-orange-600" })
|
|
7897
8015
|
]
|
|
7898
8016
|
}
|
|
7899
8017
|
)
|
|
7900
8018
|
] })
|
|
7901
8019
|
] }),
|
|
7902
8020
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
7903
|
-
!i.includes(
|
|
8021
|
+
!i.includes(h) && a.map((N) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7904
8022
|
/* @__PURE__ */ jsx(
|
|
7905
8023
|
TooltipTrigger,
|
|
7906
8024
|
{
|
|
7907
8025
|
className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
|
|
7908
8026
|
asChild: !0,
|
|
7909
|
-
children: React__default.createElement(N.item, { blockId:
|
|
8027
|
+
children: React__default.createElement(N.item, { blockId: h })
|
|
7910
8028
|
}
|
|
7911
8029
|
),
|
|
7912
8030
|
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: N.tooltip })
|
|
7913
8031
|
] })),
|
|
7914
|
-
canAddChildBlock(
|
|
8032
|
+
canAddChildBlock(f == null ? void 0 : f._type) && !i.includes(h) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7915
8033
|
/* @__PURE__ */ jsx(
|
|
7916
8034
|
TooltipTrigger,
|
|
7917
8035
|
{
|
|
7918
|
-
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id:
|
|
8036
|
+
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: h }),
|
|
7919
8037
|
className: "cursor-pointer rounded bg-transparent hover:text-black",
|
|
7920
8038
|
asChild: !0,
|
|
7921
8039
|
children: /* @__PURE__ */ jsx(PlusIcon$1, { size: "15" })
|
|
@@ -7928,7 +8046,7 @@ const selectParent = (o, n) => {
|
|
|
7928
8046
|
TooltipTrigger,
|
|
7929
8047
|
{
|
|
7930
8048
|
onClick: (N) => {
|
|
7931
|
-
N.stopPropagation(), c(
|
|
8049
|
+
N.stopPropagation(), c(h), o.isOpen && o.toggle();
|
|
7932
8050
|
},
|
|
7933
8051
|
className: "cursor-pointer rounded bg-transparent hover:text-black",
|
|
7934
8052
|
asChild: !0,
|
|
@@ -7937,7 +8055,7 @@ const selectParent = (o, n) => {
|
|
|
7937
8055
|
),
|
|
7938
8056
|
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999]", side: "left", children: l("Hide block") })
|
|
7939
8057
|
] }),
|
|
7940
|
-
/* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id:
|
|
8058
|
+
/* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: h, children: /* @__PURE__ */ jsx(MoreVertical, { size: "15" }) })
|
|
7941
8059
|
] })
|
|
7942
8060
|
]
|
|
7943
8061
|
}
|
|
@@ -8586,14 +8704,14 @@ function QuickPrompts({ onClick: o }) {
|
|
|
8586
8704
|
) }) });
|
|
8587
8705
|
}
|
|
8588
8706
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
8589
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(),
|
|
8707
|
+
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null), h = useRef(null);
|
|
8590
8708
|
useEffect(() => {
|
|
8591
8709
|
var x;
|
|
8592
|
-
(x =
|
|
8710
|
+
(x = m.current) == null || x.focus();
|
|
8593
8711
|
}, []);
|
|
8594
|
-
const
|
|
8595
|
-
const { usage:
|
|
8596
|
-
!l &&
|
|
8712
|
+
const f = (x) => {
|
|
8713
|
+
const { usage: b } = x || {};
|
|
8714
|
+
!l && b && g(b), h.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
8597
8715
|
};
|
|
8598
8716
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
8599
8717
|
/* @__PURE__ */ jsxs(
|
|
@@ -8611,14 +8729,14 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8611
8729
|
/* @__PURE__ */ jsx(
|
|
8612
8730
|
Textarea,
|
|
8613
8731
|
{
|
|
8614
|
-
ref:
|
|
8732
|
+
ref: m,
|
|
8615
8733
|
value: i,
|
|
8616
8734
|
onChange: (x) => c(x.target.value),
|
|
8617
8735
|
placeholder: n("Ask AI to edit content"),
|
|
8618
8736
|
className: "w-full",
|
|
8619
8737
|
rows: 3,
|
|
8620
8738
|
onKeyDown: (x) => {
|
|
8621
|
-
x.key === "Enter" && (x.preventDefault(),
|
|
8739
|
+
x.key === "Enter" && (x.preventDefault(), h.current && clearTimeout(h.current), g(void 0), r("content", o, i, f));
|
|
8622
8740
|
}
|
|
8623
8741
|
}
|
|
8624
8742
|
),
|
|
@@ -8628,7 +8746,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8628
8746
|
{
|
|
8629
8747
|
disabled: i.trim().length < 5 || a,
|
|
8630
8748
|
onClick: () => {
|
|
8631
|
-
|
|
8749
|
+
h.current && clearTimeout(h.current), g(void 0), r("content", o, i, f);
|
|
8632
8750
|
},
|
|
8633
8751
|
variant: "default",
|
|
8634
8752
|
className: "w-fit",
|
|
@@ -8661,7 +8779,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8661
8779
|
QuickPrompts,
|
|
8662
8780
|
{
|
|
8663
8781
|
onClick: (x) => {
|
|
8664
|
-
|
|
8782
|
+
h.current && clearTimeout(h.current), g(void 0), r("content", o, x, f);
|
|
8665
8783
|
}
|
|
8666
8784
|
}
|
|
8667
8785
|
)
|
|
@@ -8671,15 +8789,15 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8671
8789
|
] }) }) : null
|
|
8672
8790
|
] });
|
|
8673
8791
|
}, AISetContext = () => {
|
|
8674
|
-
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1),
|
|
8792
|
+
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), m = useRef(null);
|
|
8675
8793
|
useEffect(() => {
|
|
8676
8794
|
n && a(n);
|
|
8677
8795
|
}, [n]);
|
|
8678
|
-
const
|
|
8796
|
+
const h = async () => {
|
|
8679
8797
|
try {
|
|
8680
|
-
d(!0), u(null), await i(r), toast.success(o("Updated AI Context")),
|
|
8681
|
-
} catch (
|
|
8682
|
-
u(
|
|
8798
|
+
d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
|
|
8799
|
+
} catch (f) {
|
|
8800
|
+
u(f);
|
|
8683
8801
|
} finally {
|
|
8684
8802
|
d(!1);
|
|
8685
8803
|
}
|
|
@@ -8687,25 +8805,25 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8687
8805
|
return /* @__PURE__ */ jsx(
|
|
8688
8806
|
Accordion,
|
|
8689
8807
|
{
|
|
8690
|
-
onValueChange: (
|
|
8691
|
-
g(
|
|
8808
|
+
onValueChange: (f) => {
|
|
8809
|
+
g(f !== "");
|
|
8692
8810
|
},
|
|
8693
8811
|
type: "single",
|
|
8694
8812
|
collapsible: !0,
|
|
8695
8813
|
children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
|
|
8696
|
-
/* @__PURE__ */ jsx(AccordionTrigger, { ref:
|
|
8814
|
+
/* @__PURE__ */ jsx(AccordionTrigger, { ref: m, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
|
|
8697
8815
|
/* @__PURE__ */ jsxs(AccordionContent, { children: [
|
|
8698
8816
|
/* @__PURE__ */ jsx(
|
|
8699
8817
|
Textarea,
|
|
8700
8818
|
{
|
|
8701
8819
|
ref: l,
|
|
8702
8820
|
value: r,
|
|
8703
|
-
onChange: (
|
|
8821
|
+
onChange: (f) => a(f.target.value),
|
|
8704
8822
|
placeholder: o("Tell about this page eg this page is about"),
|
|
8705
8823
|
className: "mt-1 w-full",
|
|
8706
8824
|
rows: 10,
|
|
8707
|
-
onKeyDown: (
|
|
8708
|
-
|
|
8825
|
+
onKeyDown: (f) => {
|
|
8826
|
+
f.key === "Enter" && (f.preventDefault(), h());
|
|
8709
8827
|
}
|
|
8710
8828
|
}
|
|
8711
8829
|
),
|
|
@@ -8717,7 +8835,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8717
8835
|
Button,
|
|
8718
8836
|
{
|
|
8719
8837
|
disabled: r.trim().length < 5,
|
|
8720
|
-
onClick: () =>
|
|
8838
|
+
onClick: () => h(),
|
|
8721
8839
|
variant: "default",
|
|
8722
8840
|
className: "w-fit",
|
|
8723
8841
|
size: "sm",
|
|
@@ -8746,7 +8864,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8746
8864
|
AlertDialogAction,
|
|
8747
8865
|
{
|
|
8748
8866
|
onClick: () => {
|
|
8749
|
-
a(""),
|
|
8867
|
+
a(""), h();
|
|
8750
8868
|
},
|
|
8751
8869
|
children: o("Yes, Delete")
|
|
8752
8870
|
}
|
|
@@ -8903,53 +9021,53 @@ const AiAssistant = () => {
|
|
|
8903
9021
|
preloadedAttributes: n = [],
|
|
8904
9022
|
onAttributesChange: r
|
|
8905
9023
|
}) {
|
|
8906
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [
|
|
9024
|
+
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();
|
|
8907
9025
|
useEffect(() => {
|
|
8908
9026
|
l(n);
|
|
8909
9027
|
}, [n]);
|
|
8910
|
-
const
|
|
9028
|
+
const y = () => {
|
|
8911
9029
|
if (i.startsWith("@")) {
|
|
8912
|
-
|
|
9030
|
+
h("Attribute keys cannot start with '@'");
|
|
8913
9031
|
return;
|
|
8914
9032
|
}
|
|
8915
9033
|
if (i) {
|
|
8916
9034
|
const S = [...a, { key: i, value: d }];
|
|
8917
|
-
r(S), l(a), c(""), p(""),
|
|
9035
|
+
r(S), l(a), c(""), p(""), h("");
|
|
8918
9036
|
}
|
|
8919
|
-
},
|
|
9037
|
+
}, B = (S) => {
|
|
8920
9038
|
const C = a.filter((L, v) => v !== S);
|
|
8921
9039
|
r(C), l(C);
|
|
8922
9040
|
}, E = (S) => {
|
|
8923
9041
|
g(S), c(a[S].key), p(a[S].value);
|
|
8924
9042
|
}, w = () => {
|
|
8925
9043
|
if (i.startsWith("@")) {
|
|
8926
|
-
|
|
9044
|
+
h("Attribute keys cannot start with '@'");
|
|
8927
9045
|
return;
|
|
8928
9046
|
}
|
|
8929
9047
|
if (u !== null && i) {
|
|
8930
9048
|
const S = [...a];
|
|
8931
|
-
S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""),
|
|
9049
|
+
S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), h("");
|
|
8932
9050
|
}
|
|
8933
9051
|
}, _ = (S) => {
|
|
8934
|
-
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() :
|
|
9052
|
+
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() : y());
|
|
8935
9053
|
}, j = useCallback((S) => {
|
|
8936
|
-
const C = (k) => /[.,!?;:]/.test(k), L = (k,
|
|
9054
|
+
const C = (k) => /[.,!?;:]/.test(k), L = (k, A, T) => {
|
|
8937
9055
|
let I = "", P = "";
|
|
8938
|
-
const N =
|
|
8939
|
-
return
|
|
9056
|
+
const N = A > 0 ? k[A - 1] : "", D = A < k.length ? k[A] : "";
|
|
9057
|
+
return A > 0 && (N === "." || !C(N) && N !== " ") && (I = " "), A < k.length && !C(D) && D !== " " && (P = " "), {
|
|
8940
9058
|
text: I + T + P,
|
|
8941
9059
|
prefixLength: I.length,
|
|
8942
9060
|
suffixLength: P.length
|
|
8943
9061
|
};
|
|
8944
9062
|
}, v = x.current;
|
|
8945
9063
|
if (v) {
|
|
8946
|
-
const k = v.selectionStart || 0,
|
|
9064
|
+
const k = v.selectionStart || 0, A = v.value || "", T = v.selectionEnd || k;
|
|
8947
9065
|
if (T > k) {
|
|
8948
|
-
const $ = `{{${S}}}`, { text: R } = L(
|
|
9066
|
+
const $ = `{{${S}}}`, { text: R } = L(A, k, $), O = A.slice(0, k) + R + A.slice(T);
|
|
8949
9067
|
p(O);
|
|
8950
9068
|
return;
|
|
8951
9069
|
}
|
|
8952
|
-
const P = `{{${S}}}`, { text: N } = L(
|
|
9070
|
+
const P = `{{${S}}}`, { text: N } = L(A, k, P), D = A.slice(0, k) + N + A.slice(k);
|
|
8953
9071
|
p(D);
|
|
8954
9072
|
}
|
|
8955
9073
|
}, []);
|
|
@@ -8958,7 +9076,7 @@ const AiAssistant = () => {
|
|
|
8958
9076
|
"form",
|
|
8959
9077
|
{
|
|
8960
9078
|
onSubmit: (S) => {
|
|
8961
|
-
S.preventDefault(), u !== null ? w() :
|
|
9079
|
+
S.preventDefault(), u !== null ? w() : y();
|
|
8962
9080
|
},
|
|
8963
9081
|
className: "space-y-3",
|
|
8964
9082
|
children: [
|
|
@@ -8972,7 +9090,7 @@ const AiAssistant = () => {
|
|
|
8972
9090
|
autoCorrect: "off",
|
|
8973
9091
|
spellCheck: "false",
|
|
8974
9092
|
id: "attrKey",
|
|
8975
|
-
ref:
|
|
9093
|
+
ref: f,
|
|
8976
9094
|
value: i,
|
|
8977
9095
|
onChange: (S) => c(S.target.value),
|
|
8978
9096
|
placeholder: "Enter Key",
|
|
@@ -8983,7 +9101,7 @@ const AiAssistant = () => {
|
|
|
8983
9101
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
8984
9102
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
8985
9103
|
/* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
|
|
8986
|
-
!isEmpty(
|
|
9104
|
+
!isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: j })
|
|
8987
9105
|
] }),
|
|
8988
9106
|
/* @__PURE__ */ jsx(
|
|
8989
9107
|
Textarea,
|
|
@@ -9004,7 +9122,7 @@ const AiAssistant = () => {
|
|
|
9004
9122
|
] })
|
|
9005
9123
|
] }),
|
|
9006
9124
|
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: !i.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: u !== null ? "Save" : "Add" }) }),
|
|
9007
|
-
|
|
9125
|
+
m && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: m })
|
|
9008
9126
|
]
|
|
9009
9127
|
}
|
|
9010
9128
|
),
|
|
@@ -9015,7 +9133,7 @@ const AiAssistant = () => {
|
|
|
9015
9133
|
] }),
|
|
9016
9134
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
9017
9135
|
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => E(C), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
|
|
9018
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
9136
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(C), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
|
|
9019
9137
|
] })
|
|
9020
9138
|
] }, C)) })
|
|
9021
9139
|
] });
|
|
@@ -9215,8 +9333,8 @@ const RootLayout = () => {
|
|
|
9215
9333
|
x.preventDefault();
|
|
9216
9334
|
}, u = (x) => {
|
|
9217
9335
|
n(o === x ? null : x);
|
|
9218
|
-
}, g = useSidebarMenuItems(), { t:
|
|
9219
|
-
return /* @__PURE__ */ jsx("div", { dir:
|
|
9336
|
+
}, g = useSidebarMenuItems(), { t: m } = useTranslation(), h = [...g, ...c], f = useBuilderProp("htmlDir", "ltr");
|
|
9337
|
+
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: [
|
|
9220
9338
|
/* @__PURE__ */ jsxs(
|
|
9221
9339
|
"div",
|
|
9222
9340
|
{
|
|
@@ -9226,21 +9344,21 @@ const RootLayout = () => {
|
|
|
9226
9344
|
/* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
|
|
9227
9345
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
9228
9346
|
/* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
9229
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children:
|
|
9347
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: h.map((x, b) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9230
9348
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
9231
9349
|
Button,
|
|
9232
9350
|
{
|
|
9233
|
-
variant: o ===
|
|
9351
|
+
variant: o === b ? "default" : "ghost",
|
|
9234
9352
|
className: "mb-2 rounded-lg p-2 transition-colors",
|
|
9235
|
-
onClick: () => u(
|
|
9353
|
+
onClick: () => u(b),
|
|
9236
9354
|
children: get(x, "icon", null)
|
|
9237
9355
|
},
|
|
9238
|
-
|
|
9356
|
+
b
|
|
9239
9357
|
) }),
|
|
9240
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
9241
|
-
] }, "button" +
|
|
9358
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(x.label) }) })
|
|
9359
|
+
] }, "button" + b)) }),
|
|
9242
9360
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
9243
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((x,
|
|
9361
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((x, b) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(x, {}) }, `sidebar-component-${b}`)) })
|
|
9244
9362
|
] }),
|
|
9245
9363
|
/* @__PURE__ */ jsx(
|
|
9246
9364
|
motion.div,
|
|
@@ -9253,14 +9371,14 @@ const RootLayout = () => {
|
|
|
9253
9371
|
/* @__PURE__ */ jsxs(
|
|
9254
9372
|
"div",
|
|
9255
9373
|
{
|
|
9256
|
-
className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(
|
|
9374
|
+
className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(h, `${o}.isInternal`, !1) ? "" : "w-64"}`,
|
|
9257
9375
|
children: [
|
|
9258
|
-
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(
|
|
9259
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9376
|
+
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(h, `${o}.icon`, null) }),
|
|
9377
|
+
/* @__PURE__ */ jsx("span", { children: m(h[o].label) })
|
|
9260
9378
|
]
|
|
9261
9379
|
}
|
|
9262
9380
|
),
|
|
9263
|
-
/* @__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(
|
|
9381
|
+
/* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(h, `${o}.component`, null), {}) }) })
|
|
9264
9382
|
] })
|
|
9265
9383
|
}
|
|
9266
9384
|
),
|
|
@@ -9279,11 +9397,11 @@ const RootLayout = () => {
|
|
|
9279
9397
|
/* @__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: [
|
|
9280
9398
|
/* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
|
|
9281
9399
|
" ",
|
|
9282
|
-
|
|
9400
|
+
m("AI Assistant")
|
|
9283
9401
|
] }) }) : l === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
9284
9402
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
9285
9403
|
/* @__PURE__ */ jsx(Paintbrush, { className: "h-4 w-4 rtl:ml-2" }),
|
|
9286
|
-
|
|
9404
|
+
m("Theme Settings")
|
|
9287
9405
|
] }),
|
|
9288
9406
|
/* @__PURE__ */ jsx(
|
|
9289
9407
|
Button,
|
|
@@ -9405,9 +9523,9 @@ export {
|
|
|
9405
9523
|
generateUUID as generateBlockId,
|
|
9406
9524
|
getBlocksFromHTML,
|
|
9407
9525
|
getClassValueAndUnit,
|
|
9408
|
-
|
|
9526
|
+
We as i18n,
|
|
9409
9527
|
cn$1 as mergeClasses,
|
|
9410
|
-
|
|
9528
|
+
Fe as registerChaiBlock,
|
|
9411
9529
|
useAddBlock,
|
|
9412
9530
|
useAddClassesToBlocks,
|
|
9413
9531
|
useAskAi,
|
|
@@ -9450,7 +9568,7 @@ export {
|
|
|
9450
9568
|
useStylingState,
|
|
9451
9569
|
useTheme,
|
|
9452
9570
|
useThemeOptions,
|
|
9453
|
-
|
|
9571
|
+
Ve as useTranslation,
|
|
9454
9572
|
useUILibraryBlocks,
|
|
9455
9573
|
useUndoManager,
|
|
9456
9574
|
useUpdateBlocksProps,
|