@chaibuilder/sdk 3.1.7 → 3.1.9
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/{code-editor-D1w8nUwt.js → code-editor-B1G67AXy.js} +1 -1
- package/dist/{code-editor-DEY4IkBJ.cjs → code-editor-CgrS41Jk.cjs} +1 -1
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +4 -1
- package/dist/core.js +1 -1
- package/dist/{css-import-modal-P7f5SEKA.cjs → css-import-modal-BLAkS06W.cjs} +2 -2
- package/dist/{css-import-modal-DK2j6oGY.js → css-import-modal-DgLi5BIu.js} +25 -25
- package/dist/{index-Cj8rTugy.js → index-Do47CY7C.js} +853 -837
- package/dist/{index-CONV5Fbc.cjs → index-kbs2fSny.cjs} +5 -5
- package/dist/{rte-widget-modal-CsOaIXCW.js → rte-widget-modal-BiZPyPF3.js} +1 -1
- package/dist/{rte-widget-modal-D_Yor38o.cjs → rte-widget-modal-CB3K6Mon.cjs} +1 -1
- package/package.json +1 -1
|
@@ -4,7 +4,7 @@ var $ = (o, n, r) => W(o, typeof n != "symbol" ? n + "" : n, r);
|
|
|
4
4
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
5
5
|
import { useRegisteredChaiBlocks, getRegisteredChaiBlock, getDefaultBlockProps, syncBlocksWithDefaults, useRegisteredFonts, getBlockFormSchemas } from "@chaibuilder/runtime";
|
|
6
6
|
import { get, find, filter, flatten, has, map, includes, without, compact, isEmpty, isString, each, omit, values, pick, startsWith, isFunction, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, kebabCase, round, reverse, findIndex, uniq, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, sortBy } from "lodash-es";
|
|
7
|
-
import { SquareIcon, ZoomInIcon, ChevronRightIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, CaretDownIcon, Cross1Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, ListBulletIcon, ValueIcon, TextAlignCenterIcon, TextAlignRightIcon, TextAlignLeftIcon, Link2Icon, LinkBreak2Icon, EnterFullScreenIcon, ExclamationTriangleIcon, Pencil2Icon, ChevronLeftIcon, LoopIcon, IdCardIcon, PlusCircledIcon, ChevronDownIcon, InfoCircledIcon, FileIcon, DotsVerticalIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, BoxIcon, MinusIcon, CrossCircledIcon, MobileIcon, LaptopIcon, DesktopIcon, CircleIcon, MagnifyingGlassIcon, ReloadIcon, CaretRightIcon, FrameIcon, EraserIcon, CheckIcon, DownloadIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, DoubleArrowDownIcon, DoubleArrowUpIcon, ResetIcon, UploadIcon, TextIcon, CornerTopRightIcon, MixerHorizontalIcon, SunIcon, MoonIcon, FaceIcon, ShuffleIcon, ChatBubbleIcon, StopIcon, DotsHorizontalIcon, LightningBoltIcon, StackIcon, DragHandleDots2Icon } from "@radix-ui/react-icons";
|
|
7
|
+
import { SquareIcon, ZoomInIcon, ChevronRightIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, GearIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, CaretDownIcon, Cross1Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, ListBulletIcon, ValueIcon, TextAlignCenterIcon, TextAlignRightIcon, TextAlignLeftIcon, Link2Icon, LinkBreak2Icon, EnterFullScreenIcon, ExclamationTriangleIcon, Pencil2Icon, ChevronLeftIcon, LoopIcon, IdCardIcon, PlusCircledIcon, ChevronDownIcon, InfoCircledIcon, FileIcon, DotsVerticalIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, BoxIcon, MinusIcon, CrossCircledIcon, MobileIcon, LaptopIcon, DesktopIcon, CircleIcon, MagnifyingGlassIcon, ReloadIcon, CaretRightIcon, FrameIcon, EraserIcon, CheckIcon, DownloadIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, DoubleArrowDownIcon, DoubleArrowUpIcon, ResetIcon, UploadIcon, TextIcon, CornerTopRightIcon, MixerHorizontalIcon, SunIcon, MoonIcon, FaceIcon, ShuffleIcon, ChatBubbleIcon, StopIcon, DotsHorizontalIcon, LightningBoltIcon, StackIcon, DragHandleDots2Icon } from "@radix-ui/react-icons";
|
|
8
8
|
import * as React from "react";
|
|
9
9
|
import React__default, { useMemo, useCallback, useEffect, useState, useRef, Component, Children, memo, createElement, createContext, useContext, Suspense, lazy, useReducer, useDebugValue } from "react";
|
|
10
10
|
import { atom, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
|
|
@@ -223,16 +223,16 @@ function insertBlocksAtPosition(o, n, r, a) {
|
|
|
223
223
|
const l = [...n];
|
|
224
224
|
let i = [...o];
|
|
225
225
|
if (r) {
|
|
226
|
-
const
|
|
227
|
-
if (
|
|
226
|
+
const u = o.find((g) => g._id === r);
|
|
227
|
+
if (u && u.content !== void 0 && u.content !== "" && !o.some((m) => m._parent === r)) {
|
|
228
228
|
const h = {
|
|
229
229
|
_id: generateUUID(),
|
|
230
230
|
_parent: r,
|
|
231
231
|
_type: "Text",
|
|
232
|
-
content:
|
|
232
|
+
content: u.content
|
|
233
233
|
};
|
|
234
|
-
Object.keys(
|
|
235
|
-
f.startsWith("content-") && (h[f] =
|
|
234
|
+
Object.keys(u).forEach((f) => {
|
|
235
|
+
f.startsWith("content-") && (h[f] = u[f]);
|
|
236
236
|
}), l.unshift(h), i = i.map((f) => {
|
|
237
237
|
if (f._id === r) {
|
|
238
238
|
const x = { ...f, content: "" };
|
|
@@ -244,14 +244,14 @@ function insertBlocksAtPosition(o, n, r, a) {
|
|
|
244
244
|
});
|
|
245
245
|
}
|
|
246
246
|
}
|
|
247
|
-
let c = i.filter((
|
|
248
|
-
r && (c = i.filter((
|
|
249
|
-
const
|
|
247
|
+
let c = i.filter((u) => !u._parent);
|
|
248
|
+
r && (c = i.filter((u) => u._parent === r));
|
|
249
|
+
const d = !isNaN(a) || a > -1 ? Math.min(a, c.length) : c.length;
|
|
250
250
|
let p = i.length;
|
|
251
|
-
for (let
|
|
252
|
-
if (r !== void 0 ? i[
|
|
253
|
-
if (g ===
|
|
254
|
-
p =
|
|
251
|
+
for (let u = 0, g = 0; u < i.length; u++)
|
|
252
|
+
if (r !== void 0 ? i[u]._parent === r : !i[u]._parent) {
|
|
253
|
+
if (g === d) {
|
|
254
|
+
p = u;
|
|
255
255
|
break;
|
|
256
256
|
}
|
|
257
257
|
g++;
|
|
@@ -269,11 +269,11 @@ function findNodeById(o, n) {
|
|
|
269
269
|
return o.first((r) => r.model._id === n) || null;
|
|
270
270
|
}
|
|
271
271
|
function moveNode(o, n, r, a) {
|
|
272
|
-
var
|
|
272
|
+
var u, g;
|
|
273
273
|
const l = findNodeById(o, n), i = findNodeById(o, r);
|
|
274
274
|
if (!l || !i) return !1;
|
|
275
275
|
i.children || (i.model.children = []);
|
|
276
|
-
let c = (
|
|
276
|
+
let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((m) => m.model._id === n);
|
|
277
277
|
l.drop(), c = Math.max(c, 0);
|
|
278
278
|
const p = (((g = l == null ? void 0 : l.model) == null ? void 0 : g._parent) || "root") === r && c <= a ? a - 1 : a;
|
|
279
279
|
try {
|
|
@@ -291,15 +291,15 @@ function handleOldParentTextBlock(o, n) {
|
|
|
291
291
|
if (l.length === 2) {
|
|
292
292
|
const i = l.find((c) => c._id !== n._id);
|
|
293
293
|
if (i && i._type === "Text" && "content" in a)
|
|
294
|
-
return o.map((
|
|
295
|
-
if (
|
|
296
|
-
const p = { ...
|
|
297
|
-
return Object.keys(i).forEach((
|
|
298
|
-
|
|
294
|
+
return o.map((d) => {
|
|
295
|
+
if (d._id === r) {
|
|
296
|
+
const p = { ...d, content: i.content };
|
|
297
|
+
return Object.keys(i).forEach((u) => {
|
|
298
|
+
u.startsWith("content-") && (p[u] = i[u]);
|
|
299
299
|
}), p;
|
|
300
300
|
}
|
|
301
|
-
return
|
|
302
|
-
}).filter((
|
|
301
|
+
return d;
|
|
302
|
+
}).filter((d) => d._id !== i._id);
|
|
303
303
|
}
|
|
304
304
|
return o;
|
|
305
305
|
}
|
|
@@ -314,32 +314,32 @@ function handleNewParentTextBlock(o, n, r) {
|
|
|
314
314
|
_type: "Text",
|
|
315
315
|
content: a.content
|
|
316
316
|
};
|
|
317
|
-
Object.keys(a).forEach((
|
|
318
|
-
|
|
317
|
+
Object.keys(a).forEach((u) => {
|
|
318
|
+
u.startsWith("content-") && (c[u] = a[u]);
|
|
319
319
|
});
|
|
320
|
-
const
|
|
321
|
-
if (
|
|
322
|
-
const g = { ...
|
|
320
|
+
const d = o.map((u) => {
|
|
321
|
+
if (u._id === r) {
|
|
322
|
+
const g = { ...u, content: "" };
|
|
323
323
|
return Object.keys(g).forEach((m) => {
|
|
324
324
|
m.startsWith("content-") && (g[m] = "");
|
|
325
325
|
}), g;
|
|
326
326
|
}
|
|
327
|
-
return
|
|
328
|
-
}), p =
|
|
329
|
-
return p !== -1 ? [...
|
|
327
|
+
return u;
|
|
328
|
+
}), p = d.findIndex((u) => u._id === n._id);
|
|
329
|
+
return p !== -1 ? [...d.slice(0, p), c, ...d.slice(p)] : [c, ...d];
|
|
330
330
|
}
|
|
331
331
|
return o;
|
|
332
332
|
}
|
|
333
333
|
function moveBlocksWithChildren(o, n, r, a) {
|
|
334
334
|
if (!n) return o;
|
|
335
|
-
const l = o.find((
|
|
335
|
+
const l = o.find((u) => u._id === n);
|
|
336
336
|
if (!l) return o;
|
|
337
337
|
let i = handleOldParentTextBlock(o, l);
|
|
338
338
|
const c = r || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
|
|
339
339
|
if (moveNode(p, n, c, a)) {
|
|
340
|
-
let
|
|
341
|
-
const g =
|
|
342
|
-
return g && (g._parent = c === "root" ? null : c),
|
|
340
|
+
let u = flattenTree(p);
|
|
341
|
+
const g = u.find((m) => m._id === n);
|
|
342
|
+
return g && (g._parent = c === "root" ? null : c), u.shift(), r && (u = handleNewParentTextBlock(u, l, r)), u;
|
|
343
343
|
}
|
|
344
344
|
return i;
|
|
345
345
|
}
|
|
@@ -361,16 +361,16 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
|
|
|
361
361
|
}), [o, n]);
|
|
362
362
|
}, removeNestedBlocks = (o, n) => {
|
|
363
363
|
let r = [...o], a = [];
|
|
364
|
-
n.forEach((
|
|
365
|
-
const p = r.find((m) => m._id ===
|
|
364
|
+
n.forEach((d) => {
|
|
365
|
+
const p = r.find((m) => m._id === d);
|
|
366
366
|
if (!p || !p._parent) return;
|
|
367
|
-
const
|
|
367
|
+
const u = p._parent, g = r.filter((m) => m._parent === u);
|
|
368
368
|
if (g.length === 2) {
|
|
369
|
-
const m = g.find((h) => h._id !==
|
|
369
|
+
const m = g.find((h) => h._id !== d);
|
|
370
370
|
if (m && m._type === "Text") {
|
|
371
|
-
const h = r.find((f) => f._id ===
|
|
371
|
+
const h = r.find((f) => f._id === u);
|
|
372
372
|
h && "content" in h && (r = r.map((f) => {
|
|
373
|
-
if (f._id ===
|
|
373
|
+
if (f._id === u) {
|
|
374
374
|
const x = { ...f, content: m.content };
|
|
375
375
|
return Object.keys(m).forEach((b) => {
|
|
376
376
|
b.startsWith("content-") && (x[b] = m[b]);
|
|
@@ -381,15 +381,15 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
|
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
383
|
});
|
|
384
|
-
const l = [...n, ...a], i = [], c = filter(r, (
|
|
384
|
+
const l = [...n, ...a], i = [], c = filter(r, (d) => includes(l, d._id) || includes(l, d._parent) ? (i.push(d._id), !1) : !0);
|
|
385
385
|
return isEmpty(i) ? c : removeNestedBlocks(c, i);
|
|
386
386
|
}, useRemoveBlocks = () => {
|
|
387
387
|
const [o] = useBlocksStore(), [n, r] = useSelectedBlockIds(), { setNewBlocks: a } = useBlocksStoreUndoableActions(), { hasPermission: l } = usePermissions();
|
|
388
388
|
return useCallback(
|
|
389
389
|
(i) => {
|
|
390
|
-
var
|
|
390
|
+
var d;
|
|
391
391
|
if (!l(PERMISSIONS.DELETE_BLOCK)) return;
|
|
392
|
-
const c = ((
|
|
392
|
+
const c = ((d = find(o, { _id: i[0] })) == null ? void 0 : d._parent) || null;
|
|
393
393
|
a(removeNestedBlocks(o, i)), setTimeout(() => r(c ? [c] : []), 200);
|
|
394
394
|
},
|
|
395
395
|
[o, r, n, l]
|
|
@@ -424,8 +424,8 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
|
|
|
424
424
|
},
|
|
425
425
|
addBlocks: (a, l, i) => {
|
|
426
426
|
o((c) => {
|
|
427
|
-
const
|
|
428
|
-
return n({ type: "blocks-updated", blocks:
|
|
427
|
+
const d = insertBlocksAtPosition(c, a, l, i);
|
|
428
|
+
return n({ type: "blocks-updated", blocks: d }), d;
|
|
429
429
|
});
|
|
430
430
|
},
|
|
431
431
|
removeBlocks: (a) => {
|
|
@@ -436,13 +436,13 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
|
|
|
436
436
|
},
|
|
437
437
|
moveBlocks: (a, l, i) => {
|
|
438
438
|
o((c) => {
|
|
439
|
-
let
|
|
439
|
+
let d = [...c];
|
|
440
440
|
for (let p = 0; p < a.length; p++)
|
|
441
|
-
|
|
441
|
+
d = moveBlocksWithChildren(d, a[p], l, i);
|
|
442
442
|
return each(a, (p) => {
|
|
443
|
-
const
|
|
444
|
-
|
|
445
|
-
}), n({ type: "blocks-updated", blocks:
|
|
443
|
+
const u = find(d, (g) => g._id === p);
|
|
444
|
+
u && r({ id: p, props: { _parent: u._parent || null } });
|
|
445
|
+
}), n({ type: "blocks-updated", blocks: d }), d;
|
|
446
446
|
});
|
|
447
447
|
},
|
|
448
448
|
updateBlocksProps: (a) => {
|
|
@@ -459,7 +459,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
|
|
|
459
459
|
status: "idle",
|
|
460
460
|
props: {},
|
|
461
461
|
error: void 0
|
|
462
|
-
}), c = useUpdateBlocksPropsRealtime(),
|
|
462
|
+
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (f) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), m = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
|
|
463
463
|
return useEffect(() => {
|
|
464
464
|
if (n === "mock") {
|
|
465
465
|
if (isFunction(a)) {
|
|
@@ -471,7 +471,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
|
|
|
471
471
|
}
|
|
472
472
|
return;
|
|
473
473
|
}
|
|
474
|
-
n === "live" && (!g && !m || (i((f) => ({ ...f, status: "loading", props: {} })),
|
|
474
|
+
n === "live" && (!g && !m || (i((f) => ({ ...f, status: "loading", props: {} })), d({ block: o }).then((f = {}) => {
|
|
475
475
|
g ? (p((x) => ({
|
|
476
476
|
...x,
|
|
477
477
|
[o._id]: {
|
|
@@ -486,7 +486,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
|
|
|
486
486
|
[o._id]: { status: "error", error: f, props: [] }
|
|
487
487
|
})), i((x) => ({ ...x, status: "error", error: f, props: {} }))) : i((x) => ({ ...x, status: "error", error: f, props: {} }));
|
|
488
488
|
})));
|
|
489
|
-
}, [o == null ? void 0 : o._id,
|
|
489
|
+
}, [o == null ? void 0 : o._id, u, g, m, a, n]), {
|
|
490
490
|
$loading: get(l, "status") === "loading",
|
|
491
491
|
...o ? get(l, "props", {}) : {}
|
|
492
492
|
};
|
|
@@ -640,13 +640,13 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
|
|
|
640
640
|
}
|
|
641
641
|
}) : !1, useSavePage = () => {
|
|
642
642
|
const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (f) => {
|
|
643
|
-
}), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang:
|
|
643
|
+
}), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: d, fallbackLang: p } = useLanguages(), [u] = useIsPageLoaded(), g = () => {
|
|
644
644
|
const f = l();
|
|
645
|
-
return !
|
|
645
|
+
return !d || d === p ? !1 : checkMissingTranslations(f.blocks || [], d);
|
|
646
646
|
};
|
|
647
647
|
return { savePage: useThrottledCallback(
|
|
648
648
|
async (f = !1) => {
|
|
649
|
-
if (!c("save_page") || !
|
|
649
|
+
if (!c("save_page") || !u)
|
|
650
650
|
return;
|
|
651
651
|
n("SAVING"), a("SAVING");
|
|
652
652
|
const x = l();
|
|
@@ -659,11 +659,11 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
|
|
|
659
659
|
n("SAVED"), a("SAVED");
|
|
660
660
|
}, 100), !0;
|
|
661
661
|
},
|
|
662
|
-
[l, n, i, r, a,
|
|
662
|
+
[l, n, i, r, a, u],
|
|
663
663
|
3e3
|
|
664
664
|
// save only every 5 seconds
|
|
665
665
|
), savePageAsync: async () => {
|
|
666
|
-
if (!c("save_page") || !
|
|
666
|
+
if (!c("save_page") || !u)
|
|
667
667
|
return;
|
|
668
668
|
n("SAVING"), a("SAVING");
|
|
669
669
|
const f = l();
|
|
@@ -683,23 +683,23 @@ const undoRedoStateAtom = atom({
|
|
|
683
683
|
canRedo: !1
|
|
684
684
|
}), useUndoManager = () => {
|
|
685
685
|
const [, o] = useAtom$1(builderSaveStateAtom), [n, r] = useAtom$1(undoRedoStateAtom), a = useBuilderProp("onSaveStateChange", noop), l = useCallback(() => {
|
|
686
|
-
const
|
|
686
|
+
const u = {
|
|
687
687
|
canUndo: undoManager.hasUndo(),
|
|
688
688
|
canRedo: undoManager.hasRedo()
|
|
689
689
|
};
|
|
690
|
-
r(
|
|
690
|
+
r(u), o("UNSAVED"), a("UNSAVED");
|
|
691
691
|
}, [r, o, a]);
|
|
692
692
|
useEffect(() => (undoManager.setCallback(l), () => {
|
|
693
693
|
undoManager.setCallback(noop);
|
|
694
694
|
}), [l]);
|
|
695
695
|
const i = useCallback(
|
|
696
|
-
(
|
|
697
|
-
undoManager.add(
|
|
696
|
+
(u) => {
|
|
697
|
+
undoManager.add(u), l();
|
|
698
698
|
},
|
|
699
699
|
[l]
|
|
700
700
|
), c = useCallback(() => {
|
|
701
701
|
undoManager.undo(), l();
|
|
702
|
-
}, [l]),
|
|
702
|
+
}, [l]), d = useCallback(() => {
|
|
703
703
|
undoManager.redo(), l();
|
|
704
704
|
}, [l]), p = useCallback(() => {
|
|
705
705
|
undoManager.clear(), r({
|
|
@@ -711,12 +711,12 @@ const undoRedoStateAtom = atom({
|
|
|
711
711
|
() => ({
|
|
712
712
|
add: i,
|
|
713
713
|
undo: c,
|
|
714
|
-
redo:
|
|
714
|
+
redo: d,
|
|
715
715
|
hasUndo: () => n.canUndo,
|
|
716
716
|
hasRedo: () => n.canRedo,
|
|
717
717
|
clear: p
|
|
718
718
|
}),
|
|
719
|
-
[i, c,
|
|
719
|
+
[i, c, d, n.canUndo, n.canRedo, p]
|
|
720
720
|
);
|
|
721
721
|
}, useBlocksStore = () => useAtom$1(presentBlocksAtom), useBlocksStoreUndoableActions = () => {
|
|
722
722
|
const { add: o } = useUndoManager(), [n] = useBlocksStore(), {
|
|
@@ -728,13 +728,13 @@ const undoRedoStateAtom = atom({
|
|
|
728
728
|
} = useBlocksStoreManager();
|
|
729
729
|
return {
|
|
730
730
|
moveBlocks: (x, b, y) => {
|
|
731
|
-
const S = map(x, (
|
|
732
|
-
const B = n.find((A) => A._id ===
|
|
733
|
-
return { _id:
|
|
734
|
-
}), C = S.find(({ _id:
|
|
731
|
+
const S = map(x, (v) => {
|
|
732
|
+
const B = n.find((A) => A._id === v)._parent || null, k = n.filter((A) => B ? A._parent === B : !A._parent).map((A) => A._id).indexOf(v);
|
|
733
|
+
return { _id: v, oldParent: B, oldPosition: k };
|
|
734
|
+
}), C = S.find(({ _id: v }) => v === x[0]);
|
|
735
735
|
C && C.oldParent === b && C.oldPosition === y || (i(x, b, y), o({
|
|
736
|
-
undo: () => each(S, ({ _id:
|
|
737
|
-
i([
|
|
736
|
+
undo: () => each(S, ({ _id: v, oldParent: _, oldPosition: B }) => {
|
|
737
|
+
i([v], _, B);
|
|
738
738
|
}),
|
|
739
739
|
redo: () => i(x, b, y)
|
|
740
740
|
}));
|
|
@@ -747,7 +747,7 @@ const undoRedoStateAtom = atom({
|
|
|
747
747
|
},
|
|
748
748
|
removeBlocks: (x) => {
|
|
749
749
|
var C;
|
|
750
|
-
const b = (C = first(x)) == null ? void 0 : C._parent, S = n.filter((
|
|
750
|
+
const b = (C = first(x)) == null ? void 0 : C._parent, S = n.filter((v) => b ? v._parent === b : !v._parent).indexOf(first(x));
|
|
751
751
|
l(map(x, "_id")), o({
|
|
752
752
|
undo: () => a(x, b, S),
|
|
753
753
|
redo: () => l(map(x, "_id"))
|
|
@@ -759,8 +759,8 @@ const undoRedoStateAtom = atom({
|
|
|
759
759
|
S = map(x, (C) => ({ _id: C, ...y }));
|
|
760
760
|
else {
|
|
761
761
|
const C = keys(b);
|
|
762
|
-
S = map(x, (
|
|
763
|
-
const _ = n.find((I) => I._id ===
|
|
762
|
+
S = map(x, (v) => {
|
|
763
|
+
const _ = n.find((I) => I._id === v), B = { _id: v };
|
|
764
764
|
return each(C, (I) => B[I] = _[I]), B;
|
|
765
765
|
});
|
|
766
766
|
}
|
|
@@ -781,8 +781,8 @@ const undoRedoStateAtom = atom({
|
|
|
781
781
|
updateMultipleBlocksProps: (x) => {
|
|
782
782
|
let b = [];
|
|
783
783
|
b = map(x, (y) => {
|
|
784
|
-
const S = keys(y), C = n.find((_) => _._id === y._id),
|
|
785
|
-
return each(S, (_) =>
|
|
784
|
+
const S = keys(y), C = n.find((_) => _._id === y._id), v = {};
|
|
785
|
+
return each(S, (_) => v[_] = C[_]), v;
|
|
786
786
|
}), c(x), o({
|
|
787
787
|
undo: () => c(b),
|
|
788
788
|
redo: () => c(x)
|
|
@@ -820,7 +820,7 @@ import.meta.vitest && describe("canDropBlock Function", () => {
|
|
|
820
820
|
});
|
|
821
821
|
const useAddBlock = () => {
|
|
822
822
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
823
|
-
(i, c,
|
|
823
|
+
(i, c, d) => {
|
|
824
824
|
var h;
|
|
825
825
|
for (let f = 0; f < i.length; f++) {
|
|
826
826
|
const { _id: x } = i[f];
|
|
@@ -830,26 +830,26 @@ const useAddBlock = () => {
|
|
|
830
830
|
b[y]._parent = i[f]._id;
|
|
831
831
|
}
|
|
832
832
|
const p = first(i);
|
|
833
|
-
let
|
|
834
|
-
return c && (
|
|
833
|
+
let u, g;
|
|
834
|
+
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);
|
|
835
835
|
},
|
|
836
836
|
[r, o, n]
|
|
837
837
|
);
|
|
838
838
|
return { addCoreBlock: useCallback(
|
|
839
|
-
(i, c,
|
|
839
|
+
(i, c, d) => {
|
|
840
840
|
if (has(i, "blocks")) {
|
|
841
841
|
const b = i.blocks;
|
|
842
|
-
return a(b, c,
|
|
842
|
+
return a(b, c, d);
|
|
843
843
|
}
|
|
844
|
-
const p = generateUUID(),
|
|
844
|
+
const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
|
|
845
845
|
_type: i.type,
|
|
846
846
|
_id: p,
|
|
847
|
-
...
|
|
847
|
+
...u,
|
|
848
848
|
...has(i, "_name") && { _name: i._name },
|
|
849
849
|
...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
|
|
850
850
|
};
|
|
851
851
|
let m, h;
|
|
852
|
-
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,
|
|
852
|
+
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;
|
|
853
853
|
},
|
|
854
854
|
[r, a, o, n]
|
|
855
855
|
), addPredefinedBlock: a };
|
|
@@ -1959,11 +1959,11 @@ function removeDuplicateClasses(o) {
|
|
|
1959
1959
|
if (r.length === 1) return r[0].fullCls;
|
|
1960
1960
|
for (const l of r) {
|
|
1961
1961
|
const i = l.property, c = n.indexOf(l.mq);
|
|
1962
|
-
for (let
|
|
1963
|
-
const p = n[
|
|
1964
|
-
if (
|
|
1965
|
-
a = a.replace(
|
|
1966
|
-
else if (
|
|
1962
|
+
for (let d = c + 1; d < n.length; d++) {
|
|
1963
|
+
const p = n[d], u = r.find((g) => g.property === i && g.mq === p);
|
|
1964
|
+
if (u && u.cls === l.cls)
|
|
1965
|
+
a = a.replace(u.fullCls, "");
|
|
1966
|
+
else if (u && u.cls !== l.cls)
|
|
1967
1967
|
break;
|
|
1968
1968
|
}
|
|
1969
1969
|
}
|
|
@@ -1983,12 +1983,12 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), add
|
|
|
1983
1983
|
)
|
|
1984
1984
|
), i = first(o(selectedStylingBlocksAtom));
|
|
1985
1985
|
return map(l, (c) => {
|
|
1986
|
-
const
|
|
1986
|
+
const d = o(c), p = get(d, i.prop, `${STYLES_KEY},`), { classes: u } = getSplitChaiClasses(p);
|
|
1987
1987
|
return {
|
|
1988
|
-
ids: [
|
|
1988
|
+
ids: [d._id],
|
|
1989
1989
|
props: {
|
|
1990
1990
|
[i.prop]: `${STYLES_KEY},${orderClassesByBreakpoint(
|
|
1991
|
-
removeDuplicateClasses(twMerge(
|
|
1991
|
+
removeDuplicateClasses(twMerge(u, a))
|
|
1992
1992
|
)}`
|
|
1993
1993
|
}
|
|
1994
1994
|
};
|
|
@@ -2229,11 +2229,11 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), add
|
|
|
2229
2229
|
for (const i of l) {
|
|
2230
2230
|
const c = r[i];
|
|
2231
2231
|
if (isString(c)) {
|
|
2232
|
-
const
|
|
2232
|
+
const d = chunk(c.split(""), 12);
|
|
2233
2233
|
let p = "";
|
|
2234
2234
|
o([n], { [i]: "" });
|
|
2235
|
-
for (let
|
|
2236
|
-
p += u
|
|
2235
|
+
for (let u = 0; u < d.length; u++)
|
|
2236
|
+
p += d[u].join(""), o([n], { [i]: p }), await new Promise((g) => setTimeout(g, a));
|
|
2237
2237
|
}
|
|
2238
2238
|
}
|
|
2239
2239
|
},
|
|
@@ -2271,16 +2271,16 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2271
2271
|
return r = flattenDeep([...r, ...getChildBlocks(n, o, r)]), r;
|
|
2272
2272
|
}, pickOnlyAIProps = (o, n, r) => compact(
|
|
2273
2273
|
o.map((a) => {
|
|
2274
|
-
const l = ["_id", "_type", "_parent"], i = pick(a, l), c = getRegisteredChaiBlock(a._type),
|
|
2275
|
-
for (const
|
|
2276
|
-
if (!l.includes(
|
|
2277
|
-
const g = get(a, `${
|
|
2278
|
-
u
|
|
2274
|
+
const l = ["_id", "_type", "_parent"], i = pick(a, l), c = getRegisteredChaiBlock(a._type), d = {}, p = get(c, "aiProps", []);
|
|
2275
|
+
for (const u in a)
|
|
2276
|
+
if (!l.includes(u) && p.includes(u)) {
|
|
2277
|
+
const g = get(a, `${u}-${n}`, ""), m = get(a, u, "");
|
|
2278
|
+
d[u] = isString(g) && g.trim() || m, r && (d[u] = m);
|
|
2279
2279
|
}
|
|
2280
|
-
return isEmpty(
|
|
2280
|
+
return isEmpty(d) ? !1 : (has(i, "_parent") && isEmpty(i._parent) && delete i._parent, { ...i, ...d });
|
|
2281
2281
|
})
|
|
2282
2282
|
), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
|
|
2283
|
-
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [
|
|
2283
|
+
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) => {
|
|
2284
2284
|
const x = cloneDeep(f.find((b) => b._id === h));
|
|
2285
2285
|
for (const b in x) {
|
|
2286
2286
|
const y = x[b];
|
|
@@ -2298,7 +2298,7 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2298
2298
|
if (l) {
|
|
2299
2299
|
n(!0), a(null);
|
|
2300
2300
|
try {
|
|
2301
|
-
const y = p ===
|
|
2301
|
+
const y = p === u ? "" : p, S = x.toLowerCase().includes("translate the content"), C = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p, S) : [m(f, d)], v = await l(h, addLangToPrompt(x, g, h), C, y), { blocks: _, error: B } = v;
|
|
2302
2302
|
if (B) {
|
|
2303
2303
|
a(B);
|
|
2304
2304
|
return;
|
|
@@ -2312,7 +2312,7 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2312
2312
|
c(I);
|
|
2313
2313
|
} else
|
|
2314
2314
|
i(_);
|
|
2315
|
-
b && b(
|
|
2315
|
+
b && b(v);
|
|
2316
2316
|
} catch (y) {
|
|
2317
2317
|
a(y);
|
|
2318
2318
|
} finally {
|
|
@@ -2324,8 +2324,8 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2324
2324
|
l,
|
|
2325
2325
|
n,
|
|
2326
2326
|
p,
|
|
2327
|
-
d,
|
|
2328
2327
|
u,
|
|
2328
|
+
d,
|
|
2329
2329
|
g,
|
|
2330
2330
|
c,
|
|
2331
2331
|
i
|
|
@@ -2338,18 +2338,18 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2338
2338
|
const [o, n] = useAtom$1(partialBlocksStoreAtom), r = useCallback((l) => get(o, l, []), [o]), a = useCallback(() => n({}), [n]);
|
|
2339
2339
|
return { getPartailBlocks: r, reset: a };
|
|
2340
2340
|
}, useWatchPartailBlocks = () => {
|
|
2341
|
-
const [o] = useBlocksStore(), [n, r] = useAtom$1(partialBlocksStoreAtom), [a, l] = useAtom$1(partialBlocksLoadingStateAtom), i = useBuilderProp("getPartialBlockBlocks", async (
|
|
2341
|
+
const [o] = useBlocksStore(), [n, r] = useAtom$1(partialBlocksStoreAtom), [a, l] = useAtom$1(partialBlocksLoadingStateAtom), i = useBuilderProp("getPartialBlockBlocks", async (d) => []), c = useMemo(() => o.filter((d) => d._type === "PartialBlock" || d._type === "GlobalBlock").map((d) => get(d, "partialBlockId", get(d, "globalBlock", ""))), [o]);
|
|
2342
2342
|
useEffect(() => {
|
|
2343
|
-
forEach(c, (
|
|
2344
|
-
has(n,
|
|
2345
|
-
r((
|
|
2346
|
-
...
|
|
2347
|
-
[
|
|
2343
|
+
forEach(c, (d) => {
|
|
2344
|
+
has(n, d) || get(a, `${d}.loading`, !1) || (l((p) => ({ ...p, [d]: { loading: !0, error: null } })), i(d).then((p) => {
|
|
2345
|
+
r((u) => ({ ...u, [d]: p })), l((u) => ({
|
|
2346
|
+
...u,
|
|
2347
|
+
[d]: { loading: !1, error: null }
|
|
2348
2348
|
}));
|
|
2349
2349
|
}).catch((p) => {
|
|
2350
|
-
l((
|
|
2351
|
-
...
|
|
2352
|
-
[
|
|
2350
|
+
l((u) => ({
|
|
2351
|
+
...u,
|
|
2352
|
+
[d]: { loading: !1, error: p.message }
|
|
2353
2353
|
}));
|
|
2354
2354
|
}));
|
|
2355
2355
|
});
|
|
@@ -2362,7 +2362,7 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2362
2362
|
c
|
|
2363
2363
|
]);
|
|
2364
2364
|
}, partialBlocksListAtom = atom({}), usePartialBlocksList = () => {
|
|
2365
|
-
const [o, n] = useState(!1), [r, a] = useState(null), [l, i] = useAtom$1(partialBlocksListAtom), c = useBuilderProp("getPartialBlocks", async () => []),
|
|
2365
|
+
const [o, n] = useState(!1), [r, a] = useState(null), [l, i] = useAtom$1(partialBlocksListAtom), c = useBuilderProp("getPartialBlocks", async () => []), d = useCallback(async () => {
|
|
2366
2366
|
n(!0), a(null);
|
|
2367
2367
|
try {
|
|
2368
2368
|
const p = await c();
|
|
@@ -2372,12 +2372,12 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2372
2372
|
}
|
|
2373
2373
|
}, [c, i]);
|
|
2374
2374
|
return useEffect(() => {
|
|
2375
|
-
|
|
2376
|
-
}, []), { data: l, isLoading: o, refetch:
|
|
2375
|
+
d();
|
|
2376
|
+
}, []), { data: l, isLoading: o, refetch: d, error: r };
|
|
2377
2377
|
}, useBuilderReset = () => {
|
|
2378
|
-
const { clear: o } = useUndoManager(), [, n] = useSelectedBlockIds(), { clearHighlight: r } = useBlockHighlight(), [, a] = useSelectedStylingBlocks(), [, l] = useAtom$1(aiAssistantActiveAtom), { reset: i } = usePartialBlocksStore(), { setSaveState: c } = useSavePage(), [,
|
|
2378
|
+
const { clear: o } = useUndoManager(), [, n] = useSelectedBlockIds(), { clearHighlight: r } = useBlockHighlight(), [, a] = useSelectedStylingBlocks(), [, l] = useAtom$1(aiAssistantActiveAtom), { reset: i } = usePartialBlocksStore(), { setSaveState: c } = useSavePage(), [, d] = useBlockRepeaterDataAtom();
|
|
2379
2379
|
return () => {
|
|
2380
|
-
|
|
2380
|
+
d({}), n([]), a([]), r(), o(), l(!1), i(), c("SAVED");
|
|
2381
2381
|
};
|
|
2382
2382
|
}, canvasZoomAtom = atomWithStorage("canvasZoom", 100), useCanvasZoom = () => useAtom$1(canvasZoomAtom), codeEditorAtom = atom(null), useCodeEditor = () => useAtom$1(codeEditorAtom), cutBlockIdsAtom = atom([]), useCutBlockIds = () => {
|
|
2383
2383
|
const [o, n] = useAtom$1(cutBlockIdsAtom), r = useSetAtom$1(copiedBlockIdsAtom), a = useCallback(
|
|
@@ -2389,17 +2389,17 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2389
2389
|
return [o, a];
|
|
2390
2390
|
}, copiedBlockIdsAtom = atom([]), useCopyBlocks = () => {
|
|
2391
2391
|
const [o] = useBlocksStore(), [n, r] = useAtom$1(copiedBlockIdsAtom), a = useSetAtom$1(cutBlockIdsAtom), { getPartailBlocks: l } = usePartialBlocksStore(), i = useBuilderProp("flags.copyPaste", !0), c = useCallback(
|
|
2392
|
-
(p) => p.some((
|
|
2392
|
+
(p) => p.some((u) => getDuplicatedBlocks(o, u, null).some((m) => m._type === "PartialBlock" || m._type === "GlobalBlock")),
|
|
2393
2393
|
[o]
|
|
2394
|
-
),
|
|
2395
|
-
async (p,
|
|
2394
|
+
), d = useCallback(
|
|
2395
|
+
async (p, u = !1) => {
|
|
2396
2396
|
try {
|
|
2397
2397
|
if (isEmpty(p)) return;
|
|
2398
2398
|
r(p), a([]);
|
|
2399
2399
|
const g = {
|
|
2400
2400
|
_chai_copied_blocks: p.flatMap((m) => {
|
|
2401
2401
|
const h = getDuplicatedBlocks(o, m, null);
|
|
2402
|
-
if (!
|
|
2402
|
+
if (!u)
|
|
2403
2403
|
return h;
|
|
2404
2404
|
let f = [];
|
|
2405
2405
|
for (const x of h)
|
|
@@ -2427,7 +2427,7 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2427
2427
|
},
|
|
2428
2428
|
[r, a, o]
|
|
2429
2429
|
);
|
|
2430
|
-
return [n,
|
|
2430
|
+
return [n, d, c];
|
|
2431
2431
|
}, useCopyToClipboard = () => {
|
|
2432
2432
|
const [o, n] = useState(null), r = useBuilderProp("flags.copyPaste", !0), a = useCallback(async (l) => {
|
|
2433
2433
|
if (!r)
|
|
@@ -2450,12 +2450,12 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2450
2450
|
(a, l = null) => {
|
|
2451
2451
|
const i = [];
|
|
2452
2452
|
each(a, (c) => {
|
|
2453
|
-
const
|
|
2454
|
-
l ? l === "root" && (l = null) : l =
|
|
2453
|
+
const d = o.find((h) => h._id === c);
|
|
2454
|
+
l ? l === "root" && (l = null) : l = d._parent;
|
|
2455
2455
|
const g = filter(
|
|
2456
2456
|
o,
|
|
2457
2457
|
(h) => isString(l) ? h._parent === l : !h._parent
|
|
2458
|
-
).indexOf(
|
|
2458
|
+
).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
|
|
2459
2459
|
r(m, l, g), i.push(get(m, "0._id", ""));
|
|
2460
2460
|
}), n(i);
|
|
2461
2461
|
},
|
|
@@ -2471,27 +2471,27 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2471
2471
|
c.current = "loading", r((p) => ({ ...p, [o == null ? void 0 : o.id]: { loading: "loading", blocks: [] } }));
|
|
2472
2472
|
try {
|
|
2473
2473
|
const p = await a(o);
|
|
2474
|
-
c.current = "idle", r((
|
|
2474
|
+
c.current = "idle", r((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "complete", blocks: p || [] } }));
|
|
2475
2475
|
} catch {
|
|
2476
|
-
c.current = "idle", r((
|
|
2476
|
+
c.current = "idle", r((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "complete", blocks: [] } }));
|
|
2477
2477
|
}
|
|
2478
2478
|
}
|
|
2479
2479
|
})();
|
|
2480
2480
|
}, [o, l, i, c, r, a]);
|
|
2481
|
-
const
|
|
2481
|
+
const d = useCallback(
|
|
2482
2482
|
(p) => {
|
|
2483
|
-
r((
|
|
2483
|
+
r((u) => ({ ...u, [p]: { loading: "idle", blocks: [] } }));
|
|
2484
2484
|
},
|
|
2485
2485
|
[r]
|
|
2486
2486
|
);
|
|
2487
|
-
return { data: l || [], isLoading: i === "loading", resetLibrary:
|
|
2487
|
+
return { data: l || [], isLoading: i === "loading", resetLibrary: d };
|
|
2488
2488
|
}, useCanPaste = () => {
|
|
2489
2489
|
const [o] = useBlocksStore();
|
|
2490
2490
|
return (n, r) => {
|
|
2491
2491
|
var i;
|
|
2492
2492
|
const a = ((i = find(o, { _id: r })) == null ? void 0 : i._type) || null, l = first(n.map((c) => {
|
|
2493
|
-
var
|
|
2494
|
-
return (
|
|
2493
|
+
var d;
|
|
2494
|
+
return (d = find(o, { _id: c })) == null ? void 0 : d._type;
|
|
2495
2495
|
}));
|
|
2496
2496
|
return canAcceptChildBlock(a, l);
|
|
2497
2497
|
};
|
|
@@ -2518,9 +2518,9 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2518
2518
|
if (o.length > 0)
|
|
2519
2519
|
return l(o, c);
|
|
2520
2520
|
try {
|
|
2521
|
-
const
|
|
2522
|
-
if (
|
|
2523
|
-
const p = JSON.parse(
|
|
2521
|
+
const d = await navigator.clipboard.readText();
|
|
2522
|
+
if (d) {
|
|
2523
|
+
const p = JSON.parse(d);
|
|
2524
2524
|
return has(p, "_chai_copied_blocks");
|
|
2525
2525
|
}
|
|
2526
2526
|
} catch {
|
|
@@ -2532,7 +2532,7 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2532
2532
|
),
|
|
2533
2533
|
pasteBlocks: useCallback(
|
|
2534
2534
|
async (c) => {
|
|
2535
|
-
const
|
|
2535
|
+
const d = Array.isArray(c) ? c[0] : c;
|
|
2536
2536
|
if (!(navigator != null && navigator.permissions)) {
|
|
2537
2537
|
toast.error("Cannot check clipboard permissions.");
|
|
2538
2538
|
return;
|
|
@@ -2554,9 +2554,9 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2554
2554
|
async () => {
|
|
2555
2555
|
const p = await navigator.clipboard.readText();
|
|
2556
2556
|
if (p) {
|
|
2557
|
-
const
|
|
2558
|
-
if (has(
|
|
2559
|
-
a(
|
|
2557
|
+
const u = JSON.parse(p);
|
|
2558
|
+
if (has(u, "_chai_copied_blocks"))
|
|
2559
|
+
a(u._chai_copied_blocks, d === "root" ? null : d);
|
|
2560
2560
|
else
|
|
2561
2561
|
throw new Error("Nothing to paste");
|
|
2562
2562
|
} else
|
|
@@ -2583,20 +2583,20 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2583
2583
|
)
|
|
2584
2584
|
);
|
|
2585
2585
|
return map(i, (c) => {
|
|
2586
|
-
const
|
|
2587
|
-
let { classes:
|
|
2586
|
+
const d = o(c), p = a;
|
|
2587
|
+
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
2588
2588
|
return each(p, (m) => {
|
|
2589
2589
|
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
2590
|
-
|
|
2590
|
+
u = u.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
2591
2591
|
const x = first(m.split(":"));
|
|
2592
2592
|
includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(m.split(":").pop().trim());
|
|
2593
2593
|
}), each(p, (m) => {
|
|
2594
2594
|
const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
|
|
2595
2595
|
g = g.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
2596
2596
|
}), {
|
|
2597
|
-
ids: [
|
|
2597
|
+
ids: [d._id],
|
|
2598
2598
|
props: {
|
|
2599
|
-
[l.prop]: `${STYLES_KEY}${g},${
|
|
2599
|
+
[l.prop]: `${STYLES_KEY}${g},${u}`
|
|
2600
2600
|
}
|
|
2601
2601
|
};
|
|
2602
2602
|
});
|
|
@@ -2627,7 +2627,7 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2627
2627
|
);
|
|
2628
2628
|
}, useResetBlockStyles = () => {
|
|
2629
2629
|
const o = useSelectedBlock(), n = useUpdateBlocksProps(), r = useCallback((c) => getDefaultBlockProps(c) || {}, []), a = useCallback((c) => Object.keys(c).filter(
|
|
2630
|
-
(
|
|
2630
|
+
(d) => typeof c[d] == "string" && c[d].startsWith("#styles:")
|
|
2631
2631
|
), []), l = useCallback(
|
|
2632
2632
|
(c) => {
|
|
2633
2633
|
if (!o) return;
|
|
@@ -2640,7 +2640,7 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2640
2640
|
if (!o) return;
|
|
2641
2641
|
const c = a(o);
|
|
2642
2642
|
if (c.length === 0) return;
|
|
2643
|
-
const
|
|
2643
|
+
const d = r(o._type), p = pick(d, c);
|
|
2644
2644
|
n([o._id], p);
|
|
2645
2645
|
}, [o, a, r, n]), reset: l };
|
|
2646
2646
|
}, useStylingBreakpoint = () => useAtom$1(styleBreakpointAtom), canvasWidthAtom = atomWithStorage("canvasWidth", 800), canvasDisplayWidthAtom = atomWithStorage("canvasDisplayWidth", 800), canvasBreakpointAtom = atom((o) => {
|
|
@@ -2662,7 +2662,7 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2662
2662
|
}), useSelectedBlockAllClasses = () => useAtomValue$1(selectedBlockAllClassesAtom), MQ = { xs: 0, sm: 1, md: 2, lg: 3, xl: 4, "2xl": 5 }, selectedBlockCurrentClassesAtom = atom((o) => {
|
|
2663
2663
|
const n = o(canvasBreakpointAtom), r = o(styleStateAtom), a = o(darkModeAtom), l = getQueries(n);
|
|
2664
2664
|
let i = filter(o(selectedBlockAllClassesAtom), { mod: r });
|
|
2665
|
-
return startsWith(r, "_") || (i = filter(i, (c) => l.includes(c.mq))), i = i.sort((c,
|
|
2665
|
+
return startsWith(r, "_") || (i = filter(i, (c) => l.includes(c.mq))), i = i.sort((c, d) => MQ[c.mq] - MQ[d.mq]), a || (i = filter(i, { dark: !1 })), i;
|
|
2666
2666
|
}), getQueries = (o) => {
|
|
2667
2667
|
let n = [];
|
|
2668
2668
|
switch (o) {
|
|
@@ -2700,11 +2700,11 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2700
2700
|
if (!l) return null;
|
|
2701
2701
|
let i = l._parent;
|
|
2702
2702
|
for (; i; ) {
|
|
2703
|
-
const
|
|
2704
|
-
if (!
|
|
2705
|
-
if ((c = getRegisteredChaiBlock(
|
|
2706
|
-
return
|
|
2707
|
-
i =
|
|
2703
|
+
const d = find(n, { _id: i });
|
|
2704
|
+
if (!d) return null;
|
|
2705
|
+
if ((c = getRegisteredChaiBlock(d._type)) != null && c.wrapper)
|
|
2706
|
+
return d;
|
|
2707
|
+
i = d._parent;
|
|
2708
2708
|
}
|
|
2709
2709
|
return null;
|
|
2710
2710
|
});
|
|
@@ -2737,18 +2737,18 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
|
|
|
2737
2737
|
var i;
|
|
2738
2738
|
if (o.type !== "element" || !o.attributes)
|
|
2739
2739
|
return o;
|
|
2740
|
-
o.tagName === "span" && o.attributes.find((
|
|
2740
|
+
o.tagName === "span" && o.attributes.find((d) => d.key === "role" && d.value === "link") && (o.tagName = "a", o.attributes = o.attributes.filter((d) => d.key !== "role"));
|
|
2741
2741
|
const a = o.attributes.find((c) => c.key === "data-block-type"), l = o.attributes.find((c) => c.key === "data-block-id");
|
|
2742
2742
|
if (a) {
|
|
2743
2743
|
const c = a.value;
|
|
2744
2744
|
if (CORE_BLOCKS$1.includes(c) || (i = r == null ? void 0 : r.EXTRA_CORE_BLOCKS) != null && i.includes(c))
|
|
2745
|
-
o.attributes = o.attributes.filter((
|
|
2745
|
+
o.attributes = o.attributes.filter((d) => d.key !== "data-block-type"), o.children && (o.children = o.children.map((d) => transformNode(d, n, r)));
|
|
2746
2746
|
else {
|
|
2747
|
-
const
|
|
2748
|
-
o.tagName =
|
|
2749
|
-
const p = getRegisteredChaiBlock(c),
|
|
2750
|
-
if (
|
|
2751
|
-
...Object.entries(
|
|
2747
|
+
const d = `chai-${kebabCase(c)}`;
|
|
2748
|
+
o.tagName = d, l ? o.attributes = [{ key: "id", value: l.value }] : o.attributes = [], o.attributes.push({ key: "chai-type", value: c });
|
|
2749
|
+
const p = getRegisteredChaiBlock(c), u = n.find((g) => g._id === (l == null ? void 0 : l.value));
|
|
2750
|
+
if (u && o.attributes.push(
|
|
2751
|
+
...Object.entries(u).filter(([g]) => !["_id", "_type", "_parent", "_index", "_name"].includes(g)).map(([g, m]) => ({
|
|
2752
2752
|
key: g,
|
|
2753
2753
|
value: typeof m == "string" ? m : JSON.stringify(m)
|
|
2754
2754
|
}))
|
|
@@ -2785,8 +2785,8 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
|
|
|
2785
2785
|
const l = o != null && o._id ? `[data-block-id="${o._id}"]` : "#canvas", i = (m = (g = r.contentDocument) == null ? void 0 : g.querySelector(l)) == null ? void 0 : m[l === "#canvas" ? "innerHTML" : "outerHTML"];
|
|
2786
2786
|
if (!i) return "";
|
|
2787
2787
|
const p = parse(i).map(cleanNode).filter((h) => h !== null).map((h) => transformNode(h, n, a));
|
|
2788
|
-
let
|
|
2789
|
-
return
|
|
2788
|
+
let u = stringify(p);
|
|
2789
|
+
return u = u.replace(/#styles:,/g, "#styles:"), u.replace(/\s+/g, " ").trim();
|
|
2790
2790
|
},
|
|
2791
2791
|
[o, r]
|
|
2792
2792
|
);
|
|
@@ -2796,14 +2796,14 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
|
|
|
2796
2796
|
const l = a.i18nProps;
|
|
2797
2797
|
if (!l) return r;
|
|
2798
2798
|
const i = filter(n, { _type: r._type }), c = pick(r, l);
|
|
2799
|
-
return each(c, (
|
|
2800
|
-
const
|
|
2799
|
+
return each(c, (d, p) => {
|
|
2800
|
+
const u = find(i, (g) => {
|
|
2801
2801
|
var f;
|
|
2802
|
-
const m = typeof g[p] == "string" ? (f = g[p]) == null ? void 0 : f.trim().toLowerCase() : JSON.stringify(g[p]), h = typeof
|
|
2802
|
+
const m = typeof g[p] == "string" ? (f = g[p]) == null ? void 0 : f.trim().toLowerCase() : JSON.stringify(g[p]), h = typeof d == "string" ? d.trim().toLowerCase() : JSON.stringify(d);
|
|
2803
2803
|
return m === h;
|
|
2804
2804
|
});
|
|
2805
|
-
if (
|
|
2806
|
-
const g = filter(Object.keys(
|
|
2805
|
+
if (u) {
|
|
2806
|
+
const g = filter(Object.keys(u), (h) => startsWith(h, `${p}-`)), m = pick(u, g);
|
|
2807
2807
|
r = { ...r, ...m };
|
|
2808
2808
|
}
|
|
2809
2809
|
}), r;
|
|
@@ -2835,9 +2835,9 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
|
|
|
2835
2835
|
if (!i) return null;
|
|
2836
2836
|
const c = (i == null ? void 0 : i.i18nProps) ?? [];
|
|
2837
2837
|
if (c.length === 0) return null;
|
|
2838
|
-
const
|
|
2839
|
-
return each$1(
|
|
2840
|
-
p[
|
|
2838
|
+
const d = r === "ALL" ? Object.keys(l).filter((u) => c.find((g) => u.startsWith(g))) : c.map((u) => r ? `${u}-${r}` : u), p = pick$1(l, ["_id"]);
|
|
2839
|
+
return each$1(d, (u) => {
|
|
2840
|
+
p[u] = get$1(l, u, get$1(l, u.replace(`-${r}`, "")));
|
|
2841
2841
|
}), p;
|
|
2842
2842
|
})
|
|
2843
2843
|
) : [];
|
|
@@ -2885,11 +2885,11 @@ const getAllDescendantIds = (o, n) => {
|
|
|
2885
2885
|
}, replaceBlock = (o, n, r) => {
|
|
2886
2886
|
const a = find(o, { _id: n });
|
|
2887
2887
|
if (!a) return o;
|
|
2888
|
-
const l = o.findIndex((m) => m._id === n), i = getAllDescendantIds(o, n), c = /* @__PURE__ */ new Set([n, ...i]),
|
|
2888
|
+
const l = o.findIndex((m) => m._id === n), i = getAllDescendantIds(o, n), c = /* @__PURE__ */ new Set([n, ...i]), d = o.filter((m) => !c.has(m._id)), p = new Set(r.map((m) => m._id)), u = r.map((m) => !m._parent || !p.has(m._parent) ? { ...m, _parent: a._parent } : m);
|
|
2889
2889
|
return [
|
|
2890
|
-
...
|
|
2891
|
-
...
|
|
2892
|
-
...
|
|
2890
|
+
...d.slice(0, l),
|
|
2891
|
+
...u,
|
|
2892
|
+
...d.slice(l)
|
|
2893
2893
|
];
|
|
2894
2894
|
}, useReplaceBlock = () => {
|
|
2895
2895
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { setNewBlocks: r } = useBlocksStoreUndoableActions(), { hasPermission: a } = usePermissions();
|
|
@@ -2971,6 +2971,7 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), ScalePerc
|
|
|
2971
2971
|
OPEN_ADD_BLOCK: "OPEN_ADD_BLOCK",
|
|
2972
2972
|
CLOSE_ADD_BLOCK: "CLOSE_ADD_BLOCK",
|
|
2973
2973
|
SHOW_BLOCK_SETTINGS: "SHOW_BLOCK_SETTINGS",
|
|
2974
|
+
GOTO_BLOCK_SETTINGS: "GOTO_BLOCK_SETTINGS",
|
|
2974
2975
|
//CANVAS Events
|
|
2975
2976
|
CLEAR_CANVAS_SELECTION: "CLEAR_CANVAS_SELECTION",
|
|
2976
2977
|
CANVAS_BLOCK_SELECTED: "CANVAS_BLOCK_SELECTED",
|
|
@@ -2978,12 +2979,12 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), ScalePerc
|
|
|
2978
2979
|
// Export Code
|
|
2979
2980
|
OPEN_EXPORT_CODE: "OPEN_EXPORT_CODE"
|
|
2980
2981
|
}, AddBlockDropdown = ({ block: o, children: n }) => {
|
|
2981
|
-
const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"),
|
|
2982
|
+
const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (m) => c ? get(m, "_parent") === c : !get(m, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), g = (m) => {
|
|
2982
2983
|
if (m === "CHILD")
|
|
2983
2984
|
pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
|
|
2984
2985
|
else {
|
|
2985
|
-
const h = { _id: c || "", position:
|
|
2986
|
-
m === "BEFORE" ? h.position = Math.max(
|
|
2986
|
+
const h = { _id: c || "", position: d == null ? void 0 : d.length };
|
|
2987
|
+
m === "BEFORE" ? h.position = Math.max(u, 0) : m === "AFTER" && (h.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, h);
|
|
2987
2988
|
}
|
|
2988
2989
|
};
|
|
2989
2990
|
return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
@@ -3002,9 +3003,9 @@ function getOrientation(o, n = null) {
|
|
|
3002
3003
|
const c = r.flexDirection;
|
|
3003
3004
|
return c === "column" || c === "column-reverse" ? "vertical" : "horizontal";
|
|
3004
3005
|
} else if (l === "grid") {
|
|
3005
|
-
const c = r.gridAutoFlow,
|
|
3006
|
-
return c.includes("column") ||
|
|
3007
|
-
|
|
3006
|
+
const c = r.gridAutoFlow, d = r.gridTemplateColumns;
|
|
3007
|
+
return c.includes("column") || d && d !== "none" && d !== "" && !d.includes("calc") && // Handle calc expressions
|
|
3008
|
+
d.split(" ").length <= 1 ? "vertical" : "horizontal";
|
|
3008
3009
|
} else if (i === "inline-block" || i === "inline")
|
|
3009
3010
|
return "horizontal";
|
|
3010
3011
|
return "vertical";
|
|
@@ -3030,11 +3031,11 @@ const FrameContext = React__default.createContext({ document: doc, window: win }
|
|
|
3030
3031
|
return "VERTICAL";
|
|
3031
3032
|
}
|
|
3032
3033
|
}, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
|
|
3033
|
-
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"),
|
|
3034
|
+
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, m = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, i, a), f = useCallback(
|
|
3034
3035
|
(x) => {
|
|
3035
|
-
isDisabledControl(g, m, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null,
|
|
3036
|
+
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());
|
|
3036
3037
|
},
|
|
3037
|
-
[g, m, p,
|
|
3038
|
+
[g, m, p, u, i, c, n]
|
|
3038
3039
|
);
|
|
3039
3040
|
return useHotkeys(
|
|
3040
3041
|
"shift+up, shift+down, shift+left, shift+right",
|
|
@@ -3050,18 +3051,20 @@ const FrameContext = React__default.createContext({ document: doc, window: win }
|
|
|
3050
3051
|
o,
|
|
3051
3052
|
n
|
|
3052
3053
|
);
|
|
3053
|
-
return r ? null : /* @__PURE__ */ jsx(Fragment, { children: CONTROLS.map(({ ControlIcon:
|
|
3054
|
-
|
|
3054
|
+
return r ? null : /* @__PURE__ */ jsx(Fragment, { children: CONTROLS.map(({ ControlIcon: d, dir: p, key: u }) => c !== p || isDisabledControl(a, l, u) ? null : /* @__PURE__ */ jsx(
|
|
3055
|
+
d,
|
|
3055
3056
|
{
|
|
3056
|
-
onClick: () => i(
|
|
3057
|
+
onClick: () => i(u),
|
|
3057
3058
|
className: "rounded p-px hover:bg-white hover:text-blue-500"
|
|
3058
3059
|
},
|
|
3059
|
-
|
|
3060
|
+
u
|
|
3060
3061
|
)) });
|
|
3061
3062
|
}, AiIcon = ({
|
|
3062
3063
|
className: o = "h-full w-full",
|
|
3063
3064
|
onClick: n = noop$1
|
|
3064
|
-
}) => /* @__PURE__ */ jsx("svg", { className: o, viewBox: "0 0 256 256", fill: "currentColor", onClick: n, children: /* @__PURE__ */ jsx("path", { d: "m198.39 128.986-52.16-19.216-19.216-52.16a16 16 0 0 0-30.028 0L77.77 109.77l-52.16 19.216a16 16 0 0 0 0 30.028l52.16 19.216 19.216 52.16a16 16 0 0 0 30.028 0l19.216-52.16 52.16-19.216a16 16 0 0 0 0-30.028m-57.69 34.23a15.97 15.97 0 0 0-9.483 9.483l-19.22 52.152-19.214-52.15a15.97 15.97 0 0 0-9.482-9.484l-52.152-19.22 52.15-19.214a15.97 15.97 0 0 0 9.484-9.482l19.22-52.152 19.214 52.15a15.97 15.97 0 0 0 9.482 9.484l52.152 19.22ZM144 40a8 8 0 0 1 8-8h16V16a8 8 0 0 1 16 0v16h16a8 8 0 0 1 0 16h-16v16a8 8 0 0 1-16 0V48h-16a8 8 0 0 1-8-8m104 48a8 8 0 0 1-8 8h-8v8a8 8 0 0 1-16 0v-8h-8a8 8 0 0 1 0-16h8v-8a8 8 0 0 1 16 0v8h8a8 8 0 0 1 8 8" }) })
|
|
3065
|
+
}) => /* @__PURE__ */ jsx("svg", { className: o, viewBox: "0 0 256 256", fill: "currentColor", onClick: n, children: /* @__PURE__ */ jsx("path", { d: "m198.39 128.986-52.16-19.216-19.216-52.16a16 16 0 0 0-30.028 0L77.77 109.77l-52.16 19.216a16 16 0 0 0 0 30.028l52.16 19.216 19.216 52.16a16 16 0 0 0 30.028 0l19.216-52.16 52.16-19.216a16 16 0 0 0 0-30.028m-57.69 34.23a15.97 15.97 0 0 0-9.483 9.483l-19.22 52.152-19.214-52.15a15.97 15.97 0 0 0-9.482-9.484l-52.152-19.22 52.15-19.214a15.97 15.97 0 0 0 9.484-9.482l19.22-52.152 19.214 52.15a15.97 15.97 0 0 0 9.482 9.484l52.152 19.22ZM144 40a8 8 0 0 1 8-8h16V16a8 8 0 0 1 16 0v16h16a8 8 0 0 1 0 16h-16v16a8 8 0 0 1-16 0V48h-16a8 8 0 0 1-8-8m104 48a8 8 0 0 1-8 8h-8v8a8 8 0 0 1-16 0v-8h-8a8 8 0 0 1 0-16h8v-8a8 8 0 0 1 16 0v8h8a8 8 0 0 1 8 8" }) }), GotoSettingsIcon = ({ blockId: o, className: n }) => /* @__PURE__ */ jsx(GearIcon, { className: n, onClick: () => {
|
|
3066
|
+
o && pubsub.publish(CHAI_BUILDER_EVENTS.GOTO_BLOCK_SETTINGS, o);
|
|
3067
|
+
} });
|
|
3065
3068
|
function getTargetedBlock(o) {
|
|
3066
3069
|
if (o.getAttribute("data-block-id") === "canvas")
|
|
3067
3070
|
return null;
|
|
@@ -3082,15 +3085,15 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
|
|
|
3082
3085
|
const { editingBlockId: o, setEditingBlockId: n, setEditingItemIndex: r } = useInlineEditing();
|
|
3083
3086
|
return useCallback(
|
|
3084
3087
|
(a) => {
|
|
3085
|
-
var
|
|
3088
|
+
var d;
|
|
3086
3089
|
if (a == null || a.preventDefault(), a == null || a.stopPropagation(), o) return;
|
|
3087
3090
|
const l = getTargetedBlock(a.target);
|
|
3088
3091
|
if (!isInlineEditable(l)) return;
|
|
3089
3092
|
const i = l.getAttribute("data-block-id");
|
|
3090
3093
|
if (!i || !l) return;
|
|
3091
3094
|
const c = l.closest('[data-block-type="Repeater"]');
|
|
3092
|
-
c ? (
|
|
3093
|
-
p.contains(l) && r(
|
|
3095
|
+
c ? (d = c == null ? void 0 : c.childNodes) == null || d.forEach((p, u) => {
|
|
3096
|
+
p.contains(l) && r(u);
|
|
3094
3097
|
}) : r(-1), n(i);
|
|
3095
3098
|
},
|
|
3096
3099
|
[o, n, r]
|
|
@@ -3107,11 +3110,11 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
|
|
|
3107
3110
|
return;
|
|
3108
3111
|
}
|
|
3109
3112
|
if (c != null && c.getAttribute("data-block-parent")) {
|
|
3110
|
-
const
|
|
3111
|
-
pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, { blockId:
|
|
3113
|
+
const d = c.getAttribute("data-style-prop"), p = c.getAttribute("data-style-id"), u = c.getAttribute("data-block-parent");
|
|
3114
|
+
pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, { blockId: u, styleId: p, styleProp: d });
|
|
3112
3115
|
} else if (c != null && c.getAttribute("data-block-id")) {
|
|
3113
|
-
const
|
|
3114
|
-
pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED,
|
|
3116
|
+
const d = c.getAttribute("data-block-id");
|
|
3117
|
+
pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, d === "canvas" ? [] : [d]);
|
|
3115
3118
|
}
|
|
3116
3119
|
n(), r.current = (/* @__PURE__ */ new Date()).getTime();
|
|
3117
3120
|
},
|
|
@@ -3162,29 +3165,29 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
|
|
|
3162
3165
|
}
|
|
3163
3166
|
);
|
|
3164
3167
|
}, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), BlockSelectionHighlighter = () => {
|
|
3165
|
-
const o = useSelectedBlock(), { document: n } = useFrame(), [r] = useSelectedStylingBlocks(), [a, l] = useState([]), [, i] = useState([]), c = (
|
|
3166
|
-
const { top:
|
|
3167
|
-
return
|
|
3168
|
+
const o = useSelectedBlock(), { document: n } = useFrame(), [r] = useSelectedStylingBlocks(), [a, l] = useState([]), [, i] = useState([]), c = (d, p = 0) => {
|
|
3169
|
+
const { top: u } = d.getBoundingClientRect();
|
|
3170
|
+
return u + p >= 0 && u - p <= window.innerHeight;
|
|
3168
3171
|
};
|
|
3169
3172
|
return useEffect(() => {
|
|
3170
|
-
var
|
|
3173
|
+
var d;
|
|
3171
3174
|
if (o != null && o._id && o.type !== "Multiple" && n) {
|
|
3172
3175
|
const p = getElementByDataBlockId(n, o._id);
|
|
3173
|
-
p && (c(p) || (
|
|
3176
|
+
p && (c(p) || (d = n.defaultView) == null || d.scrollTo({ top: p.offsetTop, behavior: "smooth" }), l([p]));
|
|
3174
3177
|
}
|
|
3175
3178
|
}, [o == null ? void 0 : o._id, o == null ? void 0 : o.type, n]), useEffect(() => {
|
|
3176
3179
|
if (!isEmpty(r) && n) {
|
|
3177
|
-
const
|
|
3178
|
-
i(
|
|
3180
|
+
const d = getElementByStyleId(n, first(r).id);
|
|
3181
|
+
i(d ? [d] : [null]);
|
|
3179
3182
|
} else
|
|
3180
3183
|
i([null]);
|
|
3181
3184
|
}, [r, n]), /* @__PURE__ */ jsx(BlockFloatingSelector, { block: o, selectedBlockElement: a[0] });
|
|
3182
3185
|
}, BlockFloatingSelector = ({ block: o, selectedBlockElement: n }) => {
|
|
3183
|
-
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission:
|
|
3186
|
+
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), { editingBlockId: p } = useInlineEditing(), { document: u } = useFrame(), g = useBuilderProp("flags.gotoSettings", !1), { floatingStyles: m, refs: h, update: f } = useFloating({
|
|
3184
3187
|
placement: "top-start",
|
|
3185
3188
|
middleware: [
|
|
3186
3189
|
shift({
|
|
3187
|
-
boundary:
|
|
3190
|
+
boundary: u == null ? void 0 : u.body,
|
|
3188
3191
|
limiter: limitShift({
|
|
3189
3192
|
offset: 8,
|
|
3190
3193
|
mainAxis: !0,
|
|
@@ -3192,81 +3195,88 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
|
|
|
3192
3195
|
})
|
|
3193
3196
|
}),
|
|
3194
3197
|
flip({
|
|
3195
|
-
boundary:
|
|
3198
|
+
boundary: u == null ? void 0 : u.body,
|
|
3196
3199
|
fallbackPlacements: ["bottom-start", "top-end", "bottom-end", "inside"]
|
|
3197
3200
|
}),
|
|
3198
3201
|
size({
|
|
3199
|
-
boundary:
|
|
3200
|
-
apply({ availableWidth:
|
|
3201
|
-
Object.assign(
|
|
3202
|
-
maxWidth: `${Math.max(200,
|
|
3203
|
-
maxHeight: `${Math.max(100,
|
|
3202
|
+
boundary: u == null ? void 0 : u.body,
|
|
3203
|
+
apply({ availableWidth: S, availableHeight: C, elements: v }) {
|
|
3204
|
+
Object.assign(v.floating.style, {
|
|
3205
|
+
maxWidth: `${Math.max(200, S)}px`,
|
|
3206
|
+
maxHeight: `${Math.max(100, C)}px`
|
|
3204
3207
|
});
|
|
3205
3208
|
}
|
|
3206
3209
|
})
|
|
3207
3210
|
],
|
|
3208
3211
|
elements: { reference: n }
|
|
3209
3212
|
});
|
|
3210
|
-
useResizeObserver(n, () =>
|
|
3211
|
-
const
|
|
3213
|
+
useResizeObserver(n, () => f(), n !== null), useResizeObserver(u == null ? void 0 : u.body, () => f(), (u == null ? void 0 : u.body) !== null);
|
|
3214
|
+
const x = get(o, "_parent", null), b = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
|
|
3212
3215
|
useEffect(() => {
|
|
3213
3216
|
if (n) {
|
|
3214
|
-
const
|
|
3215
|
-
return () => clearTimeout(
|
|
3217
|
+
const S = setTimeout(() => f(), 500);
|
|
3218
|
+
return () => clearTimeout(S);
|
|
3216
3219
|
} else
|
|
3217
|
-
|
|
3220
|
+
f();
|
|
3218
3221
|
}, [n]);
|
|
3219
|
-
const [,
|
|
3222
|
+
const [, y] = useSidebarActivePanel();
|
|
3220
3223
|
return !n || !o || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
3221
3224
|
"div",
|
|
3222
3225
|
{
|
|
3223
3226
|
role: "button",
|
|
3224
3227
|
tabIndex: 0,
|
|
3225
|
-
ref:
|
|
3226
|
-
style:
|
|
3227
|
-
onClick: (
|
|
3228
|
-
|
|
3228
|
+
ref: h.setFloating,
|
|
3229
|
+
style: m,
|
|
3230
|
+
onClick: (S) => {
|
|
3231
|
+
S.stopPropagation(), S.preventDefault();
|
|
3229
3232
|
},
|
|
3230
|
-
onMouseEnter: (
|
|
3231
|
-
|
|
3233
|
+
onMouseEnter: (S) => {
|
|
3234
|
+
S.stopPropagation(), i(null);
|
|
3232
3235
|
},
|
|
3233
|
-
onKeyDown: (
|
|
3236
|
+
onKeyDown: (S) => S.stopPropagation(),
|
|
3234
3237
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3235
3238
|
children: [
|
|
3236
|
-
|
|
3239
|
+
x && /* @__PURE__ */ jsx(
|
|
3237
3240
|
ArrowUpIcon,
|
|
3238
3241
|
{
|
|
3239
3242
|
className: "rounded p-0.5 hover:bg-white/20",
|
|
3240
3243
|
onClick: () => {
|
|
3241
|
-
c([]), l([
|
|
3244
|
+
c([]), l([x]);
|
|
3242
3245
|
}
|
|
3243
3246
|
}
|
|
3244
3247
|
),
|
|
3245
|
-
/* @__PURE__ */ jsx(BlockActionLabel, { label:
|
|
3248
|
+
/* @__PURE__ */ jsx(BlockActionLabel, { label: b, block: o }),
|
|
3246
3249
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 pl-1 pr-1.5", children: [
|
|
3247
|
-
|
|
3250
|
+
d(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
|
|
3248
3251
|
AiIcon,
|
|
3249
3252
|
{
|
|
3250
3253
|
className: "h-4 w-4 rounded hover:bg-white hover:text-blue-500",
|
|
3251
|
-
onClick: () =>
|
|
3254
|
+
onClick: () => y("chai-chat-panel")
|
|
3255
|
+
}
|
|
3256
|
+
),
|
|
3257
|
+
g && /* @__PURE__ */ jsx(
|
|
3258
|
+
GotoSettingsIcon,
|
|
3259
|
+
{
|
|
3260
|
+
blockId: o == null ? void 0 : o._id,
|
|
3261
|
+
className: "h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500"
|
|
3252
3262
|
}
|
|
3253
3263
|
),
|
|
3254
3264
|
/* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500" }) }),
|
|
3255
|
-
canDuplicateBlock(get(o, "_type", "")) &&
|
|
3265
|
+
canDuplicateBlock(get(o, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(
|
|
3256
3266
|
CopyIcon,
|
|
3257
3267
|
{
|
|
3258
3268
|
className: "h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500",
|
|
3259
3269
|
onClick: () => a([o == null ? void 0 : o._id])
|
|
3260
3270
|
}
|
|
3261
3271
|
) : null,
|
|
3262
|
-
canDeleteBlock(get(o, "_type", "")) &&
|
|
3272
|
+
canDeleteBlock(get(o, "_type", "")) && d(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(
|
|
3263
3273
|
TrashIcon,
|
|
3264
3274
|
{
|
|
3265
3275
|
className: "h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500",
|
|
3266
3276
|
onClick: () => r([o == null ? void 0 : o._id])
|
|
3267
3277
|
}
|
|
3268
3278
|
) : null,
|
|
3269
|
-
|
|
3279
|
+
d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: o, updateFloatingBar: f })
|
|
3270
3280
|
] })
|
|
3271
3281
|
]
|
|
3272
3282
|
}
|
|
@@ -3443,8 +3453,8 @@ class Frame extends Component {
|
|
|
3443
3453
|
const r = this.getDoc();
|
|
3444
3454
|
if (!r)
|
|
3445
3455
|
return null;
|
|
3446
|
-
const a = this.props.contentDidMount, l = this.props.contentDidUpdate, i = r.defaultView || r.parentView, c = /* @__PURE__ */ jsx(Content, { contentDidMount: a, contentDidUpdate: l, children: /* @__PURE__ */ jsx(FrameContextProvider, { value: { document: r, window: i }, children: /* @__PURE__ */ jsx("div", { className: "frame-content", children: this.props.children }) }) }),
|
|
3447
|
-
return [ReactDOM.createPortal(this.props.head, this.getDoc().head), ReactDOM.createPortal(c,
|
|
3456
|
+
const a = this.props.contentDidMount, l = this.props.contentDidUpdate, i = r.defaultView || r.parentView, c = /* @__PURE__ */ jsx(Content, { contentDidMount: a, contentDidUpdate: l, children: /* @__PURE__ */ jsx(FrameContextProvider, { value: { document: r, window: i }, children: /* @__PURE__ */ jsx("div", { className: "frame-content", children: this.props.children }) }) }), d = this.getMountTarget();
|
|
3457
|
+
return [ReactDOM.createPortal(this.props.head, this.getDoc().head), ReactDOM.createPortal(c, d)];
|
|
3448
3458
|
}
|
|
3449
3459
|
render() {
|
|
3450
3460
|
const r = {
|
|
@@ -3468,12 +3478,12 @@ $(Frame, "defaultProps", {
|
|
|
3468
3478
|
initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
|
|
3469
3479
|
});
|
|
3470
3480
|
const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: n })), useKeyEventWatcher = (o) => {
|
|
3471
|
-
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo:
|
|
3472
|
-
useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () =>
|
|
3481
|
+
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), h = o ? { document: o } : {};
|
|
3482
|
+
useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys(
|
|
3473
3483
|
"ctrl+c,command+c",
|
|
3474
|
-
() =>
|
|
3484
|
+
() => u(n),
|
|
3475
3485
|
{ ...h, enabled: !isEmpty(n), preventDefault: !0 },
|
|
3476
|
-
[n,
|
|
3486
|
+
[n, u]
|
|
3477
3487
|
), useHotkeys(
|
|
3478
3488
|
"ctrl+v,command+v",
|
|
3479
3489
|
() => {
|
|
@@ -3580,7 +3590,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3580
3590
|
heading: get(o, "fontFamily.heading"),
|
|
3581
3591
|
body: get(o, "fontFamily.body")
|
|
3582
3592
|
};
|
|
3583
|
-
return n.filter((
|
|
3593
|
+
return n.filter((d) => d.family === i || d.family === c);
|
|
3584
3594
|
}, [o == null ? void 0 : o.fontFamily, n]), a = useMemo(() => getThemeFontsUrls(filter(r, (i) => has(i, "url"))), [r]), l = useMemo(
|
|
3585
3595
|
() => getThemeCustomFontFace(filter(r, (i) => has(i, "src"))),
|
|
3586
3596
|
[r]
|
|
@@ -3602,14 +3612,14 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3602
3612
|
const { clientWidth: p } = i.current;
|
|
3603
3613
|
n(p);
|
|
3604
3614
|
}, []);
|
|
3605
|
-
const
|
|
3615
|
+
const d = useCallback(() => {
|
|
3606
3616
|
a([]), l([]);
|
|
3607
3617
|
}, [a, l]);
|
|
3608
3618
|
return /* @__PURE__ */ jsx(
|
|
3609
3619
|
"div",
|
|
3610
3620
|
{
|
|
3611
3621
|
id: "main-content",
|
|
3612
|
-
onClick:
|
|
3622
|
+
onClick: d,
|
|
3613
3623
|
className: "h-full w-full border-l-4 border-r-4 pb-0",
|
|
3614
3624
|
ref: i,
|
|
3615
3625
|
children: o
|
|
@@ -3623,9 +3633,9 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3623
3633
|
return useCallback(
|
|
3624
3634
|
(n, r) => isEmpty(r) ? {} : Object.entries(r).reduce((a, [l, i]) => {
|
|
3625
3635
|
const c = [];
|
|
3626
|
-
let
|
|
3627
|
-
for (;
|
|
3628
|
-
c.push(
|
|
3636
|
+
let d = find(o, { _id: n });
|
|
3637
|
+
for (; d; )
|
|
3638
|
+
c.push(d), d = find(o, { _id: d._parent });
|
|
3629
3639
|
const p = find(c, { _type: i.block });
|
|
3630
3640
|
return p && (a[l] = get(p, get(i, "prop"), null)), a;
|
|
3631
3641
|
}, {}),
|
|
@@ -3691,22 +3701,22 @@ const RteDropdownMenu = ({
|
|
|
3691
3701
|
from: a,
|
|
3692
3702
|
menuRef: l
|
|
3693
3703
|
}) => {
|
|
3694
|
-
const { document: i } = useFrame(), [c,
|
|
3704
|
+
const { document: i } = useFrame(), [c, d] = useState({ left: void 0, right: void 0, top: void 0, bottom: void 0 }), [p, u] = useState(!1), g = useRef(null);
|
|
3695
3705
|
if (useEffect(() => {
|
|
3696
3706
|
var S, C;
|
|
3697
3707
|
if (!p) {
|
|
3698
|
-
|
|
3708
|
+
d({ left: void 0, right: void 0, top: void 0, bottom: void 0 });
|
|
3699
3709
|
return;
|
|
3700
3710
|
}
|
|
3701
3711
|
const m = (S = g.current) == null ? void 0 : S.getBoundingClientRect(), h = (C = l.current) == null ? void 0 : C.getBoundingClientRect();
|
|
3702
3712
|
let f = m == null ? void 0 : m.left, x = (m == null ? void 0 : m.bottom) + 4, b, y;
|
|
3703
|
-
(h == null ? void 0 : h.left) + (h == null ? void 0 : h.width) + 50 >= i.body.offsetWidth && (f = void 0, b = i.body.offsetWidth - (m == null ? void 0 : m.right)), x + 202 >= i.body.clientHeight && (x = null, y = i.body.clientHeight - (m == null ? void 0 : m.bottom) + (h == null ? void 0 : h.height)),
|
|
3713
|
+
(h == null ? void 0 : h.left) + (h == null ? void 0 : h.width) + 50 >= i.body.offsetWidth && (f = void 0, b = i.body.offsetWidth - (m == null ? void 0 : m.right)), x + 202 >= i.body.clientHeight && (x = null, y = i.body.clientHeight - (m == null ? void 0 : m.bottom) + (h == null ? void 0 : h.height)), d({ left: f, top: x, right: b, bottom: y });
|
|
3704
3714
|
}, [p]), a === "canvas") {
|
|
3705
3715
|
const m = () => {
|
|
3706
|
-
|
|
3716
|
+
u(!1), o && (o == null || o.view.focus(), o == null || o.chain().focus().run());
|
|
3707
3717
|
};
|
|
3708
3718
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3709
|
-
/* @__PURE__ */ jsx("div", { ref: g, onClick: () =>
|
|
3719
|
+
/* @__PURE__ */ jsx("div", { ref: g, onClick: () => u((h) => !h), className: "cursor-pointer", children: n }),
|
|
3710
3720
|
p && (c.left !== void 0 || c.top !== void 0 || c.right !== void 0 || c.bottom !== void 0) && createPortal(
|
|
3711
3721
|
/* @__PURE__ */ jsx(
|
|
3712
3722
|
"div",
|
|
@@ -3733,9 +3743,9 @@ const RteDropdownMenu = ({
|
|
|
3733
3743
|
)
|
|
3734
3744
|
] });
|
|
3735
3745
|
}
|
|
3736
|
-
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(DropdownMenu, { open: p, onOpenChange:
|
|
3746
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(DropdownMenu, { open: p, onOpenChange: u, children: [
|
|
3737
3747
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { className: "relative outline-none", asChild: !0, children: n }),
|
|
3738
|
-
/* @__PURE__ */ jsx(DropdownMenuContent, { className: "z-50 rounded-md border bg-white p-1 text-xs shadow-xl", children: p && (typeof r == "function" ? r(() =>
|
|
3748
|
+
/* @__PURE__ */ jsx(DropdownMenuContent, { className: "z-50 rounded-md border bg-white p-1 text-xs shadow-xl", children: p && (typeof r == "function" ? r(() => u(!1)) : r) })
|
|
3739
3749
|
] }) });
|
|
3740
3750
|
};
|
|
3741
3751
|
atomWithStorage("chai-builder-blocks", []);
|
|
@@ -3807,7 +3817,7 @@ const getActiveClasses$1 = (o, n, r) => {
|
|
|
3807
3817
|
onRemoveHighlightColor: i,
|
|
3808
3818
|
onClose: c
|
|
3809
3819
|
}) => {
|
|
3810
|
-
const [
|
|
3820
|
+
const [d] = useDarkMode(), [p] = useAtom$1(lsThemeAtom), u = (p == null ? void 0 : p.colors) || {}, g = Object.values(u).map((f) => get(f, d ? "1" : "0")), [m, h] = useState("TEXT");
|
|
3811
3821
|
return /* @__PURE__ */ jsxs("div", { id: "rte-widget-color-picker", className: "px-1", children: [
|
|
3812
3822
|
/* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center justify-between rounded-md border bg-muted", children: [
|
|
3813
3823
|
/* @__PURE__ */ jsx(
|
|
@@ -3848,8 +3858,8 @@ const getActiveClasses$1 = (o, n, r) => {
|
|
|
3848
3858
|
)
|
|
3849
3859
|
] });
|
|
3850
3860
|
}, RteColorPicker = ({ editor: o, from: n, menuRef: r }) => {
|
|
3851
|
-
var C,
|
|
3852
|
-
const a = (C = o == null ? void 0 : o.getAttributes("textStyle")) == null ? void 0 : C.color, l = (
|
|
3861
|
+
var C, v;
|
|
3862
|
+
const a = (C = o == null ? void 0 : o.getAttributes("textStyle")) == null ? void 0 : C.color, l = (v = o == null ? void 0 : o.getAttributes("highlight")) == null ? void 0 : v.color, [i, c] = useState(a || "#000000F2"), [d, p] = useState(l || "#00000057"), [u, g] = useDebouncedState(i, 150), [m, h] = useDebouncedState(d, 150), f = (_, B) => {
|
|
3853
3863
|
B ? (c(_), g(_)) : (o == null || o.chain().setColor(_).run(), c(_));
|
|
3854
3864
|
}, x = (_, B) => {
|
|
3855
3865
|
B ? (p(_), h(_)) : (o == null || o.chain().setHighlight({ color: _ }).run(), p(_));
|
|
@@ -3863,8 +3873,8 @@ const getActiveClasses$1 = (o, n, r) => {
|
|
|
3863
3873
|
}, [l]), useEffect(() => {
|
|
3864
3874
|
m != null && m.includes("#") && (m == null ? void 0 : m.length) >= 3 && (o == null || o.chain().setHighlight({ color: m }).run());
|
|
3865
3875
|
}, [m]), useEffect(() => {
|
|
3866
|
-
|
|
3867
|
-
}, [
|
|
3876
|
+
u != null && u.includes("#") && (u == null ? void 0 : u.length) >= 3 && (o == null || o.chain().setColor(u).run());
|
|
3877
|
+
}, [u]), /* @__PURE__ */ jsx(
|
|
3868
3878
|
RteDropdownMenu,
|
|
3869
3879
|
{
|
|
3870
3880
|
editor: o,
|
|
@@ -3886,7 +3896,7 @@ const getActiveClasses$1 = (o, n, r) => {
|
|
|
3886
3896
|
ColorPickerContent,
|
|
3887
3897
|
{
|
|
3888
3898
|
textColor: i,
|
|
3889
|
-
highlightColor:
|
|
3899
|
+
highlightColor: d,
|
|
3890
3900
|
onChangeTextColor: f,
|
|
3891
3901
|
onChangeHighlightColor: x,
|
|
3892
3902
|
onRemoveTextColor: b,
|
|
@@ -4158,35 +4168,35 @@ const RichTextEditor = memo(
|
|
|
4158
4168
|
value: o,
|
|
4159
4169
|
blockId: "active-inline-editing-element",
|
|
4160
4170
|
placeholder: "Enter text here",
|
|
4161
|
-
onUpdate: ({ editor:
|
|
4162
|
-
onBlur: ({ editor:
|
|
4171
|
+
onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
|
|
4172
|
+
onBlur: ({ editor: u, event: g }) => {
|
|
4163
4173
|
const m = g == null ? void 0 : g.relatedTarget, h = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = i.querySelector("#chai-rich-text-menu-bar"), b = h == null ? void 0 : h.contains(m), y = f == null ? void 0 : f.contains(m), S = x == null ? void 0 : x.contains(m), C = window.document.getElementById("rte-widget-color-picker");
|
|
4164
4174
|
if (!b && !y && !S && !C) {
|
|
4165
|
-
const
|
|
4166
|
-
r(
|
|
4175
|
+
const v = (u == null ? void 0 : u.getHTML()) || "";
|
|
4176
|
+
r(v);
|
|
4167
4177
|
}
|
|
4168
4178
|
},
|
|
4169
4179
|
from: "canvas"
|
|
4170
4180
|
});
|
|
4171
4181
|
useEffect(() => {
|
|
4172
4182
|
var g, m;
|
|
4173
|
-
const
|
|
4174
|
-
|
|
4183
|
+
const u = getInitialTextAlign(n);
|
|
4184
|
+
u && ((g = c == null ? void 0 : c.commands) == null || g.setTextAlign(u)), (m = c == null ? void 0 : c.commands) == null || m.focus(), c == null || c.emit("focus", {
|
|
4175
4185
|
editor: c,
|
|
4176
4186
|
event: new FocusEvent("focus"),
|
|
4177
4187
|
transaction: []
|
|
4178
4188
|
});
|
|
4179
4189
|
}, [c]);
|
|
4180
|
-
const
|
|
4190
|
+
const d = useMemo(() => {
|
|
4181
4191
|
var m;
|
|
4182
|
-
const
|
|
4183
|
-
if (!n) return
|
|
4192
|
+
const u = "max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";
|
|
4193
|
+
if (!n) return u;
|
|
4184
4194
|
const g = ((m = n == null ? void 0 : n.className) == null ? void 0 : m.replace("sr-only", "")) || "";
|
|
4185
|
-
return `${
|
|
4186
|
-
}, [n]), p = (
|
|
4187
|
-
|
|
4195
|
+
return `${u} ${g}`;
|
|
4196
|
+
}, [n]), p = (u) => {
|
|
4197
|
+
u.key === "Escape" && l(u);
|
|
4188
4198
|
};
|
|
4189
|
-
return c && /* @__PURE__ */ jsxs("div", { onKeyDown: p, onClick: (
|
|
4199
|
+
return c && /* @__PURE__ */ jsxs("div", { onKeyDown: p, onClick: (u) => u.stopPropagation(), className: "relative", children: [
|
|
4190
4200
|
/* @__PURE__ */ jsx(
|
|
4191
4201
|
BubbleMenu,
|
|
4192
4202
|
{
|
|
@@ -4197,7 +4207,7 @@ const RichTextEditor = memo(
|
|
|
4197
4207
|
children: /* @__PURE__ */ jsx(RteMenubar, { editor: c, from: "canvas" })
|
|
4198
4208
|
}
|
|
4199
4209
|
),
|
|
4200
|
-
/* @__PURE__ */ jsx(EditorContent, { onKeyDown: p, value: o, editor: c, className:
|
|
4210
|
+
/* @__PURE__ */ jsx(EditorContent, { onKeyDown: p, value: o, editor: c, className: d })
|
|
4201
4211
|
] });
|
|
4202
4212
|
}
|
|
4203
4213
|
), MemoizedEditor = memo(
|
|
@@ -4209,20 +4219,20 @@ const RichTextEditor = memo(
|
|
|
4209
4219
|
onChange: l,
|
|
4210
4220
|
onEscape: i
|
|
4211
4221
|
}) => {
|
|
4212
|
-
const { document: c, window:
|
|
4222
|
+
const { document: c, window: d } = useFrame();
|
|
4213
4223
|
useEffect(() => {
|
|
4214
4224
|
if (a.current) {
|
|
4215
4225
|
a.current.innerHTML = n, a.current.focus();
|
|
4216
|
-
const h = c.createRange(), f =
|
|
4226
|
+
const h = c.createRange(), f = d.getSelection();
|
|
4217
4227
|
h.selectNodeContents(a.current), h.collapse(!1), f == null || f.removeAllRanges(), f == null || f.addRange(h), a.current.focus();
|
|
4218
4228
|
} else
|
|
4219
4229
|
r();
|
|
4220
|
-
}, [c,
|
|
4230
|
+
}, [c, d]);
|
|
4221
4231
|
const p = useMemo(() => {
|
|
4222
4232
|
var f;
|
|
4223
4233
|
const h = ((f = o == null ? void 0 : o.tagName) == null ? void 0 : f.toLowerCase()) || "div";
|
|
4224
4234
|
return h === "button" ? "div" : h;
|
|
4225
|
-
}, [o]),
|
|
4235
|
+
}, [o]), u = useCallback(
|
|
4226
4236
|
(h) => {
|
|
4227
4237
|
(h.key === "Enter" || h.key === "Escape") && i(h);
|
|
4228
4238
|
},
|
|
@@ -4248,23 +4258,23 @@ const RichTextEditor = memo(
|
|
|
4248
4258
|
return /* @__PURE__ */ jsx(Fragment, { children: createElement(p, {
|
|
4249
4259
|
ref: a,
|
|
4250
4260
|
onBlur: g,
|
|
4251
|
-
onKeyDown:
|
|
4261
|
+
onKeyDown: u,
|
|
4252
4262
|
...m
|
|
4253
4263
|
}) });
|
|
4254
4264
|
}
|
|
4255
4265
|
), WithBlockTextEditor = memo(
|
|
4256
4266
|
({ block: o, children: n }) => {
|
|
4257
|
-
const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex:
|
|
4267
|
+
const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang: f } = useLanguages(), [, x] = useSelectedBlockIds(), b = useRef(null), y = l, { blockContent: S, blockType: C } = useMemo(() => {
|
|
4258
4268
|
var j;
|
|
4259
4269
|
const k = o._type;
|
|
4260
4270
|
let A = o[r];
|
|
4261
|
-
const
|
|
4262
|
-
return f && ((j =
|
|
4263
|
-
}, [o, f]),
|
|
4271
|
+
const w = getRegisteredChaiBlock(o._type);
|
|
4272
|
+
return f && ((j = w == null ? void 0 : w.i18nProps) == null ? void 0 : j.includes(r)) && has(o, `${r}-${f}`) && (A = get(o, `${r}-${f}`)), { blockContent: A, blockType: k };
|
|
4273
|
+
}, [o, f]), v = useCallback(
|
|
4264
4274
|
(k) => {
|
|
4265
|
-
var
|
|
4266
|
-
const A = k || ((
|
|
4267
|
-
h([y], { [r]: A }),
|
|
4275
|
+
var w;
|
|
4276
|
+
const A = k || ((w = g.current) == null ? void 0 : w.innerText);
|
|
4277
|
+
h([y], { [r]: A }), u(null), c(null), d(-1), x([]), y && setTimeout(() => x([y]), 100);
|
|
4268
4278
|
},
|
|
4269
4279
|
[y, h, c, x, f]
|
|
4270
4280
|
), _ = useDebouncedCallback(
|
|
@@ -4275,7 +4285,7 @@ const RichTextEditor = memo(
|
|
|
4275
4285
|
1e3
|
|
4276
4286
|
), B = useCallback(
|
|
4277
4287
|
(k) => {
|
|
4278
|
-
k.preventDefault(), y && (b.current = y),
|
|
4288
|
+
k.preventDefault(), y && (b.current = y), v(), setTimeout(() => {
|
|
4279
4289
|
const A = b.current;
|
|
4280
4290
|
b.current = null, x([A]);
|
|
4281
4291
|
}, 100);
|
|
@@ -4285,8 +4295,8 @@ const RichTextEditor = memo(
|
|
|
4285
4295
|
useEffect(() => {
|
|
4286
4296
|
var E;
|
|
4287
4297
|
if (!y) return;
|
|
4288
|
-
const k = `[data-block-id="${y}"]`, A = i >= 0 ? `[data-block-index="${i}"]` : "",
|
|
4289
|
-
|
|
4298
|
+
const k = `[data-block-id="${y}"]`, A = i >= 0 ? `[data-block-index="${i}"]` : "", w = a.querySelector(`${k}${A}`);
|
|
4299
|
+
w && ((E = w == null ? void 0 : w.classList) == null || E.add("sr-only"), u(w));
|
|
4290
4300
|
}, [y, C, a, i]);
|
|
4291
4301
|
const I = useMemo(() => p ? (m(), ["RichText", "Paragraph"].includes(C) ? /* @__PURE__ */ jsx(
|
|
4292
4302
|
RichTextEditor,
|
|
@@ -4294,7 +4304,7 @@ const RichTextEditor = memo(
|
|
|
4294
4304
|
blockContent: S,
|
|
4295
4305
|
editingElement: p,
|
|
4296
4306
|
onChange: _,
|
|
4297
|
-
onClose:
|
|
4307
|
+
onClose: v,
|
|
4298
4308
|
onEscape: B
|
|
4299
4309
|
}
|
|
4300
4310
|
) : /* @__PURE__ */ jsx(
|
|
@@ -4303,11 +4313,11 @@ const RichTextEditor = memo(
|
|
|
4303
4313
|
editorRef: g,
|
|
4304
4314
|
blockContent: S,
|
|
4305
4315
|
editingElement: p,
|
|
4306
|
-
onClose:
|
|
4316
|
+
onClose: v,
|
|
4307
4317
|
onChange: _,
|
|
4308
4318
|
onEscape: B
|
|
4309
4319
|
}
|
|
4310
|
-
)) : null, [p, y, C, S,
|
|
4320
|
+
)) : null, [p, y, C, S, v, f]);
|
|
4311
4321
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4312
4322
|
I,
|
|
4313
4323
|
n
|
|
@@ -4345,20 +4355,20 @@ const RichTextEditor = memo(
|
|
|
4345
4355
|
blockAtom: n,
|
|
4346
4356
|
children: r
|
|
4347
4357
|
}) => {
|
|
4348
|
-
const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang:
|
|
4349
|
-
() => m ? applyBindingToBlockProps(applyLanguage(i,
|
|
4358
|
+
const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useAtom$1(dataBindingActiveAtom), h = get(c, "component", null), { index: f, key: x } = useContext(RepeaterContext), { mode: b } = useEditorMode(), y = useMemo(
|
|
4359
|
+
() => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
|
|
4350
4360
|
index: f,
|
|
4351
4361
|
key: x
|
|
4352
|
-
}) : applyLanguage(i,
|
|
4353
|
-
[i,
|
|
4362
|
+
}) : applyLanguage(i, d, c),
|
|
4363
|
+
[i, d, c, g, m, f, x]
|
|
4354
4364
|
), S = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), C = useMemo(
|
|
4355
|
-
() =>
|
|
4356
|
-
[i._id, i._type,
|
|
4357
|
-
),
|
|
4365
|
+
() => u(i._id, getBlockRuntimeProps(i._type)),
|
|
4366
|
+
[i._id, i._type, u, getBlockRuntimeProps]
|
|
4367
|
+
), v = useMemo(
|
|
4358
4368
|
() => ({
|
|
4359
4369
|
blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": f },
|
|
4360
4370
|
inBuilder: b === "edit",
|
|
4361
|
-
lang:
|
|
4371
|
+
lang: d || p,
|
|
4362
4372
|
...y,
|
|
4363
4373
|
...S,
|
|
4364
4374
|
...C,
|
|
@@ -4368,7 +4378,7 @@ const RichTextEditor = memo(
|
|
|
4368
4378
|
b,
|
|
4369
4379
|
i._id,
|
|
4370
4380
|
i._type,
|
|
4371
|
-
|
|
4381
|
+
d,
|
|
4372
4382
|
p,
|
|
4373
4383
|
y,
|
|
4374
4384
|
S,
|
|
@@ -4378,7 +4388,7 @@ const RichTextEditor = memo(
|
|
|
4378
4388
|
), _ = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]), B = useMemo(() => get(i, "_show", !0), [i]);
|
|
4379
4389
|
if (isNull(h) || !B) return null;
|
|
4380
4390
|
let I = /* @__PURE__ */ jsx(Suspense, { children: createElement(h, {
|
|
4381
|
-
...
|
|
4391
|
+
...v,
|
|
4382
4392
|
children: r({
|
|
4383
4393
|
_id: i._id,
|
|
4384
4394
|
_type: i._type,
|
|
@@ -4394,8 +4404,8 @@ const RichTextEditor = memo(
|
|
|
4394
4404
|
return _ ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: k }) : k;
|
|
4395
4405
|
}, PartialWrapper$1 = ({ children: o, partialBlockId: n }) => {
|
|
4396
4406
|
const r = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
|
|
4397
|
-
(
|
|
4398
|
-
if (
|
|
4407
|
+
(d) => {
|
|
4408
|
+
if (d.stopPropagation(), a !== "SAVED") {
|
|
4399
4409
|
toast.error("You have unsaved changes. Please save the page first.");
|
|
4400
4410
|
return;
|
|
4401
4411
|
}
|
|
@@ -4425,16 +4435,16 @@ const RichTextEditor = memo(
|
|
|
4425
4435
|
}) => {
|
|
4426
4436
|
const l = useGetBlockAtom(r);
|
|
4427
4437
|
let i = useMemo(
|
|
4428
|
-
() => filter(o, (
|
|
4438
|
+
() => filter(o, (d) => has(d, "_id") && (isEmpty(n) ? !d._parent : d._parent === n)),
|
|
4429
4439
|
[o, n]
|
|
4430
4440
|
);
|
|
4431
4441
|
const c = useCallback(
|
|
4432
|
-
(
|
|
4442
|
+
(d) => filter(o, (p) => p._parent === d).length > 0,
|
|
4433
4443
|
[o]
|
|
4434
4444
|
);
|
|
4435
|
-
return c && (a === "Heading" || a === "Paragraph" || a === "Link") && (i = adjustSpacingInContentBlocks(i)), map(i, (
|
|
4436
|
-
const p = l(
|
|
4437
|
-
return p ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block:
|
|
4445
|
+
return c && (a === "Heading" || a === "Paragraph" || a === "Link") && (i = adjustSpacingInContentBlocks(i)), map(i, (d) => {
|
|
4446
|
+
const p = l(d._id);
|
|
4447
|
+
return p ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: d, children: (u) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: p, asyncProps: u, children: ({ _id: g, _type: m, partialBlockId: h, repeaterItems: f, $repeaterItemsKey: x }) => m === "Repeater" ? isArray(f) && f.map((b, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: m }) }, `${g}-${y}`)) : m === "GlobalBlock" || m === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : c(g) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: m }) : null }) }, d._id) : null;
|
|
4438
4448
|
});
|
|
4439
4449
|
}, PageBlocksRenderer = () => {
|
|
4440
4450
|
const [o] = useBlocksStore();
|
|
@@ -4444,24 +4454,24 @@ const RichTextEditor = memo(
|
|
|
4444
4454
|
return /* @__PURE__ */ jsx(Fragment, { children: n });
|
|
4445
4455
|
}, useCanvasScale = (o) => {
|
|
4446
4456
|
const [n] = useCanvasDisplayWidth(), [, r] = useCanvasZoom(), a = useBuilderProp("htmlDir", "ltr"), [l, i] = useState({}), c = useCallback(() => {
|
|
4447
|
-
const { width:
|
|
4448
|
-
if (
|
|
4449
|
-
const
|
|
4457
|
+
const { width: d, height: p } = o;
|
|
4458
|
+
if (d < n) {
|
|
4459
|
+
const u = parseFloat((d / n).toFixed(2).toString());
|
|
4450
4460
|
let g = {};
|
|
4451
|
-
const m = p *
|
|
4461
|
+
const m = p * u, h = d * u;
|
|
4452
4462
|
p && (g = {
|
|
4453
4463
|
// Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
|
|
4454
4464
|
height: 100 + (p - m) / m * 100 + "%",
|
|
4455
|
-
width: 100 + (
|
|
4465
|
+
width: 100 + (d - h) / h * 100 + "%"
|
|
4456
4466
|
}), i({
|
|
4457
4467
|
position: "relative",
|
|
4458
4468
|
top: 0,
|
|
4459
|
-
transform: `scale(${
|
|
4469
|
+
transform: `scale(${u})`,
|
|
4460
4470
|
transformOrigin: a === "rtl" ? "top right" : "top left",
|
|
4461
4471
|
...g,
|
|
4462
4472
|
maxWidth: "none"
|
|
4463
4473
|
// TODO: Add max-width to the wrapper
|
|
4464
|
-
}), r(
|
|
4474
|
+
}), r(u * 100);
|
|
4465
4475
|
} else
|
|
4466
4476
|
i({}), r(100);
|
|
4467
4477
|
}, [n, o, a, r]);
|
|
@@ -4474,26 +4484,26 @@ const RichTextEditor = memo(
|
|
|
4474
4484
|
setTimeout(() => {
|
|
4475
4485
|
if (!isEmpty(n))
|
|
4476
4486
|
return;
|
|
4477
|
-
const
|
|
4478
|
-
if (
|
|
4479
|
-
const p =
|
|
4487
|
+
const d = getElementByDataBlockId(a, first(i));
|
|
4488
|
+
if (d) {
|
|
4489
|
+
const p = d.getAttribute("data-style-prop");
|
|
4480
4490
|
if (p) {
|
|
4481
|
-
const
|
|
4482
|
-
r([{ id:
|
|
4491
|
+
const u = d.getAttribute("data-style-id"), g = d.getAttribute("data-block-parent");
|
|
4492
|
+
r([{ id: u, prop: p, blockId: g }]);
|
|
4483
4493
|
}
|
|
4484
4494
|
}
|
|
4485
4495
|
}, 100);
|
|
4486
|
-
}, [a, i, r, n]), useEffect(() => () => l(), [l]), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, (
|
|
4487
|
-
|
|
4488
|
-
}), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, (
|
|
4489
|
-
if (!
|
|
4490
|
-
const { blockId: p, styleId:
|
|
4491
|
-
p && (includes(i, p) || c == null || c.closeAll(), r([{ id:
|
|
4496
|
+
}, [a, i, r, n]), useEffect(() => () => l(), [l]), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, (d) => {
|
|
4497
|
+
d && (!isEmpty(d) && !includes(i, first(d)) && (c == null || c.closeAll()), o(d));
|
|
4498
|
+
}), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, (d) => {
|
|
4499
|
+
if (!d) return;
|
|
4500
|
+
const { blockId: p, styleId: u, styleProp: g } = d;
|
|
4501
|
+
p && (includes(i, p) || c == null || c.closeAll(), r([{ id: u, prop: g, blockId: p }]), o([p]));
|
|
4492
4502
|
}), usePubSub(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION, () => {
|
|
4493
4503
|
l(), o([]), r([]);
|
|
4494
4504
|
}), null;
|
|
4495
4505
|
}, StaticCanvas = () => {
|
|
4496
|
-
const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [,
|
|
4506
|
+
const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useCanvasIframe(), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), g = useCallback(
|
|
4497
4507
|
(h) => {
|
|
4498
4508
|
i((f) => ({ ...f, width: h }));
|
|
4499
4509
|
},
|
|
@@ -4506,8 +4516,8 @@ const RichTextEditor = memo(
|
|
|
4506
4516
|
}, [a, o]);
|
|
4507
4517
|
const m = useMemo(() => {
|
|
4508
4518
|
let h = IframeInitialContent;
|
|
4509
|
-
return h = h.replace("__HTML_DIR__",
|
|
4510
|
-
}, [
|
|
4519
|
+
return h = h.replace("__HTML_DIR__", u), h;
|
|
4520
|
+
}, [u]);
|
|
4511
4521
|
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: g, onResize: g, children: /* @__PURE__ */ jsx(
|
|
4512
4522
|
"div",
|
|
4513
4523
|
{
|
|
@@ -4517,7 +4527,7 @@ const RichTextEditor = memo(
|
|
|
4517
4527
|
children: /* @__PURE__ */ jsxs(
|
|
4518
4528
|
ChaiFrame,
|
|
4519
4529
|
{
|
|
4520
|
-
contentDidMount: () =>
|
|
4530
|
+
contentDidMount: () => d(r.current),
|
|
4521
4531
|
ref: r,
|
|
4522
4532
|
id: "canvas-iframe",
|
|
4523
4533
|
style: { ...c, ...isEmpty(c) ? { width: `${o}px` } : {} },
|
|
@@ -4552,7 +4562,7 @@ const RichTextEditor = memo(
|
|
|
4552
4562
|
/* @__PURE__ */ jsx("p", { className: "font-semibold", children: o("Oops! Something went wrong.") }),
|
|
4553
4563
|
/* @__PURE__ */ jsx("p", { children: o("Please try again.") })
|
|
4554
4564
|
] }) });
|
|
4555
|
-
}, CodeEditor$1 = React__default.lazy(() => import("./code-editor-
|
|
4565
|
+
}, CodeEditor$1 = React__default.lazy(() => import("./code-editor-B1G67AXy.js")), CanvasArea = () => {
|
|
4556
4566
|
const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
|
|
4557
4567
|
return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40", children: [
|
|
4558
4568
|
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
|
|
@@ -4592,9 +4602,9 @@ const RichTextEditor = memo(
|
|
|
4592
4602
|
useEffect(() => {
|
|
4593
4603
|
i(o || "");
|
|
4594
4604
|
}, [o]);
|
|
4595
|
-
const c = (
|
|
4596
|
-
i(
|
|
4597
|
-
const p = sanitizeSvg(
|
|
4605
|
+
const c = (d) => {
|
|
4606
|
+
i(d);
|
|
4607
|
+
const p = sanitizeSvg(d);
|
|
4598
4608
|
n(p);
|
|
4599
4609
|
};
|
|
4600
4610
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex flex-col gap-2", id: "icon-picker-field", children: [
|
|
@@ -4608,7 +4618,7 @@ const RichTextEditor = memo(
|
|
|
4608
4618
|
autoCorrect: "off",
|
|
4609
4619
|
spellCheck: "false",
|
|
4610
4620
|
value: l,
|
|
4611
|
-
onChange: (
|
|
4621
|
+
onChange: (d) => c(d.target.value),
|
|
4612
4622
|
placeholder: a("SVG_code"),
|
|
4613
4623
|
rows: 2,
|
|
4614
4624
|
className: "no-scrollbar w-full rounded-md border border-border bg-background px-3 py-1.5 text-xs shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"
|
|
@@ -4621,7 +4631,7 @@ const RichTextEditor = memo(
|
|
|
4621
4631
|
] })
|
|
4622
4632
|
] });
|
|
4623
4633
|
}, DefaultMediaManager = ({ close: o, onSelect: n, mode: r = "image" }) => {
|
|
4624
|
-
const [a, l] = useState(""), [i, c] = useState(!1), [
|
|
4634
|
+
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), m = async (f) => {
|
|
4625
4635
|
if (!f.trim()) {
|
|
4626
4636
|
p(!1), g("Please enter a URL");
|
|
4627
4637
|
return;
|
|
@@ -4636,9 +4646,9 @@ const RichTextEditor = memo(
|
|
|
4636
4646
|
}, { t: h } = useTranslation();
|
|
4637
4647
|
return /* @__PURE__ */ jsxs("div", { className: "flex w-96 flex-col gap-4 p-4", children: [
|
|
4638
4648
|
/* @__PURE__ */ jsx("h2", { className: "text-xl font-semibold", children: h(`${r.charAt(0).toUpperCase() + r.slice(1)} Manager`) }),
|
|
4639
|
-
|
|
4649
|
+
u && /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
|
|
4640
4650
|
/* @__PURE__ */ jsx(ExclamationTriangleIcon, { className: "h-4 w-4" }),
|
|
4641
|
-
/* @__PURE__ */ jsx(AlertDescription, { children:
|
|
4651
|
+
/* @__PURE__ */ jsx(AlertDescription, { children: u })
|
|
4642
4652
|
] }),
|
|
4643
4653
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
|
|
4644
4654
|
/* @__PURE__ */ jsx(
|
|
@@ -4656,7 +4666,7 @@ const RichTextEditor = memo(
|
|
|
4656
4666
|
Button,
|
|
4657
4667
|
{
|
|
4658
4668
|
onClick: () => n({ id: "dam-id", url: a, width: 600, height: 400, description: "This is image description" }),
|
|
4659
|
-
disabled: !
|
|
4669
|
+
disabled: !d || i,
|
|
4660
4670
|
children: h("Insert")
|
|
4661
4671
|
}
|
|
4662
4672
|
)
|
|
@@ -4691,31 +4701,31 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4691
4701
|
const n = ((l = o.split("/").pop()) == null ? void 0 : l.split("?")[0]) || "";
|
|
4692
4702
|
return [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg", ".bmp", ".ico", ".avif"].some((i) => n.toLowerCase().endsWith(i)) ? n : "";
|
|
4693
4703
|
}, ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
4694
|
-
const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(),
|
|
4704
|
+
const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = usePageExternalData(), u = r.split(".").pop() || "", g = i ? `_${u}Id-${i}` : `_${u}Id`, m = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, g, m ? c == null ? void 0 : c.assetId : ""), f = useMemo(() => {
|
|
4695
4705
|
if (!o || !c || !/\{\{.*?\}\}/.test(o)) return o;
|
|
4696
|
-
const
|
|
4697
|
-
return get(_,
|
|
4698
|
-
}, [o, c, p,
|
|
4699
|
-
const
|
|
4700
|
-
if (
|
|
4701
|
-
n(
|
|
4702
|
-
const _ =
|
|
4706
|
+
const v = { ...c, [u]: o }, _ = applyBindingToBlockProps(v, p, { index: -1, key: "" });
|
|
4707
|
+
return get(_, u, o);
|
|
4708
|
+
}, [o, c, p, u]), x = !!h || f !== PLACEHOLDER_IMAGE, b = (C) => {
|
|
4709
|
+
const v = isArray(C) ? first(C) : C;
|
|
4710
|
+
if (v) {
|
|
4711
|
+
n(v == null ? void 0 : v.url);
|
|
4712
|
+
const _ = v == null ? void 0 : v.width, B = v == null ? void 0 : v.height, I = g.includes("mobile");
|
|
4703
4713
|
if (c != null && c._id) {
|
|
4704
4714
|
const k = {
|
|
4705
4715
|
..._ && { [I ? "mobileWidth" : "width"]: _ },
|
|
4706
4716
|
...B && { [I ? "mobileHeight" : "height"]: B },
|
|
4707
|
-
...
|
|
4717
|
+
...v.description && { alt: v.description }
|
|
4708
4718
|
};
|
|
4709
|
-
if (set(k, g,
|
|
4710
|
-
|
|
4719
|
+
if (set(k, g, v.id), isEmpty(k)) return;
|
|
4720
|
+
d([c._id], k);
|
|
4711
4721
|
}
|
|
4712
4722
|
}
|
|
4713
4723
|
}, y = useCallback(() => {
|
|
4714
4724
|
if (n(PLACEHOLDER_IMAGE), c != null && c._id) {
|
|
4715
|
-
const C = {},
|
|
4716
|
-
set(C, g, ""), set(C,
|
|
4725
|
+
const C = {}, v = g.includes("mobile");
|
|
4726
|
+
set(C, g, ""), set(C, v ? "mobileWidth" : "width", ""), set(C, v ? "mobileHeight" : "height", ""), d([c._id], C);
|
|
4717
4727
|
}
|
|
4718
|
-
}, [n, c == null ? void 0 : c._id,
|
|
4728
|
+
}, [n, c == null ? void 0 : c._id, d, g]), S = getFileName(f);
|
|
4719
4729
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex items-start gap-x-3", children: [
|
|
4720
4730
|
f ? /* @__PURE__ */ jsxs("div", { className: "group relative", children: [
|
|
4721
4731
|
/* @__PURE__ */ jsx(
|
|
@@ -4768,24 +4778,24 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4768
4778
|
] })
|
|
4769
4779
|
] });
|
|
4770
4780
|
}, PathDropdown = ({ data: o, onSelect: n, dataType: r }) => {
|
|
4771
|
-
const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o),
|
|
4781
|
+
const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (m) => Array.isArray(m) ? "array" : typeof m == "object" && m !== null ? "object" : "value", p = React__default.useCallback(
|
|
4772
4782
|
(m) => {
|
|
4773
4783
|
const h = (f) => r === "value" ? f === "value" || f === "object" : r === "array" ? f === "array" : f === r;
|
|
4774
4784
|
m.type === "object" ? (l((f) => [...f, m.key]), c(m.value)) : h(m.type) && n([...a, m.key].join("."), r);
|
|
4775
4785
|
},
|
|
4776
4786
|
[a, n, r]
|
|
4777
|
-
),
|
|
4787
|
+
), u = React__default.useCallback(() => {
|
|
4778
4788
|
if (a.length > 0) {
|
|
4779
4789
|
const m = a.slice(0, -1);
|
|
4780
4790
|
l(m), c(m.reduce((h, f) => h[f], o));
|
|
4781
4791
|
}
|
|
4782
|
-
}, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([m, h]) => ({ key: m, value: h, type:
|
|
4792
|
+
}, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([m, h]) => ({ key: m, value: h, type: d(h) })).filter((m) => !startsWith(m.key, REPEATER_PREFIX) && m.key.includes("/") ? !1 : r === "value" ? m.type === "value" || m.type === "object" : r === "array" ? m.type === "array" || m.type === "object" : r === "object" ? m.type === "object" : !0) : [], [i, r]);
|
|
4783
4793
|
return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
|
|
4784
4794
|
/* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
|
|
4785
4795
|
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
4786
4796
|
/* @__PURE__ */ jsx(CommandEmpty, { children: t("No option found.") }),
|
|
4787
4797
|
/* @__PURE__ */ jsxs(CommandGroup, { children: [
|
|
4788
|
-
a.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect:
|
|
4798
|
+
a.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: u, className: "flex items-center text-sm", children: [
|
|
4789
4799
|
/* @__PURE__ */ jsx(ChevronLeftIcon, { className: "mr-2 h-4 w-4" }),
|
|
4790
4800
|
t("Back")
|
|
4791
4801
|
] }),
|
|
@@ -4825,7 +4835,7 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
|
|
|
4825
4835
|
] });
|
|
4826
4836
|
};
|
|
4827
4837
|
function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
4828
|
-
const [a, l] = React__default.useState(!1), i = useBuilderProp("collections", []), c = React__default.useMemo(() => r === "array" ? { ...i.map((p) => p.id).reduce((p,
|
|
4838
|
+
const [a, l] = React__default.useState(!1), i = useBuilderProp("collections", []), c = React__default.useMemo(() => r === "array" ? { ...i.map((p) => p.id).reduce((p, u) => ({ ...p, [COLLECTION_PREFIX + u]: [] }), {}), ...o } : o, [o, i, r]);
|
|
4829
4839
|
return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
|
|
4830
4840
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4831
4841
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
@@ -4854,8 +4864,8 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4854
4864
|
PathDropdown,
|
|
4855
4865
|
{
|
|
4856
4866
|
data: c,
|
|
4857
|
-
onSelect: (
|
|
4858
|
-
n(
|
|
4867
|
+
onSelect: (d, p) => {
|
|
4868
|
+
n(d, p), l(!1);
|
|
4859
4869
|
},
|
|
4860
4870
|
dataType: r
|
|
4861
4871
|
}
|
|
@@ -4868,21 +4878,21 @@ const DataBindingSelector = ({
|
|
|
4868
4878
|
id: r,
|
|
4869
4879
|
formData: a
|
|
4870
4880
|
}) => {
|
|
4871
|
-
const l = usePageExternalData(), i = useBuilderProp("flags.dataBinding", !0), c = useSelectedBlockHierarchy(),
|
|
4881
|
+
const l = usePageExternalData(), i = useBuilderProp("flags.dataBinding", !0), c = useSelectedBlockHierarchy(), d = useSelectedBlock(), p = useMemo(() => {
|
|
4872
4882
|
if (c.length === 1) return "";
|
|
4873
4883
|
const m = c.find((x) => x._type === "Repeater"), f = get(m, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
|
|
4874
4884
|
return `${REPEATER_PREFIX}${startsWith(f, COLLECTION_PREFIX) ? `${f}/${m._id}` : f}`;
|
|
4875
|
-
}, [c]),
|
|
4885
|
+
}, [c]), u = useMemo(() => first(get(l, p.replace(REPEATER_PREFIX, ""), [])), [p, l]), g = useCallback(
|
|
4876
4886
|
(m, h) => {
|
|
4877
4887
|
if (m = isEmpty(p) ? m : m.replace(`${p}`, "$index"), h === "array" || h === "object") {
|
|
4878
4888
|
n(`{{${m}}}`, {}, r);
|
|
4879
4889
|
return;
|
|
4880
4890
|
}
|
|
4881
|
-
const f = (S) => /[.,!?;:]/.test(S), x = (S, C,
|
|
4891
|
+
const f = (S) => /[.,!?;:]/.test(S), x = (S, C, v) => {
|
|
4882
4892
|
let _ = "", B = "";
|
|
4883
4893
|
const I = C > 0 ? S[C - 1] : "", k = C < S.length ? S[C] : "";
|
|
4884
4894
|
return C > 0 && (I === "." || !f(I) && I !== " ") && (_ = " "), C < S.length && !f(k) && k !== " " && (B = " "), {
|
|
4885
|
-
text: _ +
|
|
4895
|
+
text: _ + v + B,
|
|
4886
4896
|
prefixLength: _.length,
|
|
4887
4897
|
suffixLength: B.length
|
|
4888
4898
|
};
|
|
@@ -4894,37 +4904,37 @@ const DataBindingSelector = ({
|
|
|
4894
4904
|
if (S) {
|
|
4895
4905
|
const C = `{{${m}}}`;
|
|
4896
4906
|
S.commands.focus();
|
|
4897
|
-
const { from:
|
|
4898
|
-
if (
|
|
4907
|
+
const { from: v, to: _ } = S.state.selection;
|
|
4908
|
+
if (v !== _)
|
|
4899
4909
|
S.chain().deleteSelection().insertContent(C).run();
|
|
4900
4910
|
else {
|
|
4901
|
-
const { state: I } = S, k = I.selection.from, A = I.doc.textBetween(Math.max(0, k - 1), k),
|
|
4911
|
+
const { state: I } = S, k = I.selection.from, A = I.doc.textBetween(Math.max(0, k - 1), k), w = I.doc.textBetween(k, Math.min(k + 1, I.doc.content.size));
|
|
4902
4912
|
let E = "";
|
|
4903
4913
|
k > 0 && A !== " " && !f(A) && (E = " ");
|
|
4904
4914
|
let j = "";
|
|
4905
|
-
|
|
4915
|
+
w && w !== " " && !f(w) && (j = " "), S.chain().insertContent(E + C + j).run();
|
|
4906
4916
|
}
|
|
4907
4917
|
setTimeout(() => n(S.getHTML(), {}, r), 100);
|
|
4908
4918
|
return;
|
|
4909
4919
|
}
|
|
4910
4920
|
} else {
|
|
4911
|
-
const S = b, C = S.selectionStart || 0,
|
|
4921
|
+
const S = b, C = S.selectionStart || 0, v = S.value || "", _ = S.selectionEnd || C;
|
|
4912
4922
|
if (_ > C) {
|
|
4913
|
-
const
|
|
4923
|
+
const w = `{{${m}}}`, { text: E } = x(v, C, w), j = v.slice(0, C) + E + v.slice(_);
|
|
4914
4924
|
n(j, {}, r);
|
|
4915
4925
|
return;
|
|
4916
4926
|
}
|
|
4917
|
-
const I = `{{${m}}}`, { text: k } = x(
|
|
4927
|
+
const I = `{{${m}}}`, { text: k } = x(v, C, I), A = v.slice(0, C) + k + v.slice(C);
|
|
4918
4928
|
n(A, {}, r);
|
|
4919
4929
|
}
|
|
4920
4930
|
},
|
|
4921
|
-
[r, n, a,
|
|
4931
|
+
[r, n, a, d == null ? void 0 : d._id, p]
|
|
4922
4932
|
);
|
|
4923
4933
|
return i ? /* @__PURE__ */ jsx(
|
|
4924
4934
|
NestedPathSelector,
|
|
4925
4935
|
{
|
|
4926
4936
|
data: {
|
|
4927
|
-
...
|
|
4937
|
+
...u && { [p]: u },
|
|
4928
4938
|
...l
|
|
4929
4939
|
},
|
|
4930
4940
|
onSelect: g,
|
|
@@ -4937,67 +4947,67 @@ const DataBindingSelector = ({
|
|
|
4937
4947
|
onChange: r
|
|
4938
4948
|
}) => {
|
|
4939
4949
|
var A;
|
|
4940
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (
|
|
4950
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (w, E) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [f, x] = useState([]), [b, y] = useState(-1), S = useRef(null), C = (A = n == null ? void 0 : n.find((w) => w.key === u)) == null ? void 0 : A.name;
|
|
4941
4951
|
useEffect(() => {
|
|
4942
4952
|
if (h(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4943
|
-
const
|
|
4953
|
+
const w = split(o, ":"), E = get(w, 1, "page") || "page";
|
|
4944
4954
|
g(E), (async () => {
|
|
4945
|
-
const j = await l(E, [get(
|
|
4955
|
+
const j = await l(E, [get(w, 2, "page")]);
|
|
4946
4956
|
j && Array.isArray(j) && h(get(j, [0, "name"], ""));
|
|
4947
4957
|
})();
|
|
4948
4958
|
}, [o]);
|
|
4949
|
-
const
|
|
4950
|
-
async (
|
|
4951
|
-
if (isEmpty(
|
|
4959
|
+
const v = useDebouncedCallback(
|
|
4960
|
+
async (w) => {
|
|
4961
|
+
if (isEmpty(w))
|
|
4952
4962
|
x([]);
|
|
4953
4963
|
else {
|
|
4954
|
-
const E = await l(
|
|
4964
|
+
const E = await l(u, w);
|
|
4955
4965
|
x(E);
|
|
4956
4966
|
}
|
|
4957
4967
|
c(!1), y(-1);
|
|
4958
4968
|
},
|
|
4959
|
-
[
|
|
4969
|
+
[u],
|
|
4960
4970
|
300
|
|
4961
|
-
), _ = (
|
|
4962
|
-
const E = ["pageType",
|
|
4963
|
-
E[1] && (r(E.join(":")), h(
|
|
4964
|
-
}, B = (
|
|
4965
|
-
switch (
|
|
4971
|
+
), _ = (w) => {
|
|
4972
|
+
const E = ["pageType", u, w.id];
|
|
4973
|
+
E[1] && (r(E.join(":")), h(w.name), p(!1), x([]), y(-1));
|
|
4974
|
+
}, B = (w) => {
|
|
4975
|
+
switch (w.key) {
|
|
4966
4976
|
case "ArrowDown":
|
|
4967
|
-
|
|
4977
|
+
w.preventDefault(), y((E) => E < f.length - 1 ? E + 1 : E);
|
|
4968
4978
|
break;
|
|
4969
4979
|
case "ArrowUp":
|
|
4970
|
-
|
|
4980
|
+
w.preventDefault(), y((E) => E > 0 ? E - 1 : E);
|
|
4971
4981
|
break;
|
|
4972
4982
|
case "Enter":
|
|
4973
|
-
if (
|
|
4983
|
+
if (w.preventDefault(), f.length === 0) return;
|
|
4974
4984
|
b >= 0 && _(f[b]);
|
|
4975
4985
|
break;
|
|
4976
4986
|
case "Escape":
|
|
4977
|
-
|
|
4987
|
+
w.preventDefault(), I();
|
|
4978
4988
|
break;
|
|
4979
4989
|
}
|
|
4980
4990
|
};
|
|
4981
4991
|
useEffect(() => {
|
|
4982
4992
|
if (b >= 0 && S.current) {
|
|
4983
|
-
const
|
|
4984
|
-
|
|
4993
|
+
const w = S.current.children[b];
|
|
4994
|
+
w == null || w.scrollIntoView({ block: "nearest" });
|
|
4985
4995
|
}
|
|
4986
4996
|
}, [b]);
|
|
4987
4997
|
const I = () => {
|
|
4988
4998
|
h(""), x([]), y(-1), p(!1), r("");
|
|
4989
|
-
}, k = (
|
|
4990
|
-
h(
|
|
4999
|
+
}, k = (w) => {
|
|
5000
|
+
h(w), p(!isEmpty(w)), c(!0), v(w);
|
|
4991
5001
|
};
|
|
4992
5002
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4993
|
-
/* @__PURE__ */ jsx("select", { name: "pageType", value:
|
|
4994
|
-
|
|
5003
|
+
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (w) => g(w.target.value), children: map(n, (w) => /* @__PURE__ */ jsx("option", { value: w.key, children: w.name }, w.key)) }),
|
|
5004
|
+
u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
|
|
4995
5005
|
/* @__PURE__ */ jsx(
|
|
4996
5006
|
"input",
|
|
4997
5007
|
{
|
|
4998
5008
|
type: "text",
|
|
4999
5009
|
value: m,
|
|
5000
|
-
onChange: (
|
|
5010
|
+
onChange: (w) => k(w.target.value),
|
|
5001
5011
|
onKeyDown: B,
|
|
5002
5012
|
placeholder: a(`Search ${C ?? ""}`),
|
|
5003
5013
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
@@ -5005,36 +5015,36 @@ const DataBindingSelector = ({
|
|
|
5005
5015
|
),
|
|
5006
5016
|
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: I, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-4 w-4" }) }) })
|
|
5007
5017
|
] }),
|
|
5008
|
-
(i || !isEmpty(f) ||
|
|
5018
|
+
(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: [
|
|
5009
5019
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
5010
5020
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
5011
|
-
] }) :
|
|
5021
|
+
] }) : d && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
5012
5022
|
a("No results found for"),
|
|
5013
5023
|
' "',
|
|
5014
5024
|
m,
|
|
5015
5025
|
'"'
|
|
5016
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref: S, children: map(f == null ? void 0 : f.slice(0, 20), (
|
|
5026
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: S, children: map(f == null ? void 0 : f.slice(0, 20), (w, E) => /* @__PURE__ */ jsxs(
|
|
5017
5027
|
"li",
|
|
5018
5028
|
{
|
|
5019
|
-
onClick: () => _(
|
|
5020
|
-
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(
|
|
5029
|
+
onClick: () => _(w),
|
|
5030
|
+
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(w.id) ? "bg-blue-200" : E === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
5021
5031
|
children: [
|
|
5022
|
-
|
|
5032
|
+
w.name,
|
|
5023
5033
|
" ",
|
|
5024
|
-
|
|
5034
|
+
w.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
|
|
5025
5035
|
"( ",
|
|
5026
|
-
|
|
5036
|
+
w.slug,
|
|
5027
5037
|
" )"
|
|
5028
5038
|
] })
|
|
5029
5039
|
]
|
|
5030
5040
|
},
|
|
5031
|
-
|
|
5041
|
+
w.id
|
|
5032
5042
|
)) }) })
|
|
5033
5043
|
] });
|
|
5034
5044
|
}, LinkField = ({ schema: o, formData: n, onChange: r, name: a }) => {
|
|
5035
|
-
const { t: l } = useTranslation(), { type: i = "pageType", href: c = "", target:
|
|
5036
|
-
() => isEmpty(m) ? "" : isEmpty(
|
|
5037
|
-
[m,
|
|
5045
|
+
const { t: l } = useTranslation(), { type: i = "pageType", href: c = "", target: d = "self" } = n ?? {}, p = useBuilderProp("pageTypes", []), { selectedLang: u, fallbackLang: g, languages: m } = useLanguages(), h = useMemo(
|
|
5046
|
+
() => isEmpty(m) ? "" : isEmpty(u) ? g : u,
|
|
5047
|
+
[m, u, g]
|
|
5038
5048
|
), f = useMemo(() => get(LANGUAGES, h, h), [h]), x = i === "pageType" && isEmpty(p) ? "url" : i;
|
|
5039
5049
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
5040
5050
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center justify-between gap-x-2 text-xs font-medium", children: [
|
|
@@ -5097,9 +5107,9 @@ const DataBindingSelector = ({
|
|
|
5097
5107
|
autoCorrect: "off",
|
|
5098
5108
|
spellCheck: "false",
|
|
5099
5109
|
type: "checkbox",
|
|
5100
|
-
defaultChecked:
|
|
5110
|
+
defaultChecked: d === "_blank",
|
|
5101
5111
|
className: "!w-fit cursor-pointer rounded-md border border-border",
|
|
5102
|
-
onChange: () => r({ ...n, target:
|
|
5112
|
+
onChange: () => r({ ...n, target: d === "_blank" ? "_self" : "_blank" })
|
|
5103
5113
|
}
|
|
5104
5114
|
),
|
|
5105
5115
|
/* @__PURE__ */ jsx("span", { className: "pt-1 text-xs", children: l("Open in new tab") })
|
|
@@ -5122,8 +5132,8 @@ const DataBindingSelector = ({
|
|
|
5122
5132
|
]
|
|
5123
5133
|
}
|
|
5124
5134
|
) });
|
|
5125
|
-
}, RTEModal = React__default.lazy(() => import("./rte-widget-modal-
|
|
5126
|
-
const c = useRef(null), [
|
|
5135
|
+
}, RTEModal = React__default.lazy(() => import("./rte-widget-modal-BiZPyPF3.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: l, onBlur: i }) => {
|
|
5136
|
+
const c = useRef(null), [d, p] = useState(!1), u = useRTEditor({
|
|
5127
5137
|
blockId: o,
|
|
5128
5138
|
value: a,
|
|
5129
5139
|
placeholder: r,
|
|
@@ -5137,26 +5147,26 @@ const DataBindingSelector = ({
|
|
|
5137
5147
|
}
|
|
5138
5148
|
});
|
|
5139
5149
|
useEffect(() => {
|
|
5140
|
-
c.current &&
|
|
5141
|
-
}, [o,
|
|
5150
|
+
c.current && u && (c.current.__chaiRTE = u);
|
|
5151
|
+
}, [o, u]);
|
|
5142
5152
|
const g = () => {
|
|
5143
5153
|
p(!1);
|
|
5144
5154
|
}, m = /* @__PURE__ */ jsxs("div", { id: `chai-rte-${n}`, ref: c, className: "mt-1 rounded-md border border-input", children: [
|
|
5145
|
-
/* @__PURE__ */ jsx(RteMenubar, { editor:
|
|
5155
|
+
/* @__PURE__ */ jsx(RteMenubar, { editor: u, onExpand: () => p(!0) }),
|
|
5146
5156
|
/* @__PURE__ */ jsx(
|
|
5147
5157
|
EditorContent,
|
|
5148
5158
|
{
|
|
5149
|
-
editor:
|
|
5159
|
+
editor: u,
|
|
5150
5160
|
id: n,
|
|
5151
5161
|
placeholder: r,
|
|
5152
|
-
className: `overflow-auto ${
|
|
5162
|
+
className: `overflow-auto ${d ? "max-h-[500px] min-h-[400px]" : "max-h-[200px] min-h-[100px]"}`
|
|
5153
5163
|
},
|
|
5154
5164
|
n
|
|
5155
5165
|
)
|
|
5156
5166
|
] });
|
|
5157
5167
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5158
|
-
|
|
5159
|
-
|
|
5168
|
+
d && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsx(RTEModal, { isOpen: d, onClose: g, editor: u, rteElement: m }) }),
|
|
5169
|
+
d ? /* @__PURE__ */ jsx("div", { children: "Open in modal" }) : /* @__PURE__ */ jsx("div", { className: "relative", children: m })
|
|
5160
5170
|
] });
|
|
5161
5171
|
}, RichTextEditorField = (o) => {
|
|
5162
5172
|
const { editingBlockId: n } = useInlineEditing(), [r, a] = useState(null), l = useSelectedBlock(), i = l == null ? void 0 : l._id;
|
|
@@ -5166,25 +5176,25 @@ const DataBindingSelector = ({
|
|
|
5166
5176
|
}, SliderField = ({ formData: o, onChange: n }) => {
|
|
5167
5177
|
const [r] = useBlocksStore(), a = useSelectedBlock(), l = useWrapperBlock(), { addCoreBlock: i } = useAddBlock(), [, c] = useSelectedBlockIds();
|
|
5168
5178
|
if (!a && !l) return null;
|
|
5169
|
-
const
|
|
5179
|
+
const d = (a == null ? void 0 : a._type) === "Slider" ? a : l, p = find(r, { _parent: d == null ? void 0 : d._id, _type: "Slides" });
|
|
5170
5180
|
if (!p) return null;
|
|
5171
|
-
const
|
|
5181
|
+
const u = filter(r, { _parent: p == null ? void 0 : p._id, _type: "Slide" }), g = (o == null ? void 0 : o.currentSlide) || get(u, "0._id");
|
|
5172
5182
|
useEffect(() => {
|
|
5173
5183
|
(a == null ? void 0 : a._type) === "Slide" && (o == null ? void 0 : o.currentSlide) !== (a == null ? void 0 : a._id) && n({ ...o, currentSlide: a == null ? void 0 : a._id });
|
|
5174
5184
|
}, [a]), useEffect(() => {
|
|
5175
|
-
|
|
5176
|
-
}, [o,
|
|
5185
|
+
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
|
|
5186
|
+
}, [o, u]);
|
|
5177
5187
|
const m = () => {
|
|
5178
|
-
const x = findIndex(
|
|
5188
|
+
const x = findIndex(u, { _id: g });
|
|
5179
5189
|
if (x > -1) {
|
|
5180
|
-
const b = (x + 1) %
|
|
5190
|
+
const b = (x + 1) % u.length, y = get(u, [b, "_id"]);
|
|
5181
5191
|
if (!y) return;
|
|
5182
5192
|
n({ ...o, currentSlide: y }), c([y]);
|
|
5183
5193
|
}
|
|
5184
5194
|
}, h = () => {
|
|
5185
|
-
const x = findIndex(
|
|
5195
|
+
const x = findIndex(u, { _id: g });
|
|
5186
5196
|
if (x > -1) {
|
|
5187
|
-
const b = (x - 1 +
|
|
5197
|
+
const b = (x - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
|
|
5188
5198
|
if (!y) return;
|
|
5189
5199
|
n({ ...o, currentSlide: y }), c([y]);
|
|
5190
5200
|
}
|
|
@@ -5201,10 +5211,10 @@ const DataBindingSelector = ({
|
|
|
5201
5211
|
/* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
|
|
5202
5212
|
/* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
|
|
5203
5213
|
" ",
|
|
5204
|
-
findIndex(
|
|
5214
|
+
findIndex(u, { _id: g }) + 1
|
|
5205
5215
|
] }),
|
|
5206
5216
|
"/",
|
|
5207
|
-
|
|
5217
|
+
u.length
|
|
5208
5218
|
] }) : "-" }),
|
|
5209
5219
|
/* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) }),
|
|
5210
5220
|
/* @__PURE__ */ jsxs(
|
|
@@ -5281,15 +5291,15 @@ const DataBindingSelector = ({
|
|
|
5281
5291
|
] }) })
|
|
5282
5292
|
] });
|
|
5283
5293
|
}, SourcesField = ({ formData: o, onChange: n }) => {
|
|
5284
|
-
const r = get(o, "srcsets", []) || [], a = (c,
|
|
5285
|
-
const p = c.target.name,
|
|
5294
|
+
const r = get(o, "srcsets", []) || [], a = (c, d) => {
|
|
5295
|
+
const p = c.target.name, u = c.target.value;
|
|
5286
5296
|
n({
|
|
5287
|
-
srcsets: map(r, (g, m) => m ===
|
|
5297
|
+
srcsets: map(r, (g, m) => m === d ? { ...g, [p]: u } : g)
|
|
5288
5298
|
});
|
|
5289
5299
|
}, l = () => {
|
|
5290
5300
|
n({ srcsets: [...r, {}] });
|
|
5291
5301
|
}, i = (c) => {
|
|
5292
|
-
n({ srcsets: reject(r, (
|
|
5302
|
+
n({ srcsets: reject(r, (d, p) => p === c) });
|
|
5293
5303
|
};
|
|
5294
5304
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
5295
5305
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pb-2", children: [
|
|
@@ -5304,12 +5314,12 @@ const DataBindingSelector = ({
|
|
|
5304
5314
|
}
|
|
5305
5315
|
)
|
|
5306
5316
|
] }),
|
|
5307
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: r.length === 0 ? /* @__PURE__ */ jsx("div", { className: "rounded border border-dashed border-gray-200 p-2 text-xs italic text-gray-500", children: "Add additional sources to create responsive videos" }) : map(r, (c,
|
|
5317
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: r.length === 0 ? /* @__PURE__ */ jsx("div", { className: "rounded border border-dashed border-gray-200 p-2 text-xs italic text-gray-500", children: "Add additional sources to create responsive videos" }) : map(r, (c, d) => /* @__PURE__ */ jsxs("div", { className: "group relative space-y-1.5 rounded border border-gray-200 px-2 pb-1.5", children: [
|
|
5308
5318
|
/* @__PURE__ */ jsx(
|
|
5309
5319
|
"button",
|
|
5310
5320
|
{
|
|
5311
5321
|
type: "button",
|
|
5312
|
-
onClick: () => i(
|
|
5322
|
+
onClick: () => i(d),
|
|
5313
5323
|
className: "absolute -right-px -top-0 -translate-y-1/2 rounded-full bg-red-100 p-1 opacity-0 hover:bg-red-200 group-hover:opacity-100",
|
|
5314
5324
|
children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-2.5 w-2.5 text-red-500" })
|
|
5315
5325
|
}
|
|
@@ -5323,7 +5333,7 @@ const DataBindingSelector = ({
|
|
|
5323
5333
|
placeholder: "Enter width (in px)",
|
|
5324
5334
|
type: "number",
|
|
5325
5335
|
value: get(c, "width"),
|
|
5326
|
-
onChange: (p) => a(p,
|
|
5336
|
+
onChange: (p) => a(p, d),
|
|
5327
5337
|
className: "!placeholder:text-gray-100 !mt-0 !rounded-none !border-0 !p-0 !text-xs"
|
|
5328
5338
|
}
|
|
5329
5339
|
)
|
|
@@ -5337,16 +5347,16 @@ const DataBindingSelector = ({
|
|
|
5337
5347
|
placeholder: "Enter url",
|
|
5338
5348
|
className: "!mt-0 !rounded-none !border-0 !p-0 !text-xs !shadow-none",
|
|
5339
5349
|
value: get(c, "url", ""),
|
|
5340
|
-
onChange: (p) => a(p,
|
|
5350
|
+
onChange: (p) => a(p, d)
|
|
5341
5351
|
}
|
|
5342
5352
|
)
|
|
5343
5353
|
] })
|
|
5344
|
-
] },
|
|
5354
|
+
] }, d)) })
|
|
5345
5355
|
] });
|
|
5346
5356
|
}, CodeEditor = ({ id: o, placeholder: n }) => {
|
|
5347
5357
|
const { t: r } = useTranslation(), [, a] = useCodeEditor(), l = useSelectedBlock();
|
|
5348
5358
|
if (typeof window > "u") return null;
|
|
5349
|
-
const i = o.replace("root.", ""), c = get(l, i, ""),
|
|
5359
|
+
const i = o.replace("root.", ""), c = get(l, i, ""), d = () => {
|
|
5350
5360
|
const p = l == null ? void 0 : l._id;
|
|
5351
5361
|
a({ blockId: p, blockProp: i, placeholder: n, initialCode: get(l, i, c) });
|
|
5352
5362
|
};
|
|
@@ -5354,35 +5364,35 @@ const DataBindingSelector = ({
|
|
|
5354
5364
|
/* @__PURE__ */ jsx(
|
|
5355
5365
|
"button",
|
|
5356
5366
|
{
|
|
5357
|
-
onClick:
|
|
5367
|
+
onClick: d,
|
|
5358
5368
|
className: "w-[90%] max-w-full cursor-default truncate text-pretty rounded border border-border bg-background p-2 text-left text-[10px]",
|
|
5359
5369
|
children: c.trim().length > 0 ? c.substring(0, 46) : n || "Eg: <script>console.log('Hello, world!');<\/script>"
|
|
5360
5370
|
}
|
|
5361
5371
|
),
|
|
5362
|
-
/* @__PURE__ */ jsx(Button, { onClick:
|
|
5372
|
+
/* @__PURE__ */ jsx(Button, { onClick: d, size: "sm", variant: "outline", className: "w-fit", children: r("Open code editor") })
|
|
5363
5373
|
] });
|
|
5364
5374
|
}, CollectionFilterSortField = ({ id: o, value: n, onChange: r, onBlur: a }) => {
|
|
5365
|
-
const l = useBuilderProp("collections", []), i = useSelectedBlock(), c = get(i, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1").replace(COLLECTION_PREFIX, ""),
|
|
5375
|
+
const l = useBuilderProp("collections", []), i = useSelectedBlock(), c = get(i, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1").replace(COLLECTION_PREFIX, ""), d = find(l, { id: c }), u = get(d, o === "root.filter" ? "filters" : "sorts", []);
|
|
5366
5376
|
return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("select", { value: n, onChange: (g) => r(g.target.value), onBlur: (g) => a(o, g.target.value), children: [
|
|
5367
5377
|
/* @__PURE__ */ jsx("option", { value: "", children: "Select" }),
|
|
5368
|
-
|
|
5378
|
+
u.map((g) => /* @__PURE__ */ jsx("option", { value: g.id, children: g.name }, g.id))
|
|
5369
5379
|
] }) });
|
|
5370
5380
|
}, JSONFormFieldTemplate = (o) => {
|
|
5371
|
-
const { id: n, classNames: r, label: a, children: l, errors: i, help: c, hidden:
|
|
5381
|
+
const { id: n, classNames: r, label: a, children: l, errors: i, help: c, hidden: d, required: p, schema: u, formData: g, onChange: m } = o, { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), b = useMemo(
|
|
5372
5382
|
() => isEmpty(x) ? "" : isEmpty(h) ? f : h,
|
|
5373
5383
|
[x, h, f]
|
|
5374
|
-
), y = useMemo(() => get(LANGUAGES, b, b), [b]), S = usePageExternalData(), C = useSelectedBlock(),
|
|
5375
|
-
() => get(
|
|
5376
|
-
[
|
|
5384
|
+
), y = useMemo(() => get(LANGUAGES, b, b), [b]), S = usePageExternalData(), C = useSelectedBlock(), v = useRegisteredChaiBlocks(), _ = useMemo(
|
|
5385
|
+
() => get(v, [C == null ? void 0 : C._type, "i18nProps"], []),
|
|
5386
|
+
[v, C == null ? void 0 : C._type]
|
|
5377
5387
|
), [B, I] = useState(null);
|
|
5378
|
-
if (
|
|
5388
|
+
if (d)
|
|
5379
5389
|
return null;
|
|
5380
|
-
if (
|
|
5390
|
+
if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: l });
|
|
5381
5391
|
const A = _ == null ? void 0 : _.includes(n.replace("root.", ""));
|
|
5382
|
-
if (
|
|
5392
|
+
if (u.type === "array") {
|
|
5383
5393
|
const j = B === n;
|
|
5384
5394
|
return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
|
|
5385
|
-
|
|
5395
|
+
u.title && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsxs(
|
|
5386
5396
|
"label",
|
|
5387
5397
|
{
|
|
5388
5398
|
htmlFor: n,
|
|
@@ -5394,7 +5404,7 @@ const DataBindingSelector = ({
|
|
|
5394
5404
|
/* @__PURE__ */ jsx("span", { className: "leading-tight", children: a }),
|
|
5395
5405
|
" ",
|
|
5396
5406
|
/* @__PURE__ */ jsx(Badge, { className: "m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500", children: /* @__PURE__ */ jsx("span", { className: "text-[9px] font-medium text-slate-600", children: g == null ? void 0 : g.length }) }),
|
|
5397
|
-
|
|
5407
|
+
u.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5398
5408
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5399
5409
|
InfoCircledIcon,
|
|
5400
5410
|
{
|
|
@@ -5403,7 +5413,7 @@ const DataBindingSelector = ({
|
|
|
5403
5413
|
onMouseDown: (N) => N.stopPropagation()
|
|
5404
5414
|
}
|
|
5405
5415
|
) }),
|
|
5406
|
-
/* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children:
|
|
5416
|
+
/* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: u.description })
|
|
5407
5417
|
] }) })
|
|
5408
5418
|
]
|
|
5409
5419
|
}
|
|
@@ -5415,25 +5425,25 @@ const DataBindingSelector = ({
|
|
|
5415
5425
|
] })
|
|
5416
5426
|
] });
|
|
5417
5427
|
}
|
|
5418
|
-
const
|
|
5428
|
+
const w = n.replace("root.", ""), E = _.includes(w) && !isEmpty(h) && isEmpty(g);
|
|
5419
5429
|
return /* @__PURE__ */ jsxs("div", { className: r, children: [
|
|
5420
|
-
|
|
5430
|
+
u.title && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
5421
5431
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
5422
|
-
/* @__PURE__ */ jsxs("label", { htmlFor: n, className:
|
|
5432
|
+
/* @__PURE__ */ jsxs("label", { htmlFor: n, className: u.type === "object" ? "pb-2" : "", children: [
|
|
5423
5433
|
a,
|
|
5424
5434
|
" ",
|
|
5425
5435
|
A && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
|
|
5426
5436
|
" ",
|
|
5427
5437
|
y
|
|
5428
5438
|
] }),
|
|
5429
|
-
p &&
|
|
5439
|
+
p && u.type !== "object" ? " *" : null
|
|
5430
5440
|
] }),
|
|
5431
|
-
|
|
5441
|
+
u.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5432
5442
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(InfoCircledIcon, { className: "h-3 w-3 text-muted-foreground/70" }) }),
|
|
5433
|
-
/* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children:
|
|
5443
|
+
/* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: u.description })
|
|
5434
5444
|
] }) })
|
|
5435
5445
|
] }),
|
|
5436
|
-
!
|
|
5446
|
+
!u.enum && !u.oneOf && S && /* @__PURE__ */ jsxs("span", { className: "flex items-center space-x-1", children: [
|
|
5437
5447
|
E ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5438
5448
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
5439
5449
|
"svg",
|
|
@@ -5464,7 +5474,7 @@ const DataBindingSelector = ({
|
|
|
5464
5474
|
/* @__PURE__ */ jsx(
|
|
5465
5475
|
DataBindingSelector,
|
|
5466
5476
|
{
|
|
5467
|
-
schema:
|
|
5477
|
+
schema: u,
|
|
5468
5478
|
onChange: (j) => {
|
|
5469
5479
|
m(j, g, n);
|
|
5470
5480
|
},
|
|
@@ -5515,7 +5525,7 @@ const DataBindingSelector = ({
|
|
|
5515
5525
|
" ",
|
|
5516
5526
|
/* @__PURE__ */ jsx("span", { children: "Add" })
|
|
5517
5527
|
] }) }), JSONForm = memo(({ blockId: o, schema: n, uiSchema: r, formData: a, onChange: l }) => {
|
|
5518
|
-
const { selectedLang: i } = useLanguages(), c = useBlockSettingComponents("widget"),
|
|
5528
|
+
const { selectedLang: i } = useLanguages(), c = useBlockSettingComponents("widget"), d = useBlockSettingComponents("field"), p = useBlockSettingComponents("template"), u = useThrottledCallback(
|
|
5519
5529
|
async ({ formData: g }, m) => {
|
|
5520
5530
|
get(g, m) === void 0 && set(g, m, ""), l({ formData: g }, m);
|
|
5521
5531
|
},
|
|
@@ -5540,7 +5550,7 @@ const DataBindingSelector = ({
|
|
|
5540
5550
|
link: LinkField,
|
|
5541
5551
|
slider: SliderField,
|
|
5542
5552
|
sources: SourcesField,
|
|
5543
|
-
...
|
|
5553
|
+
...d
|
|
5544
5554
|
},
|
|
5545
5555
|
templates: {
|
|
5546
5556
|
FieldTemplate: JSONFormFieldTemplate,
|
|
@@ -5561,7 +5571,7 @@ const DataBindingSelector = ({
|
|
|
5561
5571
|
onChange: ({ formData: g }, m) => {
|
|
5562
5572
|
if (!m || o !== (g == null ? void 0 : g._id)) return;
|
|
5563
5573
|
const h = take(m.split("."), 2).join(".").replace("root.", "");
|
|
5564
|
-
|
|
5574
|
+
u({ formData: g }, h);
|
|
5565
5575
|
}
|
|
5566
5576
|
},
|
|
5567
5577
|
i
|
|
@@ -5573,11 +5583,11 @@ const DataBindingSelector = ({
|
|
|
5573
5583
|
}), a;
|
|
5574
5584
|
};
|
|
5575
5585
|
function BlockSettings() {
|
|
5576
|
-
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c,
|
|
5586
|
+
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: B }, I, k) => {
|
|
5577
5587
|
I && (c == null ? void 0 : c._id) === n._id && a([n._id], { [I]: get(B, I) }, k);
|
|
5578
5588
|
}, x = useCallback(
|
|
5579
5589
|
debounce(({ formData: B }, I, k) => {
|
|
5580
|
-
f({ formData: B }, I, k),
|
|
5590
|
+
f({ formData: B }, I, k), d(B);
|
|
5581
5591
|
}, 1500),
|
|
5582
5592
|
[n == null ? void 0 : n._id, o]
|
|
5583
5593
|
), b = ({ formData: B }, I) => {
|
|
@@ -5598,7 +5608,7 @@ function BlockSettings() {
|
|
|
5598
5608
|
} catch {
|
|
5599
5609
|
return { schema: {}, uiSchema: {} };
|
|
5600
5610
|
}
|
|
5601
|
-
}, [n]), { wrapperSchema:
|
|
5611
|
+
}, [n]), { wrapperSchema: v, wrapperUiSchema: _ } = useMemo(() => {
|
|
5602
5612
|
if (!g || !(g != null && g._type))
|
|
5603
5613
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5604
5614
|
const B = g == null ? void 0 : g._type, { schema: I = {}, uiSchema: k = {} } = getBlockFormSchemas(B);
|
|
@@ -5609,7 +5619,7 @@ function BlockSettings() {
|
|
|
5609
5619
|
/* @__PURE__ */ jsxs(
|
|
5610
5620
|
"div",
|
|
5611
5621
|
{
|
|
5612
|
-
onClick: () =>
|
|
5622
|
+
onClick: () => u((B) => !B),
|
|
5613
5623
|
className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
|
|
5614
5624
|
children: [
|
|
5615
5625
|
p ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-4 w-4 text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 text-slate-400" }),
|
|
@@ -5630,7 +5640,7 @@ function BlockSettings() {
|
|
|
5630
5640
|
blockId: g == null ? void 0 : g._id,
|
|
5631
5641
|
onChange: y,
|
|
5632
5642
|
formData: h,
|
|
5633
|
-
schema:
|
|
5643
|
+
schema: v,
|
|
5634
5644
|
uiSchema: _
|
|
5635
5645
|
}
|
|
5636
5646
|
) })
|
|
@@ -5653,7 +5663,7 @@ const BlockStylingProps = () => {
|
|
|
5653
5663
|
if (!o) return null;
|
|
5654
5664
|
const c = Object.keys(o).filter(
|
|
5655
5665
|
(x) => typeof o[x] == "string" && o[x].startsWith("#styles:")
|
|
5656
|
-
), { reset:
|
|
5666
|
+
), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (f = n[0]) == null ? void 0 : f.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, m = g ? g.split(" ").filter((x) => !isEmpty(x)) : [], h = (x) => find(n, (b) => b.prop === x);
|
|
5657
5667
|
return /* @__PURE__ */ jsx(Fragment, { children: p && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
|
|
5658
5668
|
/* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
|
|
5659
5669
|
i("Style element"),
|
|
@@ -5685,7 +5695,7 @@ const BlockStylingProps = () => {
|
|
|
5685
5695
|
{
|
|
5686
5696
|
className: "text-xs",
|
|
5687
5697
|
onClick: () => {
|
|
5688
|
-
|
|
5698
|
+
d(x);
|
|
5689
5699
|
},
|
|
5690
5700
|
children: i("Reset style")
|
|
5691
5701
|
}
|
|
@@ -5817,13 +5827,13 @@ const BlockStylingProps = () => {
|
|
|
5817
5827
|
negative: i,
|
|
5818
5828
|
cssProperty: c
|
|
5819
5829
|
}) => {
|
|
5820
|
-
const { setDragData:
|
|
5830
|
+
const { setDragData: d } = useContext(BlockSettingsContext);
|
|
5821
5831
|
return /* @__PURE__ */ jsx(
|
|
5822
5832
|
"button",
|
|
5823
5833
|
{
|
|
5824
5834
|
type: "button",
|
|
5825
5835
|
onMouseDown: (p) => {
|
|
5826
|
-
const
|
|
5836
|
+
const u = {
|
|
5827
5837
|
onDrag: r,
|
|
5828
5838
|
onDragEnd: a,
|
|
5829
5839
|
dragging: !0,
|
|
@@ -5833,7 +5843,7 @@ const BlockStylingProps = () => {
|
|
|
5833
5843
|
negative: i,
|
|
5834
5844
|
cssProperty: c
|
|
5835
5845
|
};
|
|
5836
|
-
l(
|
|
5846
|
+
l(u), d(u);
|
|
5837
5847
|
},
|
|
5838
5848
|
color: void 0,
|
|
5839
5849
|
className: "relative z-50 ml-1 hidden h-6 cursor-row-resize rounded bg-background/70 px-2 group-hover:inline",
|
|
@@ -5853,50 +5863,50 @@ const BlockStylingProps = () => {
|
|
|
5853
5863
|
},
|
|
5854
5864
|
a
|
|
5855
5865
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
5856
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix:
|
|
5866
|
+
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(""), [S, C] = useState(!1), [v, _] = useState(!1);
|
|
5857
5867
|
useEffect(() => {
|
|
5858
|
-
const { value:
|
|
5868
|
+
const { value: w, unit: E } = getClassValueAndUnit(i);
|
|
5859
5869
|
if (E === "") {
|
|
5860
|
-
l(
|
|
5870
|
+
l(w), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
5861
5871
|
return;
|
|
5862
5872
|
}
|
|
5863
|
-
h(E), l(E === "class" || isEmpty(
|
|
5864
|
-
}, [i, p,
|
|
5865
|
-
const B = useThrottledCallback((
|
|
5866
|
-
(
|
|
5867
|
-
const E = getUserInputValues(`${a}`,
|
|
5873
|
+
h(E), l(E === "class" || isEmpty(w) ? "" : w);
|
|
5874
|
+
}, [i, p, u]);
|
|
5875
|
+
const B = useThrottledCallback((w) => c(w), [c], THROTTLE_TIME), I = useThrottledCallback((w) => c(w, !1), [c], THROTTLE_TIME), k = useCallback(
|
|
5876
|
+
(w = !1) => {
|
|
5877
|
+
const E = getUserInputValues(`${a}`, u);
|
|
5868
5878
|
if (get(E, "error", !1)) {
|
|
5869
5879
|
x(!0);
|
|
5870
5880
|
return;
|
|
5871
5881
|
}
|
|
5872
5882
|
const j = get(E, "unit") !== "" ? get(E, "unit") : m;
|
|
5873
5883
|
if (j === "auto" || j === "none") {
|
|
5874
|
-
B(`${
|
|
5884
|
+
B(`${d}${j}`);
|
|
5875
5885
|
return;
|
|
5876
5886
|
}
|
|
5877
5887
|
if (get(E, "value") === "")
|
|
5878
5888
|
return;
|
|
5879
|
-
const T = `${get(E, "value", "").startsWith("-") ? "-" : ""}${
|
|
5880
|
-
|
|
5889
|
+
const T = `${get(E, "value", "").startsWith("-") ? "-" : ""}${d}[${get(E, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
|
|
5890
|
+
w ? I(T) : B(T);
|
|
5881
5891
|
},
|
|
5882
|
-
[B, I, a, m,
|
|
5892
|
+
[B, I, a, m, d, u]
|
|
5883
5893
|
), A = useCallback(
|
|
5884
|
-
(
|
|
5885
|
-
const E = getUserInputValues(`${a}`,
|
|
5894
|
+
(w) => {
|
|
5895
|
+
const E = getUserInputValues(`${a}`, u);
|
|
5886
5896
|
if (get(E, "error", !1)) {
|
|
5887
5897
|
x(!0);
|
|
5888
5898
|
return;
|
|
5889
5899
|
}
|
|
5890
|
-
if (
|
|
5891
|
-
B(`${
|
|
5900
|
+
if (w === "auto" || w === "none") {
|
|
5901
|
+
B(`${d}${w}`);
|
|
5892
5902
|
return;
|
|
5893
5903
|
}
|
|
5894
5904
|
if (get(E, "value") === "")
|
|
5895
5905
|
return;
|
|
5896
|
-
const j = get(E, "unit") !== "" ? get(E, "unit") :
|
|
5906
|
+
const j = get(E, "unit") !== "" ? get(E, "unit") : w, T = `${get(E, "value", "").startsWith("-") ? "-" : ""}${d}[${get(E, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
|
|
5897
5907
|
B(T);
|
|
5898
5908
|
},
|
|
5899
|
-
[B, a,
|
|
5909
|
+
[B, a, d, u]
|
|
5900
5910
|
);
|
|
5901
5911
|
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: [
|
|
5902
5912
|
/* @__PURE__ */ jsx(
|
|
@@ -5917,29 +5927,29 @@ const BlockStylingProps = () => {
|
|
|
5917
5927
|
"input",
|
|
5918
5928
|
{
|
|
5919
5929
|
readOnly: m === "class",
|
|
5920
|
-
onKeyPress: (
|
|
5921
|
-
|
|
5930
|
+
onKeyPress: (w) => {
|
|
5931
|
+
w.key === "Enter" && k();
|
|
5922
5932
|
},
|
|
5923
|
-
onKeyDown: (
|
|
5924
|
-
if (
|
|
5933
|
+
onKeyDown: (w) => {
|
|
5934
|
+
if (w.keyCode !== 38 && w.keyCode !== 40)
|
|
5925
5935
|
return;
|
|
5926
|
-
|
|
5927
|
-
const E = parseInt$1(
|
|
5936
|
+
w.preventDefault(), _(!0);
|
|
5937
|
+
const E = parseInt$1(w.target.value);
|
|
5928
5938
|
let j = isNaN$1(E) ? 0 : E;
|
|
5929
|
-
|
|
5930
|
-
const N = `${j}`, P = `${N.startsWith("-") ? "-" : ""}${
|
|
5939
|
+
w.keyCode === 38 && (j += 1), w.keyCode === 40 && (j -= 1);
|
|
5940
|
+
const N = `${j}`, P = `${N.startsWith("-") ? "-" : ""}${d}[${N.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
5931
5941
|
I(P);
|
|
5932
5942
|
},
|
|
5933
|
-
onKeyUp: (
|
|
5934
|
-
|
|
5943
|
+
onKeyUp: (w) => {
|
|
5944
|
+
v && (w.preventDefault(), _(!1));
|
|
5935
5945
|
},
|
|
5936
5946
|
onBlur: () => k(),
|
|
5937
|
-
onChange: (
|
|
5938
|
-
x(!1), l(
|
|
5947
|
+
onChange: (w) => {
|
|
5948
|
+
x(!1), l(w.target.value);
|
|
5939
5949
|
},
|
|
5940
|
-
onClick: (
|
|
5950
|
+
onClick: (w) => {
|
|
5941
5951
|
var E;
|
|
5942
|
-
(E =
|
|
5952
|
+
(E = w == null ? void 0 : w.target) == null || E.select(), r(!1);
|
|
5943
5953
|
},
|
|
5944
5954
|
value: S ? b : a,
|
|
5945
5955
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
@@ -5956,18 +5966,18 @@ const BlockStylingProps = () => {
|
|
|
5956
5966
|
onClick: () => r(!n),
|
|
5957
5967
|
className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
|
|
5958
5968
|
children: [
|
|
5959
|
-
/* @__PURE__ */ jsx("span", { className: `inline-block ${
|
|
5960
|
-
|
|
5969
|
+
/* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: m }),
|
|
5970
|
+
u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
|
|
5961
5971
|
]
|
|
5962
5972
|
}
|
|
5963
5973
|
) }),
|
|
5964
5974
|
/* @__PURE__ */ jsx(TooltipContent, { className: "bg-background", children: /* @__PURE__ */ jsx(
|
|
5965
5975
|
UnitSelection,
|
|
5966
5976
|
{
|
|
5967
|
-
units:
|
|
5977
|
+
units: u,
|
|
5968
5978
|
current: m,
|
|
5969
|
-
onSelect: (
|
|
5970
|
-
r(!1), h(
|
|
5979
|
+
onSelect: (w) => {
|
|
5980
|
+
r(!1), h(w), A(w);
|
|
5971
5981
|
}
|
|
5972
5982
|
}
|
|
5973
5983
|
) })
|
|
@@ -5977,17 +5987,17 @@ const BlockStylingProps = () => {
|
|
|
5977
5987
|
DragStyleButton,
|
|
5978
5988
|
{
|
|
5979
5989
|
onDragStart: () => C(!0),
|
|
5980
|
-
onDragEnd: (
|
|
5981
|
-
if (y(() => ""), C(!1), isEmpty(
|
|
5990
|
+
onDragEnd: (w) => {
|
|
5991
|
+
if (y(() => ""), C(!1), isEmpty(w))
|
|
5982
5992
|
return;
|
|
5983
|
-
const E = `${
|
|
5993
|
+
const E = `${w}`, N = `${E.startsWith("-") ? "-" : ""}${d}[${E.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
5984
5994
|
B(N);
|
|
5985
5995
|
},
|
|
5986
|
-
onDrag: (
|
|
5987
|
-
if (isEmpty(
|
|
5996
|
+
onDrag: (w) => {
|
|
5997
|
+
if (isEmpty(w))
|
|
5988
5998
|
return;
|
|
5989
|
-
y(
|
|
5990
|
-
const E = `${
|
|
5999
|
+
y(w);
|
|
6000
|
+
const E = `${w}`, N = `${E.startsWith("-") ? "-" : ""}${d}[${E.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
5991
6001
|
I(N);
|
|
5992
6002
|
},
|
|
5993
6003
|
currentValue: a,
|
|
@@ -6001,7 +6011,7 @@ const BlockStylingProps = () => {
|
|
|
6001
6011
|
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
6002
6012
|
/* @__PURE__ */ jsx(StyleContext.Provider, { value: { canReset: n, canChange: r }, children: o })
|
|
6003
6013
|
), DropDownChoices = ({ label: o, property: n, onChange: r }) => {
|
|
6004
|
-
const { getClasses: a } = useTailwindClassList(), l = a(n), i = useCurrentClassByProperty(n), c = useMemo(() => get(i, "cls", ""), [i]), { canChange:
|
|
6014
|
+
const { getClasses: a } = useTailwindClassList(), l = a(n), i = useCurrentClassByProperty(n), c = useMemo(() => get(i, "cls", ""), [i]), { canChange: d } = useContext(StyleContext), p = /\[.*\]/g.test(c);
|
|
6005
6015
|
return /* @__PURE__ */ jsx("div", { className: o ? "w-full rounded" : "grow", children: p ? /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
6006
6016
|
/* @__PURE__ */ jsx(Input$1, { className: "w-[70%] rounded py-1", readOnly: !0, value: c }),
|
|
6007
6017
|
/* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
@@ -6012,15 +6022,15 @@ const BlockStylingProps = () => {
|
|
|
6012
6022
|
DropDown,
|
|
6013
6023
|
{
|
|
6014
6024
|
rounded: o,
|
|
6015
|
-
onChange: (
|
|
6025
|
+
onChange: (u) => r(u, n),
|
|
6016
6026
|
selected: c,
|
|
6017
6027
|
options: l,
|
|
6018
|
-
disabled: !
|
|
6028
|
+
disabled: !d
|
|
6019
6029
|
}
|
|
6020
6030
|
) });
|
|
6021
6031
|
};
|
|
6022
6032
|
function DropDown({ selected: o, onChange: n, rounded: r = !1, options: a, disabled: l = !1 }) {
|
|
6023
|
-
const i = o.replace(/.*:/g, "").trim(), { undo: c, redo:
|
|
6033
|
+
const i = o.replace(/.*:/g, "").trim(), { undo: c, redo: d } = useUndoManager();
|
|
6024
6034
|
return /* @__PURE__ */ jsxs(
|
|
6025
6035
|
"select",
|
|
6026
6036
|
{
|
|
@@ -6028,12 +6038,12 @@ function DropDown({ selected: o, onChange: n, rounded: r = !1, options: a, disab
|
|
|
6028
6038
|
className: `${r ? "rounded-md border border-border" : "border-0"} disable:bg-gray-500 h-full w-full truncate rounded bg-background px-2 py-1 text-xs outline-none disabled:cursor-not-allowed`,
|
|
6029
6039
|
onChange: (p) => n(p.target.value),
|
|
6030
6040
|
onKeyDown: (p) => {
|
|
6031
|
-
p.ctrlKey && (p.key === "z" && c(), p.key === "y" &&
|
|
6041
|
+
p.ctrlKey && (p.key === "z" && c(), p.key === "y" && d());
|
|
6032
6042
|
},
|
|
6033
6043
|
value: i,
|
|
6034
6044
|
children: [
|
|
6035
6045
|
/* @__PURE__ */ jsx("option", { className: "bg-transparent", value: "" }),
|
|
6036
|
-
a.map((p,
|
|
6046
|
+
a.map((p, u) => /* @__PURE__ */ jsx("option", { className: "bg-transparent", value: p, children: p }, `option-${u}`))
|
|
6037
6047
|
]
|
|
6038
6048
|
}
|
|
6039
6049
|
);
|
|
@@ -6051,7 +6061,7 @@ const COLOR_PROP = {
|
|
|
6051
6061
|
ringColor: "ring",
|
|
6052
6062
|
ringOffsetColor: "ring-offset"
|
|
6053
6063
|
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
6054
|
-
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [
|
|
6064
|
+
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(
|
|
6055
6065
|
// eslint-disable-next-line no-shadow
|
|
6056
6066
|
(b) => {
|
|
6057
6067
|
["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" })));
|
|
@@ -6075,9 +6085,9 @@ const COLOR_PROP = {
|
|
|
6075
6085
|
}, [r]);
|
|
6076
6086
|
const { match: x } = useTailwindClassList();
|
|
6077
6087
|
return useEffect(() => {
|
|
6078
|
-
const y = `${get(COLOR_PROP, o, "")}-${
|
|
6088
|
+
const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
6079
6089
|
x(o, y) && n(y, o);
|
|
6080
|
-
}, [x,
|
|
6090
|
+
}, [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: [
|
|
6081
6091
|
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
6082
6092
|
DropDown,
|
|
6083
6093
|
{
|
|
@@ -6315,29 +6325,29 @@ const COLOR_PROP = {
|
|
|
6315
6325
|
static: Cross1Icon
|
|
6316
6326
|
}, IconChoices = ({ property: o, onChange: n }) => {
|
|
6317
6327
|
const { getClasses: r } = useTailwindClassList(), a = r(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
|
|
6318
|
-
return /* @__PURE__ */ jsx("div", { className: "flex grow flex-wrap gap-1", children: map(a, (
|
|
6328
|
+
return /* @__PURE__ */ jsx("div", { className: "flex grow flex-wrap gap-1", children: map(a, (d) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6319
6329
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6320
6330
|
"button",
|
|
6321
6331
|
{
|
|
6322
6332
|
type: "button",
|
|
6323
6333
|
disabled: !l,
|
|
6324
|
-
onClick: () => n(
|
|
6325
|
-
className: `cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${c ===
|
|
6326
|
-
children: React__default.createElement(get(EDITOR_ICONS,
|
|
6334
|
+
onClick: () => n(d, o),
|
|
6335
|
+
className: `cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${c === d ? "bg-primary text-white" : "disabled:bg-gray-600 disabled:text-gray-400"}`,
|
|
6336
|
+
children: React__default.createElement(get(EDITOR_ICONS, d, BoxIcon))
|
|
6327
6337
|
}
|
|
6328
6338
|
) }),
|
|
6329
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(
|
|
6339
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(d)) })
|
|
6330
6340
|
] })) });
|
|
6331
6341
|
}, RangeChoices = ({ property: o, onChange: n }) => {
|
|
6332
|
-
const { canReset: r, canChange: a } = useContext(StyleContext), l = useCurrentClassByProperty(o), i = useMemo(() => get(l, "cls", ""), [l]), { getClasses: c } = useTailwindClassList(),
|
|
6333
|
-
return /* @__PURE__ */ jsx("div", { className: "flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs", children:
|
|
6342
|
+
const { canReset: r, canChange: a } = useContext(StyleContext), l = useCurrentClassByProperty(o), i = useMemo(() => get(l, "cls", ""), [l]), { getClasses: c } = useTailwindClassList(), d = c(o, [""]), p = d.indexOf(i) > -1 ? d.indexOf(i) : 0, u = /\[.*\]/g.test(i);
|
|
6343
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs", children: u ? /* @__PURE__ */ jsx("div", { className: "px-2 py-[5px]", children: i }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6334
6344
|
/* @__PURE__ */ jsx(
|
|
6335
6345
|
"button",
|
|
6336
6346
|
{
|
|
6337
6347
|
type: "button",
|
|
6338
6348
|
className: "hover:bg-bg-gray-700 box-border w-2/12 rounded-bl rounded-tl bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",
|
|
6339
6349
|
disabled: !a && (!r || p - 1 < 0),
|
|
6340
|
-
onClick: () => n(nth(
|
|
6350
|
+
onClick: () => n(nth(d, p - 1), o),
|
|
6341
6351
|
children: /* @__PURE__ */ jsx("span", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
|
|
6342
6352
|
MinusIcon,
|
|
6343
6353
|
{
|
|
@@ -6352,12 +6362,12 @@ const COLOR_PROP = {
|
|
|
6352
6362
|
{
|
|
6353
6363
|
type: "button",
|
|
6354
6364
|
className: "hover:bg-bg-gray-700 w-2/12 rounded-br rounded-tr bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",
|
|
6355
|
-
disabled: !a && (!r || p + 1 >=
|
|
6356
|
-
onClick: () => n(nth(
|
|
6365
|
+
disabled: !a && (!r || p + 1 >= d.length),
|
|
6366
|
+
onClick: () => n(nth(d, p + 1), o),
|
|
6357
6367
|
children: /* @__PURE__ */ jsx("span", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
|
|
6358
6368
|
PlusIcon,
|
|
6359
6369
|
{
|
|
6360
|
-
className: !a && (!r || p + 1 >=
|
|
6370
|
+
className: !a && (!r || p + 1 >= d.length) ? "text-gray-500" : "text-black/60 dark:text-white/60"
|
|
6361
6371
|
}
|
|
6362
6372
|
) })
|
|
6363
6373
|
}
|
|
@@ -6451,23 +6461,23 @@ const COLOR_PROP = {
|
|
|
6451
6461
|
"2xl": "1536px"
|
|
6452
6462
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6453
6463
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6454
|
-
}, units: c, negative:
|
|
6464
|
+
}, 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(
|
|
6455
6465
|
(I, k = !0) => {
|
|
6456
|
-
const A = { dark: p, mq: g, mod:
|
|
6457
|
-
(p ||
|
|
6458
|
-
const
|
|
6459
|
-
h(x, [
|
|
6466
|
+
const A = { dark: p, mq: g, mod: u, cls: I, property: l, fullCls: "" };
|
|
6467
|
+
(p || u !== "") && (A.mq = "xs");
|
|
6468
|
+
const w = generateFullClsName(A);
|
|
6469
|
+
h(x, [w], k);
|
|
6460
6470
|
},
|
|
6461
|
-
[x, p, g,
|
|
6471
|
+
[x, p, g, u, l, h]
|
|
6462
6472
|
), S = useCallback(() => {
|
|
6463
6473
|
f(x, [b], !0);
|
|
6464
6474
|
}, [x, b, f]), C = useMemo(() => canChangeClass(m, g), [m, g]);
|
|
6465
6475
|
useEffect(() => {
|
|
6466
6476
|
i(C, m);
|
|
6467
6477
|
}, [C, i, m]);
|
|
6468
|
-
const [, ,
|
|
6478
|
+
const [, , v] = useScreenSizeWidth(), _ = useCallback(
|
|
6469
6479
|
(I) => {
|
|
6470
|
-
|
|
6480
|
+
v({
|
|
6471
6481
|
xs: 400,
|
|
6472
6482
|
sm: 640,
|
|
6473
6483
|
md: 800,
|
|
@@ -6476,8 +6486,8 @@ const COLOR_PROP = {
|
|
|
6476
6486
|
"2xl": 1920
|
|
6477
6487
|
}[I]);
|
|
6478
6488
|
},
|
|
6479
|
-
[
|
|
6480
|
-
), B = get(m, "dark", null) === p && get(m, "mod", null) ===
|
|
6489
|
+
[v]
|
|
6490
|
+
), B = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
|
|
6481
6491
|
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: C, canReset: m && B, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
6482
6492
|
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !B ? "text-foreground" : ""}`, children: n(a) }) }),
|
|
6483
6493
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
@@ -6489,7 +6499,7 @@ const COLOR_PROP = {
|
|
|
6489
6499
|
classPrefix: get(CLASS_PREFIXES, l, ""),
|
|
6490
6500
|
units: c || [],
|
|
6491
6501
|
onChange: y,
|
|
6492
|
-
negative:
|
|
6502
|
+
negative: d,
|
|
6493
6503
|
cssProperty: l
|
|
6494
6504
|
}
|
|
6495
6505
|
) : null,
|
|
@@ -6539,20 +6549,20 @@ const COLOR_PROP = {
|
|
|
6539
6549
|
units: i = basicUnits,
|
|
6540
6550
|
negative: c = !1
|
|
6541
6551
|
}) => {
|
|
6542
|
-
const { t:
|
|
6552
|
+
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((h) => map(g, "property").includes(h), [g]);
|
|
6543
6553
|
return /* @__PURE__ */ jsxs(
|
|
6544
6554
|
"div",
|
|
6545
6555
|
{
|
|
6546
6556
|
className: `mb-2 border-border py-2 first:pt-0 last:pb-0 ${r ? "border-b" : ""} ${a ? "border-t" : ""}`,
|
|
6547
6557
|
children: [
|
|
6548
6558
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6549
|
-
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children:
|
|
6559
|
+
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6550
6560
|
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: h, key: f }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6551
6561
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6552
6562
|
"button",
|
|
6553
6563
|
{
|
|
6554
6564
|
type: "button",
|
|
6555
|
-
onClick: () =>
|
|
6565
|
+
onClick: () => u(f),
|
|
6556
6566
|
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6557
6567
|
children: [
|
|
6558
6568
|
React__default.createElement("div", {
|
|
@@ -6581,11 +6591,11 @@ const COLOR_PROP = {
|
|
|
6581
6591
|
}, NestedOptions = ({ heading: o, items: n }) => {
|
|
6582
6592
|
const { t: r } = useTranslation(), a = useSelectedBlockCurrentClasses(), l = useMemo(() => {
|
|
6583
6593
|
const i = (p) => flatten(
|
|
6584
|
-
p.map((
|
|
6594
|
+
p.map((u) => u.styleType === "multiple" ? map(u.options, "key") : u.property)
|
|
6585
6595
|
), c = flatten(
|
|
6586
6596
|
n.map((p) => p.styleType === "accordion" ? i(p.items) : p.styleType === "multiple" ? map(p.options, "key") : p.property)
|
|
6587
|
-
),
|
|
6588
|
-
return intersection(c,
|
|
6597
|
+
), d = map(a, "property");
|
|
6598
|
+
return intersection(c, d).length > 0;
|
|
6589
6599
|
}, [a, n]);
|
|
6590
6600
|
return /* @__PURE__ */ jsxs("details", { children: [
|
|
6591
6601
|
/* @__PURE__ */ jsx("summary", { className: "my-px cursor-default rounded-md bg-gray-50 p-px px-2 text-[11px] text-foreground dark:bg-gray-800", children: /* @__PURE__ */ jsxs("div", { className: "inline", children: [
|
|
@@ -6602,12 +6612,12 @@ const COLOR_PROP = {
|
|
|
6602
6612
|
}, SectionContext = createContext({}), StylingGroup = ({ section: o, showAccordian: n }) => {
|
|
6603
6613
|
const { t: r } = useTranslation(), a = useSelectedBlockCurrentClasses(), l = useCallback(
|
|
6604
6614
|
(c = []) => {
|
|
6605
|
-
const
|
|
6606
|
-
for (let
|
|
6607
|
-
|
|
6615
|
+
const d = {};
|
|
6616
|
+
for (let u = 0; u < a.length; u++)
|
|
6617
|
+
d[a[u].property] = a[u].cls;
|
|
6608
6618
|
let p = !0;
|
|
6609
|
-
for (const
|
|
6610
|
-
if (!has(
|
|
6619
|
+
for (const u in c)
|
|
6620
|
+
if (!has(d, u) || d[u] !== c[u]) {
|
|
6611
6621
|
p = !1;
|
|
6612
6622
|
break;
|
|
6613
6623
|
}
|
|
@@ -6618,7 +6628,7 @@ const COLOR_PROP = {
|
|
|
6618
6628
|
return /* @__PURE__ */ jsx(SectionContext.Provider, { value: i, children: n ? /* @__PURE__ */ jsxs(AccordionItem, { value: o.heading, className: "border-none", children: [
|
|
6619
6629
|
/* @__PURE__ */ jsx(AccordionTrigger, { className: "border-slate-150 border-t py-2 text-xs", children: /* @__PURE__ */ jsx("div", { className: "flex items-center py-2", children: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-x-2 text-xs font-medium", children: startCase(r(o.heading)) }) }) }),
|
|
6620
6630
|
/* @__PURE__ */ jsx(AccordionContent, { className: "py-2", children: o.items.map((c) => has(c, "component") ? React__default.createElement(c.component, { key: c.label }) : has(c, "styleType") ? c.styleType === "multiple" ? /* @__PURE__ */ jsx(MultipleChoices, { ...c }, c.label + "multiple-choices") : c.styleType === "accordion" && l(c == null ? void 0 : c.conditions) ? /* @__PURE__ */ jsx(NestedOptions, { ...c }, c.label + "nested-options") : null : /* @__PURE__ */ jsx(BlockStyle, { ...c }, c.label + "block-style")) })
|
|
6621
|
-
] }) : /* @__PURE__ */ jsx("div", { className: "py-2", children: o.items.map((c,
|
|
6631
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "py-2", children: o.items.map((c, d) => has(c, "component") ? React__default.createElement(c.component, { key: c.label }) : has(c, "styleType") ? c.styleType === "multiple" ? /* @__PURE__ */ jsx(MultipleChoices, { ...c }, c.label + "multiple-choices" + d) : c.styleType === "accordion" && l(c == null ? void 0 : c.conditions) ? /* @__PURE__ */ jsx(NestedOptions, { ...c }, c.label + "nested-options" + d) : null : /* @__PURE__ */ jsx(BlockStyle, { ...c }, c.label + "block-style" + d)) }) });
|
|
6622
6632
|
}, TabletIcon = ({ landscape: o = !1, className: n = "" }) => /* @__PURE__ */ jsx(
|
|
6623
6633
|
"svg",
|
|
6624
6634
|
{
|
|
@@ -6681,30 +6691,32 @@ const COLOR_PROP = {
|
|
|
6681
6691
|
content: l,
|
|
6682
6692
|
currentBreakpoint: i,
|
|
6683
6693
|
breakpoint: c,
|
|
6684
|
-
width:
|
|
6694
|
+
width: d,
|
|
6685
6695
|
icon: p,
|
|
6686
|
-
onClick:
|
|
6696
|
+
onClick: u,
|
|
6697
|
+
buttonClass: g = "",
|
|
6698
|
+
activeButtonClass: m = ""
|
|
6687
6699
|
}) => {
|
|
6688
|
-
const { t:
|
|
6700
|
+
const { t: h } = useTranslation();
|
|
6689
6701
|
return r ? /* @__PURE__ */ jsxs(HoverCard, { openDelay: n, children: [
|
|
6690
6702
|
/* @__PURE__ */ jsx(HoverCardTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6691
6703
|
Button,
|
|
6692
6704
|
{
|
|
6693
|
-
onClick: () => d
|
|
6705
|
+
onClick: () => u(d),
|
|
6694
6706
|
size: "sm",
|
|
6695
|
-
className: "h-7 w-7 rounded-md p-1",
|
|
6707
|
+
className: cn$1("h-7 w-7 rounded-md p-1", c === i ? m : g),
|
|
6696
6708
|
variant: c === i ? "outline" : "ghost",
|
|
6697
6709
|
children: p
|
|
6698
6710
|
}
|
|
6699
6711
|
) }),
|
|
6700
6712
|
/* @__PURE__ */ jsx(HoverCardContent, { className: "w-fit max-w-52 border-border", children: /* @__PURE__ */ jsx("div", { className: "flex justify-between space-x-4", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
|
|
6701
|
-
/* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children:
|
|
6702
|
-
o && /* @__PURE__ */ jsx("p", { className: "text-xs", children:
|
|
6713
|
+
/* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: h(a) }),
|
|
6714
|
+
o && /* @__PURE__ */ jsx("p", { className: "text-xs", children: h(l) })
|
|
6703
6715
|
] }) }) })
|
|
6704
6716
|
] }) : /* @__PURE__ */ jsx(
|
|
6705
6717
|
Button,
|
|
6706
6718
|
{
|
|
6707
|
-
onClick: () => d
|
|
6719
|
+
onClick: () => u(d),
|
|
6708
6720
|
size: "sm",
|
|
6709
6721
|
className: "h-7 w-7 rounded-md p-1",
|
|
6710
6722
|
variant: c === i ? "outline" : "ghost",
|
|
@@ -6714,53 +6726,57 @@ const COLOR_PROP = {
|
|
|
6714
6726
|
}, Breakpoints$1 = ({
|
|
6715
6727
|
openDelay: o = 400,
|
|
6716
6728
|
canvas: n = !1,
|
|
6717
|
-
tooltip: r = !0
|
|
6729
|
+
tooltip: r = !0,
|
|
6730
|
+
buttonClass: a = "",
|
|
6731
|
+
activeButtonClass: l = ""
|
|
6718
6732
|
}) => {
|
|
6719
|
-
const [
|
|
6720
|
-
|
|
6721
|
-
},
|
|
6722
|
-
n ||
|
|
6723
|
-
},
|
|
6724
|
-
return
|
|
6733
|
+
const [i, , c] = useScreenSizeWidth(), [d, p] = useCanvasDisplayWidth(), [u, g] = useSelectedBreakpoints(), m = u, h = g, { t: f } = useTranslation(), x = useBuilderProp("breakpoints", WEB_BREAKPOINTS), b = (C) => {
|
|
6734
|
+
m.includes(C) ? m.length > 2 && h(m.filter((v) => v !== C)) : h((v) => [...v, C]);
|
|
6735
|
+
}, y = (C) => {
|
|
6736
|
+
n || c(C), p(C);
|
|
6737
|
+
}, S = getBreakpointValue(n ? d : i).toLowerCase();
|
|
6738
|
+
return x.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(x, (C) => /* @__PURE__ */ createElement(
|
|
6725
6739
|
BreakpointCard,
|
|
6726
6740
|
{
|
|
6727
6741
|
canvas: n,
|
|
6728
|
-
...
|
|
6729
|
-
onClick:
|
|
6730
|
-
key:
|
|
6731
|
-
currentBreakpoint:
|
|
6742
|
+
...C,
|
|
6743
|
+
onClick: y,
|
|
6744
|
+
key: C.breakpoint,
|
|
6745
|
+
currentBreakpoint: S
|
|
6732
6746
|
}
|
|
6733
6747
|
)) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
|
|
6734
6748
|
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
|
|
6735
|
-
|
|
6736
|
-
(
|
|
6749
|
+
x.filter((C) => includes(m, toUpper(C.breakpoint))),
|
|
6750
|
+
(C) => /* @__PURE__ */ createElement(
|
|
6737
6751
|
BreakpointCard,
|
|
6738
6752
|
{
|
|
6739
6753
|
canvas: n,
|
|
6740
6754
|
openDelay: o,
|
|
6741
6755
|
tooltip: r,
|
|
6742
|
-
...
|
|
6743
|
-
onClick:
|
|
6744
|
-
key:
|
|
6745
|
-
currentBreakpoint:
|
|
6756
|
+
...C,
|
|
6757
|
+
onClick: y,
|
|
6758
|
+
key: C.breakpoint,
|
|
6759
|
+
currentBreakpoint: S,
|
|
6760
|
+
buttonClass: a,
|
|
6761
|
+
activeButtonClass: l
|
|
6746
6762
|
}
|
|
6747
6763
|
)
|
|
6748
6764
|
) }),
|
|
6749
6765
|
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
6750
6766
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-pointer rounded-md p-1 hover:bg-background", children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "scale-90 transform" }) }) }),
|
|
6751
6767
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
|
|
6752
|
-
/* @__PURE__ */ jsx(DropdownMenuLabel, { children:
|
|
6768
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: f("Screen sizes") }),
|
|
6753
6769
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
6754
|
-
map(
|
|
6770
|
+
map(x, (C) => /* @__PURE__ */ jsx(
|
|
6755
6771
|
DropdownMenuCheckboxItem,
|
|
6756
6772
|
{
|
|
6757
|
-
disabled:
|
|
6758
|
-
onCheckedChange: () =>
|
|
6759
|
-
checked: includes(
|
|
6760
|
-
onSelect: (
|
|
6761
|
-
children:
|
|
6773
|
+
disabled: C.breakpoint === "xs",
|
|
6774
|
+
onCheckedChange: () => b(toUpper(C.breakpoint)),
|
|
6775
|
+
checked: includes(m, toUpper(C.breakpoint)),
|
|
6776
|
+
onSelect: (v) => v.preventDefault(),
|
|
6777
|
+
children: f(C.title)
|
|
6762
6778
|
},
|
|
6763
|
-
|
|
6779
|
+
C.breakpoint
|
|
6764
6780
|
))
|
|
6765
6781
|
] })
|
|
6766
6782
|
] })
|
|
@@ -6785,10 +6801,10 @@ function BreakpointSelector() {
|
|
|
6785
6801
|
}
|
|
6786
6802
|
function ManualClasses() {
|
|
6787
6803
|
var N;
|
|
6788
|
-
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [
|
|
6804
|
+
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, f] = useState(""), x = (N = first(d)) == null ? void 0 : N.prop, { classes: b } = getSplitChaiClasses(get(p, x, "")), y = b.split(" ").filter((T) => !isEmpty(T)), S = useBuilderProp("flags.copyPaste", !0), C = () => {
|
|
6789
6805
|
const T = h.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6790
|
-
|
|
6791
|
-
}, [
|
|
6806
|
+
u(m, T, !0), f("");
|
|
6807
|
+
}, [v, _] = useState([]), B = ({ value: T }) => {
|
|
6792
6808
|
const P = T.trim().toLowerCase(), R = P.match(/.+:/g);
|
|
6793
6809
|
let D = [];
|
|
6794
6810
|
if (R && R.length > 0) {
|
|
@@ -6802,7 +6818,7 @@ function ManualClasses() {
|
|
|
6802
6818
|
return _(map(D, "item"));
|
|
6803
6819
|
}, I = () => {
|
|
6804
6820
|
_([]);
|
|
6805
|
-
}, k = (T) => T.name, A = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }),
|
|
6821
|
+
}, k = (T) => T.name, A = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), w = useMemo(
|
|
6806
6822
|
() => ({
|
|
6807
6823
|
ref: o,
|
|
6808
6824
|
autoComplete: "off",
|
|
@@ -6826,7 +6842,7 @@ function ManualClasses() {
|
|
|
6826
6842
|
), E = (T) => {
|
|
6827
6843
|
debugger;
|
|
6828
6844
|
const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6829
|
-
g(m, [T]),
|
|
6845
|
+
g(m, [T]), u(m, P, !0), r(""), l(-1);
|
|
6830
6846
|
}, j = () => {
|
|
6831
6847
|
if (navigator.clipboard === void 0) {
|
|
6832
6848
|
toast.error(c("Clipboard not supported"));
|
|
@@ -6846,12 +6862,12 @@ function ManualClasses() {
|
|
|
6846
6862
|
/* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
|
|
6847
6863
|
Autosuggest,
|
|
6848
6864
|
{
|
|
6849
|
-
suggestions:
|
|
6865
|
+
suggestions: v,
|
|
6850
6866
|
onSuggestionsFetchRequested: B,
|
|
6851
6867
|
onSuggestionsClearRequested: I,
|
|
6852
6868
|
getSuggestionValue: k,
|
|
6853
6869
|
renderSuggestion: A,
|
|
6854
|
-
inputProps:
|
|
6870
|
+
inputProps: w,
|
|
6855
6871
|
containerProps: {
|
|
6856
6872
|
className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
|
|
6857
6873
|
},
|
|
@@ -7042,30 +7058,30 @@ const MAPPER = {
|
|
|
7042
7058
|
};
|
|
7043
7059
|
function BlockStyling() {
|
|
7044
7060
|
const { flexChild: o, gridChild: n } = useSelectedBlocksDisplayChild(), [r] = useSelectedStylingBlocks(), [a, l] = React__default.useState(""), [i, c] = React__default.useState({
|
|
7045
|
-
onDrag: (
|
|
7046
|
-
onDragEnd: (
|
|
7061
|
+
onDrag: (u) => u,
|
|
7062
|
+
onDragEnd: (u) => u,
|
|
7047
7063
|
dragStartY: 0,
|
|
7048
7064
|
dragging: !1,
|
|
7049
7065
|
dragStartValue: 0,
|
|
7050
7066
|
dragUnit: "",
|
|
7051
7067
|
negative: !1,
|
|
7052
7068
|
cssProperty: ""
|
|
7053
|
-
}),
|
|
7054
|
-
(
|
|
7069
|
+
}), d = useThrottledCallback(
|
|
7070
|
+
(u) => {
|
|
7055
7071
|
const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
|
|
7056
7072
|
let h = parseFloat(i.dragStartValue);
|
|
7057
7073
|
h = isNaN(h) ? 0 : h;
|
|
7058
7074
|
let f = MAPPER[i.dragUnit];
|
|
7059
7075
|
(startsWith(m, "scale") || m === "opacity") && (f = 10);
|
|
7060
|
-
let b = (i.dragStartY -
|
|
7076
|
+
let b = (i.dragStartY - u.pageY) / f + h;
|
|
7061
7077
|
g && b < 0 && (b = 0), m === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
|
|
7062
7078
|
},
|
|
7063
7079
|
[i],
|
|
7064
7080
|
50
|
|
7065
7081
|
), p = useCallback(() => {
|
|
7066
7082
|
setTimeout(() => i.onDragEnd(`${a}`), 100), c({
|
|
7067
|
-
onDrag: (
|
|
7068
|
-
onDragEnd: (
|
|
7083
|
+
onDrag: (u) => u,
|
|
7084
|
+
onDragEnd: (u) => u,
|
|
7069
7085
|
dragStartY: 0,
|
|
7070
7086
|
dragging: !1,
|
|
7071
7087
|
dragStartValue: 0,
|
|
@@ -7078,7 +7094,7 @@ function BlockStyling() {
|
|
|
7078
7094
|
i.dragging ? /* @__PURE__ */ jsx(
|
|
7079
7095
|
"div",
|
|
7080
7096
|
{
|
|
7081
|
-
onMouseMove:
|
|
7097
|
+
onMouseMove: d,
|
|
7082
7098
|
onMouseUp: () => p(),
|
|
7083
7099
|
className: "absolute inset-0 z-30 cursor-row-resize bg-gray-300/10"
|
|
7084
7100
|
}
|
|
@@ -7088,7 +7104,7 @@ function BlockStyling() {
|
|
|
7088
7104
|
/* @__PURE__ */ jsxs(Accordion, { defaultValue: ["Styles"], type: "multiple", className: "w-full", children: [
|
|
7089
7105
|
o && /* @__PURE__ */ jsx(StylingGroup, { section: FLEX_CHILD_SECTION, showAccordian: o || n }),
|
|
7090
7106
|
n && /* @__PURE__ */ jsx(StylingGroup, { section: GRID_CHILD_SECTION, showAccordian: o || n }),
|
|
7091
|
-
SETTINGS_SECTIONS.map((
|
|
7107
|
+
SETTINGS_SECTIONS.map((u) => /* @__PURE__ */ jsx(StylingGroup, { section: u, showAccordian: o || n }, u.heading))
|
|
7092
7108
|
] })
|
|
7093
7109
|
] })
|
|
7094
7110
|
] });
|
|
@@ -7099,10 +7115,10 @@ const CoreBlock = ({
|
|
|
7099
7115
|
parentId: r,
|
|
7100
7116
|
position: a
|
|
7101
7117
|
}) => {
|
|
7102
|
-
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label:
|
|
7118
|
+
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), h = () => {
|
|
7103
7119
|
if (has(o, "blocks")) {
|
|
7104
7120
|
const b = isFunction(o.blocks) ? o.blocks() : o.blocks;
|
|
7105
|
-
|
|
7121
|
+
u(syncBlocksWithDefaults(b), r || null, a);
|
|
7106
7122
|
} else
|
|
7107
7123
|
p(o, r || null, a);
|
|
7108
7124
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
@@ -7123,11 +7139,11 @@ const CoreBlock = ({
|
|
|
7123
7139
|
className: `${kebabCase$1(`chai-block-${i}`)} 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 ${n ? "opacity-50" : ""}`,
|
|
7124
7140
|
children: [
|
|
7125
7141
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
7126
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(
|
|
7142
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(d || i)) })
|
|
7127
7143
|
]
|
|
7128
7144
|
}
|
|
7129
7145
|
) }),
|
|
7130
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(
|
|
7146
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(d || i) }) })
|
|
7131
7147
|
] }) });
|
|
7132
7148
|
}, DefaultChaiBlocks = ({
|
|
7133
7149
|
parentId: o,
|
|
@@ -7152,10 +7168,10 @@ let PRE_IMPORT_HTML_HOOK = async (o) => o;
|
|
|
7152
7168
|
const registerChaiPreImportHTMLHook = (o) => {
|
|
7153
7169
|
PRE_IMPORT_HTML_HOOK = o;
|
|
7154
7170
|
}, getPreImportHTML = async (o) => await PRE_IMPORT_HTML_HOOK(o), ImportHTML = ({ parentId: o, position: n }) => {
|
|
7155
|
-
const { t: r } = useTranslation(), [a, l] = useState(""), { addPredefinedBlock: i } = useAddBlock(), [c,
|
|
7156
|
-
|
|
7157
|
-
const
|
|
7158
|
-
i([...g], o, n), l(""),
|
|
7171
|
+
const { t: r } = useTranslation(), [a, l] = useState(""), { addPredefinedBlock: i } = useAddBlock(), [c, d] = useState(!1), p = async () => {
|
|
7172
|
+
d(!0);
|
|
7173
|
+
const u = await getPreImportHTML(a), g = getBlocksFromHTML(u);
|
|
7174
|
+
i([...g], o, n), l(""), d(!1), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7159
7175
|
};
|
|
7160
7176
|
return /* @__PURE__ */ jsxs(Card, { className: "border-border/0 p-0 shadow-none", children: [
|
|
7161
7177
|
/* @__PURE__ */ jsx(CardHeader, { className: "p-3", children: /* @__PURE__ */ jsx(CardDescription, { children: r("Use HTML snippets from Tailwind CSS component libraries") }) }),
|
|
@@ -7166,8 +7182,8 @@ const registerChaiPreImportHTMLHook = (o) => {
|
|
|
7166
7182
|
{
|
|
7167
7183
|
autoFocus: !0,
|
|
7168
7184
|
tabIndex: 1,
|
|
7169
|
-
ref: (
|
|
7170
|
-
onChange: (
|
|
7185
|
+
ref: (u) => u && u.focus(),
|
|
7186
|
+
onChange: (u) => l(u.target.value),
|
|
7171
7187
|
rows: 12,
|
|
7172
7188
|
value: a,
|
|
7173
7189
|
placeholder: r("Enter your code snippet here"),
|
|
@@ -7189,9 +7205,9 @@ const registerChaiPreImportHTMLHook = (o) => {
|
|
|
7189
7205
|
className: l = "",
|
|
7190
7206
|
height: i = ""
|
|
7191
7207
|
}) => {
|
|
7192
|
-
const [c,
|
|
7193
|
-
const g =
|
|
7194
|
-
|
|
7208
|
+
const [c, d] = useState(o), p = (u) => {
|
|
7209
|
+
const g = u.target.value;
|
|
7210
|
+
d(g), n(g);
|
|
7195
7211
|
};
|
|
7196
7212
|
return /* @__PURE__ */ jsx("div", { className: cn$1("relative inline-block w-full", l), children: /* @__PURE__ */ jsxs(
|
|
7197
7213
|
"select",
|
|
@@ -7204,7 +7220,7 @@ const registerChaiPreImportHTMLHook = (o) => {
|
|
|
7204
7220
|
onChange: p,
|
|
7205
7221
|
children: [
|
|
7206
7222
|
/* @__PURE__ */ jsx("option", { value: "", disabled: !0, children: a }),
|
|
7207
|
-
r.map((
|
|
7223
|
+
r.map((u) => /* @__PURE__ */ jsx("option", { value: u.value, children: u.label }, u.value))
|
|
7208
7224
|
]
|
|
7209
7225
|
}
|
|
7210
7226
|
) });
|
|
@@ -7240,20 +7256,20 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7240
7256
|
parentId: r = void 0,
|
|
7241
7257
|
position: a = -1
|
|
7242
7258
|
}) => {
|
|
7243
|
-
const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock:
|
|
7244
|
-
const
|
|
7245
|
-
return C._type === "Box" &&
|
|
7259
|
+
const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), b = (C) => {
|
|
7260
|
+
const v = has(C, "styles_attrs.data-page-section");
|
|
7261
|
+
return C._type === "Box" && v;
|
|
7246
7262
|
}, y = useCallback(
|
|
7247
7263
|
async (C) => {
|
|
7248
7264
|
if (C.stopPropagation(), has(o, "component")) {
|
|
7249
|
-
|
|
7265
|
+
d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7250
7266
|
return;
|
|
7251
7267
|
}
|
|
7252
7268
|
i(!0);
|
|
7253
|
-
let
|
|
7254
|
-
typeof
|
|
7269
|
+
let v = await c({ library: n, block: o });
|
|
7270
|
+
typeof v == "string" && (v = getBlocksFromHTML(v)), isEmpty(v) || p(syncBlocksWithDefaults(v), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7255
7271
|
},
|
|
7256
|
-
[
|
|
7272
|
+
[d, p, o, c, n, r, a]
|
|
7257
7273
|
);
|
|
7258
7274
|
return /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7259
7275
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
@@ -7263,10 +7279,10 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7263
7279
|
} : y,
|
|
7264
7280
|
draggable: f ? "true" : "false",
|
|
7265
7281
|
onDragStart: async (C) => {
|
|
7266
|
-
const
|
|
7282
|
+
const v = await c({ library: n, block: o });
|
|
7267
7283
|
let _ = r;
|
|
7268
|
-
if (b(first(
|
|
7269
|
-
const B = { blocks:
|
|
7284
|
+
if (b(first(v)) && (_ = null), !isEmpty(v)) {
|
|
7285
|
+
const B = { blocks: v, uiLibrary: !0, parent: _ };
|
|
7270
7286
|
if (C.dataTransfer.setData("text/plain", JSON.stringify(B)), o.preview) {
|
|
7271
7287
|
const I = new Image();
|
|
7272
7288
|
I.src = o.preview, I.onload = () => {
|
|
@@ -7275,7 +7291,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7275
7291
|
} else
|
|
7276
7292
|
C.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7277
7293
|
x(B), setTimeout(() => {
|
|
7278
|
-
|
|
7294
|
+
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7279
7295
|
}, 200);
|
|
7280
7296
|
}
|
|
7281
7297
|
},
|
|
@@ -7297,7 +7313,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7297
7313
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "max-w-xs", children: /* @__PURE__ */ jsx("p", { className: "font-medium", children: m }) }) })
|
|
7298
7314
|
] });
|
|
7299
7315
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
7300
|
-
const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((E) => E.id === r) || first(l), { data: c, isLoading:
|
|
7316
|
+
const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((E) => E.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [m, h] = useState([]), f = useRef(null);
|
|
7301
7317
|
useEffect(() => {
|
|
7302
7318
|
c && c.length > 0 && (f.current = new Fuse(c, {
|
|
7303
7319
|
keys: ["name", "label", "description", "group"],
|
|
@@ -7305,14 +7321,14 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7305
7321
|
ignoreLocation: !0
|
|
7306
7322
|
}));
|
|
7307
7323
|
}, [c]), useEffect(() => {
|
|
7308
|
-
if (!
|
|
7324
|
+
if (!u.trim() || !f.current) {
|
|
7309
7325
|
h([]);
|
|
7310
7326
|
return;
|
|
7311
7327
|
}
|
|
7312
|
-
const E = f.current.search(
|
|
7328
|
+
const E = f.current.search(u).map((j) => j.item);
|
|
7313
7329
|
h(E);
|
|
7314
|
-
}, [
|
|
7315
|
-
const x =
|
|
7330
|
+
}, [u]);
|
|
7331
|
+
const x = u.trim() && !isEmpty(m) ? m : c, b = groupBy(x, "group"), [y, S] = useState(null);
|
|
7316
7332
|
useEffect(() => {
|
|
7317
7333
|
if (isEmpty(keys(b))) {
|
|
7318
7334
|
S(null);
|
|
@@ -7323,21 +7339,21 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7323
7339
|
return;
|
|
7324
7340
|
}
|
|
7325
7341
|
}, [b, y]);
|
|
7326
|
-
const C = get(b, y, []),
|
|
7327
|
-
|
|
7328
|
-
|
|
7342
|
+
const C = get(b, y, []), v = useRef(null), { t: _ } = useTranslation(), B = (E) => {
|
|
7343
|
+
v.current && (clearTimeout(v.current), v.current = null), v.current = setTimeout(() => {
|
|
7344
|
+
v.current && S(E);
|
|
7329
7345
|
}, 400);
|
|
7330
7346
|
}, I = () => {
|
|
7331
7347
|
i != null && i.id && p(i.id);
|
|
7332
7348
|
}, k = () => {
|
|
7333
7349
|
g("");
|
|
7334
7350
|
};
|
|
7335
|
-
if (
|
|
7351
|
+
if (d)
|
|
7336
7352
|
return /* @__PURE__ */ jsxs("div", { className: "mt-4 grid h-full w-full grid-cols-12 gap-2", children: [
|
|
7337
7353
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7338
7354
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7339
7355
|
] });
|
|
7340
|
-
const A = filter(C, (E, j) => j % 2 === 0),
|
|
7356
|
+
const A = filter(C, (E, j) => j % 2 === 0), w = filter(C, (E, j) => j % 2 === 1);
|
|
7341
7357
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
|
|
7342
7358
|
/* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
7343
7359
|
/* @__PURE__ */ jsx(MagnifyingGlassIcon, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
|
|
@@ -7345,12 +7361,12 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7345
7361
|
Input$1,
|
|
7346
7362
|
{
|
|
7347
7363
|
placeholder: _("Search blocks..."),
|
|
7348
|
-
value:
|
|
7364
|
+
value: u,
|
|
7349
7365
|
onChange: (E) => g(E.target.value),
|
|
7350
7366
|
className: "w-full pl-8 pr-8"
|
|
7351
7367
|
}
|
|
7352
7368
|
),
|
|
7353
|
-
|
|
7369
|
+
u && /* @__PURE__ */ jsx(
|
|
7354
7370
|
"button",
|
|
7355
7371
|
{
|
|
7356
7372
|
onClick: k,
|
|
@@ -7365,7 +7381,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7365
7381
|
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
|
|
7366
7382
|
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: _("Groups") }),
|
|
7367
7383
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7368
|
-
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(b) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children:
|
|
7384
|
+
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(b) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: u ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7369
7385
|
/* @__PURE__ */ jsx("p", { className: "text-sm", children: _("Failed to load the UI library. Try again") }),
|
|
7370
7386
|
/* @__PURE__ */ jsxs(Button, { onClick: I, variant: "outline", size: "sm", className: "gap-2", children: [
|
|
7371
7387
|
/* @__PURE__ */ jsx(ReloadIcon, { className: "h-4 w-4" }),
|
|
@@ -7375,7 +7391,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7375
7391
|
"div",
|
|
7376
7392
|
{
|
|
7377
7393
|
onMouseEnter: () => B(j),
|
|
7378
|
-
onMouseLeave: () => clearTimeout(
|
|
7394
|
+
onMouseLeave: () => clearTimeout(v.current),
|
|
7379
7395
|
role: "button",
|
|
7380
7396
|
onClick: () => S(j),
|
|
7381
7397
|
className: cn$1(
|
|
@@ -7394,7 +7410,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7394
7410
|
/* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-col border-l border-border", children: /* @__PURE__ */ jsxs(
|
|
7395
7411
|
ScrollArea,
|
|
7396
7412
|
{
|
|
7397
|
-
onMouseEnter: () =>
|
|
7413
|
+
onMouseEnter: () => v.current ? clearTimeout(v.current) : null,
|
|
7398
7414
|
className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
|
|
7399
7415
|
children: [
|
|
7400
7416
|
isEmpty(C) && !isEmpty(b) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
|
|
@@ -7408,7 +7424,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7408
7424
|
},
|
|
7409
7425
|
`block-${j}`
|
|
7410
7426
|
)) }),
|
|
7411
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children:
|
|
7427
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: w.map((E, j) => /* @__PURE__ */ jsx(
|
|
7412
7428
|
BlockCard,
|
|
7413
7429
|
{
|
|
7414
7430
|
parentId: o,
|
|
@@ -7441,9 +7457,9 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7441
7457
|
position: n,
|
|
7442
7458
|
gridCols: r = "grid-cols-2"
|
|
7443
7459
|
}) => {
|
|
7444
|
-
const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [
|
|
7460
|
+
const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [d, p] = useAtom$1(partialBlocksDataAtom), [u, g] = useAtom$1(hasInitializedPartialBlocksAtom);
|
|
7445
7461
|
useEffect(() => {
|
|
7446
|
-
if (!
|
|
7462
|
+
if (!u || Object.keys(d.blocks).length === 0)
|
|
7447
7463
|
if (c)
|
|
7448
7464
|
p({
|
|
7449
7465
|
blocks: [],
|
|
@@ -7483,17 +7499,17 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7483
7499
|
}, [
|
|
7484
7500
|
l,
|
|
7485
7501
|
a,
|
|
7486
|
-
|
|
7502
|
+
u,
|
|
7487
7503
|
g,
|
|
7488
7504
|
p,
|
|
7489
|
-
|
|
7505
|
+
d.blocks,
|
|
7490
7506
|
c
|
|
7491
7507
|
]);
|
|
7492
7508
|
const m = () => {
|
|
7493
7509
|
p((h) => ({ ...h, isLoading: !0, error: null })), g(!1), i();
|
|
7494
7510
|
};
|
|
7495
|
-
return
|
|
7496
|
-
/* @__PURE__ */ jsx("p", { children:
|
|
7511
|
+
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: [
|
|
7512
|
+
/* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
|
|
7497
7513
|
/* @__PURE__ */ jsx(
|
|
7498
7514
|
"button",
|
|
7499
7515
|
{
|
|
@@ -7508,15 +7524,15 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7508
7524
|
gridCols: r,
|
|
7509
7525
|
parentId: o,
|
|
7510
7526
|
position: n,
|
|
7511
|
-
groups:
|
|
7512
|
-
blocks:
|
|
7527
|
+
groups: d.groups,
|
|
7528
|
+
blocks: d.blocks
|
|
7513
7529
|
}
|
|
7514
7530
|
);
|
|
7515
7531
|
}, ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, n) => {
|
|
7516
7532
|
has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...n });
|
|
7517
7533
|
}, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4", disableBlockGroupsSidebar: i }) => {
|
|
7518
7534
|
var E;
|
|
7519
|
-
const { t: c } = useTranslation(), [
|
|
7535
|
+
const { t: c } = useTranslation(), [d] = useBlocksStore(), [p, u] = useState(""), g = useRef(null), [m] = useAtom$1(addBlockTabAtom), h = (E = find(d, (j) => j._id === r)) == null ? void 0 : E._type, [f, x] = useState("all"), [b, y] = useState(null), S = useRef(null);
|
|
7520
7536
|
useEffect(() => {
|
|
7521
7537
|
const j = setTimeout(() => {
|
|
7522
7538
|
var N;
|
|
@@ -7532,7 +7548,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7532
7548
|
}), []);
|
|
7533
7549
|
const C = useCallback((j) => {
|
|
7534
7550
|
y(j), S.current && S.current(j);
|
|
7535
|
-
}, []),
|
|
7551
|
+
}, []), v = useCallback(() => {
|
|
7536
7552
|
y(null), S.current && S.current.cancel();
|
|
7537
7553
|
}, []), _ = useCallback((j) => {
|
|
7538
7554
|
S.current && S.current.cancel(), x(j), y(null);
|
|
@@ -7552,9 +7568,9 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7552
7568
|
), k = useMemo(
|
|
7553
7569
|
() => sortBy(I, (j) => CORE_GROUPS.indexOf(j) === -1 ? 99 : CORE_GROUPS.indexOf(j)),
|
|
7554
7570
|
[I]
|
|
7555
|
-
), A = useMemo(() => f === "all" ? B : filter(values(B), { group: f }), [B, f]),
|
|
7571
|
+
), A = useMemo(() => f === "all" ? B : filter(values(B), { group: f }), [B, f]), w = useMemo(() => f === "all" ? k : [f], [k, f]);
|
|
7556
7572
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7557
|
-
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80
|
|
7573
|
+
/* @__PURE__ */ jsx("div", { className: `${i ? "px-2" : "px-4"} sticky top-0 py-2 z-10 bg-background/80 backdrop-blur-sm`, children: /* @__PURE__ */ jsx(
|
|
7558
7574
|
Input$1,
|
|
7559
7575
|
{
|
|
7560
7576
|
ref: g,
|
|
@@ -7562,7 +7578,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7562
7578
|
placeholder: c("Search blocks..."),
|
|
7563
7579
|
value: p,
|
|
7564
7580
|
className: "-ml-2",
|
|
7565
|
-
onChange: (j) =>
|
|
7581
|
+
onChange: (j) => u(j.target.value)
|
|
7566
7582
|
}
|
|
7567
7583
|
) }),
|
|
7568
7584
|
/* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
|
|
@@ -7572,7 +7588,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7572
7588
|
{
|
|
7573
7589
|
onClick: () => _("all"),
|
|
7574
7590
|
onMouseEnter: () => C("all"),
|
|
7575
|
-
onMouseLeave:
|
|
7591
|
+
onMouseLeave: v,
|
|
7576
7592
|
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${f === "all" || b === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7577
7593
|
children: c("All")
|
|
7578
7594
|
},
|
|
@@ -7583,7 +7599,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7583
7599
|
{
|
|
7584
7600
|
onClick: () => _(j),
|
|
7585
7601
|
onMouseEnter: () => C(j),
|
|
7586
|
-
onMouseLeave:
|
|
7602
|
+
onMouseLeave: v,
|
|
7587
7603
|
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${f === j || b === j ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7588
7604
|
children: capitalize(c(j.toLowerCase()))
|
|
7589
7605
|
},
|
|
@@ -7599,7 +7615,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7599
7615
|
' "',
|
|
7600
7616
|
p,
|
|
7601
7617
|
'"'
|
|
7602
|
-
] }) }) : /* @__PURE__ */ jsx("div", { className: "
|
|
7618
|
+
] }) }) : /* @__PURE__ */ jsx("div", { className: `${i ? "p-0" : "p-4"} space-y-6`, children: w.map((j) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7603
7619
|
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(c(j.toLowerCase())) }),
|
|
7604
7620
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
|
|
7605
7621
|
f === "all" ? filter(values(A), { group: j }) : values(A),
|
|
@@ -7625,7 +7641,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7625
7641
|
parentId: r = void 0,
|
|
7626
7642
|
position: a = -1
|
|
7627
7643
|
}) => {
|
|
7628
|
-
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [,
|
|
7644
|
+
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("flags.importHtml", !0), { data: u } = usePartialBlocksList(), g = Object.keys(u || {}).length > 0, { hasPermission: m } = usePermissions();
|
|
7629
7645
|
useEffect(() => {
|
|
7630
7646
|
i === "partials" && !g && c("library");
|
|
7631
7647
|
}, [i, g, c]);
|
|
@@ -7643,7 +7659,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7643
7659
|
Tabs,
|
|
7644
7660
|
{
|
|
7645
7661
|
onValueChange: (S) => {
|
|
7646
|
-
|
|
7662
|
+
d(""), c(S);
|
|
7647
7663
|
},
|
|
7648
7664
|
value: i,
|
|
7649
7665
|
className: "flex h-full max-h-full flex-col overflow-hidden",
|
|
@@ -7769,10 +7785,10 @@ const registerChaiSaveToLibrary = (o) => {
|
|
|
7769
7785
|
}, SaveToLibraryModal = () => {
|
|
7770
7786
|
const [o, n] = useAtom$1(saveToLibraryModalAtom), { t: r } = useTranslation(), [a] = useBlocksStore(), l = () => n({ isOpen: !1, blockId: null }), i = useSaveToLibraryComponent(), c = useMemo(() => {
|
|
7771
7787
|
if (!o.blockId) return [];
|
|
7772
|
-
const
|
|
7773
|
-
return
|
|
7788
|
+
const d = find(a, { _id: o.blockId });
|
|
7789
|
+
return d == null || delete d._parent, [d, ...getBlocks(a, d == null ? void 0 : d._id)];
|
|
7774
7790
|
}, [o.blockId, a]);
|
|
7775
|
-
return /* @__PURE__ */ jsx(Dialog, { open: o.isOpen, onOpenChange: (
|
|
7791
|
+
return /* @__PURE__ */ jsx(Dialog, { open: o.isOpen, onOpenChange: (d) => !d && l(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "p-4 sm:max-w-[450px]", children: [
|
|
7776
7792
|
/* @__PURE__ */ jsx(DialogHeader, { className: "pb-2", children: /* @__PURE__ */ jsx(DialogTitle, { children: r("Save to Library") }) }),
|
|
7777
7793
|
i && !isEmpty(o.blockId) && /* @__PURE__ */ jsx(i, { blockId: o.blockId, blocks: c, close: l })
|
|
7778
7794
|
] }) });
|
|
@@ -7814,35 +7830,35 @@ const registerChaiSaveToLibrary = (o) => {
|
|
|
7814
7830
|
}
|
|
7815
7831
|
) : null;
|
|
7816
7832
|
}, CopyPasteBlocks = () => {
|
|
7817
|
-
const [o] = useBlocksStore(), [n] = useSelectedBlockIds(), { pasteBlocks: r } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), c = useSelectedBlock(),
|
|
7818
|
-
const
|
|
7833
|
+
const [o] = useBlocksStore(), [n] = useSelectedBlockIds(), { pasteBlocks: r } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), c = useSelectedBlock(), d = useBuilderProp("flags.copyPaste", !0), p = useCallback(() => {
|
|
7834
|
+
const u = n.map((g) => {
|
|
7819
7835
|
const m = o.find((h) => h._id === g);
|
|
7820
7836
|
return {
|
|
7821
7837
|
id: g,
|
|
7822
7838
|
data: m
|
|
7823
7839
|
};
|
|
7824
7840
|
});
|
|
7825
|
-
l(
|
|
7841
|
+
l(u.map((g) => g.id)) ? toast.warning("Partial blocks detected. Clone partial blocks?", {
|
|
7826
7842
|
cancel: {
|
|
7827
7843
|
label: i("No"),
|
|
7828
7844
|
onClick: () => {
|
|
7829
|
-
a(
|
|
7845
|
+
a(u.map((g) => g.id)), toast.dismiss();
|
|
7830
7846
|
}
|
|
7831
7847
|
},
|
|
7832
7848
|
action: {
|
|
7833
7849
|
label: i("Yes"),
|
|
7834
7850
|
onClick: () => {
|
|
7835
7851
|
a(
|
|
7836
|
-
|
|
7852
|
+
u.map((g) => g.id),
|
|
7837
7853
|
!0
|
|
7838
7854
|
), toast.dismiss();
|
|
7839
7855
|
}
|
|
7840
7856
|
},
|
|
7841
7857
|
position: "top-center"
|
|
7842
|
-
}) : a(
|
|
7858
|
+
}) : a(u.map((g) => g.id));
|
|
7843
7859
|
}, [n, o, a, l]);
|
|
7844
7860
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7845
|
-
|
|
7861
|
+
d && /* @__PURE__ */ jsxs(
|
|
7846
7862
|
DropdownMenuItem,
|
|
7847
7863
|
{
|
|
7848
7864
|
disabled: !canDuplicateBlock(c == null ? void 0 : c._type),
|
|
@@ -7855,7 +7871,7 @@ const registerChaiSaveToLibrary = (o) => {
|
|
|
7855
7871
|
]
|
|
7856
7872
|
}
|
|
7857
7873
|
),
|
|
7858
|
-
|
|
7874
|
+
d && /* @__PURE__ */ jsxs(
|
|
7859
7875
|
DropdownMenuItem,
|
|
7860
7876
|
{
|
|
7861
7877
|
className: "flex items-center gap-x-4 text-xs",
|
|
@@ -7909,7 +7925,7 @@ const registerChaiSaveToLibrary = (o) => {
|
|
|
7909
7925
|
}
|
|
7910
7926
|
);
|
|
7911
7927
|
}, BlockContextMenuContent = ({ node: o }) => {
|
|
7912
|
-
const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), { hasPermission: i } = usePermissions(), { librarySite: c } = useBuilderProp("flags", { librarySite: !1 }),
|
|
7928
|
+
const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), { hasPermission: i } = usePermissions(), { librarySite: c } = useBuilderProp("flags", { librarySite: !1 }), d = useCallback(() => {
|
|
7913
7929
|
a(r);
|
|
7914
7930
|
}, [r, a]), p = useMemo(() => has(l, "_libBlockId") && !isEmpty(l._libBlockId), [l == null ? void 0 : l._libBlockId]);
|
|
7915
7931
|
return o === "BODY" ? /* @__PURE__ */ jsx(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: i(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -7931,7 +7947,7 @@ const registerChaiSaveToLibrary = (o) => {
|
|
|
7931
7947
|
DropdownMenuItem,
|
|
7932
7948
|
{
|
|
7933
7949
|
disabled: !1,
|
|
7934
|
-
onClick: (
|
|
7950
|
+
onClick: (u) => u.preventDefault(),
|
|
7935
7951
|
className: "flex items-center gap-x-4 text-xs",
|
|
7936
7952
|
children: /* @__PURE__ */ jsx(ClearCanvas, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-4 text-xs", children: [
|
|
7937
7953
|
/* @__PURE__ */ jsx(EraserIcon, {}),
|
|
@@ -7960,7 +7976,7 @@ const registerChaiSaveToLibrary = (o) => {
|
|
|
7960
7976
|
{
|
|
7961
7977
|
disabled: !canDuplicateBlock(l == null ? void 0 : l._type),
|
|
7962
7978
|
className: "flex items-center gap-x-4 text-xs",
|
|
7963
|
-
onClick:
|
|
7979
|
+
onClick: d,
|
|
7964
7980
|
children: [
|
|
7965
7981
|
/* @__PURE__ */ jsx(CardStackPlusIcon, {}),
|
|
7966
7982
|
" ",
|
|
@@ -8032,20 +8048,20 @@ const Input = ({ node: o }) => {
|
|
|
8032
8048
|
}, truncateText = (o, n) => o.length > n ? o.substring(0, n) + "..." : o, Node$1 = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
8033
8049
|
var D;
|
|
8034
8050
|
const { t: a } = useTranslation(), l = useUpdateBlocksProps(), [i] = useAtom$1(canvasIframeAtom), { hasPermission: c } = usePermissions();
|
|
8035
|
-
let
|
|
8036
|
-
const p = o.children.length > 0, { highlightBlock:
|
|
8051
|
+
let d = null;
|
|
8052
|
+
const p = o.children.length > 0, { highlightBlock: u, clearHighlight: g } = useBlockHighlight(), { id: m, data: h, isSelected: f, willReceiveDrop: x, isDragging: b, isEditing: y, handleClick: S } = o, C = get(h, "_show", !0), v = (L) => {
|
|
8037
8053
|
L.stopPropagation(), C && o.toggle();
|
|
8038
8054
|
}, _ = (L) => {
|
|
8039
|
-
L.isInternal && (
|
|
8055
|
+
L.isInternal && (d = L.isOpen, L.isOpen && L.close());
|
|
8040
8056
|
}, B = (L) => {
|
|
8041
|
-
L.isInternal &&
|
|
8057
|
+
L.isInternal && d !== null && (d ? L.open() : L.close(), d = null);
|
|
8042
8058
|
}, [I, k] = useAtom$1(currentAddSelection), A = () => {
|
|
8043
8059
|
var L;
|
|
8044
|
-
|
|
8045
|
-
},
|
|
8060
|
+
w(), o.parent.isSelected || k((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id);
|
|
8061
|
+
}, w = () => {
|
|
8046
8062
|
k(null);
|
|
8047
8063
|
}, E = (L) => {
|
|
8048
|
-
|
|
8064
|
+
w(), L.stopPropagation(), !o.isOpen && C && o.toggle(), S(L);
|
|
8049
8065
|
};
|
|
8050
8066
|
useEffect(() => {
|
|
8051
8067
|
const L = setTimeout(() => {
|
|
@@ -8059,7 +8075,7 @@ const Input = ({ node: o }) => {
|
|
|
8059
8075
|
const V = M.getBoundingClientRect(), H = i.getBoundingClientRect();
|
|
8060
8076
|
V.top >= H.top && V.left >= H.left && V.bottom <= H.bottom && V.right <= H.right || (F.documentElement.scrollTop = M.offsetTop - H.top);
|
|
8061
8077
|
}, N = (L) => {
|
|
8062
|
-
|
|
8078
|
+
w();
|
|
8063
8079
|
const O = get(o, "parent.id");
|
|
8064
8080
|
O !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: O, position: L }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: L });
|
|
8065
8081
|
};
|
|
@@ -8085,7 +8101,7 @@ const Input = ({ node: o }) => {
|
|
|
8085
8101
|
return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
|
|
8086
8102
|
"div",
|
|
8087
8103
|
{
|
|
8088
|
-
onMouseEnter: () =>
|
|
8104
|
+
onMouseEnter: () => u(m),
|
|
8089
8105
|
onMouseLeave: () => g(),
|
|
8090
8106
|
onClick: E,
|
|
8091
8107
|
style: n,
|
|
@@ -8110,7 +8126,7 @@ const Input = ({ node: o }) => {
|
|
|
8110
8126
|
L.stopPropagation(), N(o.childIndex);
|
|
8111
8127
|
},
|
|
8112
8128
|
onMouseEnter: A,
|
|
8113
|
-
onMouseLeave:
|
|
8129
|
+
onMouseLeave: w,
|
|
8114
8130
|
className: "absolute -top-0.5 h-0.5 w-[90%] rounded bg-primary/80 opacity-0 delay-200 duration-200 group-hover:opacity-100",
|
|
8115
8131
|
children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-primary/80 p-1 outline outline-2 outline-white hover:bg-primary/80", children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-2 w-2 stroke-[2] text-white" }) })
|
|
8116
8132
|
}
|
|
@@ -8133,7 +8149,7 @@ const Input = ({ node: o }) => {
|
|
|
8133
8149
|
"div",
|
|
8134
8150
|
{
|
|
8135
8151
|
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
8136
|
-
children: p && /* @__PURE__ */ jsx("button", { onClick:
|
|
8152
|
+
children: p && /* @__PURE__ */ jsx("button", { onClick: v, type: "button", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) })
|
|
8137
8153
|
}
|
|
8138
8154
|
),
|
|
8139
8155
|
/* @__PURE__ */ jsxs(
|
|
@@ -8230,8 +8246,8 @@ const Input = ({ node: o }) => {
|
|
|
8230
8246
|
return (n, r) => {
|
|
8231
8247
|
var i;
|
|
8232
8248
|
const a = (i = find(o, { _id: r })) == null ? void 0 : i._type, l = first(n.map((c) => {
|
|
8233
|
-
var
|
|
8234
|
-
return (
|
|
8249
|
+
var d;
|
|
8250
|
+
return (d = find(o, { _id: c })) == null ? void 0 : d._type;
|
|
8235
8251
|
}));
|
|
8236
8252
|
return canAcceptChildBlock(a, l);
|
|
8237
8253
|
};
|
|
@@ -8610,7 +8626,7 @@ const Input = ({ node: o }) => {
|
|
|
8610
8626
|
"popover-foreground": ["#3d3436", "#f2e9e4"]
|
|
8611
8627
|
}
|
|
8612
8628
|
}, LazyCssImportModal = lazy(
|
|
8613
|
-
() => import("./css-import-modal-
|
|
8629
|
+
() => import("./css-import-modal-DgLi5BIu.js").then((o) => ({ default: o.CssImportModal }))
|
|
8614
8630
|
), PREV_THEME_KEY = "chai-builder-previous-theme", DEFAULT_THEME_PRESET = [
|
|
8615
8631
|
{ shadcn_default: defaultShadcnPreset },
|
|
8616
8632
|
{ twitter_theme: twitter },
|
|
@@ -8632,12 +8648,12 @@ const Input = ({ node: o }) => {
|
|
|
8632
8648
|
console.warn("Failed to clear previous theme from localStorage:", o);
|
|
8633
8649
|
}
|
|
8634
8650
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
8635
|
-
const [n, r] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1),
|
|
8636
|
-
if (
|
|
8637
|
-
const k =
|
|
8651
|
+
const [n, r] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions(), g = useBuilderProp("flags.importTheme", !0), m = useBuilderProp("flags.darkMode", !0);
|
|
8652
|
+
if (d) {
|
|
8653
|
+
const k = d.map((A) => Object.keys(A)[0]);
|
|
8638
8654
|
DEFAULT_THEME_PRESET.forEach((A) => {
|
|
8639
|
-
const
|
|
8640
|
-
k.includes(
|
|
8655
|
+
const w = Object.keys(A)[0];
|
|
8656
|
+
k.includes(w) || d.push(A);
|
|
8641
8657
|
});
|
|
8642
8658
|
}
|
|
8643
8659
|
const [h, f] = useTheme(), x = useThemeOptions(), { t: b } = useTranslation(), y = React.useCallback(
|
|
@@ -8659,7 +8675,7 @@ const Input = ({ node: o }) => {
|
|
|
8659
8675
|
},
|
|
8660
8676
|
[h, f]
|
|
8661
8677
|
), S = () => {
|
|
8662
|
-
const k =
|
|
8678
|
+
const k = d.find((A) => Object.keys(A)[0] === a);
|
|
8663
8679
|
if (k) {
|
|
8664
8680
|
const A = Object.values(k)[0];
|
|
8665
8681
|
A && typeof A == "object" && "fontFamily" in A && "borderRadius" in A && "colors" in A ? (y(A), l("")) : console.error("Invalid preset structure:", A);
|
|
@@ -8667,7 +8683,7 @@ const Input = ({ node: o }) => {
|
|
|
8667
8683
|
console.error("Preset not found:", a);
|
|
8668
8684
|
}, C = (k) => {
|
|
8669
8685
|
y(k), l("");
|
|
8670
|
-
},
|
|
8686
|
+
}, v = useDebouncedCallback(
|
|
8671
8687
|
(k, A) => {
|
|
8672
8688
|
f(() => ({
|
|
8673
8689
|
...h,
|
|
@@ -8690,12 +8706,12 @@ const Input = ({ node: o }) => {
|
|
|
8690
8706
|
), B = useDebouncedCallback(
|
|
8691
8707
|
(k, A) => {
|
|
8692
8708
|
f(() => {
|
|
8693
|
-
const
|
|
8694
|
-
return n ? set(
|
|
8709
|
+
const w = get(h, `colors.${k}`);
|
|
8710
|
+
return n ? set(w, 1, A) : set(w, 0, A), {
|
|
8695
8711
|
...h,
|
|
8696
8712
|
colors: {
|
|
8697
8713
|
...h.colors,
|
|
8698
|
-
[k]:
|
|
8714
|
+
[k]: w
|
|
8699
8715
|
}
|
|
8700
8716
|
};
|
|
8701
8717
|
});
|
|
@@ -8703,21 +8719,21 @@ const Input = ({ node: o }) => {
|
|
|
8703
8719
|
[h],
|
|
8704
8720
|
200
|
|
8705
8721
|
), I = (k) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(k.items).map(([A]) => {
|
|
8706
|
-
const
|
|
8707
|
-
return
|
|
8722
|
+
const w = get(h, `colors.${A}.${n ? 1 : 0}`);
|
|
8723
|
+
return w ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
8708
8724
|
/* @__PURE__ */ jsx(
|
|
8709
8725
|
ColorPickerInput,
|
|
8710
8726
|
{
|
|
8711
|
-
value:
|
|
8727
|
+
value: w,
|
|
8712
8728
|
onChange: (E) => B(A, E)
|
|
8713
8729
|
}
|
|
8714
8730
|
),
|
|
8715
8731
|
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: A.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((E) => E.charAt(0).toUpperCase() + E.slice(1)).join(" ") + (!A.toLowerCase().includes("foreground") && !A.toLowerCase().includes("border") && !A.toLowerCase().includes("input") && !A.toLowerCase().includes("ring") && !A.toLowerCase().includes("background") ? " Background" : "") })
|
|
8716
8732
|
] }, A) : null;
|
|
8717
8733
|
}) });
|
|
8718
|
-
return
|
|
8734
|
+
return u("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
8719
8735
|
/* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
8720
|
-
|
|
8736
|
+
d.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mx-0 my-2 flex flex-col gap-1 py-2", children: [
|
|
8721
8737
|
/* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
|
|
8722
8738
|
/* @__PURE__ */ jsx(Label, { className: "text-sm", children: b("Presets") }),
|
|
8723
8739
|
/* @__PURE__ */ jsx("div", { className: "flex gap-2", children: g && /* @__PURE__ */ jsxs(Button, { className: "px-1", variant: "link", size: "sm", onClick: () => c(!0), children: [
|
|
@@ -8727,10 +8743,10 @@ const Input = ({ node: o }) => {
|
|
|
8727
8743
|
] }),
|
|
8728
8744
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-0", children: [
|
|
8729
8745
|
/* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
|
|
8730
|
-
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select preset" }) }),
|
|
8731
|
-
/* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(
|
|
8732
|
-
const A = Object.keys(k)[0],
|
|
8733
|
-
return /* @__PURE__ */ jsx(SelectItem, { value: A, children: capitalize(
|
|
8746
|
+
/* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: b("Select preset") }) }),
|
|
8747
|
+
/* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((k) => {
|
|
8748
|
+
const A = Object.keys(k)[0], w = A.replaceAll("_", " ");
|
|
8749
|
+
return /* @__PURE__ */ jsx(SelectItem, { value: A, children: capitalize(w) }, A);
|
|
8734
8750
|
}) })
|
|
8735
8751
|
] }) }),
|
|
8736
8752
|
/* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: S, children: b("Apply") }) })
|
|
@@ -8740,14 +8756,14 @@ const Input = ({ node: o }) => {
|
|
|
8740
8756
|
/* @__PURE__ */ jsxs("div", { className: cn$1("my-2 space-y-3", o), children: [
|
|
8741
8757
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8742
8758
|
/* @__PURE__ */ jsx(TextIcon, { className: "h-3 w-3 text-gray-600" }),
|
|
8743
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Typography" })
|
|
8759
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: b("Typography") })
|
|
8744
8760
|
] }),
|
|
8745
8761
|
(x == null ? void 0 : x.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(x.fontFamily).map(([k, A]) => /* @__PURE__ */ jsx(
|
|
8746
8762
|
FontSelector,
|
|
8747
8763
|
{
|
|
8748
8764
|
label: k,
|
|
8749
8765
|
value: h.fontFamily[k.replace(/font-/g, "")] || A[Object.keys(A)[0]],
|
|
8750
|
-
onChange: (
|
|
8766
|
+
onChange: (w) => v(k, w)
|
|
8751
8767
|
},
|
|
8752
8768
|
k
|
|
8753
8769
|
)) }),
|
|
@@ -8756,7 +8772,7 @@ const Input = ({ node: o }) => {
|
|
|
8756
8772
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
8757
8773
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8758
8774
|
/* @__PURE__ */ jsx(CornerTopRightIcon, { className: "h-3 w-3 text-gray-600" }),
|
|
8759
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Border Radius" })
|
|
8775
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: b("Border Radius") })
|
|
8760
8776
|
] }),
|
|
8761
8777
|
/* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: h.borderRadius })
|
|
8762
8778
|
] }),
|
|
@@ -8767,7 +8783,7 @@ const Input = ({ node: o }) => {
|
|
|
8767
8783
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
8768
8784
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8769
8785
|
/* @__PURE__ */ jsx(MixerHorizontalIcon, { className: "h-3 w-3 text-gray-600" }),
|
|
8770
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Colors" })
|
|
8786
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: b("Colors") })
|
|
8771
8787
|
] }),
|
|
8772
8788
|
m && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8773
8789
|
/* @__PURE__ */ jsx(SunIcon, { className: "h-4 w-4" }),
|
|
@@ -8785,7 +8801,7 @@ const Input = ({ node: o }) => {
|
|
|
8785
8801
|
] }),
|
|
8786
8802
|
/* @__PURE__ */ jsx("div", { className: "space-y-2", children: x.colors.map((k) => I(k)) })
|
|
8787
8803
|
] }),
|
|
8788
|
-
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: i && g && /* @__PURE__ */ jsx(
|
|
8804
|
+
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: b("Loading...") }), children: i && g && /* @__PURE__ */ jsx(
|
|
8789
8805
|
LazyCssImportModal,
|
|
8790
8806
|
{
|
|
8791
8807
|
open: i,
|
|
@@ -8800,7 +8816,7 @@ const Input = ({ node: o }) => {
|
|
|
8800
8816
|
/* @__PURE__ */ jsx("br", {})
|
|
8801
8817
|
] }),
|
|
8802
8818
|
p && /* @__PURE__ */ jsx("div", { className: "absolute bottom-4 w-full", children: React.createElement(p) })
|
|
8803
|
-
] }) : /* @__PURE__ */ jsx("div", { className: "relative w-full", children: /* @__PURE__ */ jsx("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto text-center", o), children: /* @__PURE__ */ jsx("div", { className: "mt-10 h-full items-center justify-center gap-2 text-muted-foreground", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: "You don't have permission to edit the theme. Please contact your administrator to get access." }) }) }) });
|
|
8819
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "relative w-full", children: /* @__PURE__ */ jsx("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto text-center", o), children: /* @__PURE__ */ jsx("div", { className: "mt-10 h-full items-center justify-center gap-2 text-muted-foreground", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: b("You don't have permission to edit the theme. Please contact your administrator to get access.") }) }) }) });
|
|
8804
8820
|
}), Core = "Core", Import = "Import", Breakpoints = "Breakpoints", Clear = "Clear", Cancel = "Cancel", Yes = "Yes", Preview = "Preview", Settings = "Settings", Styling = "Style", SVG_code = "Enter SVG code here", Remove = "Remove", Choose = "Choose", Cut = "Cut", Copy = "Copy", Paste = "Paste", Delete = "Delete", classes = "classes", Theme = "Theme", Outline = "Outline", Copied = "Copied", Stop = "Stop", Edit = "Edit", Tag = "Tag", Value = "Value", URL$1 = "URL", Images = "Images", Library = "Library", Blocks = "Blocks", Basic = "Basic", Media = "Media", Advanced = "Advanced", Form = "Form", Groups = "Groups", Accordions = "Accordions", Buttons = "Buttons", Layouts = "Layouts", FAQ = "FAQ", Hero = "Hero", Features = "Features", Footer = "Footer", Navbar = "Navbar", Icons = "Icons", Testimonials = "Testimonials", Blog = "Blog", Saved = "Saved", Unsaved = "Unsaved", Randomize = "Randomize", Classes = "Classes", All = "All", Undo = "Undo", Redo = "Redo", Duplicate = "Duplicate", Close = "Close", Selected = "Selected", Select = "Select", Attributes = "Attributes", apply = "apply", presets = "presets", Orientation = "Orientation", Color = "Color", Upload = "Upload", Apply = "Apply", Back = "Back", Insert = "Insert", Rename = "Rename", Partials = "Partials", Happy = "Happy", Sad = "Sad", Retry = "Retry", canvas_empty = "Canvas is empty", Presets = "Presets", No = "No", Saving = "Saving", theme_config = { heading_font: "Heading Font", body_font: "Body Font", rounded_corner: "Rounded Corners", primary: "Primary", secondary: "Secondary", background: "Background", text_color: "Text Color", background_dark_mode: "Background (Dark Mode)", text_color_dark_mode: "Text Color (Dark Mode)" }, web_blocks = { box: "box", tag: "Tag", div: "div", level: "Level", header: "header", footer: "footer", section: "section", article: "article", aside: "aside", main: "main", nav: "navigation", figure: "figure", details: "details", summary: "summary", dialog: "dialog", strike: "strike", caption: "caption", legend: "legend", figcaption: "figure caption", mark: "mark", background_image: "Background Image", label: "Label", default: "default", icon_size: "Icon Size", icon_position: "Icon Position", start: "Start", end: "End", button: "Button", custom_html: "Custom HTML", html_code: "HTML Code", default_snippet: "The HTML snippet goes here...", placeholder: "Enter custom HTML code here", custom_script: "Custom Script", dark_mode: "Dark Mode", divider: "Divider", empty_box: "Empty Box", heading: "Heading", image: "Image", alt: "Alt", width: "Width", height: "Height", video: "Video", span: "Span", content: "Content", icon: "Icon", richtext: "Rich Text", list: "List", list_type: "List Type", listitem: "List Item", link: "Link", list_item: "List Item", none: "None", disc: "Disc", number: "Number", paragraph: "Paragraph", lightbox_link: "Lightbox Link", href: "Link", type: "Type", iframe: "iframe", inline: "inline", ajax: "ajax", autoplay: "Video autoplay", max_width: "Max Width", backdrop_color: "Background Color", gallery_name: "Gallery Name", slot: "Slot", empty_slot: "Empty Slot", text: "Text", video_url: "Video URL", controls: "Show Controls", loop: "Loop", muted: "Muted", checkbox: "Checkbox", required: "Required", checked: "Checked", submit_button: "Submit Button", form: "Form", submit_url: "Submit URL", error_message: "Error Message", success_message: "Success Message", input: "Input", value: "Value", show_label: "Show Label", field_name: "Field Name", radio: "Radio", multiple: "Multiple", options: "Options", select: "Select", multiple_choice: "Multiple Choice", textarea: "Textarea", rows: "Rows" }, lngEn = {
|
|
8805
8821
|
"Add block": "Add Block",
|
|
8806
8822
|
"Add Block": "Add Block",
|
|
@@ -9304,17 +9320,17 @@ function QuickPrompts({ onClick: o }) {
|
|
|
9304
9320
|
lang: get(LANGUAGES, a, a)
|
|
9305
9321
|
})
|
|
9306
9322
|
}), /* @__PURE__ */ jsx("div", { className: n ? "pointer-events-none opacity-50" : "", children: /* @__PURE__ */ jsx("ul", { className: "space-y-1", children: c.map(
|
|
9307
|
-
({ name:
|
|
9323
|
+
({ name: d, icon: p, subMenus: u, prompt: g }) => u ? /* @__PURE__ */ jsxs(Popover, { children: [
|
|
9308
9324
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
9309
9325
|
"li",
|
|
9310
9326
|
{
|
|
9311
9327
|
className: "flex cursor-pointer items-center space-x-2 rounded p-1 pl-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",
|
|
9312
9328
|
children: [
|
|
9313
9329
|
/* @__PURE__ */ jsx(p, { className: "h-4 w-4" }),
|
|
9314
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9330
|
+
/* @__PURE__ */ jsx("span", { children: d })
|
|
9315
9331
|
]
|
|
9316
9332
|
},
|
|
9317
|
-
|
|
9333
|
+
d
|
|
9318
9334
|
) }),
|
|
9319
9335
|
/* @__PURE__ */ jsx(PopoverContent, { side: "right", children: /* @__PURE__ */ jsx("ul", { children: /* @__PURE__ */ jsx("li", { children: r("Happy") }) }) })
|
|
9320
9336
|
] }) : /* @__PURE__ */ jsxs(
|
|
@@ -9324,28 +9340,28 @@ function QuickPrompts({ onClick: o }) {
|
|
|
9324
9340
|
className: "flex cursor-pointer items-center space-x-2 rounded p-1 text-xs hover:bg-primary/10 hover:text-primary dark:hover:bg-gray-800",
|
|
9325
9341
|
children: [
|
|
9326
9342
|
/* @__PURE__ */ jsx(p, { className: "h-3.5 w-3.5" }),
|
|
9327
|
-
/* @__PURE__ */ jsx("span", { children: r(
|
|
9343
|
+
/* @__PURE__ */ jsx("span", { children: r(d) })
|
|
9328
9344
|
]
|
|
9329
9345
|
},
|
|
9330
|
-
|
|
9346
|
+
d
|
|
9331
9347
|
)
|
|
9332
9348
|
) }) });
|
|
9333
9349
|
}
|
|
9334
9350
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
9335
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""),
|
|
9351
|
+
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), u = useSelectedBlock();
|
|
9336
9352
|
useEffect(() => {
|
|
9337
9353
|
var m;
|
|
9338
|
-
(m =
|
|
9354
|
+
(m = d.current) == null || m.focus();
|
|
9339
9355
|
}, []);
|
|
9340
9356
|
const g = () => {
|
|
9341
9357
|
l || c("");
|
|
9342
9358
|
};
|
|
9343
9359
|
return /* @__PURE__ */ jsx("div", { className: "", children: o ? /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
9344
9360
|
/* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-gray-500", children: "Selected block" }),
|
|
9345
|
-
|
|
9346
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
9361
|
+
u && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1 rounded border border-primary/20 bg-primary/10 p-1.5 text-xs text-primary", children: [
|
|
9362
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: u._type }),
|
|
9347
9363
|
" ",
|
|
9348
|
-
/* @__PURE__ */ jsx("p", { className: "truncate whitespace-nowrap leading-none", children:
|
|
9364
|
+
/* @__PURE__ */ jsx("p", { className: "truncate whitespace-nowrap leading-none", children: u._name || u._type })
|
|
9349
9365
|
] }),
|
|
9350
9366
|
/* @__PURE__ */ jsx("br", {}),
|
|
9351
9367
|
/* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-gray-500", children: "Quick actions" }),
|
|
@@ -9363,7 +9379,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
9363
9379
|
/* @__PURE__ */ jsx(
|
|
9364
9380
|
Textarea,
|
|
9365
9381
|
{
|
|
9366
|
-
ref:
|
|
9382
|
+
ref: d,
|
|
9367
9383
|
value: i,
|
|
9368
9384
|
onChange: (m) => c(m.target.value),
|
|
9369
9385
|
placeholder: n("Ask AI to edit content"),
|
|
@@ -9442,7 +9458,7 @@ const UndoRedo = () => {
|
|
|
9442
9458
|
/* @__PURE__ */ jsxs("div", { className: "flex h-full items-center", children: [
|
|
9443
9459
|
n ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
9444
9460
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", className: "h-7 w-7 rounded-md p-1", children: /* @__PURE__ */ jsx(DotsHorizontalIcon, { className: "h-4 w-4" }) }) }),
|
|
9445
|
-
/* @__PURE__ */ jsx(DropdownMenuContent, { className: "w-56 border-border text-xs", children: /* @__PURE__ */ jsxs(DropdownMenuItem, { className: "flex items-center gap-2", onSelect: (
|
|
9461
|
+
/* @__PURE__ */ jsx(DropdownMenuContent, { className: "w-56 border-border text-xs", children: /* @__PURE__ */ jsxs(DropdownMenuItem, { className: "flex items-center gap-2", onSelect: (d) => d.preventDefault(), children: [
|
|
9446
9462
|
/* @__PURE__ */ jsx(LightningBoltIcon, { className: "h-4 w-4 text-gray-500" }),
|
|
9447
9463
|
/* @__PURE__ */ jsx("span", { className: "flex-1", children: l("Data Binding") }),
|
|
9448
9464
|
/* @__PURE__ */ jsx(Switch, { checked: r, onCheckedChange: () => a(!r) })
|
|
@@ -9453,8 +9469,8 @@ const UndoRedo = () => {
|
|
|
9453
9469
|
] });
|
|
9454
9470
|
}, AddBlocksDialog = () => {
|
|
9455
9471
|
const { t: o } = useTranslation(), [n, r] = useState(""), [a, l] = useState(-1), [i, c] = useState(!1);
|
|
9456
|
-
return usePubSub(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, (
|
|
9457
|
-
r(
|
|
9472
|
+
return usePubSub(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, (d) => {
|
|
9473
|
+
r(d ? d._id : null), l(isNaN(d == null ? void 0 : d.position) ? -1 : d == null ? void 0 : d.position), c(!0);
|
|
9458
9474
|
}), usePubSub(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK, () => {
|
|
9459
9475
|
r(""), l(-1), c(!1);
|
|
9460
9476
|
}), /* @__PURE__ */ jsx(AlertDialog, { open: i, onOpenChange: () => i ? c(!1) : "", children: /* @__PURE__ */ jsxs(AlertDialogContent, { className: "max-w-5xl overflow-hidden border-border", children: [
|
|
@@ -9475,7 +9491,7 @@ const UndoRedo = () => {
|
|
|
9475
9491
|
preloadedAttributes: n = [],
|
|
9476
9492
|
onAttributesChange: r
|
|
9477
9493
|
}) {
|
|
9478
|
-
const [a, l] = useState([]), [i, c] = useState(""), [
|
|
9494
|
+
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(), { t: y } = useTranslation();
|
|
9479
9495
|
useEffect(() => {
|
|
9480
9496
|
l(n);
|
|
9481
9497
|
}, [n]);
|
|
@@ -9485,27 +9501,27 @@ const UndoRedo = () => {
|
|
|
9485
9501
|
return;
|
|
9486
9502
|
}
|
|
9487
9503
|
if (i) {
|
|
9488
|
-
const k = [...a, { key: i, value:
|
|
9504
|
+
const k = [...a, { key: i, value: d }];
|
|
9489
9505
|
r(k), l(a), c(""), p(""), h("");
|
|
9490
9506
|
}
|
|
9491
9507
|
}, C = (k) => {
|
|
9492
|
-
const A = a.filter((
|
|
9508
|
+
const A = a.filter((w, E) => E !== k);
|
|
9493
9509
|
r(A), l(A);
|
|
9494
|
-
},
|
|
9510
|
+
}, v = (k) => {
|
|
9495
9511
|
g(k), c(a[k].key), p(a[k].value);
|
|
9496
9512
|
}, _ = () => {
|
|
9497
9513
|
if (i.startsWith("@")) {
|
|
9498
9514
|
h("Attribute keys cannot start with '@'");
|
|
9499
9515
|
return;
|
|
9500
9516
|
}
|
|
9501
|
-
if (
|
|
9517
|
+
if (u !== null && i) {
|
|
9502
9518
|
const k = [...a];
|
|
9503
|
-
k[
|
|
9519
|
+
k[u] = { key: i, value: d }, r(k), l(k), g(null), c(""), p(""), h("");
|
|
9504
9520
|
}
|
|
9505
9521
|
}, B = (k) => {
|
|
9506
|
-
k.key === "Enter" && !k.shiftKey && (k.preventDefault(),
|
|
9522
|
+
k.key === "Enter" && !k.shiftKey && (k.preventDefault(), u !== null ? _() : S());
|
|
9507
9523
|
}, I = useCallback((k) => {
|
|
9508
|
-
const A = (j) => /[.,!?;:]/.test(j),
|
|
9524
|
+
const A = (j) => /[.,!?;:]/.test(j), w = (j, N, T) => {
|
|
9509
9525
|
let P = "", R = "";
|
|
9510
9526
|
const D = N > 0 ? j[N - 1] : "", L = N < j.length ? j[N] : "";
|
|
9511
9527
|
return N > 0 && (D === "." || !A(D) && D !== " ") && (P = " "), N < j.length && !A(L) && L !== " " && (R = " "), {
|
|
@@ -9517,11 +9533,11 @@ const UndoRedo = () => {
|
|
|
9517
9533
|
if (E) {
|
|
9518
9534
|
const j = E.selectionStart || 0, N = E.value || "", T = E.selectionEnd || j;
|
|
9519
9535
|
if (T > j) {
|
|
9520
|
-
const O = `{{${k}}}`, { text: F } =
|
|
9536
|
+
const O = `{{${k}}}`, { text: F } = w(N, j, O), M = N.slice(0, j) + F + N.slice(T);
|
|
9521
9537
|
p(M);
|
|
9522
9538
|
return;
|
|
9523
9539
|
}
|
|
9524
|
-
const R = `{{${k}}}`, { text: D } =
|
|
9540
|
+
const R = `{{${k}}}`, { text: D } = w(N, j, R), L = N.slice(0, j) + D + N.slice(j);
|
|
9525
9541
|
p(L);
|
|
9526
9542
|
}
|
|
9527
9543
|
}, []);
|
|
@@ -9530,7 +9546,7 @@ const UndoRedo = () => {
|
|
|
9530
9546
|
"form",
|
|
9531
9547
|
{
|
|
9532
9548
|
onSubmit: (k) => {
|
|
9533
|
-
k.preventDefault(),
|
|
9549
|
+
k.preventDefault(), u !== null ? _() : S();
|
|
9534
9550
|
},
|
|
9535
9551
|
className: "space-y-3",
|
|
9536
9552
|
children: [
|
|
@@ -9566,7 +9582,7 @@ const UndoRedo = () => {
|
|
|
9566
9582
|
id: "attrValue",
|
|
9567
9583
|
rows: 2,
|
|
9568
9584
|
ref: x,
|
|
9569
|
-
value:
|
|
9585
|
+
value: d,
|
|
9570
9586
|
onChange: (k) => p(k.target.value),
|
|
9571
9587
|
onKeyDown: B,
|
|
9572
9588
|
placeholder: "Enter Value",
|
|
@@ -9575,7 +9591,7 @@ const UndoRedo = () => {
|
|
|
9575
9591
|
)
|
|
9576
9592
|
] })
|
|
9577
9593
|
] }),
|
|
9578
|
-
/* @__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:
|
|
9594
|
+
/* @__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" }) }),
|
|
9579
9595
|
m && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: m })
|
|
9580
9596
|
]
|
|
9581
9597
|
}
|
|
@@ -9586,7 +9602,7 @@ const UndoRedo = () => {
|
|
|
9586
9602
|
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: k.value.toString() })
|
|
9587
9603
|
] }),
|
|
9588
9604
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
9589
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
9605
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => v(A), children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-3 w-3" }) }),
|
|
9590
9606
|
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => C(A), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" }) })
|
|
9591
9607
|
] })
|
|
9592
9608
|
] }, A)) })
|
|
@@ -9594,14 +9610,14 @@ const UndoRedo = () => {
|
|
|
9594
9610
|
}), BlockAttributesEditor = React.memo(() => {
|
|
9595
9611
|
const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
|
|
9596
9612
|
React.useEffect(() => {
|
|
9597
|
-
const
|
|
9598
|
-
isEmpty(
|
|
9613
|
+
const d = map(get(o, i), (p, u) => ({ key: u, value: p }));
|
|
9614
|
+
isEmpty(d) ? r([]) : r(d);
|
|
9599
9615
|
}, [get(o, i)]);
|
|
9600
9616
|
const c = React.useCallback(
|
|
9601
|
-
(
|
|
9617
|
+
(d = []) => {
|
|
9602
9618
|
const p = {};
|
|
9603
|
-
forEach(
|
|
9604
|
-
isEmpty(
|
|
9619
|
+
forEach(d, (u) => {
|
|
9620
|
+
isEmpty(u.key) || set(p, u.key, u.value);
|
|
9605
9621
|
}), l([get(o, "_id")], { [i]: p });
|
|
9606
9622
|
},
|
|
9607
9623
|
[o, l, i]
|
|
@@ -9747,24 +9763,24 @@ registerChaiSidebarPanel("outline", {
|
|
|
9747
9763
|
panel: () => /* @__PURE__ */ jsx("div", { className: "-mt-8", children: /* @__PURE__ */ jsx(ListTree, {}) })
|
|
9748
9764
|
});
|
|
9749
9765
|
const RootLayout = () => {
|
|
9750
|
-
const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c,
|
|
9766
|
+
const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), g = reverse([...u ?? []]), m = useCallback((k) => {
|
|
9751
9767
|
k.preventDefault();
|
|
9752
9768
|
}, []), h = useMemo(() => {
|
|
9753
|
-
const k = [p].flat(), A = k.find((E) => E.id === "chai-chat-panel"),
|
|
9754
|
-
return A ? [A, ...
|
|
9769
|
+
const k = [p].flat(), A = k.find((E) => E.id === "chai-chat-panel"), w = k.filter((E) => E.id !== "chai-chat-panel");
|
|
9770
|
+
return A ? [A, ...w] : k;
|
|
9755
9771
|
}, [p]), f = useCallback(
|
|
9756
9772
|
(k) => {
|
|
9757
9773
|
console.log("handleMenuItemClick", k, n), r(n === k ? null : k);
|
|
9758
9774
|
},
|
|
9759
9775
|
[n, r]
|
|
9760
|
-
), { t: x } = useTranslation(), b = useMemo(() => [...p, ...
|
|
9776
|
+
), { t: x } = useTranslation(), b = useMemo(() => [...p, ...u], [p, u]), y = useBuilderProp("htmlDir", "ltr"), S = find(b, { id: n }) ?? first(b), C = get(S, "width", DEFAULT_PANEL_WIDTH);
|
|
9761
9777
|
useEffect(() => {
|
|
9762
9778
|
if (n !== null) {
|
|
9763
9779
|
const k = find(b, { id: n });
|
|
9764
9780
|
k && get(k, "view", "standard") === "standard" && (a.current = n, i(get(k, "width", DEFAULT_PANEL_WIDTH)));
|
|
9765
9781
|
}
|
|
9766
9782
|
}, [n, b]);
|
|
9767
|
-
const
|
|
9783
|
+
const v = useMemo(() => {
|
|
9768
9784
|
if (n === null) return 0;
|
|
9769
9785
|
const k = find(b, { id: n });
|
|
9770
9786
|
return get(k, "view", "standard") === "standard" ? C : l;
|
|
@@ -9817,8 +9833,8 @@ const RootLayout = () => {
|
|
|
9817
9833
|
{
|
|
9818
9834
|
id: "left-panel",
|
|
9819
9835
|
className: "h-full max-h-full border-r border-border",
|
|
9820
|
-
initial: { width:
|
|
9821
|
-
animate: { width:
|
|
9836
|
+
initial: { width: v },
|
|
9837
|
+
animate: { width: v },
|
|
9822
9838
|
transition: { duration: 0.3, ease: "easeInOut" },
|
|
9823
9839
|
children: n !== null && get(S, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
|
|
9824
9840
|
/* @__PURE__ */ jsx(
|
|
@@ -9857,7 +9873,7 @@ const RootLayout = () => {
|
|
|
9857
9873
|
/* @__PURE__ */ jsx(
|
|
9858
9874
|
Button,
|
|
9859
9875
|
{
|
|
9860
|
-
onClick: () =>
|
|
9876
|
+
onClick: () => d("block"),
|
|
9861
9877
|
variant: "ghost",
|
|
9862
9878
|
size: "icon",
|
|
9863
9879
|
className: "text-xs",
|
|
@@ -9981,7 +9997,7 @@ const RootLayout = () => {
|
|
|
9981
9997
|
position: n,
|
|
9982
9998
|
updatePosition: r
|
|
9983
9999
|
}) => {
|
|
9984
|
-
const a = useChaiFeatureFlags(), [l, i] = useState(""), [c,
|
|
10000
|
+
const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), g = useMemo(() => {
|
|
9985
10001
|
if (!l.trim()) return a;
|
|
9986
10002
|
const x = l.toLowerCase();
|
|
9987
10003
|
return Object.fromEntries(
|
|
@@ -9991,20 +10007,20 @@ const RootLayout = () => {
|
|
|
9991
10007
|
})
|
|
9992
10008
|
);
|
|
9993
10009
|
}, [a, l]), m = (x) => {
|
|
9994
|
-
|
|
10010
|
+
d(!0), u({
|
|
9995
10011
|
x: x.clientX - n.x,
|
|
9996
10012
|
y: x.clientY - n.y
|
|
9997
10013
|
});
|
|
9998
10014
|
}, h = (x) => {
|
|
9999
10015
|
if (!c) return;
|
|
10000
|
-
const b = x.clientX - p.x, y = x.clientY - p.y, S = x.currentTarget, C = S.offsetWidth,
|
|
10016
|
+
const b = x.clientX - p.x, y = x.clientY - p.y, S = x.currentTarget, C = S.offsetWidth, v = S.offsetHeight, _ = window.innerWidth - C, B = window.innerHeight - v, I = Math.max(0, Math.min(b, _)), k = Math.max(0, Math.min(y, B));
|
|
10001
10017
|
r(I, k);
|
|
10002
10018
|
}, f = () => {
|
|
10003
|
-
|
|
10019
|
+
d(!1);
|
|
10004
10020
|
};
|
|
10005
10021
|
return useEffect(() => {
|
|
10006
10022
|
const x = () => {
|
|
10007
|
-
c &&
|
|
10023
|
+
c && d(!1);
|
|
10008
10024
|
};
|
|
10009
10025
|
return window.addEventListener("mouseup", x), () => window.removeEventListener("mouseup", x);
|
|
10010
10026
|
}, [c]), !n || n.x < 0 || n.y < 0 ? null : /* @__PURE__ */ jsxs(
|
|
@@ -10193,7 +10209,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10193
10209
|
let i = a.get(n);
|
|
10194
10210
|
return i || (i = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, a.set(n, i), l == null || l(o, n)), i;
|
|
10195
10211
|
}, flushCallbacks = (o) => {
|
|
10196
|
-
const n = getBuildingBlocks(o), r = n[1], a = n[3], l = n[4], i = n[5], c = n[6],
|
|
10212
|
+
const n = getBuildingBlocks(o), r = n[1], a = n[3], l = n[4], i = n[5], c = n[6], d = n[13], p = [], u = (g) => {
|
|
10197
10213
|
try {
|
|
10198
10214
|
g();
|
|
10199
10215
|
} catch (m) {
|
|
@@ -10201,30 +10217,30 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10201
10217
|
}
|
|
10202
10218
|
};
|
|
10203
10219
|
do {
|
|
10204
|
-
c.f &&
|
|
10220
|
+
c.f && u(c.f);
|
|
10205
10221
|
const g = /* @__PURE__ */ new Set(), m = g.add.bind(g);
|
|
10206
10222
|
a.forEach((h) => {
|
|
10207
10223
|
var f;
|
|
10208
10224
|
return (f = r.get(h)) == null ? void 0 : f.l.forEach(m);
|
|
10209
|
-
}), a.clear(), i.forEach(m), i.clear(), l.forEach(m), l.clear(), g.forEach(
|
|
10225
|
+
}), a.clear(), i.forEach(m), i.clear(), l.forEach(m), l.clear(), g.forEach(u), a.size && d(o);
|
|
10210
10226
|
} while (a.size || i.size || l.size);
|
|
10211
10227
|
if (p.length)
|
|
10212
10228
|
throw new AggregateError(p);
|
|
10213
10229
|
}, recomputeInvalidatedAtoms = (o) => {
|
|
10214
|
-
const n = getBuildingBlocks(o), r = n[1], a = n[2], l = n[3], i = n[11], c = n[14],
|
|
10230
|
+
const n = getBuildingBlocks(o), r = n[1], a = n[2], l = n[3], i = n[11], c = n[14], d = n[17], p = [], u = /* @__PURE__ */ new WeakSet(), g = /* @__PURE__ */ new WeakSet(), m = Array.from(l);
|
|
10215
10231
|
for (; m.length; ) {
|
|
10216
10232
|
const h = m[m.length - 1], f = i(o, h);
|
|
10217
10233
|
if (g.has(h)) {
|
|
10218
10234
|
m.pop();
|
|
10219
10235
|
continue;
|
|
10220
10236
|
}
|
|
10221
|
-
if (
|
|
10237
|
+
if (u.has(h)) {
|
|
10222
10238
|
a.get(h) === f.n && p.push([h, f]), g.add(h), m.pop();
|
|
10223
10239
|
continue;
|
|
10224
10240
|
}
|
|
10225
|
-
|
|
10241
|
+
u.add(h);
|
|
10226
10242
|
for (const x of getMountedOrPendingDependents(h, f, r))
|
|
10227
|
-
|
|
10243
|
+
u.has(x) || m.push(x);
|
|
10228
10244
|
}
|
|
10229
10245
|
for (let h = p.length - 1; h >= 0; --h) {
|
|
10230
10246
|
const [f, x] = p[h];
|
|
@@ -10234,11 +10250,11 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10234
10250
|
b = !0;
|
|
10235
10251
|
break;
|
|
10236
10252
|
}
|
|
10237
|
-
b && (c(o, f),
|
|
10253
|
+
b && (c(o, f), d(o, f)), a.delete(f);
|
|
10238
10254
|
}
|
|
10239
10255
|
}, readAtomState = (o, n) => {
|
|
10240
10256
|
var r;
|
|
10241
|
-
const a = getBuildingBlocks(o), l = a[1], i = a[2], c = a[3],
|
|
10257
|
+
const a = getBuildingBlocks(o), l = a[1], i = a[2], c = a[3], d = a[6], p = a[7], u = a[11], g = a[12], m = a[13], h = a[14], f = a[16], x = a[17], b = u(o, n);
|
|
10242
10258
|
if (isAtomStateInitialized(b) && (l.has(n) && i.get(n) !== b.n || Array.from(b.d).every(
|
|
10243
10259
|
([k, A]) => (
|
|
10244
10260
|
// Recursively, read the atom state of the dependency, and
|
|
@@ -10255,7 +10271,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10255
10271
|
function C(k) {
|
|
10256
10272
|
var A;
|
|
10257
10273
|
if (isSelfAtom(n, k)) {
|
|
10258
|
-
const E =
|
|
10274
|
+
const E = u(o, k);
|
|
10259
10275
|
if (!isAtomStateInitialized(E))
|
|
10260
10276
|
if (hasInitialValue(k))
|
|
10261
10277
|
setAtomStateValueOrPromise(o, k, k.init);
|
|
@@ -10263,17 +10279,17 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10263
10279
|
throw new Error("no atom init");
|
|
10264
10280
|
return returnAtomValue(E);
|
|
10265
10281
|
}
|
|
10266
|
-
const
|
|
10282
|
+
const w = h(o, k);
|
|
10267
10283
|
try {
|
|
10268
|
-
return returnAtomValue(
|
|
10284
|
+
return returnAtomValue(w);
|
|
10269
10285
|
} finally {
|
|
10270
|
-
b.d.set(k,
|
|
10286
|
+
b.d.set(k, w.n), isPendingPromise(b.v) && addPendingPromiseToDependency(n, b.v, w), (A = l.get(k)) == null || A.t.add(n), y || S();
|
|
10271
10287
|
}
|
|
10272
10288
|
}
|
|
10273
|
-
let
|
|
10289
|
+
let v, _;
|
|
10274
10290
|
const B = {
|
|
10275
10291
|
get signal() {
|
|
10276
|
-
return
|
|
10292
|
+
return v || (v = new AbortController()), v.signal;
|
|
10277
10293
|
},
|
|
10278
10294
|
get setSelf() {
|
|
10279
10295
|
return !_ && isActuallyWritableAtom(n) && (_ = (...k) => {
|
|
@@ -10288,38 +10304,38 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10288
10304
|
}, I = b.n;
|
|
10289
10305
|
try {
|
|
10290
10306
|
const k = p(o, n, C, B);
|
|
10291
|
-
return setAtomStateValueOrPromise(o, n, k), isPromiseLike$1(k) && (registerAbortHandler(k, () =>
|
|
10307
|
+
return setAtomStateValueOrPromise(o, n, k), isPromiseLike$1(k) && (registerAbortHandler(k, () => v == null ? void 0 : v.abort()), k.then(S, S)), b;
|
|
10292
10308
|
} catch (k) {
|
|
10293
10309
|
return delete b.v, b.e = k, ++b.n, b;
|
|
10294
10310
|
} finally {
|
|
10295
|
-
y = !1, I !== b.n && i.get(n) === I && (i.set(n, b.n), c.add(n), (r =
|
|
10311
|
+
y = !1, I !== b.n && i.get(n) === I && (i.set(n, b.n), c.add(n), (r = d.c) == null || r.call(d, n));
|
|
10296
10312
|
}
|
|
10297
10313
|
}, invalidateDependents = (o, n) => {
|
|
10298
10314
|
const r = getBuildingBlocks(o), a = r[1], l = r[2], i = r[11], c = [n];
|
|
10299
10315
|
for (; c.length; ) {
|
|
10300
|
-
const
|
|
10301
|
-
for (const
|
|
10302
|
-
const g = i(o,
|
|
10303
|
-
l.set(
|
|
10316
|
+
const d = c.pop(), p = i(o, d);
|
|
10317
|
+
for (const u of getMountedOrPendingDependents(d, p, a)) {
|
|
10318
|
+
const g = i(o, u);
|
|
10319
|
+
l.set(u, g.n), c.push(u);
|
|
10304
10320
|
}
|
|
10305
10321
|
}
|
|
10306
10322
|
}, writeAtomState = (o, n, ...r) => {
|
|
10307
|
-
const a = getBuildingBlocks(o), l = a[3], i = a[6], c = a[8],
|
|
10323
|
+
const a = getBuildingBlocks(o), l = a[3], i = a[6], c = a[8], d = a[11], p = a[12], u = a[13], g = a[14], m = a[15], h = a[17];
|
|
10308
10324
|
let f = !0;
|
|
10309
10325
|
const x = (y) => returnAtomValue(g(o, y)), b = (y, ...S) => {
|
|
10310
10326
|
var C;
|
|
10311
|
-
const
|
|
10327
|
+
const v = d(o, y);
|
|
10312
10328
|
try {
|
|
10313
10329
|
if (isSelfAtom(n, y)) {
|
|
10314
10330
|
if (!hasInitialValue(y))
|
|
10315
10331
|
throw new Error("atom not writable");
|
|
10316
|
-
const _ =
|
|
10317
|
-
setAtomStateValueOrPromise(o, y, B), h(o, y), _ !==
|
|
10332
|
+
const _ = v.n, B = S[0];
|
|
10333
|
+
setAtomStateValueOrPromise(o, y, B), h(o, y), _ !== v.n && (l.add(y), (C = i.c) == null || C.call(i, y), m(o, y));
|
|
10318
10334
|
return;
|
|
10319
10335
|
} else
|
|
10320
10336
|
return writeAtomState(o, y, ...S);
|
|
10321
10337
|
} finally {
|
|
10322
|
-
f || (
|
|
10338
|
+
f || (u(o), p(o));
|
|
10323
10339
|
}
|
|
10324
10340
|
};
|
|
10325
10341
|
try {
|
|
@@ -10329,12 +10345,12 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10329
10345
|
}
|
|
10330
10346
|
}, mountDependencies = (o, n) => {
|
|
10331
10347
|
var r;
|
|
10332
|
-
const a = getBuildingBlocks(o), l = a[1], i = a[3], c = a[6],
|
|
10348
|
+
const a = getBuildingBlocks(o), l = a[1], i = a[3], c = a[6], d = a[11], p = a[15], u = a[18], g = a[19], m = d(o, n), h = l.get(n);
|
|
10333
10349
|
if (h && !isPendingPromise(m.v)) {
|
|
10334
10350
|
for (const [f, x] of m.d)
|
|
10335
10351
|
if (!h.d.has(f)) {
|
|
10336
|
-
const b =
|
|
10337
|
-
|
|
10352
|
+
const b = d(o, f);
|
|
10353
|
+
u(o, f).t.add(n), h.d.add(f), x !== b.n && (i.add(f), (r = c.c) == null || r.call(c, f), p(o, f));
|
|
10338
10354
|
}
|
|
10339
10355
|
for (const f of h.d || [])
|
|
10340
10356
|
if (!m.d.has(f)) {
|
|
@@ -10345,7 +10361,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10345
10361
|
}
|
|
10346
10362
|
}, mountAtom = (o, n) => {
|
|
10347
10363
|
var r;
|
|
10348
|
-
const a = getBuildingBlocks(o), l = a[1], i = a[4], c = a[6],
|
|
10364
|
+
const a = getBuildingBlocks(o), l = a[1], i = a[4], c = a[6], d = a[10], p = a[11], u = a[12], g = a[13], m = a[14], h = a[16], f = p(o, n);
|
|
10349
10365
|
let x = l.get(n);
|
|
10350
10366
|
if (!x) {
|
|
10351
10367
|
m(o, n);
|
|
@@ -10362,11 +10378,11 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10362
10378
|
try {
|
|
10363
10379
|
return h(o, n, ...C);
|
|
10364
10380
|
} finally {
|
|
10365
|
-
y || (g(o),
|
|
10381
|
+
y || (g(o), u(o));
|
|
10366
10382
|
}
|
|
10367
10383
|
};
|
|
10368
10384
|
try {
|
|
10369
|
-
const C =
|
|
10385
|
+
const C = d(o, n, S);
|
|
10370
10386
|
C && (x.u = () => {
|
|
10371
10387
|
y = !0;
|
|
10372
10388
|
try {
|
|
@@ -10385,14 +10401,14 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10385
10401
|
return x;
|
|
10386
10402
|
}, unmountAtom = (o, n) => {
|
|
10387
10403
|
var r;
|
|
10388
|
-
const a = getBuildingBlocks(o), l = a[1], i = a[5], c = a[6],
|
|
10404
|
+
const a = getBuildingBlocks(o), l = a[1], i = a[5], c = a[6], d = a[11], p = a[19], u = d(o, n);
|
|
10389
10405
|
let g = l.get(n);
|
|
10390
10406
|
if (g && !g.l.size && !Array.from(g.t).some((m) => {
|
|
10391
10407
|
var h;
|
|
10392
10408
|
return (h = l.get(m)) == null ? void 0 : h.d.has(n);
|
|
10393
10409
|
})) {
|
|
10394
10410
|
g.u && i.add(g.u), g = void 0, l.delete(n), (r = c.u) == null || r.call(c, n);
|
|
10395
|
-
for (const m of
|
|
10411
|
+
for (const m of u.d.keys()) {
|
|
10396
10412
|
const h = p(o, m);
|
|
10397
10413
|
h == null || h.t.delete(n);
|
|
10398
10414
|
}
|
|
@@ -10402,11 +10418,11 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
|
|
|
10402
10418
|
}, setAtomStateValueOrPromise = (o, n, r) => {
|
|
10403
10419
|
const a = getBuildingBlocks(o)[11], l = a(o, n), i = "v" in l, c = l.v;
|
|
10404
10420
|
if (isPromiseLike$1(r))
|
|
10405
|
-
for (const
|
|
10421
|
+
for (const d of l.d.keys())
|
|
10406
10422
|
addPendingPromiseToDependency(
|
|
10407
10423
|
n,
|
|
10408
10424
|
r,
|
|
10409
|
-
a(o,
|
|
10425
|
+
a(o, d)
|
|
10410
10426
|
);
|
|
10411
10427
|
l.v = r, delete l.e, (!i || !Object.is(c, l.v)) && (++l.n, isPromiseLike$1(c) && abortPromise(c));
|
|
10412
10428
|
}, storeGet = (o, n) => {
|
|
@@ -10513,23 +10529,23 @@ const isPromiseLike = (o) => typeof (o == null ? void 0 : o.then) == "function",
|
|
|
10513
10529
|
let r = continuablePromiseMap.get(o);
|
|
10514
10530
|
return r || (r = new Promise((a, l) => {
|
|
10515
10531
|
let i = o;
|
|
10516
|
-
const c = (
|
|
10517
|
-
i ===
|
|
10518
|
-
},
|
|
10519
|
-
i ===
|
|
10532
|
+
const c = (u) => (g) => {
|
|
10533
|
+
i === u && a(g);
|
|
10534
|
+
}, d = (u) => (g) => {
|
|
10535
|
+
i === u && l(g);
|
|
10520
10536
|
}, p = () => {
|
|
10521
10537
|
try {
|
|
10522
|
-
const
|
|
10523
|
-
isPromiseLike(
|
|
10524
|
-
} catch (
|
|
10525
|
-
l(
|
|
10538
|
+
const u = n();
|
|
10539
|
+
isPromiseLike(u) ? (continuablePromiseMap.set(u, r), i = u, u.then(c(u), d(u)), registerAbortHandler(u, p)) : a(u);
|
|
10540
|
+
} catch (u) {
|
|
10541
|
+
l(u);
|
|
10526
10542
|
}
|
|
10527
10543
|
};
|
|
10528
|
-
o.then(c(o),
|
|
10544
|
+
o.then(c(o), d(o)), registerAbortHandler(o, p);
|
|
10529
10545
|
}), continuablePromiseMap.set(o, r)), r;
|
|
10530
10546
|
};
|
|
10531
10547
|
function useAtomValue(o, n) {
|
|
10532
|
-
const { delay: r, unstable_promiseStatus: a = !React__default.use } = {}, l = useStore(), [[i, c,
|
|
10548
|
+
const { delay: r, unstable_promiseStatus: a = !React__default.use } = {}, l = useStore(), [[i, c, d], p] = useReducer(
|
|
10533
10549
|
(g) => {
|
|
10534
10550
|
const m = l.get(o);
|
|
10535
10551
|
return Object.is(g[0], m) && g[1] === l && g[2] === o ? g : [m, l, o];
|
|
@@ -10537,8 +10553,8 @@ function useAtomValue(o, n) {
|
|
|
10537
10553
|
void 0,
|
|
10538
10554
|
() => [l.get(o), l, o]
|
|
10539
10555
|
);
|
|
10540
|
-
let
|
|
10541
|
-
if ((c !== l ||
|
|
10556
|
+
let u = i;
|
|
10557
|
+
if ((c !== l || d !== o) && (p(), u = l.get(o)), useEffect(() => {
|
|
10542
10558
|
const g = l.sub(o, () => {
|
|
10543
10559
|
if (a)
|
|
10544
10560
|
try {
|
|
@@ -10555,11 +10571,11 @@ function useAtomValue(o, n) {
|
|
|
10555
10571
|
p();
|
|
10556
10572
|
});
|
|
10557
10573
|
return p(), g;
|
|
10558
|
-
}, [l, o, r, a]), useDebugValue(
|
|
10559
|
-
const g = createContinuablePromise(
|
|
10574
|
+
}, [l, o, r, a]), useDebugValue(u), isPromiseLike(u)) {
|
|
10575
|
+
const g = createContinuablePromise(u, () => l.get(o));
|
|
10560
10576
|
return a && attachPromiseStatus(g), use(g);
|
|
10561
10577
|
}
|
|
10562
|
-
return
|
|
10578
|
+
return u;
|
|
10563
10579
|
}
|
|
10564
10580
|
function useSetAtom(o, n) {
|
|
10565
10581
|
const r = useStore();
|
|
@@ -10576,10 +10592,10 @@ function useAtom(o, n) {
|
|
|
10576
10592
|
];
|
|
10577
10593
|
}
|
|
10578
10594
|
function domToJsx(o, n = 0) {
|
|
10579
|
-
var
|
|
10595
|
+
var u;
|
|
10580
10596
|
const r = " ".repeat(n);
|
|
10581
10597
|
if (o.nodeType === Node.TEXT_NODE) {
|
|
10582
|
-
const g = (
|
|
10598
|
+
const g = (u = o.textContent) == null ? void 0 : u.trim();
|
|
10583
10599
|
return g ? `${r}${g}
|
|
10584
10600
|
` : "";
|
|
10585
10601
|
}
|
|
@@ -10615,7 +10631,7 @@ function domToJsx(o, n = 0) {
|
|
|
10615
10631
|
(x, b) => {
|
|
10616
10632
|
const [y, S] = b.split(":").map((C) => C.trim());
|
|
10617
10633
|
if (y && S) {
|
|
10618
|
-
const C = y.replace(/-([a-z])/g, (
|
|
10634
|
+
const C = y.replace(/-([a-z])/g, (v) => v[1].toUpperCase());
|
|
10619
10635
|
x[C] = S.replace(/['"]/g, "");
|
|
10620
10636
|
}
|
|
10621
10637
|
return x;
|
|
@@ -10655,8 +10671,8 @@ function domToJsx(o, n = 0) {
|
|
|
10655
10671
|
} else
|
|
10656
10672
|
c.push(`${g.name}="${g.value}"`);
|
|
10657
10673
|
c.length > 0 && (i += " " + c.join(" "));
|
|
10658
|
-
const
|
|
10659
|
-
if (!
|
|
10674
|
+
const d = Array.from(o.childNodes);
|
|
10675
|
+
if (!d.some((g) => {
|
|
10660
10676
|
var m;
|
|
10661
10677
|
return g.nodeType === Node.TEXT_NODE ? (m = g.textContent) == null ? void 0 : m.trim() : !0;
|
|
10662
10678
|
}))
|
|
@@ -10665,7 +10681,7 @@ function domToJsx(o, n = 0) {
|
|
|
10665
10681
|
else {
|
|
10666
10682
|
i += `>
|
|
10667
10683
|
`;
|
|
10668
|
-
for (const g of
|
|
10684
|
+
for (const g of d)
|
|
10669
10685
|
i += domToJsx(g, n + 1);
|
|
10670
10686
|
i += `${r}</${a}>
|
|
10671
10687
|
`;
|
|
@@ -10700,7 +10716,7 @@ const getExportedCoded = async ({
|
|
|
10700
10716
|
isTypeScript: r = !1
|
|
10701
10717
|
}) => {
|
|
10702
10718
|
let a = (o == null ? void 0 : o._name) || (o == null ? void 0 : o._type) || "Component";
|
|
10703
|
-
a = camelCase(a).replace(/^./, (
|
|
10719
|
+
a = camelCase(a).replace(/^./, (u) => u.toUpperCase());
|
|
10704
10720
|
const l = " ";
|
|
10705
10721
|
let { jsx: i, html: c } = await convertHtmlToJsx(n);
|
|
10706
10722
|
return i = i == null ? void 0 : i.split(`
|
|
@@ -10714,7 +10730,7 @@ ${l})
|
|
|
10714
10730
|
}`, { jsx: i, html: formatHtml(c), componentName: a };
|
|
10715
10731
|
}, ExportCodeModalContent = ({ tab: o }) => {
|
|
10716
10732
|
var S;
|
|
10717
|
-
const { t: n } = useTranslation(), [r, a] = useState({ html: "", jsx: "" }), l = useSelectedBlock(), i = useBlocksHtmlForAi(), [c,
|
|
10733
|
+
const { t: n } = useTranslation(), [r, a] = useState({ html: "", jsx: "" }), l = useSelectedBlock(), i = useBlocksHtmlForAi(), [c, d] = useState(""), [p, u] = useState(!1), g = () => {
|
|
10718
10734
|
switch (o) {
|
|
10719
10735
|
case "js":
|
|
10720
10736
|
return `${c}.jsx`;
|
|
@@ -10737,20 +10753,20 @@ ${l})
|
|
|
10737
10753
|
}
|
|
10738
10754
|
}, h = useCallback(async () => {
|
|
10739
10755
|
try {
|
|
10740
|
-
|
|
10741
|
-
const C = i({ EXTRA_CORE_BLOCKS: ["Icon"] }),
|
|
10756
|
+
u(!1), await new Promise((k) => setTimeout(k, 1e3));
|
|
10757
|
+
const C = i({ EXTRA_CORE_BLOCKS: ["Icon"] }), v = o === "ts", {
|
|
10742
10758
|
jsx: _,
|
|
10743
10759
|
html: B,
|
|
10744
10760
|
componentName: I
|
|
10745
10761
|
} = await getExportedCoded({
|
|
10746
10762
|
selectedBlock: l,
|
|
10747
10763
|
html: C,
|
|
10748
|
-
isTypeScript:
|
|
10764
|
+
isTypeScript: v
|
|
10749
10765
|
});
|
|
10750
|
-
a({ html: B, jsx: _ }),
|
|
10766
|
+
a({ html: B, jsx: _ }), d(I), u(!0);
|
|
10751
10767
|
} catch {
|
|
10752
|
-
const
|
|
10753
|
-
a({ html:
|
|
10768
|
+
const v = "<div>Export failed. Close the modal and try again.</div>";
|
|
10769
|
+
a({ html: v, jsx: v }), toast.error(n("Failed to generate export HTML"));
|
|
10754
10770
|
}
|
|
10755
10771
|
}, [n, o, l, i]);
|
|
10756
10772
|
useEffect(() => {
|
|
@@ -10766,17 +10782,17 @@ ${l})
|
|
|
10766
10782
|
},
|
|
10767
10783
|
[n]
|
|
10768
10784
|
), x = (C) => {
|
|
10769
|
-
const
|
|
10785
|
+
const v = new Blob([C], { type: "text/jsx" }), _ = URL.createObjectURL(v), B = document.createElement("a");
|
|
10770
10786
|
B.href = _, B.download = g(), document.body.appendChild(B), B.click(), URL.revokeObjectURL(_), document.body.removeChild(B), toast.success(n("Export code downloaded successfully!"));
|
|
10771
10787
|
}, b = /* @__PURE__ */ jsxs("span", { children: [
|
|
10772
10788
|
"Download ",
|
|
10773
10789
|
/* @__PURE__ */ jsx("span", { className: "font-mono text-xs font-light text-gray-300", children: g() })
|
|
10774
10790
|
] }), y = useMemo(() => {
|
|
10775
|
-
const C = { extend: shadcnTheme() },
|
|
10791
|
+
const C = { extend: shadcnTheme() }, v = JSON.stringify(C, null, 2);
|
|
10776
10792
|
return `{
|
|
10777
10793
|
// Your tailwind config ...
|
|
10778
10794
|
|
|
10779
|
-
"theme": ${
|
|
10795
|
+
"theme": ${v == null ? void 0 : v.split(`
|
|
10780
10796
|
`).join(`
|
|
10781
10797
|
`)},
|
|
10782
10798
|
}`;
|
|
@@ -10847,8 +10863,8 @@ ${l})
|
|
|
10847
10863
|
}, [o.locale]), useEffect(() => {
|
|
10848
10864
|
setDebugLogs(o.debugLogs);
|
|
10849
10865
|
}, [o.debugLogs]), useEffect(() => {
|
|
10850
|
-
o.translations && each(o.translations, (c,
|
|
10851
|
-
i18n.addResourceBundle(
|
|
10866
|
+
o.translations && each(o.translations, (c, d) => {
|
|
10867
|
+
i18n.addResourceBundle(d, "translation", c, !0, !0);
|
|
10852
10868
|
});
|
|
10853
10869
|
}, [o.translations]), useEffect(() => (a !== "SAVED" ? window.onbeforeunload = () => "" : window.onbeforeunload = null, () => {
|
|
10854
10870
|
window.onbeforeunload = null;
|