@chaibuilder/sdk 2.3.1 → 2.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{code-editor-ZNSGKU5A.cjs → code-editor-BjHf4wM4.cjs} +1 -1
- package/dist/{code-editor-DCGe1BPZ.js → code-editor-BqhH_IQC.js} +1 -1
- package/dist/core.cjs +4 -4
- package/dist/core.js +457 -430
- package/dist/{toggle-BFR6fqvM.js → toggle-DW7GHkUt.js} +332 -332
- package/dist/toggle-J9Lqkd7T.cjs +1 -0
- package/dist/ui.cjs +1 -1
- package/dist/ui.js +1 -1
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +136 -134
- package/package.json +1 -1
- package/dist/toggle-BO_bUdZF.cjs +0 -1
package/dist/core.js
CHANGED
|
@@ -3,14 +3,14 @@ var V = (o, n, r) => n in o ? U(o, n, { enumerable: !0, configurable: !0, writab
|
|
|
3
3
|
var F = (o, n, r) => V(o, typeof n != "symbol" ? n + "" : n, r);
|
|
4
4
|
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
5
5
|
import { useRegisteredChaiBlocks, getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredFonts, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
|
|
6
|
-
import { BoxModelIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, CodeIcon, Link1Icon, ListBulletIcon, HeadingIcon, QuoteIcon, TextAlignLeftIcon, TextAlignCenterIcon, TextAlignRightIcon, LoopIcon,
|
|
6
|
+
import { BoxModelIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, CodeIcon, Link1Icon, ListBulletIcon, HeadingIcon, QuoteIcon, TextAlignLeftIcon, TextAlignCenterIcon, TextAlignRightIcon, LoopIcon, InfoCircledIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, Cross1Icon, BoxIcon, MinusIcon, CrossCircledIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, CaretRightIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, CheckIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
|
|
7
7
|
import { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isFunction, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, uniq, flatMapDeep, some, sortBy, round } from "lodash-es";
|
|
8
8
|
import * as React from "react";
|
|
9
9
|
import React__default, { useMemo, useCallback, useEffect, useState, useRef, Component, Children, memo, createElement, createContext, useContext, Suspense, 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";
|
|
11
11
|
import { atomWithStorage, splitAtom, useAtomCallback } from "jotai/utils";
|
|
12
12
|
import { g as generateUUID, a as getBreakpointValue, c as cn$2 } from "./common-functions-BGzDsf1z.js";
|
|
13
|
-
import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, b9 as cn$1, aW as Skeleton, d as Alert, e as AlertDescription, at as Input$1, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, av as Popover, b5 as Tooltip, b8 as TooltipTrigger, ay as PopoverTrigger, b6 as TooltipContent, ax as PopoverContent, F as Command, H as CommandInput, I as CommandList, J as CommandEmpty, K as CommandGroup, L as CommandItem, a6 as DialogHeader, a9 as DialogTitle, B as Badge, a as AccordionItem, b as AccordionTrigger, c as AccordionContent, ag as DropdownMenuLabel, ak as DropdownMenuSeparator, ac as DropdownMenuCheckboxItem, aq as HoverCard, as as HoverCardTrigger, ar as HoverCardContent, b2 as Textarea, A as Accordion, C as Card, D as CardHeader, y as CardDescription, x as CardContent, au as Label, z as CardFooter, az as ScrollArea, a_ as Tabs, b0 as TabsList, b1 as TabsTrigger, a$ as TabsContent, g as AlertDialog, q as AlertDialogTrigger, j as AlertDialogContent, m as AlertDialogHeader, p as AlertDialogTitle, k as AlertDialogDescription, l as AlertDialogFooter, i as AlertDialogCancel, h as AlertDialogAction, aZ as Switch, r as Avatar, aL as Separator, b7 as TooltipProvider, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle, aY as Toaster } from "./toggle-
|
|
13
|
+
import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, b9 as cn$1, aW as Skeleton, d as Alert, e as AlertDescription, at as Input$1, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, av as Popover, b5 as Tooltip, b8 as TooltipTrigger, ay as PopoverTrigger, b6 as TooltipContent, ax as PopoverContent, F as Command, H as CommandInput, I as CommandList, J as CommandEmpty, K as CommandGroup, L as CommandItem, a6 as DialogHeader, a9 as DialogTitle, B as Badge, a as AccordionItem, b as AccordionTrigger, c as AccordionContent, ag as DropdownMenuLabel, ak as DropdownMenuSeparator, ac as DropdownMenuCheckboxItem, aq as HoverCard, as as HoverCardTrigger, ar as HoverCardContent, b2 as Textarea, A as Accordion, C as Card, D as CardHeader, y as CardDescription, x as CardContent, au as Label, z as CardFooter, az as ScrollArea, a_ as Tabs, b0 as TabsList, b1 as TabsTrigger, a$ as TabsContent, g as AlertDialog, q as AlertDialogTrigger, j as AlertDialogContent, m as AlertDialogHeader, p as AlertDialogTitle, k as AlertDialogDescription, l as AlertDialogFooter, i as AlertDialogCancel, h as AlertDialogAction, aZ as Switch, r as Avatar, aL as Separator, b7 as TooltipProvider, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle, aY as Toaster } from "./toggle-DW7GHkUt.js";
|
|
14
14
|
import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, ChevronLeft, DatabaseIcon, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, File, Database, MoreVertical, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, Eye, ChevronsUpDown, ChevronsDownUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
|
|
15
15
|
import clsx$1, { clsx } from "clsx";
|
|
16
16
|
import { twMerge } from "tailwind-merge";
|
|
@@ -32,7 +32,6 @@ import { useEditor, BubbleMenu as BubbleMenu$1, EditorContent } from "@tiptap/re
|
|
|
32
32
|
import StarterKit from "@tiptap/starter-kit";
|
|
33
33
|
import RjForm from "@rjsf/core";
|
|
34
34
|
import validator from "@rjsf/validator-ajv8";
|
|
35
|
-
import "next-themes";
|
|
36
35
|
import Autosuggest from "react-autosuggest";
|
|
37
36
|
import { useFeature } from "flagged";
|
|
38
37
|
import { parse, stringify } from "himalaya";
|
|
@@ -47,6 +46,7 @@ import "@mhsdesign/jit-browser-tailwindcss";
|
|
|
47
46
|
import twContainer from "@tailwindcss/container-queries";
|
|
48
47
|
import { ErrorBoundary } from "react-error-boundary";
|
|
49
48
|
import { motion } from "framer-motion";
|
|
49
|
+
import "next-themes";
|
|
50
50
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
51
51
|
import { flip } from "@floating-ui/dom";
|
|
52
52
|
import { useFloating, shift } from "@floating-ui/react-dom";
|
|
@@ -297,12 +297,12 @@ class PubSub {
|
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
300
|
-
const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (
|
|
301
|
-
if (
|
|
300
|
+
const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (h) => c ? get(h, "_parent") === c : !get(h, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), g = (h) => {
|
|
301
|
+
if (h === "CHILD")
|
|
302
302
|
pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
|
|
303
303
|
else {
|
|
304
|
-
const
|
|
305
|
-
|
|
304
|
+
const m = { _id: c || "", position: d == null ? void 0 : d.length };
|
|
305
|
+
h === "BEFORE" ? m.position = Math.max(u, 0) : h === "AFTER" && (m.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, m);
|
|
306
306
|
}
|
|
307
307
|
};
|
|
308
308
|
return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
@@ -337,16 +337,16 @@ function insertBlocksAtPosition(o, n, r, a) {
|
|
|
337
337
|
let i = [...o];
|
|
338
338
|
if (r) {
|
|
339
339
|
const u = o.find((g) => g._id === r);
|
|
340
|
-
if (u && u.content !== void 0 && u.content !== "" && !o.some((
|
|
341
|
-
const
|
|
340
|
+
if (u && u.content !== void 0 && u.content !== "" && !o.some((h) => h._parent === r)) {
|
|
341
|
+
const m = {
|
|
342
342
|
_id: generateUUID(),
|
|
343
343
|
_parent: r,
|
|
344
344
|
_type: "Text",
|
|
345
345
|
content: u.content
|
|
346
346
|
};
|
|
347
347
|
Object.keys(u).forEach((x) => {
|
|
348
|
-
x.startsWith("content-") && (
|
|
349
|
-
}), l.unshift(
|
|
348
|
+
x.startsWith("content-") && (m[x] = u[x]);
|
|
349
|
+
}), l.unshift(m), i = i.map((x) => {
|
|
350
350
|
if (x._id === r) {
|
|
351
351
|
const f = { ...x, content: "" };
|
|
352
352
|
return Object.keys(f).forEach((y) => {
|
|
@@ -386,13 +386,13 @@ function moveNode(o, n, r, a) {
|
|
|
386
386
|
const l = findNodeById(o, n), i = findNodeById(o, r);
|
|
387
387
|
if (!l || !i) return !1;
|
|
388
388
|
i.children || (i.model.children = []);
|
|
389
|
-
let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((
|
|
389
|
+
let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((h) => h.model._id === n);
|
|
390
390
|
l.drop(), c = Math.max(c, 0);
|
|
391
391
|
const p = (((g = l == null ? void 0 : l.model) == null ? void 0 : g._parent) || "root") === r && c <= a ? a - 1 : a;
|
|
392
392
|
try {
|
|
393
393
|
i.addChildAtIndex(l, p);
|
|
394
|
-
} catch (
|
|
395
|
-
return console.error("Error adding child to parent:",
|
|
394
|
+
} catch (h) {
|
|
395
|
+
return console.error("Error adding child to parent:", h), !1;
|
|
396
396
|
}
|
|
397
397
|
return !0;
|
|
398
398
|
}
|
|
@@ -433,8 +433,8 @@ function handleNewParentTextBlock(o, n, r) {
|
|
|
433
433
|
const d = o.map((u) => {
|
|
434
434
|
if (u._id === r) {
|
|
435
435
|
const g = { ...u, content: "" };
|
|
436
|
-
return Object.keys(g).forEach((
|
|
437
|
-
|
|
436
|
+
return Object.keys(g).forEach((h) => {
|
|
437
|
+
h.startsWith("content-") && (g[h] = "");
|
|
438
438
|
}), g;
|
|
439
439
|
}
|
|
440
440
|
return u;
|
|
@@ -451,7 +451,7 @@ function moveBlocksWithChildren(o, n, r, a) {
|
|
|
451
451
|
const c = r || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
|
|
452
452
|
if (moveNode(p, n, c, a)) {
|
|
453
453
|
let u = flattenTree(p);
|
|
454
|
-
const g = u.find((
|
|
454
|
+
const g = u.find((h) => h._id === n);
|
|
455
455
|
return g && (g._parent = c === "root" ? null : c), u.shift(), r && (u = handleNewParentTextBlock(u, l, r)), u;
|
|
456
456
|
}
|
|
457
457
|
return i;
|
|
@@ -475,22 +475,22 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
|
|
|
475
475
|
}, removeNestedBlocks = (o, n) => {
|
|
476
476
|
let r = [...o], a = [];
|
|
477
477
|
n.forEach((d) => {
|
|
478
|
-
const p = r.find((
|
|
478
|
+
const p = r.find((h) => h._id === d);
|
|
479
479
|
if (!p || !p._parent) return;
|
|
480
|
-
const u = p._parent, g = r.filter((
|
|
480
|
+
const u = p._parent, g = r.filter((h) => h._parent === u);
|
|
481
481
|
if (g.length === 2) {
|
|
482
|
-
const
|
|
483
|
-
if (
|
|
484
|
-
const
|
|
485
|
-
|
|
482
|
+
const h = g.find((m) => m._id !== d);
|
|
483
|
+
if (h && h._type === "Text") {
|
|
484
|
+
const m = r.find((x) => x._id === u);
|
|
485
|
+
m && "content" in m && (r = r.map((x) => {
|
|
486
486
|
if (x._id === u) {
|
|
487
|
-
const f = { ...x, content:
|
|
488
|
-
return Object.keys(
|
|
489
|
-
y.startsWith("content-") && (f[y] =
|
|
487
|
+
const f = { ...x, content: h.content };
|
|
488
|
+
return Object.keys(h).forEach((y) => {
|
|
489
|
+
y.startsWith("content-") && (f[y] = h[y]);
|
|
490
490
|
}), f;
|
|
491
491
|
}
|
|
492
492
|
return x;
|
|
493
|
-
}), a.push(
|
|
493
|
+
}), a.push(h._id));
|
|
494
494
|
}
|
|
495
495
|
}
|
|
496
496
|
});
|
|
@@ -572,7 +572,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
|
|
|
572
572
|
status: "idle",
|
|
573
573
|
props: {},
|
|
574
574
|
error: void 0
|
|
575
|
-
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (x) => ({})), 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}`),
|
|
575
|
+
}), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (x) => ({})), 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}`), h = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
|
|
576
576
|
return useEffect(() => {
|
|
577
577
|
if (n === "mock") {
|
|
578
578
|
if (isFunction(a)) {
|
|
@@ -584,7 +584,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
|
|
|
584
584
|
}
|
|
585
585
|
return;
|
|
586
586
|
}
|
|
587
|
-
n === "live" && (!g && !
|
|
587
|
+
n === "live" && (!g && !h || (i((x) => ({ ...x, status: "loading", props: {} })), d({ block: o }).then((x = {}) => {
|
|
588
588
|
g ? (p((f) => ({
|
|
589
589
|
...f,
|
|
590
590
|
[o._id]: {
|
|
@@ -599,7 +599,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
|
|
|
599
599
|
[o._id]: { status: "error", error: x, props: [] }
|
|
600
600
|
})), i((f) => ({ ...f, status: "error", error: x, props: {} }))) : i((f) => ({ ...f, status: "error", error: x, props: {} }));
|
|
601
601
|
})));
|
|
602
|
-
}, [o == null ? void 0 : o._id, u, g,
|
|
602
|
+
}, [o == null ? void 0 : o._id, u, g, h, a, n]), {
|
|
603
603
|
$loading: get(l, "status") === "loading",
|
|
604
604
|
...o ? get(l, "props", {}) : {}
|
|
605
605
|
};
|
|
@@ -864,7 +864,7 @@ const undoRedoStateAtom = atom({
|
|
|
864
864
|
}, useAddBlock = () => {
|
|
865
865
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
866
866
|
(i, c, d) => {
|
|
867
|
-
var
|
|
867
|
+
var m;
|
|
868
868
|
for (let x = 0; x < i.length; x++) {
|
|
869
869
|
const { _id: f } = i[x];
|
|
870
870
|
i[x]._id = generateUUID();
|
|
@@ -874,7 +874,7 @@ const undoRedoStateAtom = atom({
|
|
|
874
874
|
}
|
|
875
875
|
const p = first(i);
|
|
876
876
|
let u, g;
|
|
877
|
-
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([(
|
|
877
|
+
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([(m = first(i)) == null ? void 0 : m._id]), first(i);
|
|
878
878
|
},
|
|
879
879
|
[r, o, n]
|
|
880
880
|
);
|
|
@@ -891,8 +891,8 @@ const undoRedoStateAtom = atom({
|
|
|
891
891
|
...has(i, "_name") && { _name: i._name },
|
|
892
892
|
...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
|
|
893
893
|
};
|
|
894
|
-
let
|
|
895
|
-
return c && (
|
|
894
|
+
let h, m;
|
|
895
|
+
return c && (h = find(o, { _id: c }), g._parent = c, m = c), !canAcceptChildBlock(h == null ? void 0 : h._type, g._type) && h && (g._parent = h._parent, m = h._parent), r([g], m, d), n([g._id]), g;
|
|
896
896
|
},
|
|
897
897
|
[r, a, o, n]
|
|
898
898
|
), addPredefinedBlock: a };
|
|
@@ -2332,8 +2332,8 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2332
2332
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
2333
2333
|
})
|
|
2334
2334
|
), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
|
|
2335
|
-
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,
|
|
2336
|
-
const f = cloneDeep(x.find((y) => y._id ===
|
|
2335
|
+
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, h = (m, x) => {
|
|
2336
|
+
const f = cloneDeep(x.find((y) => y._id === m));
|
|
2337
2337
|
for (const y in f) {
|
|
2338
2338
|
const b = f[y];
|
|
2339
2339
|
if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
|
|
@@ -2346,16 +2346,16 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2346
2346
|
};
|
|
2347
2347
|
return {
|
|
2348
2348
|
askAi: useCallback(
|
|
2349
|
-
async (
|
|
2349
|
+
async (m, x, f, y) => {
|
|
2350
2350
|
if (l) {
|
|
2351
2351
|
n(!0), a(null);
|
|
2352
2352
|
try {
|
|
2353
|
-
const b = p === u ? "" : p, v =
|
|
2353
|
+
const b = p === u ? "" : p, v = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(x, d)), p) : [h(x, d)], B = await l(m, addLangToPrompt(f, g, m), v, b), { blocks: w, error: _ } = B;
|
|
2354
2354
|
if (_) {
|
|
2355
2355
|
a(_);
|
|
2356
2356
|
return;
|
|
2357
2357
|
}
|
|
2358
|
-
if (
|
|
2358
|
+
if (m === "styles") {
|
|
2359
2359
|
const E = w.map((S) => {
|
|
2360
2360
|
for (const A in S)
|
|
2361
2361
|
A !== "_id" && (S[A] = `${STYLES_KEY},${S[A]}`);
|
|
@@ -2458,17 +2458,17 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2458
2458
|
r(d), a([]);
|
|
2459
2459
|
const u = {
|
|
2460
2460
|
_chai_copied_blocks: d.flatMap((g) => {
|
|
2461
|
-
const
|
|
2461
|
+
const h = getDuplicatedBlocks(o, g, null);
|
|
2462
2462
|
if (!p)
|
|
2463
|
-
return
|
|
2464
|
-
let
|
|
2465
|
-
for (const x of
|
|
2463
|
+
return h;
|
|
2464
|
+
let m = [];
|
|
2465
|
+
for (const x of h)
|
|
2466
2466
|
if (x._type === "PartialBlock" || x._type === "GlobalBlock") {
|
|
2467
2467
|
let f = l(x.partialBlockId);
|
|
2468
|
-
x._parent && (f == null ? void 0 : f.length) > 0 && (f = f.map((y) => (isEmpty(y._parent) && set(y, "_parent", x._parent), y))),
|
|
2468
|
+
x._parent && (f == null ? void 0 : f.length) > 0 && (f = f.map((y) => (isEmpty(y._parent) && set(y, "_parent", x._parent), y))), m = [...m, ...f];
|
|
2469
2469
|
} else
|
|
2470
|
-
|
|
2471
|
-
return
|
|
2470
|
+
m.push(x);
|
|
2471
|
+
return m;
|
|
2472
2472
|
})
|
|
2473
2473
|
};
|
|
2474
2474
|
if (!navigator.clipboard) {
|
|
@@ -2506,13 +2506,13 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2506
2506
|
(a, l = null) => {
|
|
2507
2507
|
const i = [];
|
|
2508
2508
|
each(a, (c) => {
|
|
2509
|
-
const d = o.find((
|
|
2509
|
+
const d = o.find((m) => m._id === c);
|
|
2510
2510
|
l ? l === "root" && (l = null) : l = d._parent;
|
|
2511
2511
|
const g = filter(
|
|
2512
2512
|
o,
|
|
2513
|
-
(
|
|
2514
|
-
).indexOf(d) + 1,
|
|
2515
|
-
r(
|
|
2513
|
+
(m) => isString(l) ? m._parent === l : !m._parent
|
|
2514
|
+
).indexOf(d) + 1, h = getDuplicatedBlocks(o, c, l);
|
|
2515
|
+
r(h, l, g), i.push(get(h, "0._id", ""));
|
|
2516
2516
|
}), n(i);
|
|
2517
2517
|
},
|
|
2518
2518
|
[o, n]
|
|
@@ -2649,13 +2649,13 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2649
2649
|
return map(i, (c) => {
|
|
2650
2650
|
const d = o(c), p = a;
|
|
2651
2651
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
2652
|
-
return each(p, (
|
|
2653
|
-
const
|
|
2652
|
+
return each(p, (h) => {
|
|
2653
|
+
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
|
|
2654
2654
|
u = u.replace(x, " ").replace(/\s+/g, " ").trim();
|
|
2655
|
-
const f = first(
|
|
2656
|
-
includes(["2xl", "xl", "lg", "md", "sm"], f) && p.push(
|
|
2657
|
-
}), each(p, (
|
|
2658
|
-
const
|
|
2655
|
+
const f = first(h.split(":"));
|
|
2656
|
+
includes(["2xl", "xl", "lg", "md", "sm"], f) && p.push(h.split(":").pop().trim());
|
|
2657
|
+
}), each(p, (h) => {
|
|
2658
|
+
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
|
|
2659
2659
|
g = g.replace(x, " ").replace(/\s+/g, " ").trim();
|
|
2660
2660
|
}), {
|
|
2661
2661
|
ids: [d._id],
|
|
@@ -2789,11 +2789,11 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2789
2789
|
return "VERTICAL";
|
|
2790
2790
|
}
|
|
2791
2791
|
}, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
|
|
2792
|
-
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (f) => c ? get(f, "_parent") === c : !get(f, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0,
|
|
2792
|
+
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (f) => c ? get(f, "_parent") === c : !get(f, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, h = u + 1 === (d == null ? void 0 : d.length), m = getParentBlockOrientation(c, i, a), x = useCallback(
|
|
2793
2793
|
(f) => {
|
|
2794
|
-
isDisabledControl(g,
|
|
2794
|
+
isDisabledControl(g, h, f) || p || (f === "UP" || f === "LEFT" ? l([i], c || null, u - 1) : (f === "DOWN" || f === "RIGHT") && l([i], c || null, u + 2), n());
|
|
2795
2795
|
},
|
|
2796
|
-
[g,
|
|
2796
|
+
[g, h, p, u, i, c, n]
|
|
2797
2797
|
);
|
|
2798
2798
|
return useHotkeys(
|
|
2799
2799
|
"shift+up, shift+down, shift+left, shift+right",
|
|
@@ -2803,7 +2803,7 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2803
2803
|
},
|
|
2804
2804
|
{ document: a == null ? void 0 : a.contentDocument },
|
|
2805
2805
|
[x]
|
|
2806
|
-
), { isOnlyChild: p, isFirstBlock: g, isLastBlock:
|
|
2806
|
+
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock: x, orientation: m };
|
|
2807
2807
|
}, BlockController = ({ block: o, updateFloatingBar: n }) => {
|
|
2808
2808
|
const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
|
|
2809
2809
|
o,
|
|
@@ -2943,19 +2943,19 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
2943
2943
|
i([null]);
|
|
2944
2944
|
}, [r, n]), /* @__PURE__ */ jsx(BlockFloatingSelector, { block: o, selectedBlockElement: a[0] });
|
|
2945
2945
|
}, BlockFloatingSelector = ({ block: o, selectedBlockElement: n }) => {
|
|
2946
|
-
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), { editingBlockId: p } = useInlineEditing(), { document: u } = useFrame(), { floatingStyles: g, refs:
|
|
2946
|
+
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), { editingBlockId: p } = useInlineEditing(), { document: u } = useFrame(), { floatingStyles: g, refs: h, update: m } = useFloating({
|
|
2947
2947
|
placement: "top-start",
|
|
2948
2948
|
middleware: [shift(), flip()],
|
|
2949
2949
|
elements: { reference: n }
|
|
2950
2950
|
});
|
|
2951
|
-
useResizeObserver(n, () =>
|
|
2951
|
+
useResizeObserver(n, () => m(), n !== null), useResizeObserver(u == null ? void 0 : u.body, () => m(), (u == null ? void 0 : u.body) !== null);
|
|
2952
2952
|
const x = get(o, "_parent", null), f = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
|
|
2953
2953
|
return !n || !o || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
2954
2954
|
"div",
|
|
2955
2955
|
{
|
|
2956
2956
|
role: "button",
|
|
2957
2957
|
tabIndex: 0,
|
|
2958
|
-
ref:
|
|
2958
|
+
ref: h.setFloating,
|
|
2959
2959
|
style: g,
|
|
2960
2960
|
onClick: (y) => {
|
|
2961
2961
|
y.stopPropagation(), y.preventDefault();
|
|
@@ -2980,7 +2980,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
|
|
|
2980
2980
|
/* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
|
|
2981
2981
|
canDuplicateBlock(get(o, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([o == null ? void 0 : o._id]) }) : null,
|
|
2982
2982
|
canDeleteBlock(get(o, "_type", "")) && d(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([o == null ? void 0 : o._id]) }) : null,
|
|
2983
|
-
d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: o, updateFloatingBar:
|
|
2983
|
+
d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: o, updateFloatingBar: m })
|
|
2984
2984
|
] })
|
|
2985
2985
|
]
|
|
2986
2986
|
}
|
|
@@ -3115,20 +3115,20 @@ F(Frame, "defaultProps", {
|
|
|
3115
3115
|
initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
|
|
3116
3116
|
});
|
|
3117
3117
|
const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: n })), useKeyEventWatcher = (o) => {
|
|
3118
|
-
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: g, pasteBlocks:
|
|
3118
|
+
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: g, pasteBlocks: h } = usePasteBlocks(), m = o ? { document: o } : {};
|
|
3119
3119
|
useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys(
|
|
3120
3120
|
"ctrl+c,command+c",
|
|
3121
3121
|
() => u(n),
|
|
3122
|
-
{ ...
|
|
3122
|
+
{ ...m, enabled: !isEmpty(n), preventDefault: !0 },
|
|
3123
3123
|
[n, u]
|
|
3124
3124
|
), useHotkeys(
|
|
3125
3125
|
"ctrl+v,command+v",
|
|
3126
3126
|
() => {
|
|
3127
|
-
g(n[0]) &&
|
|
3127
|
+
g(n[0]) && h(n);
|
|
3128
3128
|
},
|
|
3129
|
-
{ ...
|
|
3130
|
-
[n, g,
|
|
3131
|
-
), useHotkeys("esc", () => r([]),
|
|
3129
|
+
{ ...m, enabled: !isEmpty(n), preventDefault: !0 },
|
|
3130
|
+
[n, g, h]
|
|
3131
|
+
), useHotkeys("esc", () => r([]), m, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...m, enabled: !isEmpty(n), preventDefault: !0 }, [
|
|
3132
3132
|
n,
|
|
3133
3133
|
i
|
|
3134
3134
|
]), useHotkeys(
|
|
@@ -3136,7 +3136,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3136
3136
|
(x) => {
|
|
3137
3137
|
x.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
|
|
3138
3138
|
},
|
|
3139
|
-
|
|
3139
|
+
m,
|
|
3140
3140
|
[n, l]
|
|
3141
3141
|
);
|
|
3142
3142
|
}, KeyboardHandler = () => {
|
|
@@ -3427,7 +3427,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3427
3427
|
],
|
|
3428
3428
|
onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
|
|
3429
3429
|
onBlur: ({ editor: u, event: g }) => {
|
|
3430
|
-
const
|
|
3430
|
+
const h = g.relatedTarget, m = i.querySelector(".ProseMirror"), x = i.querySelector(".tippy-box"), f = m == null ? void 0 : m.contains(h), y = x == null ? void 0 : x.contains(h);
|
|
3431
3431
|
if (!f && !y) {
|
|
3432
3432
|
const b = (u == null ? void 0 : u.getHTML()) || "";
|
|
3433
3433
|
r(b);
|
|
@@ -3445,10 +3445,10 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3445
3445
|
});
|
|
3446
3446
|
}, [c]);
|
|
3447
3447
|
const d = useMemo(() => {
|
|
3448
|
-
var
|
|
3448
|
+
var h;
|
|
3449
3449
|
const u = "max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";
|
|
3450
3450
|
if (!n) return u;
|
|
3451
|
-
const g = ((
|
|
3451
|
+
const g = ((h = n == null ? void 0 : n.className) == null ? void 0 : h.replace("sr-only", "")) || "";
|
|
3452
3452
|
return `${u} ${g}`;
|
|
3453
3453
|
}, [n]), p = useCallback(
|
|
3454
3454
|
(u) => {
|
|
@@ -3483,28 +3483,28 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3483
3483
|
useEffect(() => {
|
|
3484
3484
|
if (a.current) {
|
|
3485
3485
|
a.current.innerText = n, a.current.focus();
|
|
3486
|
-
const
|
|
3487
|
-
|
|
3486
|
+
const m = c.createRange(), x = d.getSelection();
|
|
3487
|
+
m.selectNodeContents(a.current), m.collapse(!1), x == null || x.removeAllRanges(), x == null || x.addRange(m), a.current.focus();
|
|
3488
3488
|
} else
|
|
3489
3489
|
r();
|
|
3490
3490
|
}, [c, d]);
|
|
3491
3491
|
const p = useMemo(() => {
|
|
3492
3492
|
var x;
|
|
3493
|
-
const
|
|
3494
|
-
return
|
|
3493
|
+
const m = ((x = o == null ? void 0 : o.tagName) == null ? void 0 : x.toLowerCase()) || "div";
|
|
3494
|
+
return m === "button" ? "div" : m;
|
|
3495
3495
|
}, [o]), u = useCallback(
|
|
3496
|
-
(
|
|
3497
|
-
(
|
|
3496
|
+
(m) => {
|
|
3497
|
+
(m.key === "Enter" || m.key === "Escape") && i(m);
|
|
3498
3498
|
},
|
|
3499
3499
|
[i]
|
|
3500
3500
|
), g = useCallback(() => {
|
|
3501
3501
|
r();
|
|
3502
|
-
}, [r]),
|
|
3503
|
-
var
|
|
3502
|
+
}, [r]), h = useMemo(() => {
|
|
3503
|
+
var m;
|
|
3504
3504
|
return {
|
|
3505
3505
|
id: "active-inline-editing-element",
|
|
3506
3506
|
contentEditable: !0,
|
|
3507
|
-
className: `${((
|
|
3507
|
+
className: `${((m = o == null ? void 0 : o.className) == null ? void 0 : m.replace("sr-only", "")) || ""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,
|
|
3508
3508
|
style: cloneDeep(o == null ? void 0 : o.style) || {},
|
|
3509
3509
|
onInput: (x) => {
|
|
3510
3510
|
const f = x.target;
|
|
@@ -3519,12 +3519,12 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3519
3519
|
ref: a,
|
|
3520
3520
|
onBlur: g,
|
|
3521
3521
|
onKeyDown: u,
|
|
3522
|
-
...
|
|
3522
|
+
...h
|
|
3523
3523
|
}) });
|
|
3524
3524
|
}
|
|
3525
3525
|
), WithBlockTextEditor = memo(
|
|
3526
3526
|
({ block: o, children: n }) => {
|
|
3527
|
-
const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight:
|
|
3527
|
+
const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: h } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang: x } = useLanguages(), [, f] = useSelectedBlockIds(), y = useRef(null), b = l, { blockContent: v, blockType: B } = useMemo(() => {
|
|
3528
3528
|
var j;
|
|
3529
3529
|
const A = o._type;
|
|
3530
3530
|
let N = o[r];
|
|
@@ -3534,14 +3534,14 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3534
3534
|
(A) => {
|
|
3535
3535
|
var C;
|
|
3536
3536
|
const N = A || ((C = g.current) == null ? void 0 : C.innerText);
|
|
3537
|
-
|
|
3537
|
+
m([b], { [r]: N }), u(null), c(null), d(-1), f([]);
|
|
3538
3538
|
},
|
|
3539
|
-
[b,
|
|
3539
|
+
[b, m, c, f, x]
|
|
3540
3540
|
), _ = useDebouncedCallback(
|
|
3541
3541
|
(A) => {
|
|
3542
|
-
|
|
3542
|
+
m([b], { [r]: A });
|
|
3543
3543
|
},
|
|
3544
|
-
[b, o,
|
|
3544
|
+
[b, o, m, x],
|
|
3545
3545
|
1e3
|
|
3546
3546
|
), E = useCallback(
|
|
3547
3547
|
(A) => {
|
|
@@ -3558,7 +3558,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3558
3558
|
const A = `[data-block-id="${b}"]`, N = i >= 0 ? `[data-block-index="${i}"]` : "", C = a.querySelector(`${A}${N}`);
|
|
3559
3559
|
C && ((k = C == null ? void 0 : C.classList) == null || k.add("sr-only"), u(C));
|
|
3560
3560
|
}, [b, B, a, i]);
|
|
3561
|
-
const S = useMemo(() => p ? (
|
|
3561
|
+
const S = useMemo(() => p ? (h(), B === "RichText" ? /* @__PURE__ */ jsx(
|
|
3562
3562
|
RichTextEditor,
|
|
3563
3563
|
{
|
|
3564
3564
|
blockContent: v,
|
|
@@ -3612,12 +3612,12 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3612
3612
|
blockAtom: n,
|
|
3613
3613
|
children: r
|
|
3614
3614
|
}) => {
|
|
3615
|
-
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(), [
|
|
3616
|
-
() =>
|
|
3615
|
+
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(), [h] = useHiddenBlockIds(), [m] = useAtom$1(dataBindingActiveAtom), x = get(c, "component", null), { index: f, key: y } = useContext(RepeaterContext), b = useMemo(
|
|
3616
|
+
() => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
|
|
3617
3617
|
index: f,
|
|
3618
3618
|
key: y
|
|
3619
3619
|
}) : applyLanguage(i, d, c),
|
|
3620
|
-
[i, d, c, g,
|
|
3620
|
+
[i, d, c, g, m, f, y]
|
|
3621
3621
|
), v = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), B = useMemo(
|
|
3622
3622
|
() => u(i._id, getBlockRuntimeProps(i._type)),
|
|
3623
3623
|
[i._id, i._type, u, getBlockRuntimeProps]
|
|
@@ -3642,7 +3642,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3642
3642
|
o
|
|
3643
3643
|
]
|
|
3644
3644
|
), _ = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]);
|
|
3645
|
-
if (isNull(x) ||
|
|
3645
|
+
if (isNull(x) || h.includes(i._id)) return null;
|
|
3646
3646
|
let E = /* @__PURE__ */ jsx(Suspense, { children: createElement(x, {
|
|
3647
3647
|
...w,
|
|
3648
3648
|
children: r({
|
|
@@ -3697,7 +3697,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3697
3697
|
);
|
|
3698
3698
|
return map(l, (c) => {
|
|
3699
3699
|
const d = a(c._id);
|
|
3700
|
-
return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId:
|
|
3700
|
+
return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: h, repeaterItems: m, $repeaterItemsKey: x }) => g === "Repeater" ? isArray(m) && m.map((f, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) }, `${u}-${y}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) : null }) }, c._id) : null;
|
|
3701
3701
|
});
|
|
3702
3702
|
}, PageBlocksRenderer = () => {
|
|
3703
3703
|
const [o] = useBlocksStore();
|
|
@@ -3711,11 +3711,11 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
|
|
|
3711
3711
|
if (d < n) {
|
|
3712
3712
|
const u = parseFloat((d / n).toFixed(2).toString());
|
|
3713
3713
|
let g = {};
|
|
3714
|
-
const
|
|
3714
|
+
const h = p * u, m = d * u;
|
|
3715
3715
|
p && (g = {
|
|
3716
3716
|
// Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
|
|
3717
|
-
height: 100 + (p -
|
|
3718
|
-
width: 100 + (d -
|
|
3717
|
+
height: 100 + (p - h) / h * 100 + "%",
|
|
3718
|
+
width: 100 + (d - m) / m * 100 + "%"
|
|
3719
3719
|
}), i({
|
|
3720
3720
|
position: "relative",
|
|
3721
3721
|
top: 0,
|
|
@@ -3764,19 +3764,19 @@ const CanvasEventsWatcher = () => {
|
|
|
3764
3764
|
}), null;
|
|
3765
3765
|
}, StaticCanvas = () => {
|
|
3766
3766
|
const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useAtom$1(canvasIframeAtom), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), g = useCallback(
|
|
3767
|
-
(
|
|
3768
|
-
i((x) => ({ ...x, width:
|
|
3767
|
+
(m) => {
|
|
3768
|
+
i((x) => ({ ...x, width: m }));
|
|
3769
3769
|
},
|
|
3770
3770
|
[i]
|
|
3771
3771
|
);
|
|
3772
3772
|
useEffect(() => {
|
|
3773
3773
|
if (!a.current) return;
|
|
3774
|
-
const { clientWidth:
|
|
3775
|
-
i({ width:
|
|
3774
|
+
const { clientWidth: m, clientHeight: x } = a.current;
|
|
3775
|
+
i({ width: m, height: x });
|
|
3776
3776
|
}, [a, o]);
|
|
3777
|
-
const
|
|
3778
|
-
let
|
|
3779
|
-
return
|
|
3777
|
+
const h = useMemo(() => {
|
|
3778
|
+
let m = IframeInitialContent;
|
|
3779
|
+
return m = m.replace("__HTML_DIR__", u), m;
|
|
3780
3780
|
}, [u]);
|
|
3781
3781
|
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: g, onResize: g, children: /* @__PURE__ */ jsx(
|
|
3782
3782
|
"div",
|
|
@@ -3792,7 +3792,7 @@ const CanvasEventsWatcher = () => {
|
|
|
3792
3792
|
id: "canvas-iframe",
|
|
3793
3793
|
style: { ...c, ...isEmpty(c) ? { width: `${o}px` } : {} },
|
|
3794
3794
|
className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
|
|
3795
|
-
initialContent:
|
|
3795
|
+
initialContent: h,
|
|
3796
3796
|
children: [
|
|
3797
3797
|
/* @__PURE__ */ jsx(KeyboardHandler, {}),
|
|
3798
3798
|
/* @__PURE__ */ jsx(BlockSelectionHighlighter, {}),
|
|
@@ -3822,7 +3822,7 @@ const CanvasEventsWatcher = () => {
|
|
|
3822
3822
|
}, FallbackError = () => /* @__PURE__ */ jsx("div", { className: "h-full w-full rounded-md bg-red-200 p-4 text-red-500", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center", children: [
|
|
3823
3823
|
/* @__PURE__ */ jsx("p", { className: "font-semibold", children: "Oops! Something went wrong." }),
|
|
3824
3824
|
/* @__PURE__ */ jsx("p", { children: "Please try again." })
|
|
3825
|
-
] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-
|
|
3825
|
+
] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-BqhH_IQC.js")), CanvasArea = () => {
|
|
3826
3826
|
const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
|
|
3827
3827
|
return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2", children: [
|
|
3828
3828
|
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
|
|
@@ -3887,7 +3887,7 @@ const CanvasEventsWatcher = () => {
|
|
|
3887
3887
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: a("Paste SVG code to use as an icon") })
|
|
3888
3888
|
] });
|
|
3889
3889
|
}, DefaultMediaManager = ({ close: o, onSelect: n, mode: r = "image" }) => {
|
|
3890
|
-
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null),
|
|
3890
|
+
const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), h = async (x) => {
|
|
3891
3891
|
if (!x.trim()) {
|
|
3892
3892
|
p(!1), g("Please enter a URL");
|
|
3893
3893
|
return;
|
|
@@ -3899,9 +3899,9 @@ const CanvasEventsWatcher = () => {
|
|
|
3899
3899
|
} finally {
|
|
3900
3900
|
c(!1);
|
|
3901
3901
|
}
|
|
3902
|
-
}, { t:
|
|
3902
|
+
}, { t: m } = useTranslation();
|
|
3903
3903
|
return /* @__PURE__ */ jsxs("div", { className: "flex w-96 flex-col gap-4 p-4", children: [
|
|
3904
|
-
/* @__PURE__ */ jsx("h2", { className: "text-xl font-semibold", children:
|
|
3904
|
+
/* @__PURE__ */ jsx("h2", { className: "text-xl font-semibold", children: m(`${r.charAt(0).toUpperCase() + r.slice(1)} Manager`) }),
|
|
3905
3905
|
u && /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
|
|
3906
3906
|
/* @__PURE__ */ jsx(AlertCircle, { className: "h-4 w-4" }),
|
|
3907
3907
|
/* @__PURE__ */ jsx(AlertDescription, { children: u })
|
|
@@ -3910,20 +3910,20 @@ const CanvasEventsWatcher = () => {
|
|
|
3910
3910
|
/* @__PURE__ */ jsx(
|
|
3911
3911
|
Input$1,
|
|
3912
3912
|
{
|
|
3913
|
-
placeholder:
|
|
3913
|
+
placeholder: m(`Enter ${r} URL`),
|
|
3914
3914
|
value: a,
|
|
3915
3915
|
onChange: (x) => l(x.target.value),
|
|
3916
|
-
onKeyUp: () =>
|
|
3916
|
+
onKeyUp: () => h(a)
|
|
3917
3917
|
}
|
|
3918
3918
|
),
|
|
3919
3919
|
/* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
3920
|
-
/* @__PURE__ */ jsx(Button, { variant: "outline", onClick: o, children:
|
|
3920
|
+
/* @__PURE__ */ jsx(Button, { variant: "outline", onClick: o, children: m("Cancel") }),
|
|
3921
3921
|
/* @__PURE__ */ jsx(
|
|
3922
3922
|
Button,
|
|
3923
3923
|
{
|
|
3924
3924
|
onClick: () => n({ id: "dam-id", url: a, width: 600, height: 400, description: "This is image description" }),
|
|
3925
3925
|
disabled: !d || i,
|
|
3926
|
-
children:
|
|
3926
|
+
children: m("Insert")
|
|
3927
3927
|
}
|
|
3928
3928
|
)
|
|
3929
3929
|
] })
|
|
@@ -3950,16 +3950,16 @@ const CanvasEventsWatcher = () => {
|
|
|
3950
3950
|
MediaManagerModal.displayName = "MediaManagerModal";
|
|
3951
3951
|
const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
3952
3952
|
const { t: l } = useTranslation(), i = useSelectedBlock(), c = useUpdateBlocksProps(), d = (g) => {
|
|
3953
|
-
const
|
|
3954
|
-
if (
|
|
3955
|
-
n(
|
|
3956
|
-
const
|
|
3953
|
+
const h = isArray(g) ? first(g) : g;
|
|
3954
|
+
if (h) {
|
|
3955
|
+
n(h == null ? void 0 : h.url);
|
|
3956
|
+
const m = h == null ? void 0 : h.width, x = h == null ? void 0 : h.height;
|
|
3957
3957
|
if (i != null && i._id) {
|
|
3958
3958
|
const f = {
|
|
3959
|
-
...
|
|
3959
|
+
...m && { width: m },
|
|
3960
3960
|
...x && { height: x },
|
|
3961
|
-
...
|
|
3962
|
-
...
|
|
3961
|
+
...h.description && { alt: h.description },
|
|
3962
|
+
...h.id && { assetId: h.id }
|
|
3963
3963
|
};
|
|
3964
3964
|
if (isEmpty(f)) return;
|
|
3965
3965
|
c([i._id], f);
|
|
@@ -4004,18 +4004,18 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4004
4004
|
] })
|
|
4005
4005
|
] });
|
|
4006
4006
|
}, PathDropdown = ({ data: o, onSelect: n, dataType: r }) => {
|
|
4007
|
-
const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (
|
|
4008
|
-
(
|
|
4009
|
-
const
|
|
4010
|
-
|
|
4007
|
+
const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", p = React__default.useCallback(
|
|
4008
|
+
(h) => {
|
|
4009
|
+
const m = (x) => r === "value" ? x === "value" || x === "object" : r === "array" ? x === "array" : x === r;
|
|
4010
|
+
h.type === "object" ? (l((x) => [...x, h.key]), c(h.value)) : m(h.type) && n([...a, h.key].join("."), r);
|
|
4011
4011
|
},
|
|
4012
4012
|
[a, n, r]
|
|
4013
4013
|
), u = React__default.useCallback(() => {
|
|
4014
4014
|
if (a.length > 0) {
|
|
4015
|
-
const
|
|
4016
|
-
l(
|
|
4015
|
+
const h = a.slice(0, -1);
|
|
4016
|
+
l(h), c(h.reduce((m, x) => m[x], o));
|
|
4017
4017
|
}
|
|
4018
|
-
}, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([
|
|
4018
|
+
}, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([h, m]) => ({ key: h, value: m, type: d(m) })).filter((h) => !startsWith(h.key, REPEATER_PREFIX) && h.key.includes("/") ? !1 : r === "value" ? h.type === "value" || h.type === "object" : r === "array" ? h.type === "array" || h.type === "object" : r === "object" ? h.type === "object" : !0) : [], [i, r]);
|
|
4019
4019
|
return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
|
|
4020
4020
|
/* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
|
|
4021
4021
|
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
@@ -4025,36 +4025,36 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4025
4025
|
/* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
|
|
4026
4026
|
"Back"
|
|
4027
4027
|
] }),
|
|
4028
|
-
g.map((
|
|
4028
|
+
g.map((h) => /* @__PURE__ */ jsxs(
|
|
4029
4029
|
CommandItem,
|
|
4030
4030
|
{
|
|
4031
|
-
value:
|
|
4031
|
+
value: h.key,
|
|
4032
4032
|
disabled: !1,
|
|
4033
|
-
onSelect: () => p(
|
|
4033
|
+
onSelect: () => p(h),
|
|
4034
4034
|
className: "flex items-center justify-between",
|
|
4035
4035
|
children: [
|
|
4036
4036
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-x-2", children: [
|
|
4037
|
-
startsWith(
|
|
4038
|
-
startsWith(
|
|
4037
|
+
startsWith(h.key, REPEATER_PREFIX) ? /* @__PURE__ */ jsx(LoopIcon, {}) : startsWith(h.key, COLLECTION_PREFIX) ? /* @__PURE__ */ jsx(DatabaseIcon, {}) : null,
|
|
4038
|
+
startsWith(h.key, REPEATER_PREFIX) ? "Repeater Data" : startsWith(h.key, COLLECTION_PREFIX) ? h.key.replace(COLLECTION_PREFIX, "") : h.key
|
|
4039
4039
|
] }),
|
|
4040
4040
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4041
|
-
r === "object" &&
|
|
4041
|
+
r === "object" && h.type === "object" && /* @__PURE__ */ jsx(
|
|
4042
4042
|
Button,
|
|
4043
4043
|
{
|
|
4044
4044
|
size: "sm",
|
|
4045
4045
|
variant: "ghost",
|
|
4046
4046
|
className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
|
|
4047
|
-
onClick: (
|
|
4048
|
-
|
|
4047
|
+
onClick: (m) => {
|
|
4048
|
+
m.stopPropagation(), n([...a, h.key].join("."), r);
|
|
4049
4049
|
},
|
|
4050
4050
|
children: "Select"
|
|
4051
4051
|
}
|
|
4052
4052
|
),
|
|
4053
|
-
|
|
4053
|
+
h.type === "object" && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 opacity-50" }) })
|
|
4054
4054
|
] })
|
|
4055
4055
|
]
|
|
4056
4056
|
},
|
|
4057
|
-
|
|
4057
|
+
h.key
|
|
4058
4058
|
))
|
|
4059
4059
|
] })
|
|
4060
4060
|
] })
|
|
@@ -4106,18 +4106,18 @@ const DataBindingSelector = ({
|
|
|
4106
4106
|
}) => {
|
|
4107
4107
|
const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => {
|
|
4108
4108
|
if (i.length === 1) return "";
|
|
4109
|
-
const g = i.find((x) => x._type === "Repeater"),
|
|
4110
|
-
return `${REPEATER_PREFIX}${startsWith(
|
|
4109
|
+
const g = i.find((x) => x._type === "Repeater"), m = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
|
|
4110
|
+
return `${REPEATER_PREFIX}${startsWith(m, COLLECTION_PREFIX) ? `${m}/${g._id}` : m}`;
|
|
4111
4111
|
}, [i]), p = useMemo(() => first(get(l, d.replace(REPEATER_PREFIX, ""), [])), [d, l]), u = useCallback(
|
|
4112
|
-
(g,
|
|
4113
|
-
if (g = isEmpty(d) ? g : g.replace(`${d}`, "$index"),
|
|
4112
|
+
(g, h) => {
|
|
4113
|
+
if (g = isEmpty(d) ? g : g.replace(`${d}`, "$index"), h === "array" || h === "object") {
|
|
4114
4114
|
n(`{{${g}}}`, {}, r);
|
|
4115
4115
|
return;
|
|
4116
4116
|
}
|
|
4117
|
-
const
|
|
4117
|
+
const m = (b) => /[.,!?;:]/.test(b), x = (b, v, B) => {
|
|
4118
4118
|
let w = "", _ = "";
|
|
4119
4119
|
const E = v > 0 ? b[v - 1] : "", S = v < b.length ? b[v] : "";
|
|
4120
|
-
return v > 0 && (E === "." || !
|
|
4120
|
+
return v > 0 && (E === "." || !m(E) && E !== " ") && (w = " "), v < b.length && !m(S) && S !== " " && (_ = " "), {
|
|
4121
4121
|
text: w + B + _,
|
|
4122
4122
|
prefixLength: w.length,
|
|
4123
4123
|
suffixLength: _.length
|
|
@@ -4136,9 +4136,9 @@ const DataBindingSelector = ({
|
|
|
4136
4136
|
else {
|
|
4137
4137
|
const { state: E } = b, S = E.selection.from, A = E.doc.textBetween(Math.max(0, S - 1), S), N = E.doc.textBetween(S, Math.min(S + 1, E.doc.content.size));
|
|
4138
4138
|
let C = "";
|
|
4139
|
-
S > 0 && A !== " " && !
|
|
4139
|
+
S > 0 && A !== " " && !m(A) && (C = " ");
|
|
4140
4140
|
let k = "";
|
|
4141
|
-
N && N !== " " && !
|
|
4141
|
+
N && N !== " " && !m(N) && (k = " "), b.chain().insertContent(C + v + k).run();
|
|
4142
4142
|
}
|
|
4143
4143
|
setTimeout(() => n(b.getHTML(), {}, r), 100);
|
|
4144
4144
|
return;
|
|
@@ -4173,13 +4173,13 @@ const DataBindingSelector = ({
|
|
|
4173
4173
|
onChange: r
|
|
4174
4174
|
}) => {
|
|
4175
4175
|
var N;
|
|
4176
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [
|
|
4176
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [x, f] = useState([]), [y, b] = useState(-1), v = useRef(null), B = (N = n == null ? void 0 : n.find((C) => C.key === u)) == null ? void 0 : N.name;
|
|
4177
4177
|
useEffect(() => {
|
|
4178
|
-
if (
|
|
4178
|
+
if (m(""), f([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4179
4179
|
const C = split(o, ":"), k = get(C, 1, "page") || "page";
|
|
4180
4180
|
g(k), (async () => {
|
|
4181
4181
|
const j = await l(k, [get(C, 2, "page")]);
|
|
4182
|
-
j && Array.isArray(j) &&
|
|
4182
|
+
j && Array.isArray(j) && m(get(j, [0, "name"], ""));
|
|
4183
4183
|
})();
|
|
4184
4184
|
}, [o]);
|
|
4185
4185
|
const w = useDebouncedCallback(
|
|
@@ -4196,7 +4196,7 @@ const DataBindingSelector = ({
|
|
|
4196
4196
|
300
|
|
4197
4197
|
), _ = (C) => {
|
|
4198
4198
|
const k = ["pageType", u, C.id];
|
|
4199
|
-
k[1] && (r(k.join(":")),
|
|
4199
|
+
k[1] && (r(k.join(":")), m(C.name), p(!1), f([]), b(-1));
|
|
4200
4200
|
}, E = (C) => {
|
|
4201
4201
|
switch (C.key) {
|
|
4202
4202
|
case "ArrowDown":
|
|
@@ -4221,9 +4221,9 @@ const DataBindingSelector = ({
|
|
|
4221
4221
|
}
|
|
4222
4222
|
}, [y]);
|
|
4223
4223
|
const S = () => {
|
|
4224
|
-
|
|
4224
|
+
m(""), f([]), b(-1), p(!1), r("");
|
|
4225
4225
|
}, A = (C) => {
|
|
4226
|
-
|
|
4226
|
+
m(C), p(!isEmpty(C)), c(!0), w(C);
|
|
4227
4227
|
};
|
|
4228
4228
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4229
4229
|
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (C) => g(C.target.value), children: map(n, (C) => /* @__PURE__ */ jsx("option", { value: C.key, children: C.name }, C.key)) }),
|
|
@@ -4232,14 +4232,14 @@ const DataBindingSelector = ({
|
|
|
4232
4232
|
"input",
|
|
4233
4233
|
{
|
|
4234
4234
|
type: "text",
|
|
4235
|
-
value:
|
|
4235
|
+
value: h,
|
|
4236
4236
|
onChange: (C) => A(C.target.value),
|
|
4237
4237
|
onKeyDown: E,
|
|
4238
4238
|
placeholder: a(`Search ${B ?? ""}`),
|
|
4239
4239
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4240
4240
|
}
|
|
4241
4241
|
),
|
|
4242
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children:
|
|
4242
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
|
|
4243
4243
|
] }),
|
|
4244
4244
|
(i || !isEmpty(x) || d && isEmpty(x)) && /* @__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: [
|
|
4245
4245
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
@@ -4247,7 +4247,7 @@ const DataBindingSelector = ({
|
|
|
4247
4247
|
] }) : d && isEmpty(x) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4248
4248
|
a("No results found for"),
|
|
4249
4249
|
' "',
|
|
4250
|
-
|
|
4250
|
+
h,
|
|
4251
4251
|
'"'
|
|
4252
4252
|
] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(x == null ? void 0 : x.slice(0, 20), (C, k) => /* @__PURE__ */ jsxs(
|
|
4253
4253
|
"li",
|
|
@@ -4505,16 +4505,16 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4505
4505
|
const c = useRef(null), d = useRef(a || ""), p = usePageExternalData();
|
|
4506
4506
|
useEffect(() => {
|
|
4507
4507
|
if (o) {
|
|
4508
|
-
const
|
|
4509
|
-
return
|
|
4508
|
+
const h = document.createElement("style");
|
|
4509
|
+
return h.id = "rte-modal-styles", h.innerHTML = `
|
|
4510
4510
|
/* Ensure the NestedPathSelector popover appears above the dialog */
|
|
4511
4511
|
.rte-path-selector + [data-radix-popper-content-wrapper],
|
|
4512
4512
|
[data-radix-popper-content-wrapper] {
|
|
4513
4513
|
z-index: 9999 !important;
|
|
4514
4514
|
}
|
|
4515
|
-
`, document.head.appendChild(
|
|
4516
|
-
const
|
|
4517
|
-
|
|
4515
|
+
`, document.head.appendChild(h), () => {
|
|
4516
|
+
const m = document.getElementById("rte-modal-styles");
|
|
4517
|
+
m && m.remove();
|
|
4518
4518
|
};
|
|
4519
4519
|
}
|
|
4520
4520
|
}, [o]);
|
|
@@ -4539,13 +4539,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4539
4539
|
})
|
|
4540
4540
|
],
|
|
4541
4541
|
content: a || "",
|
|
4542
|
-
onUpdate: ({ editor:
|
|
4543
|
-
const
|
|
4544
|
-
l(
|
|
4542
|
+
onUpdate: ({ editor: h }) => {
|
|
4543
|
+
const m = h.getHTML();
|
|
4544
|
+
l(m);
|
|
4545
4545
|
},
|
|
4546
|
-
onBlur: ({ editor:
|
|
4547
|
-
const
|
|
4548
|
-
i(r,
|
|
4546
|
+
onBlur: ({ editor: h }) => {
|
|
4547
|
+
const m = h.getHTML();
|
|
4548
|
+
i(r, m);
|
|
4549
4549
|
},
|
|
4550
4550
|
editorProps: {
|
|
4551
4551
|
attributes: {
|
|
@@ -4560,22 +4560,22 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4560
4560
|
}, [o, u]), useEffect(() => {
|
|
4561
4561
|
c.current && u && (c.current.__chaiRTE = u);
|
|
4562
4562
|
}, [u, o]);
|
|
4563
|
-
const g = (
|
|
4563
|
+
const g = (h) => {
|
|
4564
4564
|
if (!u) return;
|
|
4565
|
-
const
|
|
4565
|
+
const m = `{{${h}}}`;
|
|
4566
4566
|
u.commands.focus();
|
|
4567
4567
|
const { from: x, to: f } = u.state.selection;
|
|
4568
4568
|
if (x !== f)
|
|
4569
|
-
u.chain().deleteSelection().insertContent(
|
|
4569
|
+
u.chain().deleteSelection().insertContent(m).run();
|
|
4570
4570
|
else {
|
|
4571
4571
|
const { state: b } = u, v = b.selection.from, B = b.doc.textBetween(Math.max(0, v - 1), v), w = b.doc.textBetween(v, Math.min(v + 1, b.doc.content.size));
|
|
4572
4572
|
let _ = "";
|
|
4573
4573
|
v > 0 && B !== " " && !/[.,!?;:]/.test(B) && (_ = " ");
|
|
4574
4574
|
let E = "";
|
|
4575
|
-
w && w !== " " && !/[.,!?;:]/.test(w) && (E = " "), u.chain().insertContent(_ +
|
|
4575
|
+
w && w !== " " && !/[.,!?;:]/.test(w) && (E = " "), u.chain().insertContent(_ + m + E).run();
|
|
4576
4576
|
}
|
|
4577
4577
|
};
|
|
4578
|
-
return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (
|
|
4578
|
+
return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (h) => !h && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
|
|
4579
4579
|
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center justify-between pr-8", children: [
|
|
4580
4580
|
/* @__PURE__ */ jsx("span", { children: "Rich Text Editor" }),
|
|
4581
4581
|
Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -4630,9 +4630,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4630
4630
|
}, [g]), useEffect(() => {
|
|
4631
4631
|
u(r || "");
|
|
4632
4632
|
}, [r]);
|
|
4633
|
-
const
|
|
4633
|
+
const h = (x) => {
|
|
4634
4634
|
a(x);
|
|
4635
|
-
},
|
|
4635
|
+
}, m = () => {
|
|
4636
4636
|
d(!1), g && g.commands.setContent(p);
|
|
4637
4637
|
};
|
|
4638
4638
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -4644,10 +4644,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4644
4644
|
RTEModal,
|
|
4645
4645
|
{
|
|
4646
4646
|
isOpen: c,
|
|
4647
|
-
onClose:
|
|
4647
|
+
onClose: m,
|
|
4648
4648
|
id: o,
|
|
4649
4649
|
value: p,
|
|
4650
|
-
onChange:
|
|
4650
|
+
onChange: h,
|
|
4651
4651
|
onBlur: l
|
|
4652
4652
|
}
|
|
4653
4653
|
)
|
|
@@ -4663,14 +4663,14 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4663
4663
|
}, [a]), useEffect(() => {
|
|
4664
4664
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
|
|
4665
4665
|
}, [o, u]);
|
|
4666
|
-
const
|
|
4666
|
+
const h = () => {
|
|
4667
4667
|
const f = findIndex(u, { _id: g });
|
|
4668
4668
|
if (f > -1) {
|
|
4669
4669
|
const y = (f + 1) % u.length, b = get(u, [y, "_id"]);
|
|
4670
4670
|
if (!b) return;
|
|
4671
4671
|
n({ ...o, currentSlide: b }), c([b]);
|
|
4672
4672
|
}
|
|
4673
|
-
},
|
|
4673
|
+
}, m = () => {
|
|
4674
4674
|
const f = findIndex(u, { _id: g });
|
|
4675
4675
|
if (f > -1) {
|
|
4676
4676
|
const y = (f - 1 + u.length) % u.length, b = get(u, [y, "_id"]);
|
|
@@ -4686,7 +4686,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4686
4686
|
};
|
|
4687
4687
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4688
4688
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
4689
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
4689
|
+
/* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
|
|
4690
4690
|
/* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
|
|
4691
4691
|
/* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
|
|
4692
4692
|
" ",
|
|
@@ -4695,7 +4695,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4695
4695
|
"/",
|
|
4696
4696
|
u.length
|
|
4697
4697
|
] }) : "-" }),
|
|
4698
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
4698
|
+
/* @__PURE__ */ jsx("button", { onClick: h, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
|
|
4699
4699
|
/* @__PURE__ */ jsxs(
|
|
4700
4700
|
"button",
|
|
4701
4701
|
{
|
|
@@ -4773,7 +4773,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4773
4773
|
const r = get(o, "srcsets", []) || [], a = (c, d) => {
|
|
4774
4774
|
const p = c.target.name, u = c.target.value;
|
|
4775
4775
|
n({
|
|
4776
|
-
srcsets: map(r, (g,
|
|
4776
|
+
srcsets: map(r, (g, h) => h === d ? { ...g, [p]: u } : g)
|
|
4777
4777
|
});
|
|
4778
4778
|
}, l = () => {
|
|
4779
4779
|
n({ srcsets: [...r, {}] });
|
|
@@ -4868,11 +4868,11 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4868
4868
|
required: p,
|
|
4869
4869
|
schema: u,
|
|
4870
4870
|
formData: g,
|
|
4871
|
-
onChange:
|
|
4871
|
+
onChange: h
|
|
4872
4872
|
}) => {
|
|
4873
|
-
const { selectedLang:
|
|
4874
|
-
() => isEmpty(f) ? "" : isEmpty(
|
|
4875
|
-
[f,
|
|
4873
|
+
const { selectedLang: m, fallbackLang: x, languages: f } = useLanguages(), y = useMemo(
|
|
4874
|
+
() => isEmpty(f) ? "" : isEmpty(m) ? x : m,
|
|
4875
|
+
[f, m, x]
|
|
4876
4876
|
), b = useMemo(() => get(LANGUAGES, y, y), [y]), v = usePageExternalData(), B = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = useMemo(
|
|
4877
4877
|
() => get(w, [B == null ? void 0 : B._type, "i18nProps"], []),
|
|
4878
4878
|
[w, B == null ? void 0 : B._type]
|
|
@@ -4923,7 +4923,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4923
4923
|
{
|
|
4924
4924
|
schema: u,
|
|
4925
4925
|
onChange: (C) => {
|
|
4926
|
-
|
|
4926
|
+
h(C, g, o);
|
|
4927
4927
|
},
|
|
4928
4928
|
id: o,
|
|
4929
4929
|
formData: g
|
|
@@ -4945,10 +4945,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4945
4945
|
const r = `{{${COLLECTION_PREFIX}`, a = o == null ? void 0 : o.startsWith(r);
|
|
4946
4946
|
let l = o;
|
|
4947
4947
|
return a && (l = (i = o == null ? void 0 : o.replace(r, "")) == null ? void 0 : i.replace("}}", "")), /* @__PURE__ */ jsx("div", { className: "mt-1 flex flex-col gap-1", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 rounded-md border border-blue-200 bg-blue-50 px-2 py-1 text-xs text-blue-600", children: [
|
|
4948
|
-
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2
|
|
4948
|
+
/* @__PURE__ */ jsxs("span", { className: "flex max-w-[200px] items-center gap-2", children: [
|
|
4949
4949
|
" ",
|
|
4950
|
-
a ? /* @__PURE__ */ jsx(Database, { className: "h-
|
|
4951
|
-
|
|
4950
|
+
a ? /* @__PURE__ */ jsx(Database, { className: "h-3 min-h-3 w-3 min-w-3" }) : null,
|
|
4951
|
+
/* @__PURE__ */ jsxs(Tooltip, { delayDuration: 500, children: [
|
|
4952
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-default truncate", children: l }) }),
|
|
4953
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "left", hidden: l.length < 50, children: l })
|
|
4954
|
+
] })
|
|
4952
4955
|
] }),
|
|
4953
4956
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4954
4957
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
@@ -4970,8 +4973,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4970
4973
|
/* @__PURE__ */ jsx("span", { children: "Add" })
|
|
4971
4974
|
] }) }), JSONForm = memo(({ blockId: o, schema: n, uiSchema: r, formData: a, onChange: l }) => {
|
|
4972
4975
|
const { selectedLang: i } = useLanguages(), c = useBlockSettingComponents("widget"), d = useBlockSettingComponents("field"), p = useBlockSettingComponents("template"), u = useThrottledCallback(
|
|
4973
|
-
async ({ formData: g },
|
|
4974
|
-
l({ formData: g },
|
|
4976
|
+
async ({ formData: g }, h) => {
|
|
4977
|
+
l({ formData: g }, h);
|
|
4975
4978
|
},
|
|
4976
4979
|
[l, i],
|
|
4977
4980
|
400
|
|
@@ -5012,10 +5015,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5012
5015
|
uiSchema: r,
|
|
5013
5016
|
schema: n,
|
|
5014
5017
|
formData: a,
|
|
5015
|
-
onChange: ({ formData: g },
|
|
5016
|
-
if (!
|
|
5017
|
-
const
|
|
5018
|
-
u({ formData: g },
|
|
5018
|
+
onChange: ({ formData: g }, h) => {
|
|
5019
|
+
if (!h || o !== (g == null ? void 0 : g._id)) return;
|
|
5020
|
+
const m = take(h.split("."), 2).join(".").replace("root.", "");
|
|
5021
|
+
u({ formData: g }, m);
|
|
5019
5022
|
}
|
|
5020
5023
|
},
|
|
5021
5024
|
i
|
|
@@ -5027,7 +5030,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5027
5030
|
}), a;
|
|
5028
5031
|
};
|
|
5029
5032
|
function BlockSettings() {
|
|
5030
|
-
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(),
|
|
5033
|
+
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(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), x = ({ formData: E }, S, A) => {
|
|
5031
5034
|
S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(E, S) }, A);
|
|
5032
5035
|
}, f = useCallback(
|
|
5033
5036
|
debounce(({ formData: E }, S, A) => {
|
|
@@ -5083,7 +5086,7 @@ function BlockSettings() {
|
|
|
5083
5086
|
{
|
|
5084
5087
|
blockId: g == null ? void 0 : g._id,
|
|
5085
5088
|
onChange: b,
|
|
5086
|
-
formData:
|
|
5089
|
+
formData: m,
|
|
5087
5090
|
schema: w,
|
|
5088
5091
|
uiSchema: _
|
|
5089
5092
|
}
|
|
@@ -5105,56 +5108,50 @@ const BlockStylingProps = () => {
|
|
|
5105
5108
|
const o = useSelectedBlock(), [n, r] = useSelectedStylingBlocks(), { t: a } = useTranslation();
|
|
5106
5109
|
if (!o) return null;
|
|
5107
5110
|
const l = Object.keys(o).filter(
|
|
5108
|
-
(
|
|
5109
|
-
), { reset: i
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
|
|
5116
|
-
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
{
|
|
5123
|
-
className: "flex cursor-pointer items-center gap-1 pr-1",
|
|
5124
|
-
variant: u(g) ? "default" : "secondary",
|
|
5125
|
-
onClick: () => {
|
|
5126
|
-
r([{ id: `${g}-${o._id}`, blockId: o._id, prop: g }]);
|
|
5127
|
-
},
|
|
5128
|
-
children: [
|
|
5129
|
-
startCase(g),
|
|
5130
|
-
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
5131
|
-
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5132
|
-
"button",
|
|
5133
|
-
{
|
|
5134
|
-
type: "button",
|
|
5135
|
-
className: "ml-1 rounded-sm p-0.5 hover:bg-blue-300 hover:text-blue-600",
|
|
5136
|
-
onClick: (m) => m.stopPropagation(),
|
|
5137
|
-
children: /* @__PURE__ */ jsx(MoreVertical, { className: "h-3 w-3" })
|
|
5138
|
-
}
|
|
5139
|
-
) }),
|
|
5140
|
-
/* @__PURE__ */ jsx(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: /* @__PURE__ */ jsx(
|
|
5141
|
-
DropdownMenuItem,
|
|
5142
|
-
{
|
|
5143
|
-
className: "text-xs",
|
|
5144
|
-
onClick: () => {
|
|
5145
|
-
i(g);
|
|
5146
|
-
},
|
|
5147
|
-
children: a("Reset style")
|
|
5148
|
-
}
|
|
5149
|
-
) })
|
|
5150
|
-
] })
|
|
5151
|
-
]
|
|
5111
|
+
(p) => typeof o[p] == "string" && o[p].startsWith("#styles:")
|
|
5112
|
+
), { reset: i } = useResetBlockStyles(), c = !isEmpty(l) && l.length > 1, d = (p) => find(n, (u) => u.prop === p);
|
|
5113
|
+
return /* @__PURE__ */ jsx(Fragment, { children: c && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
|
|
5114
|
+
/* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
|
|
5115
|
+
a("Style element"),
|
|
5116
|
+
":"
|
|
5117
|
+
] }),
|
|
5118
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(l, (p) => /* @__PURE__ */ jsxs(
|
|
5119
|
+
Badge,
|
|
5120
|
+
{
|
|
5121
|
+
className: "flex cursor-pointer items-center gap-1 pr-1",
|
|
5122
|
+
variant: d(p) ? "default" : "secondary",
|
|
5123
|
+
onClick: () => {
|
|
5124
|
+
r([{ id: `${p}-${o._id}`, blockId: o._id, prop: p }]);
|
|
5152
5125
|
},
|
|
5153
|
-
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5126
|
+
children: [
|
|
5127
|
+
startCase(p),
|
|
5128
|
+
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
5129
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5130
|
+
"button",
|
|
5131
|
+
{
|
|
5132
|
+
type: "button",
|
|
5133
|
+
className: "ml-1 rounded-sm p-0.5 hover:bg-blue-300 hover:text-blue-600",
|
|
5134
|
+
onClick: (u) => u.stopPropagation(),
|
|
5135
|
+
children: /* @__PURE__ */ jsx(MoreVertical, { className: "h-3 w-3" })
|
|
5136
|
+
}
|
|
5137
|
+
) }),
|
|
5138
|
+
/* @__PURE__ */ jsx(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: /* @__PURE__ */ jsx(
|
|
5139
|
+
DropdownMenuItem,
|
|
5140
|
+
{
|
|
5141
|
+
className: "text-xs",
|
|
5142
|
+
onClick: () => {
|
|
5143
|
+
i(p);
|
|
5144
|
+
},
|
|
5145
|
+
children: a("Reset style")
|
|
5146
|
+
}
|
|
5147
|
+
) })
|
|
5148
|
+
] })
|
|
5149
|
+
]
|
|
5150
|
+
},
|
|
5151
|
+
p
|
|
5152
|
+
)) }),
|
|
5153
|
+
/* @__PURE__ */ jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
|
|
5154
|
+
] }) });
|
|
5158
5155
|
}, BlockSettingsContext = React__default.createContext({
|
|
5159
5156
|
setDragData: () => {
|
|
5160
5157
|
}
|
|
@@ -5300,14 +5297,14 @@ const BlockStylingProps = () => {
|
|
|
5300
5297
|
},
|
|
5301
5298
|
a
|
|
5302
5299
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
5303
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [
|
|
5300
|
+
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [x, f] = useState(!1), [y, b] = useState(""), [v, B] = useState(!1), [w, _] = useState(!1);
|
|
5304
5301
|
useEffect(() => {
|
|
5305
5302
|
const { value: C, unit: k } = getClassValueAndUnit(i);
|
|
5306
5303
|
if (k === "") {
|
|
5307
|
-
l(C),
|
|
5304
|
+
l(C), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
5308
5305
|
return;
|
|
5309
5306
|
}
|
|
5310
|
-
|
|
5307
|
+
m(k), l(k === "class" || isEmpty(C) ? "" : C);
|
|
5311
5308
|
}, [i, p, u]);
|
|
5312
5309
|
const E = useThrottledCallback((C) => c(C), [c], THROTTLE_TIME), S = useThrottledCallback((C) => c(C, !1), [c], THROTTLE_TIME), A = useCallback(
|
|
5313
5310
|
(C = !1) => {
|
|
@@ -5316,7 +5313,7 @@ const BlockStylingProps = () => {
|
|
|
5316
5313
|
f(!0);
|
|
5317
5314
|
return;
|
|
5318
5315
|
}
|
|
5319
|
-
const j = get(k, "unit") !== "" ? get(k, "unit") :
|
|
5316
|
+
const j = get(k, "unit") !== "" ? get(k, "unit") : h;
|
|
5320
5317
|
if (j === "auto" || j === "none") {
|
|
5321
5318
|
E(`${d}${j}`);
|
|
5322
5319
|
return;
|
|
@@ -5326,7 +5323,7 @@ const BlockStylingProps = () => {
|
|
|
5326
5323
|
const L = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
|
|
5327
5324
|
C ? S(L) : E(L);
|
|
5328
5325
|
},
|
|
5329
|
-
[E, S, a,
|
|
5326
|
+
[E, S, a, h, d, u]
|
|
5330
5327
|
), N = useCallback(
|
|
5331
5328
|
(C) => {
|
|
5332
5329
|
const k = getUserInputValues(`${a}`, u);
|
|
@@ -5345,7 +5342,7 @@ const BlockStylingProps = () => {
|
|
|
5345
5342
|
},
|
|
5346
5343
|
[E, a, d, u]
|
|
5347
5344
|
);
|
|
5348
|
-
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children:
|
|
5345
|
+
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: h === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
5349
5346
|
/* @__PURE__ */ jsx(
|
|
5350
5347
|
"input",
|
|
5351
5348
|
{
|
|
@@ -5360,10 +5357,10 @@ const BlockStylingProps = () => {
|
|
|
5360
5357
|
] })
|
|
5361
5358
|
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${v ? "z-auto" : ""}`, children: [
|
|
5362
5359
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
5363
|
-
["none", "auto"].indexOf(
|
|
5360
|
+
["none", "auto"].indexOf(h) !== -1 ? null : /* @__PURE__ */ jsx(
|
|
5364
5361
|
"input",
|
|
5365
5362
|
{
|
|
5366
|
-
readOnly:
|
|
5363
|
+
readOnly: h === "class",
|
|
5367
5364
|
onKeyPress: (C) => {
|
|
5368
5365
|
C.key === "Enter" && A();
|
|
5369
5366
|
},
|
|
@@ -5374,7 +5371,7 @@ const BlockStylingProps = () => {
|
|
|
5374
5371
|
const k = parseInt$1(C.target.value);
|
|
5375
5372
|
let j = isNaN$1(k) ? 0 : k;
|
|
5376
5373
|
C.keyCode === 38 && (j += 1), C.keyCode === 40 && (j -= 1);
|
|
5377
|
-
const I = `${j}`, R = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${
|
|
5374
|
+
const I = `${j}`, R = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5378
5375
|
S(R);
|
|
5379
5376
|
},
|
|
5380
5377
|
onKeyUp: (C) => {
|
|
@@ -5403,7 +5400,7 @@ const BlockStylingProps = () => {
|
|
|
5403
5400
|
onClick: () => r(!n),
|
|
5404
5401
|
className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
|
|
5405
5402
|
children: [
|
|
5406
|
-
/* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children:
|
|
5403
|
+
/* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: h }),
|
|
5407
5404
|
u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
|
|
5408
5405
|
]
|
|
5409
5406
|
}
|
|
@@ -5412,33 +5409,33 @@ const BlockStylingProps = () => {
|
|
|
5412
5409
|
UnitSelection,
|
|
5413
5410
|
{
|
|
5414
5411
|
units: u,
|
|
5415
|
-
current:
|
|
5412
|
+
current: h,
|
|
5416
5413
|
onSelect: (C) => {
|
|
5417
|
-
r(!1),
|
|
5414
|
+
r(!1), m(C), N(C);
|
|
5418
5415
|
}
|
|
5419
5416
|
}
|
|
5420
5417
|
) })
|
|
5421
5418
|
] })
|
|
5422
5419
|
] }),
|
|
5423
|
-
["none", "auto"].indexOf(
|
|
5420
|
+
["none", "auto"].indexOf(h) !== -1 || v ? null : /* @__PURE__ */ jsx(
|
|
5424
5421
|
DragStyleButton,
|
|
5425
5422
|
{
|
|
5426
5423
|
onDragStart: () => B(!0),
|
|
5427
5424
|
onDragEnd: (C) => {
|
|
5428
5425
|
if (b(() => ""), B(!1), isEmpty(C))
|
|
5429
5426
|
return;
|
|
5430
|
-
const k = `${C}`, I = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${
|
|
5427
|
+
const k = `${C}`, I = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5431
5428
|
E(I);
|
|
5432
5429
|
},
|
|
5433
5430
|
onDrag: (C) => {
|
|
5434
5431
|
if (isEmpty(C))
|
|
5435
5432
|
return;
|
|
5436
5433
|
b(C);
|
|
5437
|
-
const k = `${C}`, I = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${
|
|
5434
|
+
const k = `${C}`, I = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
5438
5435
|
S(I);
|
|
5439
5436
|
},
|
|
5440
5437
|
currentValue: a,
|
|
5441
|
-
unit:
|
|
5438
|
+
unit: h,
|
|
5442
5439
|
negative: g,
|
|
5443
5440
|
cssProperty: p
|
|
5444
5441
|
}
|
|
@@ -5498,7 +5495,7 @@ const COLOR_PROP = {
|
|
|
5498
5495
|
ringColor: "ring",
|
|
5499
5496
|
ringOffsetColor: "ring-offset"
|
|
5500
5497
|
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
5501
|
-
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", ""),
|
|
5498
|
+
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", ""), h = get(u, "2", ""), m = useCallback(
|
|
5502
5499
|
// eslint-disable-next-line no-shadow
|
|
5503
5500
|
(y) => {
|
|
5504
5501
|
["current", "inherit", "transparent", "black", "white"].includes(y) ? (c([]), p({ color: y })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: y, shade: b.shade ? b.shade : "500" })));
|
|
@@ -5531,7 +5528,7 @@ const COLOR_PROP = {
|
|
|
5531
5528
|
disabled: !l,
|
|
5532
5529
|
rounded: !0,
|
|
5533
5530
|
selected: g,
|
|
5534
|
-
onChange:
|
|
5531
|
+
onChange: m,
|
|
5535
5532
|
options: [
|
|
5536
5533
|
"current",
|
|
5537
5534
|
"transparent",
|
|
@@ -5564,7 +5561,7 @@ const COLOR_PROP = {
|
|
|
5564
5561
|
]
|
|
5565
5562
|
}
|
|
5566
5563
|
) }),
|
|
5567
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected:
|
|
5564
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange: x, options: i }) })
|
|
5568
5565
|
] });
|
|
5569
5566
|
}, EDITOR_ICONS = {
|
|
5570
5567
|
"not-italic": () => /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M9 3H11V5H9V11H11V13H5V11H7V5H5V3H9Z", fill: "white" }) }),
|
|
@@ -5898,20 +5895,20 @@ const COLOR_PROP = {
|
|
|
5898
5895
|
"2xl": "1536px"
|
|
5899
5896
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
5900
5897
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
5901
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(),
|
|
5898
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), x = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), y = useMemo(() => get(h, "fullCls", ""), [h]), b = useCallback(
|
|
5902
5899
|
(S, A = !0) => {
|
|
5903
5900
|
const N = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
|
|
5904
5901
|
(p || u !== "") && (N.mq = "xs");
|
|
5905
5902
|
const C = generateFullClsName(N);
|
|
5906
|
-
|
|
5903
|
+
m(f, [C], A);
|
|
5907
5904
|
},
|
|
5908
|
-
[f, p, g, u, l,
|
|
5905
|
+
[f, p, g, u, l, m]
|
|
5909
5906
|
), v = useCallback(() => {
|
|
5910
5907
|
x(f, [y], !0);
|
|
5911
|
-
}, [f, y, x]), B = useMemo(() => canChangeClass(
|
|
5908
|
+
}, [f, y, x]), B = useMemo(() => canChangeClass(h, g), [h, g]);
|
|
5912
5909
|
useEffect(() => {
|
|
5913
|
-
i(B,
|
|
5914
|
-
}, [B, i,
|
|
5910
|
+
i(B, h);
|
|
5911
|
+
}, [B, i, h]);
|
|
5915
5912
|
const [, , w] = useScreenSizeWidth(), _ = useCallback(
|
|
5916
5913
|
(S) => {
|
|
5917
5914
|
w({
|
|
@@ -5924,15 +5921,15 @@ const COLOR_PROP = {
|
|
|
5924
5921
|
}[S]);
|
|
5925
5922
|
},
|
|
5926
5923
|
[w]
|
|
5927
|
-
), E = get(
|
|
5928
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset:
|
|
5929
|
-
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${
|
|
5924
|
+
), E = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
|
|
5925
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: h && E, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
5926
|
+
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !E ? "text-foreground" : ""}`, children: n(a) }) }),
|
|
5930
5927
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
5931
5928
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
5932
5929
|
r === "arbitrary" ? /* @__PURE__ */ jsx(
|
|
5933
5930
|
AdvanceChoices,
|
|
5934
5931
|
{
|
|
5935
|
-
currentClass: get(
|
|
5932
|
+
currentClass: get(h, "cls", ""),
|
|
5936
5933
|
classPrefix: get(CLASS_PREFIXES, l, ""),
|
|
5937
5934
|
units: c || [],
|
|
5938
5935
|
onChange: b,
|
|
@@ -5945,7 +5942,7 @@ const COLOR_PROP = {
|
|
|
5945
5942
|
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
|
|
5946
5943
|
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
|
|
5947
5944
|
] }),
|
|
5948
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: E ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B &&
|
|
5945
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: E ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
5949
5946
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5950
5947
|
"button",
|
|
5951
5948
|
{
|
|
@@ -5957,19 +5954,19 @@ const COLOR_PROP = {
|
|
|
5957
5954
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
5958
5955
|
"Current style is set at ",
|
|
5959
5956
|
/* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
|
|
5960
|
-
getBreakpoint(get(
|
|
5961
|
-
p && !
|
|
5957
|
+
getBreakpoint(get(h, "mq")),
|
|
5958
|
+
p && !h.dark ? "(Light mode)" : ""
|
|
5962
5959
|
] }),
|
|
5963
5960
|
/* @__PURE__ */ jsx("br", {}),
|
|
5964
5961
|
/* @__PURE__ */ jsxs(
|
|
5965
5962
|
"button",
|
|
5966
5963
|
{
|
|
5967
5964
|
type: "button",
|
|
5968
|
-
onClick: () => _(get(
|
|
5965
|
+
onClick: () => _(get(h, "mq")),
|
|
5969
5966
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
5970
5967
|
children: [
|
|
5971
5968
|
"Switch to ",
|
|
5972
|
-
get(
|
|
5969
|
+
get(h, "mq").toUpperCase()
|
|
5973
5970
|
]
|
|
5974
5971
|
}
|
|
5975
5972
|
)
|
|
@@ -5986,7 +5983,7 @@ const COLOR_PROP = {
|
|
|
5986
5983
|
units: i = basicUnits,
|
|
5987
5984
|
negative: c = !1
|
|
5988
5985
|
}) => {
|
|
5989
|
-
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(),
|
|
5986
|
+
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), h = useCallback((m) => map(g, "property").includes(m), [g]);
|
|
5990
5987
|
return /* @__PURE__ */ jsxs(
|
|
5991
5988
|
"div",
|
|
5992
5989
|
{
|
|
@@ -5994,7 +5991,7 @@ const COLOR_PROP = {
|
|
|
5994
5991
|
children: [
|
|
5995
5992
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
5996
5993
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
5997
|
-
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label:
|
|
5994
|
+
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: m, key: x }, f) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5998
5995
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
5999
5996
|
"button",
|
|
6000
5997
|
{
|
|
@@ -6003,13 +6000,13 @@ const COLOR_PROP = {
|
|
|
6003
6000
|
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${x === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6004
6001
|
children: [
|
|
6005
6002
|
React__default.createElement("div", {
|
|
6006
|
-
className:
|
|
6003
|
+
className: h(x) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6007
6004
|
}),
|
|
6008
6005
|
React__default.createElement(get(EDITOR_ICONS, x, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6009
6006
|
]
|
|
6010
6007
|
}
|
|
6011
6008
|
) }),
|
|
6012
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(
|
|
6009
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(m)) })
|
|
6013
6010
|
] }) }, `option-${f}`)) })
|
|
6014
6011
|
] }),
|
|
6015
6012
|
/* @__PURE__ */ jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsx(
|
|
@@ -6165,12 +6162,12 @@ const COLOR_PROP = {
|
|
|
6165
6162
|
canvas: n = !1,
|
|
6166
6163
|
tooltip: r = !0
|
|
6167
6164
|
}) => {
|
|
6168
|
-
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t:
|
|
6165
|
+
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), x = (b) => {
|
|
6169
6166
|
u.includes(b) ? u.length > 2 && g(u.filter((v) => v !== b)) : g((v) => [...v, b]);
|
|
6170
6167
|
}, f = (b) => {
|
|
6171
6168
|
n || l(b), c(b);
|
|
6172
6169
|
}, y = getBreakpointValue(n ? i : a).toLowerCase();
|
|
6173
|
-
return
|
|
6170
|
+
return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (b) => /* @__PURE__ */ createElement(
|
|
6174
6171
|
BreakpointCard,
|
|
6175
6172
|
{
|
|
6176
6173
|
canvas: n,
|
|
@@ -6181,7 +6178,7 @@ const COLOR_PROP = {
|
|
|
6181
6178
|
}
|
|
6182
6179
|
)) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
|
|
6183
6180
|
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
|
|
6184
|
-
|
|
6181
|
+
m.filter((b) => includes(u, toUpper(b.breakpoint))),
|
|
6185
6182
|
(b) => /* @__PURE__ */ createElement(
|
|
6186
6183
|
BreakpointCard,
|
|
6187
6184
|
{
|
|
@@ -6198,15 +6195,15 @@ const COLOR_PROP = {
|
|
|
6198
6195
|
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
6199
6196
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-pointer px-2.5 hover:opacity-80", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "scale-90 transform" }) }) }),
|
|
6200
6197
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
|
|
6201
|
-
/* @__PURE__ */ jsx(DropdownMenuLabel, { children:
|
|
6198
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: h("Screen sizes") }),
|
|
6202
6199
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
6203
|
-
map(
|
|
6200
|
+
map(m, (b) => /* @__PURE__ */ jsx(
|
|
6204
6201
|
DropdownMenuCheckboxItem,
|
|
6205
6202
|
{
|
|
6206
6203
|
disabled: b.breakpoint === "xs",
|
|
6207
6204
|
onCheckedChange: () => x(toUpper(b.breakpoint)),
|
|
6208
6205
|
checked: includes(u, toUpper(b.breakpoint)),
|
|
6209
|
-
children:
|
|
6206
|
+
children: h(b.title)
|
|
6210
6207
|
},
|
|
6211
6208
|
b.breakpoint
|
|
6212
6209
|
))
|
|
@@ -6285,11 +6282,11 @@ function Countdown() {
|
|
|
6285
6282
|
const AskAIStyles = ({ blockId: o }) => {
|
|
6286
6283
|
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
|
|
6287
6284
|
useEffect(() => {
|
|
6288
|
-
var
|
|
6289
|
-
(
|
|
6285
|
+
var m;
|
|
6286
|
+
(m = d.current) == null || m.focus();
|
|
6290
6287
|
}, []);
|
|
6291
|
-
const
|
|
6292
|
-
const { usage: x } =
|
|
6288
|
+
const h = (m) => {
|
|
6289
|
+
const { usage: x } = m || {};
|
|
6293
6290
|
!l && x && g(x), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
6294
6291
|
};
|
|
6295
6292
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
@@ -6299,12 +6296,12 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6299
6296
|
{
|
|
6300
6297
|
ref: d,
|
|
6301
6298
|
value: i,
|
|
6302
|
-
onChange: (
|
|
6299
|
+
onChange: (m) => c(m.target.value),
|
|
6303
6300
|
placeholder: n("Ask AI to edit styles"),
|
|
6304
6301
|
className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
|
|
6305
6302
|
rows: 4,
|
|
6306
|
-
onKeyDown: (
|
|
6307
|
-
|
|
6303
|
+
onKeyDown: (m) => {
|
|
6304
|
+
m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, h));
|
|
6308
6305
|
}
|
|
6309
6306
|
}
|
|
6310
6307
|
),
|
|
@@ -6314,7 +6311,7 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6314
6311
|
{
|
|
6315
6312
|
disabled: i.trim().length < 5 || a,
|
|
6316
6313
|
onClick: () => {
|
|
6317
|
-
p.current && clearTimeout(p.current), g(void 0), r("styles", o, i,
|
|
6314
|
+
p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, h);
|
|
6318
6315
|
},
|
|
6319
6316
|
variant: "default",
|
|
6320
6317
|
className: "w-fit",
|
|
@@ -6346,9 +6343,9 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
6346
6343
|
};
|
|
6347
6344
|
function ManualClasses() {
|
|
6348
6345
|
var I;
|
|
6349
|
-
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [
|
|
6346
|
+
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [x, f] = useState(""), y = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), v = b.split(" ").filter((L) => !isEmpty(L)), B = () => {
|
|
6350
6347
|
const L = x.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6351
|
-
u(
|
|
6348
|
+
u(h, L, !0), f("");
|
|
6352
6349
|
}, [w, _] = useState([]), E = ({ value: L }) => {
|
|
6353
6350
|
const R = L.trim().toLowerCase(), T = R.match(/.+:/g);
|
|
6354
6351
|
let D = [];
|
|
@@ -6387,7 +6384,7 @@ function ManualClasses() {
|
|
|
6387
6384
|
), k = (L) => {
|
|
6388
6385
|
debugger;
|
|
6389
6386
|
const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
6390
|
-
g(
|
|
6387
|
+
g(h, [L]), u(h, R, !0), r(""), l(-1);
|
|
6391
6388
|
}, j = () => {
|
|
6392
6389
|
if (navigator.clipboard === void 0) {
|
|
6393
6390
|
toast.error(c("Clipboard not supported"));
|
|
@@ -6404,7 +6401,7 @@ function ManualClasses() {
|
|
|
6404
6401
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
|
|
6405
6402
|
] })
|
|
6406
6403
|
] }),
|
|
6407
|
-
|
|
6404
|
+
m ? /* @__PURE__ */ jsxs(Popover, { children: [
|
|
6408
6405
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
|
|
6409
6406
|
/* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4" }),
|
|
6410
6407
|
/* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
|
|
@@ -6469,7 +6466,7 @@ function ManualClasses() {
|
|
|
6469
6466
|
"button",
|
|
6470
6467
|
{
|
|
6471
6468
|
onDoubleClick: () => {
|
|
6472
|
-
f(L), g(
|
|
6469
|
+
f(L), g(h, [L]), setTimeout(() => {
|
|
6473
6470
|
o.current && o.current.focus();
|
|
6474
6471
|
}, 10);
|
|
6475
6472
|
},
|
|
@@ -6479,7 +6476,7 @@ function ManualClasses() {
|
|
|
6479
6476
|
n !== L && /* @__PURE__ */ jsx(
|
|
6480
6477
|
Cross2Icon,
|
|
6481
6478
|
{
|
|
6482
|
-
onClick: () => g(
|
|
6479
|
+
onClick: () => g(h, [L], !0),
|
|
6483
6480
|
className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
|
|
6484
6481
|
}
|
|
6485
6482
|
)
|
|
@@ -6599,13 +6596,13 @@ function BlockStyling() {
|
|
|
6599
6596
|
cssProperty: ""
|
|
6600
6597
|
}), d = useThrottledCallback(
|
|
6601
6598
|
(u) => {
|
|
6602
|
-
const g = !get(i, "negative", !1),
|
|
6603
|
-
let
|
|
6604
|
-
|
|
6599
|
+
const g = !get(i, "negative", !1), h = get(i, "cssProperty", "");
|
|
6600
|
+
let m = parseFloat(i.dragStartValue);
|
|
6601
|
+
m = isNaN(m) ? 0 : m;
|
|
6605
6602
|
let x = MAPPER[i.dragUnit];
|
|
6606
|
-
(startsWith(
|
|
6607
|
-
let y = (i.dragStartY - u.pageY) / x +
|
|
6608
|
-
g && y < 0 && (y = 0),
|
|
6603
|
+
(startsWith(h, "scale") || h === "opacity") && (x = 10);
|
|
6604
|
+
let y = (i.dragStartY - u.pageY) / x + m;
|
|
6605
|
+
g && y < 0 && (y = 0), h === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
|
|
6609
6606
|
},
|
|
6610
6607
|
[i],
|
|
6611
6608
|
50
|
|
@@ -6646,7 +6643,7 @@ const CoreBlock = ({
|
|
|
6646
6643
|
parentId: r,
|
|
6647
6644
|
position: a
|
|
6648
6645
|
}) => {
|
|
6649
|
-
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight:
|
|
6646
|
+
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
|
|
6650
6647
|
if (has(o, "blocks")) {
|
|
6651
6648
|
const y = isFunction(o.blocks) ? o.blocks() : o.blocks;
|
|
6652
6649
|
u(syncBlocksWithDefaults(y), r || null, a);
|
|
@@ -6659,11 +6656,11 @@ const CoreBlock = ({
|
|
|
6659
6656
|
"button",
|
|
6660
6657
|
{
|
|
6661
6658
|
disabled: n,
|
|
6662
|
-
onClick:
|
|
6659
|
+
onClick: m,
|
|
6663
6660
|
type: "button",
|
|
6664
6661
|
onDragStart: (y) => {
|
|
6665
6662
|
y.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), y.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
6666
|
-
g([]),
|
|
6663
|
+
g([]), h();
|
|
6667
6664
|
}, 200);
|
|
6668
6665
|
},
|
|
6669
6666
|
draggable: x ? "true" : "false",
|
|
@@ -6862,7 +6859,7 @@ const CoreBlock = ({
|
|
|
6862
6859
|
}
|
|
6863
6860
|
}
|
|
6864
6861
|
}, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
|
|
6865
|
-
var
|
|
6862
|
+
var h, m, x, f, y, b, v, B;
|
|
6866
6863
|
if (r.type === "comment") return [];
|
|
6867
6864
|
let a = { _id: generateUUID() };
|
|
6868
6865
|
if (n && (a._parent = n.block._id), r.type === "text")
|
|
@@ -6902,8 +6899,8 @@ const CoreBlock = ({
|
|
|
6902
6899
|
];
|
|
6903
6900
|
a = {
|
|
6904
6901
|
...a,
|
|
6905
|
-
href: ((
|
|
6906
|
-
hrefType: ((
|
|
6902
|
+
href: ((h = l.find((_) => _.key === "href")) == null ? void 0 : h.value) || "",
|
|
6903
|
+
hrefType: ((m = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
|
|
6907
6904
|
autoplay: ((x = l.find((_) => _.key === "data-autoplay")) == null ? void 0 : x.value) === "true" ? "true" : "false",
|
|
6908
6905
|
maxWidth: ((y = (f = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : f.value) == null ? void 0 : y.replace("px", "")) || "",
|
|
6909
6906
|
backdropColor: ((b = l.find((_) => _.key === "data-overlay")) == null ? void 0 : b.value) || "",
|
|
@@ -7046,7 +7043,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7046
7043
|
parentId: r = void 0,
|
|
7047
7044
|
position: a = -1
|
|
7048
7045
|
}) => {
|
|
7049
|
-
const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(),
|
|
7046
|
+
const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), y = (B) => {
|
|
7050
7047
|
const w = has(B, "styles_attrs.data-page-section");
|
|
7051
7048
|
return B._type === "Box" && w;
|
|
7052
7049
|
}, b = useCallback(
|
|
@@ -7093,20 +7090,20 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7093
7090
|
/* @__PURE__ */ jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
|
|
7094
7091
|
/* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
|
|
7095
7092
|
] }),
|
|
7096
|
-
o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt:
|
|
7097
|
-
/* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children:
|
|
7098
|
-
|
|
7093
|
+
o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: h }) : /* @__PURE__ */ jsxs("div", { className: "flex h-fit w-full flex-col items-center justify-center gap-1 rounded-md border border-border p-6 py-10 text-center", children: [
|
|
7094
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children: h }),
|
|
7095
|
+
m && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-600", children: m })
|
|
7099
7096
|
] })
|
|
7100
7097
|
]
|
|
7101
7098
|
}
|
|
7102
7099
|
) }),
|
|
7103
7100
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsxs("div", { className: "max-w-xs", children: [
|
|
7104
|
-
/* @__PURE__ */ jsx("p", { className: "font-medium", children:
|
|
7105
|
-
|
|
7101
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium", children: h }),
|
|
7102
|
+
m && o.preview && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-primary-foreground", children: m })
|
|
7106
7103
|
] }) })
|
|
7107
7104
|
] });
|
|
7108
7105
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
7109
|
-
const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((k) => k.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [
|
|
7106
|
+
const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((k) => k.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]), x = useRef(null);
|
|
7110
7107
|
useEffect(() => {
|
|
7111
7108
|
c && c.length > 0 && (x.current = new Fuse(c, {
|
|
7112
7109
|
keys: ["name", "label", "description", "group"],
|
|
@@ -7115,13 +7112,13 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7115
7112
|
}));
|
|
7116
7113
|
}, [c]), useEffect(() => {
|
|
7117
7114
|
if (!u.trim() || !x.current) {
|
|
7118
|
-
|
|
7115
|
+
m([]);
|
|
7119
7116
|
return;
|
|
7120
7117
|
}
|
|
7121
7118
|
const k = x.current.search(u).map((j) => j.item);
|
|
7122
|
-
|
|
7119
|
+
m(k);
|
|
7123
7120
|
}, [u]);
|
|
7124
|
-
const f = u.trim() && !isEmpty(
|
|
7121
|
+
const f = u.trim() && !isEmpty(h) ? h : c, y = groupBy(f, "group"), [b, v] = useState(null);
|
|
7125
7122
|
useEffect(() => {
|
|
7126
7123
|
if (isEmpty(keys(y))) {
|
|
7127
7124
|
v(null);
|
|
@@ -7261,7 +7258,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7261
7258
|
error: c
|
|
7262
7259
|
}), g(!0);
|
|
7263
7260
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7264
|
-
const
|
|
7261
|
+
const m = Object.entries(a).map(([f, y]) => {
|
|
7265
7262
|
const b = y, v = b.type || "partial", B = formatReadableName(v);
|
|
7266
7263
|
return {
|
|
7267
7264
|
type: "PartialBlock",
|
|
@@ -7276,14 +7273,14 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7276
7273
|
// Store the original ID as partialBlockId
|
|
7277
7274
|
_name: b.name
|
|
7278
7275
|
};
|
|
7279
|
-
}), x = uniq(map(
|
|
7276
|
+
}), x = uniq(map(m, "group"));
|
|
7280
7277
|
p({
|
|
7281
|
-
blocks:
|
|
7278
|
+
blocks: m,
|
|
7282
7279
|
groups: x,
|
|
7283
7280
|
isLoading: !1,
|
|
7284
7281
|
error: null
|
|
7285
7282
|
}), g(!0);
|
|
7286
|
-
} else l ? p((
|
|
7283
|
+
} else l ? p((m) => ({ ...m, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
|
|
7287
7284
|
blocks: [],
|
|
7288
7285
|
groups: [],
|
|
7289
7286
|
isLoading: !1,
|
|
@@ -7298,15 +7295,15 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7298
7295
|
d.blocks,
|
|
7299
7296
|
c
|
|
7300
7297
|
]);
|
|
7301
|
-
const
|
|
7302
|
-
p((
|
|
7298
|
+
const h = () => {
|
|
7299
|
+
p((m) => ({ ...m, isLoading: !0, error: null })), g(!1), i();
|
|
7303
7300
|
};
|
|
7304
7301
|
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: [
|
|
7305
7302
|
/* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
|
|
7306
7303
|
/* @__PURE__ */ jsx(
|
|
7307
7304
|
"button",
|
|
7308
7305
|
{
|
|
7309
|
-
onClick:
|
|
7306
|
+
onClick: h,
|
|
7310
7307
|
className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
|
|
7311
7308
|
children: "Refresh"
|
|
7312
7309
|
}
|
|
@@ -7325,7 +7322,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7325
7322
|
has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...n });
|
|
7326
7323
|
}, 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" }) => {
|
|
7327
7324
|
var C;
|
|
7328
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom),
|
|
7325
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (C = find(c, (k) => k._id === r)) == null ? void 0 : C._type, [m, x] = useState("all"), [f, y] = useState(null), b = useRef(null);
|
|
7329
7326
|
useEffect(() => {
|
|
7330
7327
|
const k = setTimeout(() => {
|
|
7331
7328
|
var j;
|
|
@@ -7361,7 +7358,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7361
7358
|
), S = useMemo(
|
|
7362
7359
|
() => sortBy(E, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
|
|
7363
7360
|
[E]
|
|
7364
|
-
), A = useMemo(() =>
|
|
7361
|
+
), A = useMemo(() => m === "all" ? _ : filter(values(_), { group: m }), [_, m]), N = useMemo(() => m === "all" ? S : [m], [S, m]);
|
|
7365
7362
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7366
7363
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7367
7364
|
Input$1,
|
|
@@ -7382,7 +7379,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7382
7379
|
onClick: () => w("all"),
|
|
7383
7380
|
onMouseEnter: () => v("all"),
|
|
7384
7381
|
onMouseLeave: B,
|
|
7385
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${
|
|
7382
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" || f === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7386
7383
|
children: i("All")
|
|
7387
7384
|
},
|
|
7388
7385
|
"sidebar-all"
|
|
@@ -7393,7 +7390,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7393
7390
|
onClick: () => w(k),
|
|
7394
7391
|
onMouseEnter: () => v(k),
|
|
7395
7392
|
onMouseLeave: B,
|
|
7396
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${
|
|
7393
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === k || f === k ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
|
|
7397
7394
|
children: capitalize(i(k.toLowerCase()))
|
|
7398
7395
|
},
|
|
7399
7396
|
`sidebar-${k}`
|
|
@@ -7407,7 +7404,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7407
7404
|
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: N.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7408
7405
|
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
|
|
7409
7406
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
|
|
7410
|
-
|
|
7407
|
+
m === "all" ? filter(values(A), { group: k }) : values(A),
|
|
7411
7408
|
{ hidden: !0 }
|
|
7412
7409
|
).map((j) => /* @__PURE__ */ jsx(
|
|
7413
7410
|
CoreBlock,
|
|
@@ -7415,7 +7412,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7415
7412
|
parentId: r,
|
|
7416
7413
|
position: a,
|
|
7417
7414
|
block: j,
|
|
7418
|
-
disabled: !canAcceptChildBlock(
|
|
7415
|
+
disabled: !canAcceptChildBlock(h, j.type) || !canBeNestedInside(h, j.type)
|
|
7419
7416
|
},
|
|
7420
7417
|
j.type
|
|
7421
7418
|
)) })
|
|
@@ -7428,13 +7425,13 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7428
7425
|
parentId: r = void 0,
|
|
7429
7426
|
position: a = -1
|
|
7430
7427
|
}) => {
|
|
7431
|
-
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(), g = Object.keys(u || {}).length > 0, { hasPermission:
|
|
7428
|
+
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(), g = Object.keys(u || {}).length > 0, { hasPermission: h } = usePermissions();
|
|
7432
7429
|
useEffect(() => {
|
|
7433
7430
|
i === "partials" && !g && c("library");
|
|
7434
7431
|
}, [i, g, c]);
|
|
7435
|
-
const
|
|
7432
|
+
const m = useCallback(() => {
|
|
7436
7433
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7437
|
-
}, []), x = useChaiAddBlockTabs(), f = p &&
|
|
7434
|
+
}, []), x = useChaiAddBlockTabs(), f = p && h(PERMISSIONS.IMPORT_HTML), b = useChaiLibraries().length > 0;
|
|
7438
7435
|
return useEffect(() => {
|
|
7439
7436
|
i === "library" && !b && c("core");
|
|
7440
7437
|
}, [i, b, c]), /* @__PURE__ */ jsxs("div", { className: cn$2("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
@@ -7462,7 +7459,7 @@ const registerChaiLibrary = (o, n) => {
|
|
|
7462
7459
|
b && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
|
|
7463
7460
|
g && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
|
|
7464
7461
|
f ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
|
|
7465
|
-
map(x, (v) => /* @__PURE__ */ jsx(TabsContent, { value: v.id, children: React__default.createElement(v.tabContent, { close:
|
|
7462
|
+
map(x, (v) => /* @__PURE__ */ jsx(TabsContent, { value: v.id, children: React__default.createElement(v.tabContent, { close: m, parentId: r, position: a }) }, `panel-add-block-${v.id}`))
|
|
7466
7463
|
]
|
|
7467
7464
|
}
|
|
7468
7465
|
)
|
|
@@ -7584,7 +7581,7 @@ const registerChaiSaveToLibrary = (o) => {
|
|
|
7584
7581
|
}, CANNOT_COPY_BLOCKS = !navigator.clipboard, CopyPasteBlocks = () => {
|
|
7585
7582
|
const [o] = useBlocksStore(), [n] = useSelectedBlockIds(), { pasteBlocks: r } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), c = useSelectedBlock(), d = useCallback(() => {
|
|
7586
7583
|
const p = n.map((u) => {
|
|
7587
|
-
const g = o.find((
|
|
7584
|
+
const g = o.find((h) => h._id === u);
|
|
7588
7585
|
return {
|
|
7589
7586
|
id: u,
|
|
7590
7587
|
data: g
|
|
@@ -7769,8 +7766,8 @@ const Input = ({ node: o }) => {
|
|
|
7769
7766
|
var R;
|
|
7770
7767
|
const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
|
|
7771
7768
|
let p = null;
|
|
7772
|
-
const u = o.children.length > 0, { highlightBlock: g, clearHighlight:
|
|
7773
|
-
T.stopPropagation(), !l.includes(
|
|
7769
|
+
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: x, isSelected: f, willReceiveDrop: y, isDragging: b, isEditing: v, handleClick: B } = o, w = (T) => {
|
|
7770
|
+
T.stopPropagation(), !l.includes(m) && o.toggle();
|
|
7774
7771
|
}, _ = (T) => {
|
|
7775
7772
|
T.isInternal && (p = T.isOpen, T.isOpen && T.close());
|
|
7776
7773
|
}, E = (T) => {
|
|
@@ -7781,11 +7778,11 @@ const Input = ({ node: o }) => {
|
|
|
7781
7778
|
}, C = () => {
|
|
7782
7779
|
A(null);
|
|
7783
7780
|
}, k = (T) => {
|
|
7784
|
-
C(), T.stopPropagation(), !o.isOpen && !l.includes(
|
|
7781
|
+
C(), T.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), B(T);
|
|
7785
7782
|
};
|
|
7786
7783
|
useEffect(() => {
|
|
7787
7784
|
const T = setTimeout(() => {
|
|
7788
|
-
y && !o.isOpen && !b && !l.includes(
|
|
7785
|
+
y && !o.isOpen && !b && !l.includes(m) && o.toggle();
|
|
7789
7786
|
}, 500);
|
|
7790
7787
|
return () => clearTimeout(T);
|
|
7791
7788
|
}, [y, o, b]);
|
|
@@ -7799,7 +7796,7 @@ const Input = ({ node: o }) => {
|
|
|
7799
7796
|
const D = get(o, "parent.id");
|
|
7800
7797
|
D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: T }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: T });
|
|
7801
7798
|
};
|
|
7802
|
-
if (
|
|
7799
|
+
if (m === ROOT_TEMP_KEY)
|
|
7803
7800
|
return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
|
|
7804
7801
|
/* @__PURE__ */ jsx("br", {}),
|
|
7805
7802
|
d(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
|
|
@@ -7821,22 +7818,22 @@ const Input = ({ node: o }) => {
|
|
|
7821
7818
|
return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
|
|
7822
7819
|
"div",
|
|
7823
7820
|
{
|
|
7824
|
-
onMouseEnter: () => g(
|
|
7825
|
-
onMouseLeave: () =>
|
|
7821
|
+
onMouseEnter: () => g(m),
|
|
7822
|
+
onMouseLeave: () => h(),
|
|
7826
7823
|
onClick: k,
|
|
7827
7824
|
style: n,
|
|
7828
|
-
"data-node-id":
|
|
7829
|
-
ref: l.includes(
|
|
7825
|
+
"data-node-id": m,
|
|
7826
|
+
ref: l.includes(m) ? null : r,
|
|
7830
7827
|
onDragStart: () => _(o),
|
|
7831
7828
|
onDragEnd: () => E(o),
|
|
7832
7829
|
onDragOver: (T) => {
|
|
7833
|
-
T.preventDefault(), j(
|
|
7830
|
+
T.preventDefault(), j(m, "yes");
|
|
7834
7831
|
},
|
|
7835
7832
|
onDragLeave: (T) => {
|
|
7836
|
-
T.preventDefault(), j(
|
|
7833
|
+
T.preventDefault(), j(m, "no");
|
|
7837
7834
|
},
|
|
7838
7835
|
onDrop: (T) => {
|
|
7839
|
-
T.preventDefault(), j(
|
|
7836
|
+
T.preventDefault(), j(m, "no");
|
|
7840
7837
|
},
|
|
7841
7838
|
children: [
|
|
7842
7839
|
d(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((R = o == null ? void 0 : o.parent) == null ? void 0 : R.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
|
|
@@ -7860,7 +7857,7 @@ const Input = ({ node: o }) => {
|
|
|
7860
7857
|
y && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
|
|
7861
7858
|
(o == null ? void 0 : o.id) === S ? "bg-primary/10" : "",
|
|
7862
7859
|
b && "opacity-20",
|
|
7863
|
-
l.includes(
|
|
7860
|
+
l.includes(m) ? "opacity-50" : "",
|
|
7864
7861
|
L && f && "bg-primary/20 text-primary"
|
|
7865
7862
|
),
|
|
7866
7863
|
children: [
|
|
@@ -7897,11 +7894,11 @@ const Input = ({ node: o }) => {
|
|
|
7897
7894
|
)
|
|
7898
7895
|
] }),
|
|
7899
7896
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
7900
|
-
canAddChildBlock(x == null ? void 0 : x._type) && !l.includes(
|
|
7897
|
+
canAddChildBlock(x == null ? void 0 : x._type) && !l.includes(m) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7901
7898
|
/* @__PURE__ */ jsx(
|
|
7902
7899
|
TooltipTrigger,
|
|
7903
7900
|
{
|
|
7904
|
-
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id:
|
|
7901
|
+
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: m }),
|
|
7905
7902
|
className: "cursor-pointer rounded bg-transparent",
|
|
7906
7903
|
asChild: !0,
|
|
7907
7904
|
children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-3 w-3" })
|
|
@@ -7914,7 +7911,7 @@ const Input = ({ node: o }) => {
|
|
|
7914
7911
|
TooltipTrigger,
|
|
7915
7912
|
{
|
|
7916
7913
|
onClick: (T) => {
|
|
7917
|
-
T.stopPropagation(), i(
|
|
7914
|
+
T.stopPropagation(), i(m), o.isOpen && o.toggle();
|
|
7918
7915
|
},
|
|
7919
7916
|
className: "cursor-pointer rounded bg-transparent",
|
|
7920
7917
|
asChild: !0,
|
|
@@ -7923,7 +7920,7 @@ const Input = ({ node: o }) => {
|
|
|
7923
7920
|
),
|
|
7924
7921
|
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999]", side: "bottom", children: a("Hide block") })
|
|
7925
7922
|
] }),
|
|
7926
|
-
/* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id:
|
|
7923
|
+
/* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: m, children: /* @__PURE__ */ jsx(MoreVertical, { size: "15" }) })
|
|
7927
7924
|
] })
|
|
7928
7925
|
]
|
|
7929
7926
|
}
|
|
@@ -8188,9 +8185,9 @@ const Input = ({ node: o }) => {
|
|
|
8188
8185
|
)
|
|
8189
8186
|
] });
|
|
8190
8187
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
8191
|
-
const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(),
|
|
8188
|
+
const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), h = (v) => {
|
|
8192
8189
|
a(v);
|
|
8193
|
-
},
|
|
8190
|
+
}, m = () => {
|
|
8194
8191
|
const v = l.find((B) => Object.keys(B)[0] === r);
|
|
8195
8192
|
if (v) {
|
|
8196
8193
|
const B = Object.values(v)[0];
|
|
@@ -8255,7 +8252,7 @@ const Input = ({ node: o }) => {
|
|
|
8255
8252
|
"select",
|
|
8256
8253
|
{
|
|
8257
8254
|
value: r,
|
|
8258
|
-
onChange: (v) =>
|
|
8255
|
+
onChange: (v) => h(v.target.value),
|
|
8259
8256
|
className: "w-full space-y-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
8260
8257
|
children: [
|
|
8261
8258
|
/* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
|
|
@@ -8270,7 +8267,7 @@ const Input = ({ node: o }) => {
|
|
|
8270
8267
|
className: "w-full text-sm",
|
|
8271
8268
|
disabled: r === "",
|
|
8272
8269
|
variant: "default",
|
|
8273
|
-
onClick:
|
|
8270
|
+
onClick: m,
|
|
8274
8271
|
children: g("Apply")
|
|
8275
8272
|
}
|
|
8276
8273
|
) })
|
|
@@ -8764,14 +8761,14 @@ function QuickPrompts({ onClick: o }) {
|
|
|
8764
8761
|
) }) });
|
|
8765
8762
|
}
|
|
8766
8763
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
8767
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(),
|
|
8764
|
+
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), h = useRef(null), m = useRef(null);
|
|
8768
8765
|
useEffect(() => {
|
|
8769
8766
|
var f;
|
|
8770
|
-
(f =
|
|
8767
|
+
(f = h.current) == null || f.focus();
|
|
8771
8768
|
}, []);
|
|
8772
8769
|
const x = (f) => {
|
|
8773
8770
|
const { usage: y } = f || {};
|
|
8774
|
-
!l && y && g(y),
|
|
8771
|
+
!l && y && g(y), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
8775
8772
|
};
|
|
8776
8773
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
8777
8774
|
/* @__PURE__ */ jsxs(
|
|
@@ -8789,14 +8786,14 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8789
8786
|
/* @__PURE__ */ jsx(
|
|
8790
8787
|
Textarea,
|
|
8791
8788
|
{
|
|
8792
|
-
ref:
|
|
8789
|
+
ref: h,
|
|
8793
8790
|
value: i,
|
|
8794
8791
|
onChange: (f) => c(f.target.value),
|
|
8795
8792
|
placeholder: n("Ask AI to edit content"),
|
|
8796
8793
|
className: "w-full",
|
|
8797
8794
|
rows: 3,
|
|
8798
8795
|
onKeyDown: (f) => {
|
|
8799
|
-
f.key === "Enter" && (f.preventDefault(),
|
|
8796
|
+
f.key === "Enter" && (f.preventDefault(), m.current && clearTimeout(m.current), g(void 0), r("content", o, i, x));
|
|
8800
8797
|
}
|
|
8801
8798
|
}
|
|
8802
8799
|
),
|
|
@@ -8806,7 +8803,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8806
8803
|
{
|
|
8807
8804
|
disabled: i.trim().length < 5 || a,
|
|
8808
8805
|
onClick: () => {
|
|
8809
|
-
|
|
8806
|
+
m.current && clearTimeout(m.current), g(void 0), r("content", o, i, x);
|
|
8810
8807
|
},
|
|
8811
8808
|
variant: "default",
|
|
8812
8809
|
className: "w-fit",
|
|
@@ -8839,7 +8836,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8839
8836
|
QuickPrompts,
|
|
8840
8837
|
{
|
|
8841
8838
|
onClick: (f) => {
|
|
8842
|
-
|
|
8839
|
+
m.current && clearTimeout(m.current), g(void 0), r("content", o, f, x);
|
|
8843
8840
|
}
|
|
8844
8841
|
}
|
|
8845
8842
|
)
|
|
@@ -8849,13 +8846,13 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8849
8846
|
] }) }) : null
|
|
8850
8847
|
] });
|
|
8851
8848
|
}, AISetContext = () => {
|
|
8852
|
-
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1),
|
|
8849
|
+
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), h = useRef(null);
|
|
8853
8850
|
useEffect(() => {
|
|
8854
8851
|
n && a(n);
|
|
8855
8852
|
}, [n]);
|
|
8856
|
-
const
|
|
8853
|
+
const m = async () => {
|
|
8857
8854
|
try {
|
|
8858
|
-
d(!0), u(null), await i(r), toast.success(o("Updated AI Context")),
|
|
8855
|
+
d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), h.current.click();
|
|
8859
8856
|
} catch (x) {
|
|
8860
8857
|
u(x);
|
|
8861
8858
|
} finally {
|
|
@@ -8871,7 +8868,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8871
8868
|
type: "single",
|
|
8872
8869
|
collapsible: !0,
|
|
8873
8870
|
children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
|
|
8874
|
-
/* @__PURE__ */ jsx(AccordionTrigger, { ref:
|
|
8871
|
+
/* @__PURE__ */ jsx(AccordionTrigger, { ref: h, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
|
|
8875
8872
|
/* @__PURE__ */ jsxs(AccordionContent, { children: [
|
|
8876
8873
|
/* @__PURE__ */ jsx(
|
|
8877
8874
|
Textarea,
|
|
@@ -8883,7 +8880,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8883
8880
|
className: "mt-1 w-full",
|
|
8884
8881
|
rows: 10,
|
|
8885
8882
|
onKeyDown: (x) => {
|
|
8886
|
-
x.key === "Enter" && (x.preventDefault(),
|
|
8883
|
+
x.key === "Enter" && (x.preventDefault(), m());
|
|
8887
8884
|
}
|
|
8888
8885
|
}
|
|
8889
8886
|
),
|
|
@@ -8895,7 +8892,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8895
8892
|
Button,
|
|
8896
8893
|
{
|
|
8897
8894
|
disabled: r.trim().length < 5,
|
|
8898
|
-
onClick: () =>
|
|
8895
|
+
onClick: () => m(),
|
|
8899
8896
|
variant: "default",
|
|
8900
8897
|
className: "w-fit",
|
|
8901
8898
|
size: "sm",
|
|
@@ -8924,7 +8921,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8924
8921
|
AlertDialogAction,
|
|
8925
8922
|
{
|
|
8926
8923
|
onClick: () => {
|
|
8927
|
-
a(""),
|
|
8924
|
+
a(""), m();
|
|
8928
8925
|
},
|
|
8929
8926
|
children: o("Yes, Delete")
|
|
8930
8927
|
}
|
|
@@ -8985,7 +8982,7 @@ function AIChatPanel() {
|
|
|
8985
8982
|
}, [o]), useEffect(() => {
|
|
8986
8983
|
g.current && (g.current.style.height = "auto", g.current.style.height = `${Math.min(g.current.scrollHeight, 120)}px`);
|
|
8987
8984
|
}, [r]);
|
|
8988
|
-
const
|
|
8985
|
+
const h = async () => {
|
|
8989
8986
|
if (!r.trim() && !c) return;
|
|
8990
8987
|
const b = {
|
|
8991
8988
|
id: Date.now().toString(),
|
|
@@ -9002,8 +8999,8 @@ function AIChatPanel() {
|
|
|
9002
8999
|
};
|
|
9003
9000
|
n((B) => [...B, v]), i(!1), d(null);
|
|
9004
9001
|
}, 1500);
|
|
9005
|
-
},
|
|
9006
|
-
b.key === "Enter" && !b.shiftKey && (b.preventDefault(),
|
|
9002
|
+
}, m = (b) => {
|
|
9003
|
+
b.key === "Enter" && !b.shiftKey && (b.preventDefault(), h());
|
|
9007
9004
|
}, x = (b) => {
|
|
9008
9005
|
var B;
|
|
9009
9006
|
const v = (B = b.target.files) == null ? void 0 : B[0];
|
|
@@ -9076,7 +9073,7 @@ function AIChatPanel() {
|
|
|
9076
9073
|
ref: g,
|
|
9077
9074
|
value: r,
|
|
9078
9075
|
onChange: (b) => a(b.target.value),
|
|
9079
|
-
onKeyDown:
|
|
9076
|
+
onKeyDown: m,
|
|
9080
9077
|
placeholder: "Ask something...",
|
|
9081
9078
|
className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
|
|
9082
9079
|
}
|
|
@@ -9098,7 +9095,7 @@ function AIChatPanel() {
|
|
|
9098
9095
|
{
|
|
9099
9096
|
size: "sm",
|
|
9100
9097
|
className: "h-10 px-3",
|
|
9101
|
-
onClick:
|
|
9098
|
+
onClick: h,
|
|
9102
9099
|
disabled: l || !r.trim() && !c,
|
|
9103
9100
|
children: [
|
|
9104
9101
|
/* @__PURE__ */ jsx(Send, { className: "mr-1 h-4 w-4" }),
|
|
@@ -9206,18 +9203,18 @@ const AiAssistant = () => {
|
|
|
9206
9203
|
preloadedAttributes: n = [],
|
|
9207
9204
|
onAttributesChange: r
|
|
9208
9205
|
}) {
|
|
9209
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [
|
|
9206
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), x = useRef(null), f = useRef(null), y = usePageExternalData();
|
|
9210
9207
|
useEffect(() => {
|
|
9211
9208
|
l(n);
|
|
9212
9209
|
}, [n]);
|
|
9213
9210
|
const b = () => {
|
|
9214
9211
|
if (i.startsWith("@")) {
|
|
9215
|
-
|
|
9212
|
+
m("Attribute keys cannot start with '@'");
|
|
9216
9213
|
return;
|
|
9217
9214
|
}
|
|
9218
9215
|
if (i) {
|
|
9219
9216
|
const S = [...a, { key: i, value: d }];
|
|
9220
|
-
r(S), l(a), c(""), p(""),
|
|
9217
|
+
r(S), l(a), c(""), p(""), m("");
|
|
9221
9218
|
}
|
|
9222
9219
|
}, v = (S) => {
|
|
9223
9220
|
const A = a.filter((N, C) => C !== S);
|
|
@@ -9226,12 +9223,12 @@ const AiAssistant = () => {
|
|
|
9226
9223
|
g(S), c(a[S].key), p(a[S].value);
|
|
9227
9224
|
}, w = () => {
|
|
9228
9225
|
if (i.startsWith("@")) {
|
|
9229
|
-
|
|
9226
|
+
m("Attribute keys cannot start with '@'");
|
|
9230
9227
|
return;
|
|
9231
9228
|
}
|
|
9232
9229
|
if (u !== null && i) {
|
|
9233
9230
|
const S = [...a];
|
|
9234
|
-
S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""),
|
|
9231
|
+
S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), m("");
|
|
9235
9232
|
}
|
|
9236
9233
|
}, _ = (S) => {
|
|
9237
9234
|
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() : b());
|
|
@@ -9307,7 +9304,7 @@ const AiAssistant = () => {
|
|
|
9307
9304
|
] })
|
|
9308
9305
|
] }),
|
|
9309
9306
|
/* @__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" }) }),
|
|
9310
|
-
|
|
9307
|
+
h && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: h })
|
|
9311
9308
|
]
|
|
9312
9309
|
}
|
|
9313
9310
|
),
|
|
@@ -9338,7 +9335,33 @@ const AiAssistant = () => {
|
|
|
9338
9335
|
[o, l, i]
|
|
9339
9336
|
);
|
|
9340
9337
|
return /* @__PURE__ */ jsx("div", { className: "flex-col gap-y-2", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(AttrsEditor, { preloadedAttributes: n, onAttributesChange: c }) }) }) });
|
|
9341
|
-
}), NoopComponent = () => null
|
|
9338
|
+
}), NoopComponent = () => null, ResetStylesButton = () => {
|
|
9339
|
+
const { resetAll: o } = useResetBlockStyles(), { t: n } = useTranslation();
|
|
9340
|
+
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
9341
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
9342
|
+
"button",
|
|
9343
|
+
{
|
|
9344
|
+
type: "button",
|
|
9345
|
+
className: "ml-1 rounded-sm p-0.5 hover:bg-blue-300 hover:text-blue-600",
|
|
9346
|
+
onClick: (r) => r.stopPropagation(),
|
|
9347
|
+
children: /* @__PURE__ */ jsx(MoreVertical, { className: "h-3 w-3" })
|
|
9348
|
+
}
|
|
9349
|
+
) }),
|
|
9350
|
+
/* @__PURE__ */ jsx(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: /* @__PURE__ */ jsxs(
|
|
9351
|
+
DropdownMenuItem,
|
|
9352
|
+
{
|
|
9353
|
+
className: "flex items-center gap-1 text-xs",
|
|
9354
|
+
onClick: () => {
|
|
9355
|
+
o();
|
|
9356
|
+
},
|
|
9357
|
+
children: [
|
|
9358
|
+
/* @__PURE__ */ jsx(ResetIcon, { className: "h-3 w-3" }),
|
|
9359
|
+
n("Reset styles")
|
|
9360
|
+
]
|
|
9361
|
+
}
|
|
9362
|
+
) })
|
|
9363
|
+
] });
|
|
9364
|
+
};
|
|
9342
9365
|
function BlockAttributesToggle() {
|
|
9343
9366
|
const { t: o } = useTranslation(), [n, r] = useState(!0), [a] = useSelectedStylingBlocks();
|
|
9344
9367
|
return isEmpty(a) ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -9372,16 +9395,20 @@ const SettingsPanel = () => {
|
|
|
9372
9395
|
/* @__PURE__ */ jsx("br", {}),
|
|
9373
9396
|
/* @__PURE__ */ jsx("br", {})
|
|
9374
9397
|
] }) }) : l ? /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs("div", { className: "no-scrollbar h-full max-h-min w-full overflow-y-auto overflow-x-hidden", children: [
|
|
9398
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-end", children: /* @__PURE__ */ jsx(ResetStylesButton, {}) }),
|
|
9375
9399
|
/* @__PURE__ */ jsx(BlockStyling, {}),
|
|
9376
9400
|
/* @__PURE__ */ jsx(BlockAttributesToggle, {}),
|
|
9377
9401
|
/* @__PURE__ */ jsx("br", {}),
|
|
9378
9402
|
/* @__PURE__ */ jsx("br", {}),
|
|
9379
9403
|
/* @__PURE__ */ jsx("br", {})
|
|
9380
9404
|
] }) }) : /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs(Tabs, { defaultValue: "settings", className: "flex flex-1 flex-col", children: [
|
|
9381
|
-
/* @__PURE__ */ jsxs(TabsList, { className: "grid h-auto w-full grid-cols-2 p-1 py-1", children: [
|
|
9405
|
+
/* @__PURE__ */ jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsxs(TabsList, { className: "grid h-auto w-full grid-cols-2 p-1 py-1", children: [
|
|
9382
9406
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "settings", className: "text-xs", children: "Settings" }),
|
|
9383
|
-
/* @__PURE__ */
|
|
9384
|
-
|
|
9407
|
+
/* @__PURE__ */ jsxs(TabsTrigger, { value: "styles", className: "flex items-center justify-between text-xs", children: [
|
|
9408
|
+
"Styles",
|
|
9409
|
+
/* @__PURE__ */ jsx(ResetStylesButton, {})
|
|
9410
|
+
] })
|
|
9411
|
+
] }) }),
|
|
9385
9412
|
/* @__PURE__ */ jsxs(TabsContent, { value: "settings", className: "no-scrollbar h-full max-h-min overflow-y-auto", children: [
|
|
9386
9413
|
/* @__PURE__ */ jsx(BlockSettings, {}),
|
|
9387
9414
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -9438,9 +9465,9 @@ const RootLayout = () => {
|
|
|
9438
9465
|
usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
|
|
9439
9466
|
r("outline");
|
|
9440
9467
|
});
|
|
9441
|
-
const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"),
|
|
9468
|
+
const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = useCallback((S) => {
|
|
9442
9469
|
S.preventDefault();
|
|
9443
|
-
}, []),
|
|
9470
|
+
}, []), m = useCallback(
|
|
9444
9471
|
(S) => {
|
|
9445
9472
|
r(n === S ? null : S);
|
|
9446
9473
|
},
|
|
@@ -9469,15 +9496,15 @@ const RootLayout = () => {
|
|
|
9469
9496
|
}, [n, f]);
|
|
9470
9497
|
const E = useCallback(
|
|
9471
9498
|
(S) => {
|
|
9472
|
-
|
|
9499
|
+
m(S);
|
|
9473
9500
|
},
|
|
9474
|
-
[
|
|
9501
|
+
[m]
|
|
9475
9502
|
);
|
|
9476
9503
|
return /* @__PURE__ */ jsx("div", { dir: y, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
|
|
9477
9504
|
/* @__PURE__ */ jsxs(
|
|
9478
9505
|
"div",
|
|
9479
9506
|
{
|
|
9480
|
-
onContextMenu:
|
|
9507
|
+
onContextMenu: h,
|
|
9481
9508
|
className: "flex h-screen max-h-full flex-col bg-background text-foreground",
|
|
9482
9509
|
children: [
|
|
9483
9510
|
/* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
|
|
@@ -9681,12 +9708,12 @@ const RootLayout = () => {
|
|
|
9681
9708
|
return (y == null ? void 0 : y.toLowerCase().includes(f)) || ((v = b == null ? void 0 : b.description) == null ? void 0 : v.toLowerCase().includes(f));
|
|
9682
9709
|
})
|
|
9683
9710
|
);
|
|
9684
|
-
}, [a, l]),
|
|
9711
|
+
}, [a, l]), h = (f) => {
|
|
9685
9712
|
d(!0), u({
|
|
9686
9713
|
x: f.clientX - n.x,
|
|
9687
9714
|
y: f.clientY - n.y
|
|
9688
9715
|
});
|
|
9689
|
-
},
|
|
9716
|
+
}, m = (f) => {
|
|
9690
9717
|
if (!c) return;
|
|
9691
9718
|
const y = f.clientX - p.x, b = f.clientY - p.y, v = f.currentTarget, B = v.offsetWidth, w = v.offsetHeight, _ = window.innerWidth - B, E = window.innerHeight - w, S = Math.max(0, Math.min(y, _)), A = Math.max(0, Math.min(b, E));
|
|
9692
9719
|
r(S, A);
|
|
@@ -9701,8 +9728,8 @@ const RootLayout = () => {
|
|
|
9701
9728
|
}, [c]), !n || n.x < 0 || n.y < 0 ? null : /* @__PURE__ */ jsxs(
|
|
9702
9729
|
"div",
|
|
9703
9730
|
{
|
|
9704
|
-
onMouseDown:
|
|
9705
|
-
onMouseMove:
|
|
9731
|
+
onMouseDown: h,
|
|
9732
|
+
onMouseMove: m,
|
|
9706
9733
|
onMouseUp: x,
|
|
9707
9734
|
className: "fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",
|
|
9708
9735
|
style: {
|
|
@@ -9862,17 +9889,17 @@ const RootLayout = () => {
|
|
|
9862
9889
|
for (const i of n.p)
|
|
9863
9890
|
l.add(i);
|
|
9864
9891
|
return l;
|
|
9865
|
-
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (
|
|
9892
|
+
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (m, ...x) => m.read(...x), p = (m, ...x) => m.write(...x), u = (m, x) => {
|
|
9866
9893
|
var f;
|
|
9867
|
-
return (f =
|
|
9868
|
-
}, g = (
|
|
9894
|
+
return (f = m.unstable_onInit) == null ? void 0 : f.call(m, x);
|
|
9895
|
+
}, g = (m, x) => {
|
|
9869
9896
|
var f;
|
|
9870
|
-
return (f =
|
|
9871
|
-
}, ...
|
|
9872
|
-
const
|
|
9897
|
+
return (f = m.onMount) == null ? void 0 : f.call(m, x);
|
|
9898
|
+
}, ...h) => {
|
|
9899
|
+
const m = h[0] || ((A) => {
|
|
9873
9900
|
let N = o.get(A);
|
|
9874
9901
|
return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(A, N), u == null || u(A, S)), N;
|
|
9875
|
-
}), x =
|
|
9902
|
+
}), x = h[1] || (() => {
|
|
9876
9903
|
let A, N;
|
|
9877
9904
|
const C = (k) => {
|
|
9878
9905
|
try {
|
|
@@ -9891,10 +9918,10 @@ const RootLayout = () => {
|
|
|
9891
9918
|
} while (a.size || i.size || l.size);
|
|
9892
9919
|
if (A)
|
|
9893
9920
|
throw N;
|
|
9894
|
-
}), f =
|
|
9921
|
+
}), f = h[2] || (() => {
|
|
9895
9922
|
const A = [], N = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
|
|
9896
9923
|
for (; k.length; ) {
|
|
9897
|
-
const j = k[k.length - 1], I =
|
|
9924
|
+
const j = k[k.length - 1], I = m(j);
|
|
9898
9925
|
if (C.has(j)) {
|
|
9899
9926
|
k.pop();
|
|
9900
9927
|
continue;
|
|
@@ -9917,9 +9944,9 @@ const RootLayout = () => {
|
|
|
9917
9944
|
}
|
|
9918
9945
|
R && (y(I), B(I)), r.delete(I);
|
|
9919
9946
|
}
|
|
9920
|
-
}), y =
|
|
9947
|
+
}), y = h[3] || ((A) => {
|
|
9921
9948
|
var N, C;
|
|
9922
|
-
const k =
|
|
9949
|
+
const k = m(A);
|
|
9923
9950
|
if (isAtomStateInitialized(k) && (n.has(A) && r.get(A) !== k.n || Array.from(k.d).every(
|
|
9924
9951
|
([P, $]) => (
|
|
9925
9952
|
// Recursively, read the atom state of the dependency, and
|
|
@@ -9935,10 +9962,10 @@ const RootLayout = () => {
|
|
|
9935
9962
|
}, L = (P) => {
|
|
9936
9963
|
var $;
|
|
9937
9964
|
if (isSelfAtom(A, P)) {
|
|
9938
|
-
const H =
|
|
9965
|
+
const H = m(P);
|
|
9939
9966
|
if (!isAtomStateInitialized(H))
|
|
9940
9967
|
if (hasInitialValue(P))
|
|
9941
|
-
setAtomStateValueOrPromise(P, P.init,
|
|
9968
|
+
setAtomStateValueOrPromise(P, P.init, m);
|
|
9942
9969
|
else
|
|
9943
9970
|
throw new Error("no atom init");
|
|
9944
9971
|
return returnAtomValue(H);
|
|
@@ -9968,7 +9995,7 @@ const RootLayout = () => {
|
|
|
9968
9995
|
}, O = k.n;
|
|
9969
9996
|
try {
|
|
9970
9997
|
const P = d(A, L, D);
|
|
9971
|
-
return setAtomStateValueOrPromise(A, P,
|
|
9998
|
+
return setAtomStateValueOrPromise(A, P, m), isPromiseLike$1(P) && ((N = P.onCancel) == null || N.call(P, () => R == null ? void 0 : R.abort()), P.then(
|
|
9972
9999
|
I,
|
|
9973
10000
|
I
|
|
9974
10001
|
)), k;
|
|
@@ -9977,26 +10004,26 @@ const RootLayout = () => {
|
|
|
9977
10004
|
} finally {
|
|
9978
10005
|
j = !1, O !== k.n && r.get(A) === O && (r.set(A, k.n), a.add(A), (C = c.c) == null || C.call(c, A));
|
|
9979
10006
|
}
|
|
9980
|
-
}), b =
|
|
10007
|
+
}), b = h[4] || ((A) => {
|
|
9981
10008
|
const N = [A];
|
|
9982
10009
|
for (; N.length; ) {
|
|
9983
|
-
const C = N.pop(), k =
|
|
10010
|
+
const C = N.pop(), k = m(C);
|
|
9984
10011
|
for (const j of getMountedOrPendingDependents(C, k, n)) {
|
|
9985
|
-
const I =
|
|
10012
|
+
const I = m(j);
|
|
9986
10013
|
r.set(j, I.n), N.push(j);
|
|
9987
10014
|
}
|
|
9988
10015
|
}
|
|
9989
|
-
}), v =
|
|
10016
|
+
}), v = h[5] || ((A, ...N) => {
|
|
9990
10017
|
let C = !0;
|
|
9991
10018
|
const k = (I) => returnAtomValue(y(I)), j = (I, ...L) => {
|
|
9992
10019
|
var R;
|
|
9993
|
-
const T =
|
|
10020
|
+
const T = m(I);
|
|
9994
10021
|
try {
|
|
9995
10022
|
if (isSelfAtom(A, I)) {
|
|
9996
10023
|
if (!hasInitialValue(I))
|
|
9997
10024
|
throw new Error("atom not writable");
|
|
9998
10025
|
const D = T.n, O = L[0];
|
|
9999
|
-
setAtomStateValueOrPromise(I, O,
|
|
10026
|
+
setAtomStateValueOrPromise(I, O, m), B(I), D !== T.n && (a.add(I), (R = c.c) == null || R.call(c, I), b(I));
|
|
10000
10027
|
return;
|
|
10001
10028
|
} else
|
|
10002
10029
|
return v(I, ...L);
|
|
@@ -10009,13 +10036,13 @@ const RootLayout = () => {
|
|
|
10009
10036
|
} finally {
|
|
10010
10037
|
C = !1;
|
|
10011
10038
|
}
|
|
10012
|
-
}), B =
|
|
10039
|
+
}), B = h[6] || ((A) => {
|
|
10013
10040
|
var N;
|
|
10014
|
-
const C =
|
|
10041
|
+
const C = m(A), k = n.get(A);
|
|
10015
10042
|
if (k && !isPendingPromise(C.v)) {
|
|
10016
10043
|
for (const [j, I] of C.d)
|
|
10017
10044
|
if (!k.d.has(j)) {
|
|
10018
|
-
const L =
|
|
10045
|
+
const L = m(j);
|
|
10019
10046
|
w(j).t.add(A), k.d.add(j), I !== L.n && (a.add(j), (N = c.c) == null || N.call(c, j), b(j));
|
|
10020
10047
|
}
|
|
10021
10048
|
for (const j of k.d || [])
|
|
@@ -10025,9 +10052,9 @@ const RootLayout = () => {
|
|
|
10025
10052
|
I == null || I.t.delete(A);
|
|
10026
10053
|
}
|
|
10027
10054
|
}
|
|
10028
|
-
}), w =
|
|
10055
|
+
}), w = h[7] || ((A) => {
|
|
10029
10056
|
var N;
|
|
10030
|
-
const C =
|
|
10057
|
+
const C = m(A);
|
|
10031
10058
|
let k = n.get(A);
|
|
10032
10059
|
if (!k) {
|
|
10033
10060
|
y(A);
|
|
@@ -10065,9 +10092,9 @@ const RootLayout = () => {
|
|
|
10065
10092
|
}
|
|
10066
10093
|
}
|
|
10067
10094
|
return k;
|
|
10068
|
-
}), _ =
|
|
10095
|
+
}), _ = h[8] || ((A) => {
|
|
10069
10096
|
var N;
|
|
10070
|
-
const C =
|
|
10097
|
+
const C = m(A);
|
|
10071
10098
|
let k = n.get(A);
|
|
10072
10099
|
if (k && !k.l.size && !Array.from(k.t).some((j) => {
|
|
10073
10100
|
var I;
|
|
@@ -10096,7 +10123,7 @@ const RootLayout = () => {
|
|
|
10096
10123
|
u,
|
|
10097
10124
|
g,
|
|
10098
10125
|
// building-block functions
|
|
10099
|
-
|
|
10126
|
+
m,
|
|
10100
10127
|
x,
|
|
10101
10128
|
f,
|
|
10102
10129
|
y,
|