@chaibuilder/sdk 2.0.0-beta.105 → 2.0.0-beta.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +10 -5
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1049 -823
- package/dist/sdk.css +1 -6
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +92 -88
- package/package.json +8 -2
package/dist/core.js
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
1
|
var G = Object.defineProperty;
|
|
2
2
|
var K = (o, n, r) => n in o ? G(o, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[n] = r;
|
|
3
|
-
var
|
|
3
|
+
var V = (o, n, r) => K(o, typeof n != "symbol" ? n + "" : n, r);
|
|
4
4
|
import { jsx, Fragment, jsxs } from "react/jsx-runtime";
|
|
5
5
|
import * as React from "react";
|
|
6
6
|
import React__default, { createContext, useReducer, useEffect, useDebugValue, useCallback, useContext, useMemo, Component, Children, useState, useRef, Suspense, createElement, memo, lazy } from "react";
|
|
7
|
-
import { S as Skeleton, B as Button, al as Label, X as Dialog, Y as DialogTrigger, Z as DialogContent, am as Popover, az as Tooltip, aA as TooltipTrigger, an as PopoverTrigger, aB as TooltipContent, ao as PopoverContent, v as Command, x as CommandInput, y as CommandList, z as CommandEmpty, D as CommandGroup, E as CommandItem, n as Badge, a2 as DropdownMenu, a3 as DropdownMenuTrigger, a4 as DropdownMenuContent, a8 as DropdownMenuLabel, a9 as DropdownMenuSeparator, a6 as DropdownMenuCheckboxItem, ah as HoverCard, ai as HoverCardTrigger, aj as HoverCardContent, ay as Textarea, ak as Input$1, aD as TooltipPortal, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, ap as ScrollArea, ab as DropdownMenuGroup, a5 as DropdownMenuItem, aa as DropdownMenuShortcut, A as Accordion, C as Card, q as CardHeader, t as CardDescription, u as CardContent, r as CardFooter, au as Tabs, av as TabsList, aw as TabsTrigger, ax as TabsContent, H as ContextMenu, I as ContextMenuTrigger, J as ContextMenuContent, K as ContextMenuItem, e as AlertDialog, f as AlertDialogTrigger, g as AlertDialogContent, h as AlertDialogHeader, j as AlertDialogTitle, k as AlertDialogDescription, i as AlertDialogFooter, m as AlertDialogCancel, l as AlertDialogAction, at as Switch, ar as Separator, aC as TooltipProvider, as as Toaster } from "./tooltip-CuxBhGWF.js";
|
|
7
|
+
import { S as Skeleton, B as Button, al as Label, X as Dialog, Y as DialogTrigger, Z as DialogContent, am as Popover, az as Tooltip, aA as TooltipTrigger, an as PopoverTrigger, aB as TooltipContent, ao as PopoverContent, v as Command, x as CommandInput, y as CommandList, z as CommandEmpty, D as CommandGroup, E as CommandItem, _ as DialogHeader, a0 as DialogTitle, n as Badge, a2 as DropdownMenu, a3 as DropdownMenuTrigger, a4 as DropdownMenuContent, a8 as DropdownMenuLabel, a9 as DropdownMenuSeparator, a6 as DropdownMenuCheckboxItem, ah as HoverCard, ai as HoverCardTrigger, aj as HoverCardContent, ay as Textarea, ak as Input$1, aD as TooltipPortal, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, ap as ScrollArea, ab as DropdownMenuGroup, a5 as DropdownMenuItem, aa as DropdownMenuShortcut, A as Accordion, C as Card, q as CardHeader, t as CardDescription, u as CardContent, r as CardFooter, au as Tabs, av as TabsList, aw as TabsTrigger, ax as TabsContent, H as ContextMenu, I as ContextMenuTrigger, J as ContextMenuContent, K as ContextMenuItem, e as AlertDialog, f as AlertDialogTrigger, g as AlertDialogContent, h as AlertDialogHeader, j as AlertDialogTitle, k as AlertDialogDescription, i as AlertDialogFooter, m as AlertDialogCancel, l as AlertDialogAction, at as Switch, ar as Separator, aC as TooltipProvider, as as Toaster } from "./tooltip-CuxBhGWF.js";
|
|
8
8
|
import { atom as atom$1, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
|
|
9
9
|
import { find, filter, flatten, map, omit, isString, has, each, set, first, get, isObject, memoize, compact, isEmpty, noop, includes, without, keys, range, values, flattenDeep, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, throttle, isFunction as isFunction$1, reverse, startCase, debounce, capitalize, split, findIndex, take, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, uniq, flatMapDeep, some, reject, sortBy, round } from "lodash-es";
|
|
10
10
|
import { Provider as Provider$1 } from "react-wrap-balancer";
|
|
11
11
|
import { useTranslation, initReactI18next } from "react-i18next";
|
|
12
|
-
import { useTranslation as
|
|
13
|
-
import { g as generateUUID, a as getBreakpointValue, c as cn, G as GenIcon } from "./iconBase-DHfFLkem.js";
|
|
12
|
+
import { useTranslation as Ve } from "react-i18next";
|
|
13
|
+
import { g as generateUUID, a as getBreakpointValue, c as cn$1, G as GenIcon } from "./iconBase-DHfFLkem.js";
|
|
14
14
|
import { flip } from "@floating-ui/dom";
|
|
15
15
|
import { useFloating, shift } from "@floating-ui/react-dom";
|
|
16
16
|
import { ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, BoxModelIcon, ReaderIcon, DropdownMenuIcon, BoxIcon, DragHandleHorizontalIcon, ViewHorizontalIcon, BorderAllIcon, BorderTopIcon, TableIcon, RadiobuttonIcon, InputIcon, ButtonIcon, CheckboxIcon, GroupIcon, SpaceBetweenVerticallyIcon, ColumnsIcon, TextIcon, RowsIcon, SketchLogoIcon, DividerHorizontalIcon, CodeIcon, CursorTextIcon, VideoIcon, Link1Icon, HeadingIcon, ImageIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, Cross2Icon, EyeOpenIcon, EyeClosedIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, FontItalicIcon, UnderlineIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross1Icon, InfoCircledIcon, MinusIcon, TriangleDownIcon, RowSpacingIcon, CrossCircledIcon, CaretDownIcon, CaretRightIcon, CardStackIcon, CardStackPlusIcon, ScissorsIcon, CheckIcon, SunIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
|
|
17
17
|
import { useThrottledCallback, useDebouncedCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
|
|
18
18
|
import { useFeature, FlagsProvider } from "flagged";
|
|
19
19
|
import { getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredChaiBlocks, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
|
|
20
|
-
import { registerChaiBlock as
|
|
20
|
+
import { registerChaiBlock as Fe } from "@chaibuilder/runtime";
|
|
21
21
|
import { e as getDefaultExportFromCjs, d as defaultThemeOptions, g as getChaiThemeOptions, p as plugin, a as getChaiThemeCssVariables, c as getThemeFontsLinkMarkup } from "./ChaiThemeFn-Cort9tch.js";
|
|
22
22
|
import TreeModel from "tree-model";
|
|
23
23
|
import { useHotkeys } from "react-hotkeys-hook";
|
|
24
24
|
import { toast } from "sonner";
|
|
25
|
-
import { PlusIcon as PlusIcon$1, PanelRightClose, PanelRightOpen, AppWindowIcon, AlignHorizontalJustifyStart, UnfoldHorizontal, DatabaseIcon, Columns, Rows, GlobeIcon, ChevronRight,
|
|
26
|
-
import
|
|
25
|
+
import { PlusIcon as PlusIcon$1, PanelRightClose, PanelRightOpen, AppWindowIcon, AlignHorizontalJustifyStart, UnfoldHorizontal, DatabaseIcon, Columns, Rows, GlobeIcon, ChevronRight, ChevronLeft, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, X, Plus, PlusCircle, ChevronDown, Loader, SparklesIcon, EyeOff, Eye, SmileIcon, ShuffleIcon, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
|
|
26
|
+
import { useEditor, EditorContent } from "@tiptap/react";
|
|
27
|
+
import StarterKit from "@tiptap/starter-kit";
|
|
27
28
|
import typography from "@tailwindcss/typography";
|
|
28
29
|
import forms from "@tailwindcss/forms";
|
|
29
30
|
import aspectRatio from "@tailwindcss/aspect-ratio";
|
|
@@ -35,14 +36,17 @@ import { ErrorBoundary } from "react-error-boundary";
|
|
|
35
36
|
import { Resizable } from "re-resizable";
|
|
36
37
|
import RjForm from "@rjsf/core";
|
|
37
38
|
import validator from "@rjsf/validator-ajv8";
|
|
39
|
+
import Link from "@tiptap/extension-link";
|
|
40
|
+
import TextAlign from "@tiptap/extension-text-align";
|
|
41
|
+
import Underline from "@tiptap/extension-underline";
|
|
42
|
+
import clsx$1, { clsx } from "clsx";
|
|
38
43
|
import IconPicker, { IconPickerItem } from "react-icons-picker";
|
|
39
44
|
import Autosuggest from "react-autosuggest";
|
|
40
45
|
import Fuse from "fuse.js";
|
|
41
46
|
import { parse, stringify } from "himalaya";
|
|
42
|
-
import clsx from "clsx";
|
|
43
47
|
import { Tree } from "react-arborist";
|
|
44
48
|
import i18n from "i18next";
|
|
45
|
-
import { default as
|
|
49
|
+
import { default as We } from "i18next";
|
|
46
50
|
import { motion } from "framer-motion";
|
|
47
51
|
const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.write, isAtomStateInitialized = (o) => "v" in o || "e" in o, returnAtomValue = (o) => {
|
|
48
52
|
if ("e" in o)
|
|
@@ -90,37 +94,37 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
90
94
|
for (const i of n.p)
|
|
91
95
|
l.add(i);
|
|
92
96
|
return l;
|
|
93
|
-
}, 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 = (f, ...
|
|
97
|
+
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (f, ...h) => f.read(...h), p = (f, ...h) => f.write(...h), u = (f, h) => {
|
|
94
98
|
var b;
|
|
95
|
-
return (b = f.unstable_onInit) == null ? void 0 : b.call(f,
|
|
96
|
-
}, g = (f,
|
|
99
|
+
return (b = f.unstable_onInit) == null ? void 0 : b.call(f, h);
|
|
100
|
+
}, g = (f, h) => {
|
|
97
101
|
var b;
|
|
98
|
-
return (b = f.onMount) == null ? void 0 : b.call(f,
|
|
102
|
+
return (b = f.onMount) == null ? void 0 : b.call(f, h);
|
|
99
103
|
}, ...m) => {
|
|
100
|
-
const f = m[0] || ((
|
|
101
|
-
let T = o.get(
|
|
102
|
-
return T || (T = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(
|
|
103
|
-
}),
|
|
104
|
-
let
|
|
104
|
+
const f = m[0] || ((w) => {
|
|
105
|
+
let T = o.get(w);
|
|
106
|
+
return T || (T = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(w, T), u == null || u(w, _)), T;
|
|
107
|
+
}), h = m[1] || (() => {
|
|
108
|
+
let w, T;
|
|
105
109
|
const k = (v) => {
|
|
106
110
|
try {
|
|
107
111
|
v();
|
|
108
112
|
} catch (N) {
|
|
109
|
-
|
|
113
|
+
w || (w = !0, T = N);
|
|
110
114
|
}
|
|
111
115
|
};
|
|
112
116
|
do {
|
|
113
117
|
c.f && k(c.f);
|
|
114
118
|
const v = /* @__PURE__ */ new Set(), N = v.add.bind(v);
|
|
115
119
|
a.forEach((I) => {
|
|
116
|
-
var
|
|
117
|
-
return (
|
|
120
|
+
var L;
|
|
121
|
+
return (L = n.get(I)) == null ? void 0 : L.l.forEach(N);
|
|
118
122
|
}), a.clear(), i.forEach(N), i.clear(), l.forEach(N), l.clear(), v.forEach(k), a.size && b();
|
|
119
123
|
} while (a.size || i.size || l.size);
|
|
120
|
-
if (
|
|
124
|
+
if (w)
|
|
121
125
|
throw T;
|
|
122
126
|
}), b = m[2] || (() => {
|
|
123
|
-
const
|
|
127
|
+
const w = [], T = /* @__PURE__ */ new WeakSet(), k = /* @__PURE__ */ new WeakSet(), v = Array.from(a);
|
|
124
128
|
for (; v.length; ) {
|
|
125
129
|
const N = v[v.length - 1], I = f(N);
|
|
126
130
|
if (k.has(N)) {
|
|
@@ -128,85 +132,85 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
128
132
|
continue;
|
|
129
133
|
}
|
|
130
134
|
if (T.has(N)) {
|
|
131
|
-
r.get(N) === I.n &&
|
|
135
|
+
r.get(N) === I.n && w.push([N, I]), k.add(N), v.pop();
|
|
132
136
|
continue;
|
|
133
137
|
}
|
|
134
138
|
T.add(N);
|
|
135
|
-
for (const
|
|
136
|
-
T.has(
|
|
139
|
+
for (const L of getMountedOrPendingDependents(N, I, n))
|
|
140
|
+
T.has(L) || v.push(L);
|
|
137
141
|
}
|
|
138
|
-
for (let N =
|
|
139
|
-
const [I,
|
|
140
|
-
let
|
|
141
|
-
for (const
|
|
142
|
-
if (
|
|
143
|
-
|
|
142
|
+
for (let N = w.length - 1; N >= 0; --N) {
|
|
143
|
+
const [I, L] = w[N];
|
|
144
|
+
let P = !1;
|
|
145
|
+
for (const E of L.d.keys())
|
|
146
|
+
if (E !== I && a.has(E)) {
|
|
147
|
+
P = !0;
|
|
144
148
|
break;
|
|
145
149
|
}
|
|
146
|
-
|
|
150
|
+
P && (x(I), j(I)), r.delete(I);
|
|
147
151
|
}
|
|
148
|
-
}),
|
|
152
|
+
}), x = m[3] || ((w) => {
|
|
149
153
|
var T, k;
|
|
150
|
-
const v = f(
|
|
151
|
-
if (isAtomStateInitialized(v) && (n.has(
|
|
152
|
-
([
|
|
154
|
+
const v = f(w);
|
|
155
|
+
if (isAtomStateInitialized(v) && (n.has(w) && r.get(w) !== v.n || Array.from(v.d).every(
|
|
156
|
+
([R, O]) => (
|
|
153
157
|
// Recursively, read the atom state of the dependency, and
|
|
154
158
|
// check if the atom epoch number is unchanged
|
|
155
|
-
|
|
159
|
+
x(R).n === O
|
|
156
160
|
)
|
|
157
161
|
)))
|
|
158
162
|
return v;
|
|
159
163
|
v.d.clear();
|
|
160
164
|
let N = !0;
|
|
161
165
|
const I = () => {
|
|
162
|
-
n.has(
|
|
163
|
-
},
|
|
164
|
-
var
|
|
165
|
-
if (isSelfAtom(
|
|
166
|
-
const H = f(
|
|
166
|
+
n.has(w) && (j(w), b(), h());
|
|
167
|
+
}, L = (R) => {
|
|
168
|
+
var O;
|
|
169
|
+
if (isSelfAtom(w, R)) {
|
|
170
|
+
const H = f(R);
|
|
167
171
|
if (!isAtomStateInitialized(H))
|
|
168
|
-
if (hasInitialValue(
|
|
169
|
-
setAtomStateValueOrPromise(
|
|
172
|
+
if (hasInitialValue(R))
|
|
173
|
+
setAtomStateValueOrPromise(R, R.init, f);
|
|
170
174
|
else
|
|
171
175
|
throw new Error("no atom init");
|
|
172
176
|
return returnAtomValue(H);
|
|
173
177
|
}
|
|
174
|
-
const
|
|
178
|
+
const $ = x(R);
|
|
175
179
|
try {
|
|
176
|
-
return returnAtomValue(
|
|
180
|
+
return returnAtomValue($);
|
|
177
181
|
} finally {
|
|
178
|
-
v.d.set(
|
|
182
|
+
v.d.set(R, $.n), isPendingPromise(v.v) && addPendingPromiseToDependency(w, v.v, $), (O = n.get(R)) == null || O.t.add(w), N || I();
|
|
179
183
|
}
|
|
180
184
|
};
|
|
181
|
-
let
|
|
182
|
-
const
|
|
185
|
+
let P, E;
|
|
186
|
+
const D = {
|
|
183
187
|
get signal() {
|
|
184
|
-
return
|
|
188
|
+
return P || (P = new AbortController()), P.signal;
|
|
185
189
|
},
|
|
186
190
|
get setSelf() {
|
|
187
|
-
return !
|
|
191
|
+
return !E && isActuallyWritableAtom(w) && (E = (...R) => {
|
|
188
192
|
if (!N)
|
|
189
193
|
try {
|
|
190
|
-
return
|
|
194
|
+
return A(w, ...R);
|
|
191
195
|
} finally {
|
|
192
|
-
b(),
|
|
196
|
+
b(), h();
|
|
193
197
|
}
|
|
194
|
-
}),
|
|
198
|
+
}), E;
|
|
195
199
|
}
|
|
196
200
|
}, M = v.n;
|
|
197
201
|
try {
|
|
198
|
-
const
|
|
199
|
-
return setAtomStateValueOrPromise(
|
|
202
|
+
const R = d(w, L, D);
|
|
203
|
+
return setAtomStateValueOrPromise(w, R, f), isPromiseLike$2(R) && ((T = R.onCancel) == null || T.call(R, () => P == null ? void 0 : P.abort()), R.then(
|
|
200
204
|
I,
|
|
201
205
|
I
|
|
202
206
|
)), v;
|
|
203
|
-
} catch (
|
|
204
|
-
return delete v.v, v.e =
|
|
207
|
+
} catch (R) {
|
|
208
|
+
return delete v.v, v.e = R, ++v.n, v;
|
|
205
209
|
} finally {
|
|
206
|
-
N = !1, M !== v.n && r.get(
|
|
210
|
+
N = !1, M !== v.n && r.get(w) === M && (r.set(w, v.n), a.add(w), (k = c.c) == null || k.call(c, w));
|
|
207
211
|
}
|
|
208
|
-
}), y = m[4] || ((
|
|
209
|
-
const T = [
|
|
212
|
+
}), y = m[4] || ((w) => {
|
|
213
|
+
const T = [w];
|
|
210
214
|
for (; T.length; ) {
|
|
211
215
|
const k = T.pop(), v = f(k);
|
|
212
216
|
for (const N of getMountedOrPendingDependents(k, v, n)) {
|
|
@@ -214,73 +218,73 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
214
218
|
r.set(N, I.n), T.push(N);
|
|
215
219
|
}
|
|
216
220
|
}
|
|
217
|
-
}),
|
|
221
|
+
}), A = m[5] || ((w, ...T) => {
|
|
218
222
|
let k = !0;
|
|
219
|
-
const v = (I) => returnAtomValue(
|
|
220
|
-
var
|
|
221
|
-
const
|
|
223
|
+
const v = (I) => returnAtomValue(x(I)), N = (I, ...L) => {
|
|
224
|
+
var P;
|
|
225
|
+
const E = f(I);
|
|
222
226
|
try {
|
|
223
|
-
if (isSelfAtom(
|
|
227
|
+
if (isSelfAtom(w, I)) {
|
|
224
228
|
if (!hasInitialValue(I))
|
|
225
229
|
throw new Error("atom not writable");
|
|
226
|
-
const
|
|
227
|
-
setAtomStateValueOrPromise(I, M, f),
|
|
230
|
+
const D = E.n, M = L[0];
|
|
231
|
+
setAtomStateValueOrPromise(I, M, f), j(I), D !== E.n && (a.add(I), (P = c.c) == null || P.call(c, I), y(I));
|
|
228
232
|
return;
|
|
229
233
|
} else
|
|
230
|
-
return
|
|
234
|
+
return A(I, ...L);
|
|
231
235
|
} finally {
|
|
232
|
-
k || (b(),
|
|
236
|
+
k || (b(), h());
|
|
233
237
|
}
|
|
234
238
|
};
|
|
235
239
|
try {
|
|
236
|
-
return p(
|
|
240
|
+
return p(w, v, N, ...T);
|
|
237
241
|
} finally {
|
|
238
242
|
k = !1;
|
|
239
243
|
}
|
|
240
|
-
}),
|
|
244
|
+
}), j = m[6] || ((w) => {
|
|
241
245
|
var T;
|
|
242
|
-
const k = f(
|
|
246
|
+
const k = f(w), v = n.get(w);
|
|
243
247
|
if (v && !isPendingPromise(k.v)) {
|
|
244
248
|
for (const [N, I] of k.d)
|
|
245
249
|
if (!v.d.has(N)) {
|
|
246
|
-
const
|
|
247
|
-
|
|
250
|
+
const L = f(N);
|
|
251
|
+
C(N).t.add(w), v.d.add(N), I !== L.n && (a.add(N), (T = c.c) == null || T.call(c, N), y(N));
|
|
248
252
|
}
|
|
249
253
|
for (const N of v.d || [])
|
|
250
254
|
if (!k.d.has(N)) {
|
|
251
255
|
v.d.delete(N);
|
|
252
256
|
const I = S(N);
|
|
253
|
-
I == null || I.t.delete(
|
|
257
|
+
I == null || I.t.delete(w);
|
|
254
258
|
}
|
|
255
259
|
}
|
|
256
|
-
}),
|
|
260
|
+
}), C = m[7] || ((w) => {
|
|
257
261
|
var T;
|
|
258
|
-
const k = f(
|
|
259
|
-
let v = n.get(
|
|
262
|
+
const k = f(w);
|
|
263
|
+
let v = n.get(w);
|
|
260
264
|
if (!v) {
|
|
261
|
-
|
|
265
|
+
x(w);
|
|
262
266
|
for (const N of k.d.keys())
|
|
263
|
-
|
|
267
|
+
C(N).t.add(w);
|
|
264
268
|
if (v = {
|
|
265
269
|
l: /* @__PURE__ */ new Set(),
|
|
266
270
|
d: new Set(k.d.keys()),
|
|
267
271
|
t: /* @__PURE__ */ new Set()
|
|
268
|
-
}, n.set(
|
|
272
|
+
}, n.set(w, v), (T = c.m) == null || T.call(c, w), isActuallyWritableAtom(w)) {
|
|
269
273
|
const N = () => {
|
|
270
274
|
let I = !0;
|
|
271
|
-
const
|
|
275
|
+
const L = (...P) => {
|
|
272
276
|
try {
|
|
273
|
-
return
|
|
277
|
+
return A(w, ...P);
|
|
274
278
|
} finally {
|
|
275
|
-
I || (b(),
|
|
279
|
+
I || (b(), h());
|
|
276
280
|
}
|
|
277
281
|
};
|
|
278
282
|
try {
|
|
279
|
-
const
|
|
280
|
-
|
|
283
|
+
const P = g(w, L);
|
|
284
|
+
P && (v.u = () => {
|
|
281
285
|
I = !0;
|
|
282
286
|
try {
|
|
283
|
-
|
|
287
|
+
P();
|
|
284
288
|
} finally {
|
|
285
289
|
I = !1;
|
|
286
290
|
}
|
|
@@ -293,23 +297,23 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
293
297
|
}
|
|
294
298
|
}
|
|
295
299
|
return v;
|
|
296
|
-
}), S = m[8] || ((
|
|
300
|
+
}), S = m[8] || ((w) => {
|
|
297
301
|
var T;
|
|
298
|
-
const k = f(
|
|
299
|
-
let v = n.get(
|
|
302
|
+
const k = f(w);
|
|
303
|
+
let v = n.get(w);
|
|
300
304
|
if (v && !v.l.size && !Array.from(v.t).some((N) => {
|
|
301
305
|
var I;
|
|
302
|
-
return (I = n.get(N)) == null ? void 0 : I.d.has(
|
|
306
|
+
return (I = n.get(N)) == null ? void 0 : I.d.has(w);
|
|
303
307
|
})) {
|
|
304
|
-
v.u && i.add(v.u), v = void 0, n.delete(
|
|
308
|
+
v.u && i.add(v.u), v = void 0, n.delete(w), (T = c.u) == null || T.call(c, w);
|
|
305
309
|
for (const N of k.d.keys()) {
|
|
306
310
|
const I = S(N);
|
|
307
|
-
I == null || I.t.delete(
|
|
311
|
+
I == null || I.t.delete(w);
|
|
308
312
|
}
|
|
309
313
|
return;
|
|
310
314
|
}
|
|
311
315
|
return v;
|
|
312
|
-
}),
|
|
316
|
+
}), B = [
|
|
313
317
|
// store state
|
|
314
318
|
o,
|
|
315
319
|
n,
|
|
@@ -325,31 +329,31 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
325
329
|
g,
|
|
326
330
|
// building-block functions
|
|
327
331
|
f,
|
|
328
|
-
x,
|
|
329
|
-
b,
|
|
330
332
|
h,
|
|
333
|
+
b,
|
|
334
|
+
x,
|
|
331
335
|
y,
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
336
|
+
A,
|
|
337
|
+
j,
|
|
338
|
+
C,
|
|
335
339
|
S
|
|
336
340
|
], _ = {
|
|
337
|
-
get: (
|
|
338
|
-
set: (
|
|
341
|
+
get: (w) => returnAtomValue(x(w)),
|
|
342
|
+
set: (w, ...T) => {
|
|
339
343
|
try {
|
|
340
|
-
return
|
|
344
|
+
return A(w, ...T);
|
|
341
345
|
} finally {
|
|
342
|
-
b(),
|
|
346
|
+
b(), h();
|
|
343
347
|
}
|
|
344
348
|
},
|
|
345
|
-
sub: (
|
|
346
|
-
const v = w
|
|
347
|
-
return v.add(T),
|
|
348
|
-
v.delete(T), S(
|
|
349
|
+
sub: (w, T) => {
|
|
350
|
+
const v = C(w).l;
|
|
351
|
+
return v.add(T), h(), () => {
|
|
352
|
+
v.delete(T), S(w), h();
|
|
349
353
|
};
|
|
350
354
|
}
|
|
351
355
|
};
|
|
352
|
-
return Object.defineProperty(_, BUILDING_BLOCKS, { value:
|
|
356
|
+
return Object.defineProperty(_, BUILDING_BLOCKS, { value: B }), _;
|
|
353
357
|
}, INTERNAL_buildStoreRev1 = buildStore;
|
|
354
358
|
let keyCount = 0;
|
|
355
359
|
function atom(o, n) {
|
|
@@ -385,36 +389,36 @@ function splitAtom(o, n) {
|
|
|
385
389
|
if (p)
|
|
386
390
|
return p;
|
|
387
391
|
const u = d && r.get(d), g = [], m = [];
|
|
388
|
-
return c.forEach((f,
|
|
389
|
-
const b =
|
|
390
|
-
m[
|
|
391
|
-
const
|
|
392
|
-
if (
|
|
393
|
-
g[
|
|
392
|
+
return c.forEach((f, h) => {
|
|
393
|
+
const b = h;
|
|
394
|
+
m[h] = b;
|
|
395
|
+
const x = u && u.atomList[u.keyList.indexOf(b)];
|
|
396
|
+
if (x) {
|
|
397
|
+
g[h] = x;
|
|
394
398
|
return;
|
|
395
399
|
}
|
|
396
|
-
const y = (
|
|
397
|
-
const
|
|
400
|
+
const y = (j) => {
|
|
401
|
+
const C = j(l), S = j(o), _ = a(S, C == null ? void 0 : C.arr).keyList.indexOf(b);
|
|
398
402
|
if (_ < 0 || _ >= S.length) {
|
|
399
|
-
const
|
|
400
|
-
if (
|
|
401
|
-
return
|
|
403
|
+
const w = c[a(c).keyList.indexOf(b)];
|
|
404
|
+
if (w)
|
|
405
|
+
return w;
|
|
402
406
|
throw new Error("splitAtom: index out of bounds for read");
|
|
403
407
|
}
|
|
404
408
|
return S[_];
|
|
405
|
-
},
|
|
406
|
-
const
|
|
409
|
+
}, A = (j, C, S) => {
|
|
410
|
+
const B = j(l), _ = j(o), T = a(_, B == null ? void 0 : B.arr).keyList.indexOf(b);
|
|
407
411
|
if (T < 0 || T >= _.length)
|
|
408
412
|
throw new Error("splitAtom: index out of bounds for write");
|
|
409
413
|
const k = isFunction(S) ? S(_[T]) : S;
|
|
410
|
-
Object.is(_[T], k) ||
|
|
414
|
+
Object.is(_[T], k) || C(o, [
|
|
411
415
|
..._.slice(0, T),
|
|
412
416
|
k,
|
|
413
417
|
..._.slice(T + 1)
|
|
414
418
|
]);
|
|
415
419
|
};
|
|
416
|
-
g[
|
|
417
|
-
}), u && u.keyList.length === m.length && u.keyList.every((f,
|
|
420
|
+
g[h] = isWritable(o) ? atom(y, A) : atom(y);
|
|
421
|
+
}), u && u.keyList.length === m.length && u.keyList.every((f, h) => f === m[h]) ? p = u : p = { arr: c, atomList: g, keyList: m }, r.set(c, p), p;
|
|
418
422
|
}, l = atom((c) => {
|
|
419
423
|
const d = c(l), p = c(o);
|
|
420
424
|
return a(p, d == null ? void 0 : d.arr);
|
|
@@ -497,8 +501,8 @@ function createJSONStorage(o = () => {
|
|
|
497
501
|
a = b;
|
|
498
502
|
}
|
|
499
503
|
return l;
|
|
500
|
-
},
|
|
501
|
-
return isPromiseLike$1(
|
|
504
|
+
}, h = (m = (g = o()) == null ? void 0 : g.getItem(p)) != null ? m : null;
|
|
505
|
+
return isPromiseLike$1(h) ? h.then(f) : f(h);
|
|
502
506
|
},
|
|
503
507
|
setItem: (p, u) => {
|
|
504
508
|
var g;
|
|
@@ -512,13 +516,13 @@ function createJSONStorage(o = () => {
|
|
|
512
516
|
return (u = o()) == null ? void 0 : u.removeItem(p);
|
|
513
517
|
}
|
|
514
518
|
}, c = (p) => (u, g, m) => p(u, (f) => {
|
|
515
|
-
let
|
|
519
|
+
let h;
|
|
516
520
|
try {
|
|
517
|
-
|
|
521
|
+
h = JSON.parse(f || "");
|
|
518
522
|
} catch {
|
|
519
|
-
|
|
523
|
+
h = m;
|
|
520
524
|
}
|
|
521
|
-
g(
|
|
525
|
+
g(h);
|
|
522
526
|
});
|
|
523
527
|
let d;
|
|
524
528
|
try {
|
|
@@ -689,17 +693,17 @@ class Content extends Component {
|
|
|
689
693
|
class Frame extends Component {
|
|
690
694
|
constructor(r, a) {
|
|
691
695
|
super(r, a);
|
|
692
|
-
|
|
696
|
+
V(this, "setRef", (r) => {
|
|
693
697
|
this.nodeRef.current = r;
|
|
694
698
|
const { forwardedRef: a } = this.props;
|
|
695
699
|
typeof a == "function" ? a(r) : a && (a.current = r);
|
|
696
700
|
});
|
|
697
|
-
|
|
701
|
+
V(this, "handleLoad", () => {
|
|
698
702
|
clearInterval(this.loadCheck), this.state.iframeLoaded || this.setState({ iframeLoaded: !0 });
|
|
699
703
|
});
|
|
700
704
|
// In certain situations on a cold cache DOMContentLoaded never gets called
|
|
701
705
|
// fallback to an interval to check if that's the case
|
|
702
|
-
|
|
706
|
+
V(this, "loadCheck", () => setInterval(() => {
|
|
703
707
|
this.handleLoad();
|
|
704
708
|
}, 500));
|
|
705
709
|
this._isMounted = !1, this.nodeRef = React__default.createRef(), this.state = { iframeLoaded: !1 };
|
|
@@ -736,7 +740,7 @@ class Frame extends Component {
|
|
|
736
740
|
return delete r.head, delete r.initialContent, delete r.mountTarget, delete r.contentDidMount, delete r.contentDidUpdate, delete r.forwardedRef, /* @__PURE__ */ jsx("iframe", { ...r, ref: this.setRef, onLoad: this.handleLoad, children: this.state.iframeLoaded && this.renderFrameContents() });
|
|
737
741
|
}
|
|
738
742
|
}
|
|
739
|
-
|
|
743
|
+
V(Frame, "defaultProps", {
|
|
740
744
|
style: {},
|
|
741
745
|
head: null,
|
|
742
746
|
children: void 0,
|
|
@@ -1340,50 +1344,50 @@ const useBlocksStoreManager = () => {
|
|
|
1340
1344
|
updateBlocksProps: c
|
|
1341
1345
|
} = useBlocksStoreManager();
|
|
1342
1346
|
return {
|
|
1343
|
-
moveBlocks: (b,
|
|
1344
|
-
const
|
|
1345
|
-
const
|
|
1346
|
-
return { _id:
|
|
1347
|
-
}),
|
|
1348
|
-
|
|
1349
|
-
undo: () => each(
|
|
1350
|
-
i([
|
|
1347
|
+
moveBlocks: (b, x, y) => {
|
|
1348
|
+
const A = map(b, (C) => {
|
|
1349
|
+
const B = n.find((T) => T._id === C)._parent || null, w = n.filter((T) => B ? T._parent === B : !T._parent).map((T) => T._id).indexOf(C);
|
|
1350
|
+
return { _id: C, oldParent: B, oldPosition: w };
|
|
1351
|
+
}), j = A.find(({ _id: C }) => C === b[0]);
|
|
1352
|
+
j && j.oldParent === x && j.oldPosition === y || (i(b, x, y), o({
|
|
1353
|
+
undo: () => each(A, ({ _id: C, oldParent: S, oldPosition: B }) => {
|
|
1354
|
+
i([C], S, B);
|
|
1351
1355
|
}),
|
|
1352
|
-
redo: () => i(b,
|
|
1356
|
+
redo: () => i(b, x, y)
|
|
1353
1357
|
}));
|
|
1354
1358
|
},
|
|
1355
|
-
addBlocks: (b,
|
|
1356
|
-
a(b,
|
|
1359
|
+
addBlocks: (b, x, y) => {
|
|
1360
|
+
a(b, x, y), o({
|
|
1357
1361
|
undo: () => l(map(b, "_id")),
|
|
1358
|
-
redo: () => a(b,
|
|
1362
|
+
redo: () => a(b, x, y)
|
|
1359
1363
|
});
|
|
1360
1364
|
},
|
|
1361
1365
|
removeBlocks: (b) => {
|
|
1362
|
-
var
|
|
1363
|
-
const
|
|
1366
|
+
var j;
|
|
1367
|
+
const x = (j = first(b)) == null ? void 0 : j._parent, A = n.filter((C) => x ? C._parent === x : !C._parent).indexOf(first(b));
|
|
1364
1368
|
l(map(b, "_id")), o({
|
|
1365
|
-
undo: () => a(b,
|
|
1369
|
+
undo: () => a(b, x, A),
|
|
1366
1370
|
redo: () => l(map(b, "_id"))
|
|
1367
1371
|
});
|
|
1368
1372
|
},
|
|
1369
|
-
updateBlocks: (b,
|
|
1370
|
-
let
|
|
1373
|
+
updateBlocks: (b, x, y) => {
|
|
1374
|
+
let A = [];
|
|
1371
1375
|
if (y)
|
|
1372
|
-
|
|
1376
|
+
A = map(b, (j) => ({ _id: j, ...y }));
|
|
1373
1377
|
else {
|
|
1374
|
-
const
|
|
1375
|
-
|
|
1376
|
-
const S = n.find((_) => _._id ===
|
|
1377
|
-
return each(
|
|
1378
|
+
const j = keys(x);
|
|
1379
|
+
A = map(b, (C) => {
|
|
1380
|
+
const S = n.find((_) => _._id === C), B = { _id: C };
|
|
1381
|
+
return each(j, (_) => B[_] = S[_]), B;
|
|
1378
1382
|
});
|
|
1379
1383
|
}
|
|
1380
|
-
c(map(b, (
|
|
1381
|
-
undo: () => c(
|
|
1382
|
-
redo: () => c(map(b, (
|
|
1384
|
+
c(map(b, (j) => ({ _id: j, ...x }))), o({
|
|
1385
|
+
undo: () => c(A),
|
|
1386
|
+
redo: () => c(map(b, (j) => ({ _id: j, ...x })))
|
|
1383
1387
|
});
|
|
1384
1388
|
},
|
|
1385
|
-
updateBlocksRuntime: (b,
|
|
1386
|
-
c(map(b, (y) => ({ _id: y, ...
|
|
1389
|
+
updateBlocksRuntime: (b, x) => {
|
|
1390
|
+
c(map(b, (y) => ({ _id: y, ...x })));
|
|
1387
1391
|
},
|
|
1388
1392
|
setNewBlocks: (b) => {
|
|
1389
1393
|
r(b), o({
|
|
@@ -1392,12 +1396,12 @@ const useBlocksStoreManager = () => {
|
|
|
1392
1396
|
});
|
|
1393
1397
|
},
|
|
1394
1398
|
updateMultipleBlocksProps: (b) => {
|
|
1395
|
-
let
|
|
1396
|
-
|
|
1397
|
-
const
|
|
1398
|
-
return each(
|
|
1399
|
+
let x = [];
|
|
1400
|
+
x = map(b, (y) => {
|
|
1401
|
+
const A = keys(y), j = n.find((S) => S._id === y._id), C = {};
|
|
1402
|
+
return each(A, (S) => C[S] = j[S]), C;
|
|
1399
1403
|
}), c(b), o({
|
|
1400
|
-
undo: () => c(
|
|
1404
|
+
undo: () => c(x),
|
|
1401
1405
|
redo: () => c(b)
|
|
1402
1406
|
});
|
|
1403
1407
|
}
|
|
@@ -1435,12 +1439,12 @@ const useAddBlock = () => {
|
|
|
1435
1439
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
1436
1440
|
(i, c, d) => {
|
|
1437
1441
|
var f;
|
|
1438
|
-
for (let
|
|
1439
|
-
const { _id: b } = i[
|
|
1440
|
-
i[
|
|
1441
|
-
const
|
|
1442
|
-
for (let y = 0; y <
|
|
1443
|
-
|
|
1442
|
+
for (let h = 0; h < i.length; h++) {
|
|
1443
|
+
const { _id: b } = i[h];
|
|
1444
|
+
i[h]._id = generateUUID();
|
|
1445
|
+
const x = filter(i, { _parent: b });
|
|
1446
|
+
for (let y = 0; y < x.length; y++)
|
|
1447
|
+
x[y]._parent = i[h]._id;
|
|
1444
1448
|
}
|
|
1445
1449
|
const p = first(i);
|
|
1446
1450
|
let u, g;
|
|
@@ -1451,8 +1455,8 @@ const useAddBlock = () => {
|
|
|
1451
1455
|
return { addCoreBlock: useCallback(
|
|
1452
1456
|
(i, c, d) => {
|
|
1453
1457
|
if (has(i, "blocks")) {
|
|
1454
|
-
const
|
|
1455
|
-
return a(
|
|
1458
|
+
const x = i.blocks;
|
|
1459
|
+
return a(x, c, d);
|
|
1456
1460
|
}
|
|
1457
1461
|
const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
|
|
1458
1462
|
_type: i.type,
|
|
@@ -2906,43 +2910,43 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2906
2910
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
2907
2911
|
})
|
|
2908
2912
|
), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
|
|
2909
|
-
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (f,
|
|
2910
|
-
const b = cloneDeep(
|
|
2911
|
-
for (const
|
|
2912
|
-
const y = b[
|
|
2913
|
+
const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (f, h) => {
|
|
2914
|
+
const b = cloneDeep(h.find((x) => x._id === f));
|
|
2915
|
+
for (const x in b) {
|
|
2916
|
+
const y = b[x];
|
|
2913
2917
|
if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
|
|
2914
|
-
const { baseClasses:
|
|
2915
|
-
b[
|
|
2918
|
+
const { baseClasses: A, classes: j } = getSplitChaiClasses(y);
|
|
2919
|
+
b[x] = compact(flattenDeep([A, j])).join(" ");
|
|
2916
2920
|
} else
|
|
2917
|
-
|
|
2921
|
+
x !== "_id" && delete b[x];
|
|
2918
2922
|
}
|
|
2919
2923
|
return b;
|
|
2920
2924
|
};
|
|
2921
2925
|
return {
|
|
2922
2926
|
askAi: useCallback(
|
|
2923
|
-
async (f,
|
|
2927
|
+
async (f, h, b, x) => {
|
|
2924
2928
|
if (l) {
|
|
2925
2929
|
n(!0), a(null);
|
|
2926
2930
|
try {
|
|
2927
|
-
const y = p === u ? "" : p,
|
|
2931
|
+
const y = p === u ? "" : p, A = f === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(h, d)), p) : [m(h, d)], j = await l(f, addLangToPrompt(b, g, f), A, y), { blocks: C, error: S } = j;
|
|
2928
2932
|
if (S) {
|
|
2929
2933
|
a(S);
|
|
2930
2934
|
return;
|
|
2931
2935
|
}
|
|
2932
2936
|
if (f === "styles") {
|
|
2933
|
-
const
|
|
2934
|
-
for (const
|
|
2935
|
-
|
|
2937
|
+
const B = C.map((_) => {
|
|
2938
|
+
for (const w in _)
|
|
2939
|
+
w !== "_id" && (_[w] = `${STYLES_KEY},${_[w]}`);
|
|
2936
2940
|
return _;
|
|
2937
2941
|
});
|
|
2938
|
-
c(
|
|
2942
|
+
c(B);
|
|
2939
2943
|
} else
|
|
2940
|
-
i(
|
|
2941
|
-
|
|
2944
|
+
i(C);
|
|
2945
|
+
x && x(j);
|
|
2942
2946
|
} catch (y) {
|
|
2943
2947
|
a(y);
|
|
2944
2948
|
} finally {
|
|
2945
|
-
n(!1),
|
|
2949
|
+
n(!1), x && x();
|
|
2946
2950
|
}
|
|
2947
2951
|
}
|
|
2948
2952
|
},
|
|
@@ -3175,13 +3179,13 @@ const useBlockHighlight = () => {
|
|
|
3175
3179
|
const d = o(c), p = a;
|
|
3176
3180
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
3177
3181
|
return each(p, (m) => {
|
|
3178
|
-
const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
3179
|
-
u = u.replace(
|
|
3182
|
+
const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
|
|
3183
|
+
u = u.replace(h, " ").replace(/\s+/g, " ").trim();
|
|
3180
3184
|
const b = first(m.split(":"));
|
|
3181
3185
|
includes(["2xl", "xl", "lg", "md", "sm"], b) && p.push(m.split(":").pop().trim());
|
|
3182
3186
|
}), each(p, (m) => {
|
|
3183
|
-
const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
3184
|
-
g = g.replace(
|
|
3187
|
+
const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
|
|
3188
|
+
g = g.replace(h, " ").replace(/\s+/g, " ").trim();
|
|
3185
3189
|
}), {
|
|
3186
3190
|
ids: [d._id],
|
|
3187
3191
|
props: {
|
|
@@ -3274,7 +3278,7 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), layoutVariantAto
|
|
|
3274
3278
|
};
|
|
3275
3279
|
class PubSub {
|
|
3276
3280
|
constructor() {
|
|
3277
|
-
|
|
3281
|
+
V(this, "subscribers", /* @__PURE__ */ new Map());
|
|
3278
3282
|
}
|
|
3279
3283
|
subscribe(n, r) {
|
|
3280
3284
|
return this.subscribers.has(n) || this.subscribers.set(n, /* @__PURE__ */ new Set()), this.subscribers.get(n).add(r), () => {
|
|
@@ -3322,13 +3326,13 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3322
3326
|
tabIndex: 0,
|
|
3323
3327
|
ref: u.setFloating,
|
|
3324
3328
|
style: p,
|
|
3325
|
-
onClick: (
|
|
3326
|
-
|
|
3329
|
+
onClick: (h) => {
|
|
3330
|
+
h.stopPropagation(), h.preventDefault();
|
|
3327
3331
|
},
|
|
3328
|
-
onMouseEnter: (
|
|
3329
|
-
|
|
3332
|
+
onMouseEnter: (h) => {
|
|
3333
|
+
h.stopPropagation(), i(null);
|
|
3330
3334
|
},
|
|
3331
|
-
onKeyDown: (
|
|
3335
|
+
onKeyDown: (h) => h.stopPropagation(),
|
|
3332
3336
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3333
3337
|
children: [
|
|
3334
3338
|
m && /* @__PURE__ */ jsx(
|
|
@@ -3409,7 +3413,6 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3409
3413
|
</head>
|
|
3410
3414
|
<body class="font-body antialiased h-full">
|
|
3411
3415
|
<div class="frame-root h-full"></div>
|
|
3412
|
-
<script src="https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.js"><\/script>
|
|
3413
3416
|
</body>
|
|
3414
3417
|
</html>`, useKeyEventWatcher = (o) => {
|
|
3415
3418
|
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), f = o ? { document: o } : {};
|
|
@@ -3425,8 +3428,8 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3425
3428
|
i
|
|
3426
3429
|
]), useHotkeys(
|
|
3427
3430
|
"del, backspace",
|
|
3428
|
-
(
|
|
3429
|
-
|
|
3431
|
+
(h) => {
|
|
3432
|
+
h.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
|
|
3430
3433
|
},
|
|
3431
3434
|
f,
|
|
3432
3435
|
[n, l]
|
|
@@ -3524,25 +3527,25 @@ const useDnd = () => {
|
|
|
3524
3527
|
},
|
|
3525
3528
|
onDrop: (f) => {
|
|
3526
3529
|
var S;
|
|
3527
|
-
const
|
|
3528
|
-
dropIndex = calculateDropIndex(
|
|
3529
|
-
const y = d,
|
|
3530
|
-
if ((y == null ? void 0 : y._id) ===
|
|
3530
|
+
const h = dropTarget, x = getOrientation(h) === "vertical" ? f.clientY + ((S = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : S.scrollY) : f.clientX;
|
|
3531
|
+
dropIndex = calculateDropIndex(x, possiblePositions);
|
|
3532
|
+
const y = d, A = h.getAttribute("data-block-id"), j = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
|
|
3533
|
+
if ((y == null ? void 0 : y._id) === A || !j) {
|
|
3531
3534
|
m();
|
|
3532
3535
|
return;
|
|
3533
3536
|
}
|
|
3534
3537
|
if (!has(y, "_id")) {
|
|
3535
|
-
a(y,
|
|
3538
|
+
a(y, A === "canvas" ? null : A, dropIndex), setTimeout(m, 300);
|
|
3536
3539
|
return;
|
|
3537
3540
|
}
|
|
3538
|
-
let
|
|
3539
|
-
|
|
3541
|
+
let C = h.getAttribute("data-block-id");
|
|
3542
|
+
C === null && (C = f.target.parentElement.getAttribute("data-block-id")), c([y._id], C === "canvas" ? null : C, dropIndex), m(), setTimeout(removePlaceholder, 300);
|
|
3540
3543
|
},
|
|
3541
3544
|
onDragEnter: (f) => {
|
|
3542
|
-
const
|
|
3545
|
+
const h = f, b = h.target;
|
|
3543
3546
|
dropTarget = b;
|
|
3544
|
-
const
|
|
3545
|
-
u(
|
|
3547
|
+
const x = b.getAttribute("data-block-id"), y = b.getAttribute("data-dnd-dragged") !== "yes";
|
|
3548
|
+
u(x), h.stopPropagation(), h.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(b), r(!0), l(""), i([]);
|
|
3546
3549
|
},
|
|
3547
3550
|
onDragLeave: (f) => {
|
|
3548
3551
|
f.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
|
|
@@ -3557,36 +3560,29 @@ function getTargetedBlock(o) {
|
|
|
3557
3560
|
const n = o.closest("[data-block-id]");
|
|
3558
3561
|
return (n == null ? void 0 : n.getAttribute("data-block-id")) === "canvas" ? null : n;
|
|
3559
3562
|
}
|
|
3560
|
-
|
|
3561
|
-
|
|
3562
|
-
const n = document.querySelector(".ql-toolbar");
|
|
3563
|
-
n && n.parentNode.removeChild(n), o = null;
|
|
3564
|
-
}
|
|
3565
|
-
const useHandleCanvasDblClick = () => {
|
|
3566
|
-
const o = ["Heading", "Paragraph", "Text", "Link", "Span", "Button"], n = useUpdateBlocksProps(), [r, a] = useAtom$1(inlineEditingActiveAtom), { clearHighlight: l } = useBlockHighlight(), i = useGetBlockAtomValue(pageBlocksAtomsAtom);
|
|
3563
|
+
const useHandleCanvasDblClick = (o, n) => {
|
|
3564
|
+
const r = [], a = useUpdateBlocksProps(), [l, i] = useAtom$1(inlineEditingActiveAtom), { clearHighlight: c } = useBlockHighlight(), d = useGetBlockAtomValue(pageBlocksAtomsAtom);
|
|
3567
3565
|
return useCallback(
|
|
3568
|
-
(
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3566
|
+
(p) => {
|
|
3567
|
+
if (l) return;
|
|
3568
|
+
const u = getTargetedBlock(p.target);
|
|
3569
|
+
if (!u) return;
|
|
3570
|
+
const g = u.getAttribute("data-block-type");
|
|
3571
|
+
if (!g || !r.includes(g))
|
|
3573
3572
|
return;
|
|
3574
|
-
const
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
|
|
3580
|
-
const h =
|
|
3581
|
-
|
|
3582
|
-
}
|
|
3583
|
-
|
|
3584
|
-
|
|
3585
|
-
}), m.addEventListener("keydown", (h) => {
|
|
3586
|
-
(h.key === "Enter" || h.key === "Escape") && x();
|
|
3587
|
-
}), f.focus(), (b = m.querySelector(".ql-clipboard")) == null || b.remove(), a(d.getAttribute("data-block-id"));
|
|
3573
|
+
const m = u.getAttribute("data-block-id");
|
|
3574
|
+
if (!m) return;
|
|
3575
|
+
o.on("update", ({ editor: h }) => {
|
|
3576
|
+
console.log(h.getHTML());
|
|
3577
|
+
}), o.on("blur", () => {
|
|
3578
|
+
console.log("blur");
|
|
3579
|
+
const h = o.getHTML();
|
|
3580
|
+
a([m], { content: h }), n.style.display = "none", u.style.visibility = "visible";
|
|
3581
|
+
}), i(m);
|
|
3582
|
+
const f = d(m).content;
|
|
3583
|
+
o.commands.setContent(f), n.style.display = "block", u.style.visibility = "hidden", n.style.position = "absolute", n.style.top = `${u.offsetTop}px`, n.style.left = `${u.offsetLeft}px`, n.style.width = `${u.offsetWidth}px`, n.style.height = `${u.offsetHeight}px`, n.classList.add(...u.classList);
|
|
3588
3584
|
},
|
|
3589
|
-
[
|
|
3585
|
+
[l, c, d, i, a, o, n]
|
|
3590
3586
|
);
|
|
3591
3587
|
}, useHandleCanvasClick = () => {
|
|
3592
3588
|
const [, o] = useSelectedStylingBlocks(), [n, r] = useSelectedBlockIds(), [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(treeRefAtom), { clearHighlight: i } = useBlockHighlight();
|
|
@@ -3623,28 +3619,30 @@ const useHandleCanvasDblClick = () => {
|
|
|
3623
3619
|
setTimeout(() => {
|
|
3624
3620
|
if (!isEmpty(a))
|
|
3625
3621
|
return;
|
|
3626
|
-
const
|
|
3627
|
-
if (
|
|
3628
|
-
const
|
|
3629
|
-
if (
|
|
3630
|
-
const x =
|
|
3631
|
-
l([{ id: x, prop:
|
|
3622
|
+
const h = getElementByDataBlockId(n, first(r));
|
|
3623
|
+
if (h) {
|
|
3624
|
+
const b = h.getAttribute("data-style-prop");
|
|
3625
|
+
if (b) {
|
|
3626
|
+
const x = h.getAttribute("data-style-id"), y = h.getAttribute("data-block-parent");
|
|
3627
|
+
l([{ id: x, prop: b, blockId: y }]);
|
|
3632
3628
|
}
|
|
3633
3629
|
}
|
|
3634
3630
|
}, 100);
|
|
3635
3631
|
}, [n, r, l, a]);
|
|
3636
|
-
const c =
|
|
3632
|
+
const c = useEditor({
|
|
3633
|
+
extensions: [StarterKit]
|
|
3634
|
+
}), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(), f = useDnd();
|
|
3637
3635
|
return /* @__PURE__ */ jsx(
|
|
3638
3636
|
"div",
|
|
3639
3637
|
{
|
|
3640
3638
|
"data-block-id": "canvas",
|
|
3641
3639
|
id: "canvas",
|
|
3642
|
-
onClick:
|
|
3643
|
-
onDoubleClick:
|
|
3644
|
-
onMouseMove:
|
|
3645
|
-
onMouseLeave:
|
|
3646
|
-
...omit(
|
|
3647
|
-
className: "relative h-full max-w-full p-px " + (
|
|
3640
|
+
onClick: u,
|
|
3641
|
+
onDoubleClick: p,
|
|
3642
|
+
onMouseMove: g,
|
|
3643
|
+
onMouseLeave: m,
|
|
3644
|
+
...omit(f, "isDragging"),
|
|
3645
|
+
className: "relative h-full max-w-full p-px " + (f.isDragging ? "dragging" : ""),
|
|
3648
3646
|
children: o
|
|
3649
3647
|
}
|
|
3650
3648
|
);
|
|
@@ -3678,8 +3676,8 @@ const useHandleCanvasDblClick = () => {
|
|
|
3678
3676
|
forms,
|
|
3679
3677
|
aspectRatio,
|
|
3680
3678
|
containerQueries,
|
|
3681
|
-
plugin(function({ addBase:
|
|
3682
|
-
|
|
3679
|
+
plugin(function({ addBase: x, theme: y }) {
|
|
3680
|
+
x({
|
|
3683
3681
|
"h1,h2,h3,h4,h5,h6": {
|
|
3684
3682
|
fontFamily: y("fontFamily.heading")
|
|
3685
3683
|
},
|
|
@@ -3693,7 +3691,7 @@ const useHandleCanvasDblClick = () => {
|
|
|
3693
3691
|
]
|
|
3694
3692
|
});
|
|
3695
3693
|
}, [o, n, p]), useEffect(() => {
|
|
3696
|
-
g && (g.textContent = `${map(r, (
|
|
3694
|
+
g && (g.textContent = `${map(r, (x) => `[data-block-id="${x}"]`).join(",")}{
|
|
3697
3695
|
outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
|
|
3698
3696
|
}`);
|
|
3699
3697
|
}, [r, g]), useEffect(() => {
|
|
@@ -3701,18 +3699,18 @@ const useHandleCanvasDblClick = () => {
|
|
|
3701
3699
|
}, [i, f]), useEffect(() => {
|
|
3702
3700
|
u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
|
|
3703
3701
|
}, [u]), useEffect(() => {
|
|
3704
|
-
m && (m.textContent = `${map(l, ({ id:
|
|
3702
|
+
m && (m.textContent = `${map(l, ({ id: x }) => `[data-style-id="${x}"]`).join(",")}{
|
|
3705
3703
|
outline: 1px solid orange !important; outline-offset: -1px;
|
|
3706
3704
|
}`);
|
|
3707
3705
|
}, [l, m]), useEffect(() => {
|
|
3708
3706
|
d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
|
|
3709
3707
|
}, [c, d]);
|
|
3710
|
-
const
|
|
3708
|
+
const h = useMemo(
|
|
3711
3709
|
() => getChaiThemeCssVariables(o),
|
|
3712
3710
|
[o]
|
|
3713
3711
|
), b = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
|
|
3714
3712
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3715
|
-
/* @__PURE__ */ jsx("style", { id: "chai-theme", children:
|
|
3713
|
+
/* @__PURE__ */ jsx("style", { id: "chai-theme", children: h }),
|
|
3716
3714
|
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: b } })
|
|
3717
3715
|
] });
|
|
3718
3716
|
}, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
|
|
@@ -3790,10 +3788,10 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3790
3788
|
[o]
|
|
3791
3789
|
);
|
|
3792
3790
|
}, BlockRenderer = ({ blockAtom: o, children: n }) => {
|
|
3793
|
-
const [r] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(
|
|
3794
|
-
() =>
|
|
3795
|
-
[r, l, a, d,
|
|
3796
|
-
),
|
|
3791
|
+
const [r] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), m = useMemo(
|
|
3792
|
+
() => u ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
|
|
3793
|
+
[r, l, a, d, u]
|
|
3794
|
+
), f = useMemo(() => getBlockTagAttributes(r), [r]), h = useMemo(() => c(r._id, getBlockRuntimeProps(r._type)), [r]), b = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), x = useMemo(
|
|
3797
3795
|
() => ({
|
|
3798
3796
|
blockProps: {
|
|
3799
3797
|
"data-block-id": r._id,
|
|
@@ -3801,14 +3799,14 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3801
3799
|
},
|
|
3802
3800
|
inBuilder: !0,
|
|
3803
3801
|
lang: l || i,
|
|
3802
|
+
...m,
|
|
3804
3803
|
...f,
|
|
3805
|
-
...
|
|
3806
|
-
...b
|
|
3807
|
-
...h
|
|
3804
|
+
...h,
|
|
3805
|
+
...b
|
|
3808
3806
|
}),
|
|
3809
|
-
[r, l, i, f,
|
|
3807
|
+
[r, l, i, m, f, h, b]
|
|
3810
3808
|
);
|
|
3811
|
-
return isNull(
|
|
3809
|
+
return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...x, children: n }) });
|
|
3812
3810
|
}, GlobalBlocksRenderer = ({ globalBlockId: o }) => {
|
|
3813
3811
|
const { getGlobalBlocks: n } = useGlobalBlocksStore(), r = useMemo(() => n(o), [n, o]), a = useMemo(() => splitAtom(atom$1(r)), [r]);
|
|
3814
3812
|
return isEmpty(r) ? null : /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: r });
|
|
@@ -3858,43 +3856,43 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3858
3856
|
c();
|
|
3859
3857
|
}, [n, o, r, c]), l;
|
|
3860
3858
|
}, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
|
|
3861
|
-
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, m] = useState([]), [, f] = useState([]), [,
|
|
3862
|
-
p((_) => ({ ..._, width:
|
|
3859
|
+
const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, m] = useState([]), [, f] = useState([]), [, h] = useAtom$1(canvasIframeAtom), [b, x] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), A = useBuilderProp("htmlDir", "ltr"), j = (B) => {
|
|
3860
|
+
p((_) => ({ ..._, width: B }));
|
|
3863
3861
|
};
|
|
3864
3862
|
useEffect(() => {
|
|
3865
3863
|
if (!c.current) return;
|
|
3866
|
-
const { clientWidth:
|
|
3867
|
-
p({ width:
|
|
3864
|
+
const { clientWidth: B, clientHeight: _ } = c.current;
|
|
3865
|
+
p({ width: B, height: _ });
|
|
3868
3866
|
}, [c, n]);
|
|
3869
|
-
const
|
|
3870
|
-
const { top:
|
|
3871
|
-
return
|
|
3867
|
+
const C = (B, _ = 0) => {
|
|
3868
|
+
const { top: w } = B.getBoundingClientRect();
|
|
3869
|
+
return w + _ >= 0 && w - _ <= window.innerHeight;
|
|
3872
3870
|
};
|
|
3873
3871
|
useEffect(() => {
|
|
3874
|
-
var
|
|
3872
|
+
var B, _;
|
|
3875
3873
|
if (a && a.type !== "Multiple" && i.current) {
|
|
3876
|
-
const
|
|
3877
|
-
|
|
3874
|
+
const w = getElementByDataBlockId(i.current.contentDocument, a._id);
|
|
3875
|
+
w && (C(w) || (_ = (B = i.current) == null ? void 0 : B.contentWindow) == null || _.scrollTo({ top: w.offsetTop, behavior: "smooth" }), m([w]));
|
|
3878
3876
|
}
|
|
3879
3877
|
}, [a]), useEffect(() => {
|
|
3880
3878
|
if (!isEmpty(b) && i.current) {
|
|
3881
|
-
const
|
|
3879
|
+
const B = getElementByStyleId(
|
|
3882
3880
|
i.current.contentDocument,
|
|
3883
3881
|
first(b).id
|
|
3884
3882
|
);
|
|
3885
|
-
f(
|
|
3883
|
+
f(B ? [B] : [null]);
|
|
3886
3884
|
} else
|
|
3887
3885
|
f([null]);
|
|
3888
3886
|
}, [b]);
|
|
3889
3887
|
const S = useMemo(() => {
|
|
3890
|
-
let
|
|
3891
|
-
return
|
|
3892
|
-
}, [o,
|
|
3893
|
-
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount:
|
|
3888
|
+
let B = IframeInitialContent;
|
|
3889
|
+
return B = B.replace("__HTML_DIR__", A), o === "offline" && (B = B.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), B;
|
|
3890
|
+
}, [o, A]);
|
|
3891
|
+
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: j, onResize: j, children: /* @__PURE__ */ jsx(
|
|
3894
3892
|
"div",
|
|
3895
3893
|
{
|
|
3896
3894
|
onClick: () => {
|
|
3897
|
-
r([]),
|
|
3895
|
+
r([]), x([]);
|
|
3898
3896
|
},
|
|
3899
3897
|
onMouseLeave: () => setTimeout(() => l(""), 300),
|
|
3900
3898
|
className: "relative mx-auto h-full w-full overflow-hidden",
|
|
@@ -3902,7 +3900,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3902
3900
|
children: /* @__PURE__ */ jsxs(
|
|
3903
3901
|
ChaiFrame,
|
|
3904
3902
|
{
|
|
3905
|
-
contentDidMount: () =>
|
|
3903
|
+
contentDidMount: () => h(i.current),
|
|
3906
3904
|
ref: i,
|
|
3907
3905
|
id: "canvas-iframe",
|
|
3908
3906
|
style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
|
|
@@ -4161,25 +4159,25 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4161
4159
|
const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), [c, d] = useTheme(), p = useThemeOptions(), { t: u } = useTranslation(), g = (y) => {
|
|
4162
4160
|
a(y);
|
|
4163
4161
|
}, m = () => {
|
|
4164
|
-
const y = l.find((
|
|
4162
|
+
const y = l.find((A) => Object.keys(A)[0] === r);
|
|
4165
4163
|
if (y) {
|
|
4166
|
-
const
|
|
4167
|
-
|
|
4164
|
+
const A = Object.values(y)[0];
|
|
4165
|
+
A && typeof A == "object" && "fontFamily" in A && "borderRadius" in A && "colors" in A ? d(A) : console.error("Invalid preset structure:", A);
|
|
4168
4166
|
} else
|
|
4169
4167
|
console.error("Preset not found:", r);
|
|
4170
4168
|
}, f = useDebouncedCallback(
|
|
4171
|
-
(y,
|
|
4169
|
+
(y, A) => {
|
|
4172
4170
|
d(() => ({
|
|
4173
4171
|
...c,
|
|
4174
4172
|
fontFamily: {
|
|
4175
4173
|
...c.fontFamily,
|
|
4176
|
-
[y.replace(/font-/g, "")]:
|
|
4174
|
+
[y.replace(/font-/g, "")]: A
|
|
4177
4175
|
}
|
|
4178
4176
|
}));
|
|
4179
4177
|
},
|
|
4180
4178
|
[c],
|
|
4181
4179
|
200
|
|
4182
|
-
),
|
|
4180
|
+
), h = useDebouncedCallback(
|
|
4183
4181
|
(y) => {
|
|
4184
4182
|
d(() => ({
|
|
4185
4183
|
...c,
|
|
@@ -4189,35 +4187,35 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4189
4187
|
[c],
|
|
4190
4188
|
200
|
|
4191
4189
|
), b = useDebouncedCallback(
|
|
4192
|
-
(y,
|
|
4190
|
+
(y, A) => {
|
|
4193
4191
|
d(() => {
|
|
4194
|
-
const
|
|
4195
|
-
return n ? set(
|
|
4192
|
+
const j = get(c, `colors.${y}`);
|
|
4193
|
+
return n ? set(j, 1, A) : set(j, 0, A), {
|
|
4196
4194
|
...c,
|
|
4197
4195
|
colors: {
|
|
4198
4196
|
...c.colors,
|
|
4199
|
-
[y]:
|
|
4197
|
+
[y]: j
|
|
4200
4198
|
}
|
|
4201
4199
|
};
|
|
4202
4200
|
});
|
|
4203
4201
|
},
|
|
4204
4202
|
[c],
|
|
4205
4203
|
200
|
|
4206
|
-
),
|
|
4207
|
-
const
|
|
4204
|
+
), x = (y) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(y.items).map(([A]) => {
|
|
4205
|
+
const j = get(c, `colors.${A}.${n ? 1 : 0}`);
|
|
4208
4206
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
4209
4207
|
/* @__PURE__ */ jsx(
|
|
4210
4208
|
ColorPickerInput,
|
|
4211
4209
|
{
|
|
4212
|
-
value:
|
|
4213
|
-
onChange: (
|
|
4210
|
+
value: j,
|
|
4211
|
+
onChange: (C) => b(A, C)
|
|
4214
4212
|
}
|
|
4215
4213
|
),
|
|
4216
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children:
|
|
4217
|
-
] },
|
|
4214
|
+
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: A.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((C) => C.charAt(0).toUpperCase() + C.slice(1)).join(" ") + (!A.toLowerCase().includes("foreground") && !A.toLowerCase().includes("border") && !A.toLowerCase().includes("input") && !A.toLowerCase().includes("ring") && !A.toLowerCase().includes("background") ? " Background" : "") })
|
|
4215
|
+
] }, A);
|
|
4218
4216
|
}) });
|
|
4219
4217
|
return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
4220
|
-
/* @__PURE__ */ jsxs("div", { className: cn("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
4218
|
+
/* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
4221
4219
|
l.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 py-2", children: [
|
|
4222
4220
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
4223
4221
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Presets") }),
|
|
@@ -4245,26 +4243,26 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4245
4243
|
}
|
|
4246
4244
|
) })
|
|
4247
4245
|
] }),
|
|
4248
|
-
/* @__PURE__ */ jsxs("div", { className: cn("space-y-2", o), children: [
|
|
4249
|
-
(p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([y,
|
|
4246
|
+
/* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
|
|
4247
|
+
(p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([y, A]) => /* @__PURE__ */ jsx(
|
|
4250
4248
|
FontSelector,
|
|
4251
4249
|
{
|
|
4252
4250
|
label: y,
|
|
4253
|
-
value: c.fontFamily[y.replace(/font-/g, "")] ||
|
|
4254
|
-
onChange: (
|
|
4251
|
+
value: c.fontFamily[y.replace(/font-/g, "")] || A[Object.keys(A)[0]],
|
|
4252
|
+
onChange: (j) => f(y, j)
|
|
4255
4253
|
},
|
|
4256
4254
|
y
|
|
4257
4255
|
)) }),
|
|
4258
4256
|
(p == null ? void 0 : p.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
|
|
4259
4257
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Border Radius") }),
|
|
4260
4258
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
|
|
4261
|
-
/* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange:
|
|
4259
|
+
/* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange: h }),
|
|
4262
4260
|
/* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: c.borderRadius })
|
|
4263
4261
|
] })
|
|
4264
4262
|
] }),
|
|
4265
4263
|
(p == null ? void 0 : p.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
|
|
4266
4264
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Colors") }),
|
|
4267
|
-
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((y) =>
|
|
4265
|
+
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((y) => x(y)) }, n ? "dark" : "light")
|
|
4268
4266
|
] })
|
|
4269
4267
|
] }),
|
|
4270
4268
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -4430,55 +4428,383 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4430
4428
|
)
|
|
4431
4429
|
] })
|
|
4432
4430
|
] });
|
|
4433
|
-
}
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
|
|
4449
|
-
"blockquote",
|
|
4450
|
-
"color",
|
|
4451
|
-
"background",
|
|
4452
|
-
"align",
|
|
4453
|
-
"link",
|
|
4454
|
-
"image"
|
|
4455
|
-
], d = useRef(null), p = useRef(null);
|
|
4456
|
-
return useEffect(() => {
|
|
4457
|
-
if (d.current) {
|
|
4458
|
-
const u = d.current.getEditor();
|
|
4459
|
-
p.current.__quill = u;
|
|
4431
|
+
};
|
|
4432
|
+
function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
4433
|
+
const [a, l] = React.useState(!1), [i, c] = React.useState([]), [d, p] = React.useState(o);
|
|
4434
|
+
useEffect(() => {
|
|
4435
|
+
a || c([]), p(o);
|
|
4436
|
+
}, [a, o]);
|
|
4437
|
+
const u = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", g = React.useCallback(
|
|
4438
|
+
(h) => {
|
|
4439
|
+
const b = (x) => r === "value" ? x === "value" || x === "object" : r === "array" ? x === "array" : x === r;
|
|
4440
|
+
h.type === "object" ? (c((x) => [...x, h.key]), p(h.value)) : b(h.type) && (n([...i, h.key].join(".")), l(!1));
|
|
4441
|
+
},
|
|
4442
|
+
[i, n, r]
|
|
4443
|
+
), m = React.useCallback(() => {
|
|
4444
|
+
if (i.length > 0) {
|
|
4445
|
+
const h = i.slice(0, -1);
|
|
4446
|
+
c(h), p(h.reduce((b, x) => b[x], o));
|
|
4460
4447
|
}
|
|
4461
|
-
}, []),
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4448
|
+
}, [i, o]), f = React.useMemo(() => Object.entries(d).map(([h, b]) => ({
|
|
4449
|
+
key: h,
|
|
4450
|
+
value: b,
|
|
4451
|
+
type: u(b)
|
|
4452
|
+
})).filter((h) => r === "value" ? h.type === "value" || h.type === "object" : r === "array" ? h.type === "array" || h.type === "object" : r === "object" ? h.type === "object" : !0), [d, r]);
|
|
4453
|
+
return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
|
|
4454
|
+
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4455
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
4456
|
+
Button,
|
|
4457
|
+
{
|
|
4458
|
+
size: "sm",
|
|
4459
|
+
variant: "outline",
|
|
4460
|
+
className: "h-5 px-1 py-0 text-[9px] text-muted-foreground",
|
|
4461
|
+
role: "combobox",
|
|
4462
|
+
"aria-expanded": a,
|
|
4463
|
+
children: /* @__PURE__ */ jsx(DatabaseIcon, { className: "h-3 w-3" })
|
|
4464
|
+
}
|
|
4465
|
+
) }) }),
|
|
4466
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: "Add field" })
|
|
4467
|
+
] }),
|
|
4468
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "z-[1000]! relative mr-3 w-[300px] p-0", children: /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
|
|
4469
|
+
/* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
|
|
4470
|
+
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
4471
|
+
/* @__PURE__ */ jsx(CommandEmpty, { children: "No option found." }),
|
|
4472
|
+
/* @__PURE__ */ jsxs(CommandGroup, { children: [
|
|
4473
|
+
i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: m, className: "flex items-center text-sm", children: [
|
|
4474
|
+
/* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
|
|
4475
|
+
"Back"
|
|
4476
|
+
] }),
|
|
4477
|
+
f.map((h) => /* @__PURE__ */ jsxs(
|
|
4478
|
+
CommandItem,
|
|
4479
|
+
{
|
|
4480
|
+
value: h.key,
|
|
4481
|
+
disabled: !1,
|
|
4482
|
+
onSelect: () => g(h),
|
|
4483
|
+
className: "flex items-center justify-between",
|
|
4484
|
+
children: [
|
|
4485
|
+
/* @__PURE__ */ jsx("span", { children: h.key }),
|
|
4486
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4487
|
+
r === "object" && h.type === "object" && /* @__PURE__ */ jsx(
|
|
4488
|
+
Button,
|
|
4489
|
+
{
|
|
4490
|
+
size: "sm",
|
|
4491
|
+
variant: "ghost",
|
|
4492
|
+
className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
|
|
4493
|
+
onClick: (b) => {
|
|
4494
|
+
b.stopPropagation(), n([...i, h.key].join(".")), l(!1);
|
|
4495
|
+
},
|
|
4496
|
+
children: "Select"
|
|
4497
|
+
}
|
|
4498
|
+
),
|
|
4499
|
+
(h.type === "object" || h.type === "array") && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 opacity-50" }) })
|
|
4500
|
+
] })
|
|
4501
|
+
]
|
|
4502
|
+
},
|
|
4503
|
+
h.key
|
|
4504
|
+
))
|
|
4505
|
+
] })
|
|
4506
|
+
] })
|
|
4507
|
+
] }) })
|
|
4508
|
+
] });
|
|
4509
|
+
}
|
|
4510
|
+
function cn(...o) {
|
|
4511
|
+
return twMerge(clsx(o));
|
|
4512
|
+
}
|
|
4513
|
+
const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
4514
|
+
if (!o)
|
|
4515
|
+
return null;
|
|
4516
|
+
const r = () => {
|
|
4517
|
+
const l = window.prompt("URL");
|
|
4518
|
+
l && o.chain().focus().extendMarkRange("link").setLink({ href: l }).run();
|
|
4519
|
+
}, a = () => {
|
|
4520
|
+
o.chain().focus().unsetLink().run();
|
|
4521
|
+
};
|
|
4522
|
+
return /* @__PURE__ */ jsxs("div", { className: "mb-1 flex flex-wrap gap-1 rounded-md border border-border p-1", children: [
|
|
4523
|
+
/* @__PURE__ */ jsx(
|
|
4524
|
+
"button",
|
|
4525
|
+
{
|
|
4526
|
+
type: "button",
|
|
4527
|
+
onClick: () => o.chain().focus().toggleBold().run(),
|
|
4528
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("bold") }),
|
|
4529
|
+
title: "Bold",
|
|
4530
|
+
children: /* @__PURE__ */ jsx(Bold, { className: "h-4 w-4" })
|
|
4531
|
+
}
|
|
4532
|
+
),
|
|
4533
|
+
/* @__PURE__ */ jsx(
|
|
4534
|
+
"button",
|
|
4535
|
+
{
|
|
4536
|
+
type: "button",
|
|
4537
|
+
onClick: () => o.chain().focus().toggleItalic().run(),
|
|
4538
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("italic") }),
|
|
4539
|
+
title: "Italic",
|
|
4540
|
+
children: /* @__PURE__ */ jsx(Italic, { className: "h-4 w-4" })
|
|
4541
|
+
}
|
|
4542
|
+
),
|
|
4543
|
+
/* @__PURE__ */ jsx(
|
|
4544
|
+
"button",
|
|
4545
|
+
{
|
|
4546
|
+
type: "button",
|
|
4547
|
+
onClick: () => o.chain().focus().toggleUnderline().run(),
|
|
4548
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("underline") }),
|
|
4549
|
+
title: "Underline",
|
|
4550
|
+
children: /* @__PURE__ */ jsx(Underline$1, { className: "h-4 w-4" })
|
|
4551
|
+
}
|
|
4552
|
+
),
|
|
4553
|
+
/* @__PURE__ */ jsx(
|
|
4554
|
+
"button",
|
|
4555
|
+
{
|
|
4556
|
+
type: "button",
|
|
4557
|
+
onClick: () => o.chain().focus().toggleStrike().run(),
|
|
4558
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("strike") }),
|
|
4559
|
+
title: "Strike",
|
|
4560
|
+
children: /* @__PURE__ */ jsx(Strikethrough, { className: "h-4 w-4" })
|
|
4561
|
+
}
|
|
4562
|
+
),
|
|
4563
|
+
/* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px self-center bg-border" }),
|
|
4564
|
+
/* @__PURE__ */ jsx(
|
|
4565
|
+
"button",
|
|
4566
|
+
{
|
|
4567
|
+
type: "button",
|
|
4568
|
+
onClick: () => o.chain().focus().toggleBulletList().run(),
|
|
4569
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("bulletList") }),
|
|
4570
|
+
title: "Bullet List",
|
|
4571
|
+
children: /* @__PURE__ */ jsx(List, { className: "h-4 w-4" })
|
|
4572
|
+
}
|
|
4573
|
+
),
|
|
4574
|
+
/* @__PURE__ */ jsx(
|
|
4575
|
+
"button",
|
|
4576
|
+
{
|
|
4577
|
+
type: "button",
|
|
4578
|
+
onClick: () => o.chain().focus().toggleOrderedList().run(),
|
|
4579
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("orderedList") }),
|
|
4580
|
+
title: "Ordered List",
|
|
4581
|
+
children: /* @__PURE__ */ jsx(ListOrdered, { className: "h-4 w-4" })
|
|
4582
|
+
}
|
|
4583
|
+
),
|
|
4584
|
+
/* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px self-center bg-border" }),
|
|
4585
|
+
/* @__PURE__ */ jsx(
|
|
4586
|
+
"button",
|
|
4587
|
+
{
|
|
4588
|
+
type: "button",
|
|
4589
|
+
onClick: () => o.chain().focus().setTextAlign("left").run(),
|
|
4590
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive({ textAlign: "left" }) }),
|
|
4591
|
+
title: "Align Left",
|
|
4592
|
+
children: /* @__PURE__ */ jsx(AlignLeft, { className: "h-4 w-4" })
|
|
4593
|
+
}
|
|
4594
|
+
),
|
|
4595
|
+
/* @__PURE__ */ jsx(
|
|
4596
|
+
"button",
|
|
4597
|
+
{
|
|
4598
|
+
type: "button",
|
|
4599
|
+
onClick: () => o.chain().focus().setTextAlign("center").run(),
|
|
4600
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive({ textAlign: "center" }) }),
|
|
4601
|
+
title: "Align Center",
|
|
4602
|
+
children: /* @__PURE__ */ jsx(AlignCenter, { className: "h-4 w-4" })
|
|
4603
|
+
}
|
|
4604
|
+
),
|
|
4605
|
+
/* @__PURE__ */ jsx(
|
|
4606
|
+
"button",
|
|
4607
|
+
{
|
|
4608
|
+
type: "button",
|
|
4609
|
+
onClick: () => o.chain().focus().setTextAlign("right").run(),
|
|
4610
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive({ textAlign: "right" }) }),
|
|
4611
|
+
title: "Align Right",
|
|
4612
|
+
children: /* @__PURE__ */ jsx(AlignRight, { className: "h-4 w-4" })
|
|
4613
|
+
}
|
|
4614
|
+
),
|
|
4615
|
+
/* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px self-center bg-border" }),
|
|
4616
|
+
/* @__PURE__ */ jsx(
|
|
4617
|
+
"button",
|
|
4618
|
+
{
|
|
4619
|
+
type: "button",
|
|
4620
|
+
onClick: r,
|
|
4621
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("link") }),
|
|
4622
|
+
title: "Add Link",
|
|
4623
|
+
children: /* @__PURE__ */ jsx(Link$1, { className: "h-4 w-4" })
|
|
4624
|
+
}
|
|
4625
|
+
),
|
|
4626
|
+
/* @__PURE__ */ jsx(
|
|
4627
|
+
"button",
|
|
4628
|
+
{
|
|
4629
|
+
type: "button",
|
|
4630
|
+
onClick: a,
|
|
4631
|
+
className: cn("rounded p-1 hover:bg-muted"),
|
|
4632
|
+
title: "Remove Link",
|
|
4633
|
+
disabled: !o.isActive("link"),
|
|
4634
|
+
children: /* @__PURE__ */ jsx(Unlink, { className: "h-4 w-4" })
|
|
4635
|
+
}
|
|
4636
|
+
),
|
|
4637
|
+
n && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4638
|
+
/* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px self-center bg-border" }),
|
|
4639
|
+
/* @__PURE__ */ jsx(
|
|
4640
|
+
"button",
|
|
4641
|
+
{
|
|
4642
|
+
type: "button",
|
|
4643
|
+
onClick: n,
|
|
4644
|
+
className: "rounded p-1 hover:bg-muted",
|
|
4645
|
+
title: "Open in full screen mode",
|
|
4646
|
+
children: /* @__PURE__ */ jsx(Maximize2, { className: "h-4 w-4" })
|
|
4647
|
+
}
|
|
4648
|
+
)
|
|
4649
|
+
] })
|
|
4650
|
+
] });
|
|
4651
|
+
}, RTEModal = ({
|
|
4652
|
+
isOpen: o,
|
|
4653
|
+
onClose: n,
|
|
4654
|
+
id: r,
|
|
4655
|
+
value: a,
|
|
4656
|
+
onChange: l,
|
|
4657
|
+
onBlur: i
|
|
4658
|
+
}) => {
|
|
4659
|
+
const c = useRef(null), d = useRef(a || ""), p = usePageExternalData();
|
|
4660
|
+
useEffect(() => {
|
|
4661
|
+
if (o) {
|
|
4662
|
+
const m = document.createElement("style");
|
|
4663
|
+
return m.id = "rte-modal-styles", m.innerHTML = `
|
|
4664
|
+
/* Ensure the NestedPathSelector popover appears above the dialog */
|
|
4665
|
+
.rte-path-selector + [data-radix-popper-content-wrapper],
|
|
4666
|
+
[data-radix-popper-content-wrapper] {
|
|
4667
|
+
z-index: 9999 !important;
|
|
4668
|
+
}
|
|
4669
|
+
`, document.head.appendChild(m), () => {
|
|
4670
|
+
const f = document.getElementById("rte-modal-styles");
|
|
4671
|
+
f && f.remove();
|
|
4672
|
+
};
|
|
4673
|
+
}
|
|
4674
|
+
}, [o]);
|
|
4675
|
+
const u = useEditor({
|
|
4676
|
+
extensions: [
|
|
4677
|
+
StarterKit,
|
|
4678
|
+
Link.configure({
|
|
4679
|
+
openOnClick: !1,
|
|
4680
|
+
HTMLAttributes: {
|
|
4681
|
+
class: "text-primary underline"
|
|
4682
|
+
}
|
|
4683
|
+
}),
|
|
4684
|
+
TextAlign.configure({
|
|
4685
|
+
types: ["heading", "paragraph"],
|
|
4686
|
+
alignments: ["left", "center", "right"],
|
|
4687
|
+
defaultAlignment: "left"
|
|
4688
|
+
}),
|
|
4689
|
+
Underline
|
|
4690
|
+
],
|
|
4691
|
+
content: a || "",
|
|
4692
|
+
onUpdate: ({ editor: m }) => {
|
|
4693
|
+
const f = m.getHTML();
|
|
4694
|
+
l(f);
|
|
4695
|
+
},
|
|
4696
|
+
onBlur: ({ editor: m }) => {
|
|
4697
|
+
const f = m.getHTML();
|
|
4698
|
+
i(r, f);
|
|
4699
|
+
},
|
|
4700
|
+
editorProps: {
|
|
4701
|
+
attributes: {
|
|
4702
|
+
class: "prose prose-sm focus:outline-none min-h-[300px] p-2 dark:prose-invert prose-p:m-0 prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0"
|
|
4703
|
+
}
|
|
4473
4704
|
}
|
|
4474
|
-
|
|
4705
|
+
});
|
|
4706
|
+
useEffect(() => {
|
|
4707
|
+
o && u && (d.current !== a && (d.current = a || "", u.commands.setContent(a || "")), setTimeout(() => {
|
|
4708
|
+
u.commands.focus();
|
|
4709
|
+
}, 100));
|
|
4710
|
+
}, [o, u]), useEffect(() => {
|
|
4711
|
+
c.current && u && (c.current.__chaiRTE = u);
|
|
4712
|
+
}, [u, o]);
|
|
4713
|
+
const g = (m) => {
|
|
4714
|
+
if (!u) return;
|
|
4715
|
+
const f = `{{${m}}}`;
|
|
4716
|
+
u.commands.focus();
|
|
4717
|
+
const { from: h, to: b } = u.state.selection;
|
|
4718
|
+
if (h !== b)
|
|
4719
|
+
u.chain().deleteSelection().insertContent(f).run();
|
|
4720
|
+
else {
|
|
4721
|
+
const { state: y } = u, A = y.selection.from, j = y.doc.textBetween(Math.max(0, A - 1), A), C = y.doc.textBetween(A, Math.min(A + 1, y.doc.content.size));
|
|
4722
|
+
let S = "";
|
|
4723
|
+
A > 0 && j !== " " && !/[.,!?;:]/.test(j) && (S = " ");
|
|
4724
|
+
let B = "";
|
|
4725
|
+
C && C !== " " && !/[.,!?;:]/.test(C) && (B = " "), u.chain().insertContent(S + f + B).run();
|
|
4726
|
+
}
|
|
4727
|
+
};
|
|
4728
|
+
return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (m) => !m && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
|
|
4729
|
+
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center justify-between pr-8", children: [
|
|
4730
|
+
/* @__PURE__ */ jsx("span", { children: "Rich Text Editor" }),
|
|
4731
|
+
p && Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
4732
|
+
/* @__PURE__ */ jsx("span", { className: "mr-2 text-sm text-muted-foreground", children: "Add field:" }),
|
|
4733
|
+
/* @__PURE__ */ jsx("div", { className: "rte-path-selector", children: /* @__PURE__ */ jsx(NestedPathSelector, { data: p, onSelect: g }) })
|
|
4734
|
+
] })
|
|
4735
|
+
] }) }),
|
|
4736
|
+
/* @__PURE__ */ jsxs("div", { id: `chai-rte-modal-${r}`, ref: c, className: "rounded-md border border-input", children: [
|
|
4737
|
+
/* @__PURE__ */ jsx(MenuBar, { editor: u }),
|
|
4738
|
+
/* @__PURE__ */ jsx(EditorContent, { editor: u, id: `modal-${r}`, className: "p-2" })
|
|
4739
|
+
] }),
|
|
4740
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-end", children: /* @__PURE__ */ jsx(Button, { onClick: n, children: "Done" }) })
|
|
4741
|
+
] }) });
|
|
4742
|
+
}, RichTextEditorField = ({ id: o, placeholder: n, value: r, onChange: a, onBlur: l }) => {
|
|
4743
|
+
const i = useRef(null), [c, d] = useState(!1), [p, u] = useState(""), g = useEditor({
|
|
4744
|
+
extensions: [
|
|
4745
|
+
StarterKit,
|
|
4746
|
+
Link.configure({
|
|
4747
|
+
openOnClick: !1,
|
|
4748
|
+
HTMLAttributes: {
|
|
4749
|
+
class: "text-primary underline"
|
|
4750
|
+
}
|
|
4751
|
+
}),
|
|
4752
|
+
TextAlign.configure({
|
|
4753
|
+
types: ["heading", "paragraph"],
|
|
4754
|
+
alignments: ["left", "center", "right"],
|
|
4755
|
+
defaultAlignment: "left"
|
|
4756
|
+
}),
|
|
4757
|
+
Underline
|
|
4758
|
+
],
|
|
4759
|
+
content: r || "",
|
|
4760
|
+
onUpdate: ({ editor: h }) => {
|
|
4761
|
+
const b = h.getHTML();
|
|
4762
|
+
a(b), c || u(b);
|
|
4763
|
+
},
|
|
4764
|
+
onBlur: ({ editor: h }) => {
|
|
4765
|
+
const b = h.getHTML();
|
|
4766
|
+
l(o, b);
|
|
4767
|
+
},
|
|
4768
|
+
editorProps: {
|
|
4769
|
+
attributes: {
|
|
4770
|
+
class: "prose prose-sm focus:outline-none min-h-[100px] p-1 dark:prose-invert prose-p:m-0 prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0"
|
|
4771
|
+
}
|
|
4772
|
+
}
|
|
4773
|
+
});
|
|
4774
|
+
useEffect(() => {
|
|
4775
|
+
i.current.__chaiRTE = g;
|
|
4776
|
+
}, [g]), useEffect(() => {
|
|
4777
|
+
u(r || "");
|
|
4778
|
+
}, [r]);
|
|
4779
|
+
const m = (h) => {
|
|
4780
|
+
a(h);
|
|
4781
|
+
}, f = () => {
|
|
4782
|
+
d(!1), g && g.commands.setContent(p);
|
|
4783
|
+
};
|
|
4784
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4785
|
+
/* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsxs("div", { id: `chai-rte-${o}`, ref: i, className: "mt-1 rounded-md border border-input", children: [
|
|
4786
|
+
/* @__PURE__ */ jsx(MenuBar, { editor: g, onExpand: () => d(!0) }),
|
|
4787
|
+
/* @__PURE__ */ jsx(EditorContent, { editor: g, id: o, placeholder: n })
|
|
4788
|
+
] }) }),
|
|
4789
|
+
c && /* @__PURE__ */ jsx(
|
|
4790
|
+
RTEModal,
|
|
4791
|
+
{
|
|
4792
|
+
isOpen: c,
|
|
4793
|
+
onClose: f,
|
|
4794
|
+
id: o,
|
|
4795
|
+
value: p,
|
|
4796
|
+
onChange: m,
|
|
4797
|
+
onBlur: l
|
|
4798
|
+
}
|
|
4799
|
+
)
|
|
4800
|
+
] });
|
|
4475
4801
|
}, PageTypeField = ({
|
|
4476
4802
|
href: o,
|
|
4477
4803
|
pageTypes: n,
|
|
4478
4804
|
onChange: r
|
|
4479
4805
|
}) => {
|
|
4480
4806
|
var T;
|
|
4481
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (k, v) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, f] = useState(""), [
|
|
4807
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (k, v) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, f] = useState(""), [h, b] = useState([]), [x, y] = useState(-1), A = useRef(null), j = (T = n == null ? void 0 : n.find((k) => k.key === u)) == null ? void 0 : T.name;
|
|
4482
4808
|
useEffect(() => {
|
|
4483
4809
|
if (f(""), b([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4484
4810
|
const k = split(o, ":"), v = get(k, 1, "page") || "page";
|
|
@@ -4487,7 +4813,7 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4487
4813
|
N && Array.isArray(N) && f(get(N, [0, "name"], ""));
|
|
4488
4814
|
})();
|
|
4489
4815
|
}, [o]);
|
|
4490
|
-
const
|
|
4816
|
+
const C = useDebouncedCallback(
|
|
4491
4817
|
async (k) => {
|
|
4492
4818
|
if (isEmpty(k))
|
|
4493
4819
|
b([]);
|
|
@@ -4502,17 +4828,17 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4502
4828
|
), S = (k) => {
|
|
4503
4829
|
const v = ["pageType", u, k.id];
|
|
4504
4830
|
v[1] && (r(v.join(":")), f(k.name), p(!1), b([]), y(-1));
|
|
4505
|
-
},
|
|
4831
|
+
}, B = (k) => {
|
|
4506
4832
|
switch (k.key) {
|
|
4507
4833
|
case "ArrowDown":
|
|
4508
|
-
k.preventDefault(), y((v) => v <
|
|
4834
|
+
k.preventDefault(), y((v) => v < h.length - 1 ? v + 1 : v);
|
|
4509
4835
|
break;
|
|
4510
4836
|
case "ArrowUp":
|
|
4511
4837
|
k.preventDefault(), y((v) => v > 0 ? v - 1 : v);
|
|
4512
4838
|
break;
|
|
4513
4839
|
case "Enter":
|
|
4514
|
-
if (k.preventDefault(),
|
|
4515
|
-
|
|
4840
|
+
if (k.preventDefault(), h.length === 0) return;
|
|
4841
|
+
x >= 0 && S(h[x]);
|
|
4516
4842
|
break;
|
|
4517
4843
|
case "Escape":
|
|
4518
4844
|
k.preventDefault(), _();
|
|
@@ -4520,15 +4846,15 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4520
4846
|
}
|
|
4521
4847
|
};
|
|
4522
4848
|
useEffect(() => {
|
|
4523
|
-
if (
|
|
4524
|
-
const k =
|
|
4849
|
+
if (x >= 0 && A.current) {
|
|
4850
|
+
const k = A.current.children[x];
|
|
4525
4851
|
k == null || k.scrollIntoView({ block: "nearest" });
|
|
4526
4852
|
}
|
|
4527
|
-
}, [
|
|
4853
|
+
}, [x]);
|
|
4528
4854
|
const _ = () => {
|
|
4529
4855
|
f(""), b([]), y(-1), p(!1), r("");
|
|
4530
|
-
},
|
|
4531
|
-
f(k), p(!isEmpty(k)), c(!0),
|
|
4856
|
+
}, w = (k) => {
|
|
4857
|
+
f(k), p(!isEmpty(k)), c(!0), C(k);
|
|
4532
4858
|
};
|
|
4533
4859
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4534
4860
|
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (k) => g(k.target.value), children: map(n, (k) => /* @__PURE__ */ jsx("option", { value: k.key, children: k.name }, k.key)) }),
|
|
@@ -4538,27 +4864,27 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4538
4864
|
{
|
|
4539
4865
|
type: "text",
|
|
4540
4866
|
value: m,
|
|
4541
|
-
onChange: (k) =>
|
|
4542
|
-
onKeyDown:
|
|
4543
|
-
placeholder: a(`Search ${
|
|
4867
|
+
onChange: (k) => w(k.target.value),
|
|
4868
|
+
onKeyDown: B,
|
|
4869
|
+
placeholder: a(`Search ${j ?? ""}`),
|
|
4544
4870
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4545
4871
|
}
|
|
4546
4872
|
),
|
|
4547
4873
|
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: _, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
|
|
4548
4874
|
] }),
|
|
4549
|
-
(i || !isEmpty(
|
|
4875
|
+
(i || !isEmpty(h) || d && isEmpty(h)) && /* @__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: [
|
|
4550
4876
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
4551
4877
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
4552
|
-
] }) : d && isEmpty(
|
|
4878
|
+
] }) : d && isEmpty(h) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4553
4879
|
a("No results found for"),
|
|
4554
4880
|
' "',
|
|
4555
4881
|
m,
|
|
4556
4882
|
'"'
|
|
4557
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref:
|
|
4883
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(h == null ? void 0 : h.slice(0, 20), (k, v) => /* @__PURE__ */ jsxs(
|
|
4558
4884
|
"li",
|
|
4559
4885
|
{
|
|
4560
4886
|
onClick: () => S(k),
|
|
4561
|
-
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(k.id) ? "bg-blue-200" : v ===
|
|
4887
|
+
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(k.id) ? "bg-blue-200" : v === x ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
4562
4888
|
children: [
|
|
4563
4889
|
k.name,
|
|
4564
4890
|
" ",
|
|
@@ -4654,23 +4980,23 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4654
4980
|
const m = () => {
|
|
4655
4981
|
const b = findIndex(u, { _id: g });
|
|
4656
4982
|
if (b > -1) {
|
|
4657
|
-
const
|
|
4983
|
+
const x = (b + 1) % u.length, y = get(u, [x, "_id"]);
|
|
4658
4984
|
if (!y) return;
|
|
4659
4985
|
n({ ...o, currentSlide: y }), c([y]);
|
|
4660
4986
|
}
|
|
4661
4987
|
}, f = () => {
|
|
4662
4988
|
const b = findIndex(u, { _id: g });
|
|
4663
4989
|
if (b > -1) {
|
|
4664
|
-
const
|
|
4990
|
+
const x = (b - 1 + u.length) % u.length, y = get(u, [x, "_id"]);
|
|
4665
4991
|
if (!y) return;
|
|
4666
4992
|
n({ ...o, currentSlide: y }), c([y]);
|
|
4667
4993
|
}
|
|
4668
|
-
},
|
|
4994
|
+
}, h = () => {
|
|
4669
4995
|
const b = i(
|
|
4670
4996
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4671
4997
|
p == null ? void 0 : p._id
|
|
4672
|
-
),
|
|
4673
|
-
|
|
4998
|
+
), x = b == null ? void 0 : b._id;
|
|
4999
|
+
x && (n({ ...o, currentSlide: x }), c([x]));
|
|
4674
5000
|
};
|
|
4675
5001
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4676
5002
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
@@ -4687,7 +5013,7 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4687
5013
|
/* @__PURE__ */ jsxs(
|
|
4688
5014
|
"button",
|
|
4689
5015
|
{
|
|
4690
|
-
onClick:
|
|
5016
|
+
onClick: h,
|
|
4691
5017
|
className: "flex w-full items-center justify-center gap-x-1 rounded bg-gray-200 p-1.5 text-xs font-medium leading-tight hover:opacity-80",
|
|
4692
5018
|
children: [
|
|
4693
5019
|
/* @__PURE__ */ jsx(PlusCircle, { className: "h-3 w-3 stroke-[2]" }),
|
|
@@ -4749,8 +5075,8 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4749
5075
|
className: "text-xs",
|
|
4750
5076
|
pattern: "[0-9]*",
|
|
4751
5077
|
onChange: (b) => {
|
|
4752
|
-
let
|
|
4753
|
-
|
|
5078
|
+
let x = b.target.value;
|
|
5079
|
+
x.length && (x = x.replace("-", "")), n({ ...o, autoplayInterval: x });
|
|
4754
5080
|
}
|
|
4755
5081
|
}
|
|
4756
5082
|
)
|
|
@@ -4775,86 +5101,7 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4775
5101
|
),
|
|
4776
5102
|
/* @__PURE__ */ jsx(Button, { onClick: d, size: "sm", variant: "outline", className: "w-fit", children: r("Open code editor") })
|
|
4777
5103
|
] });
|
|
4778
|
-
}
|
|
4779
|
-
function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
4780
|
-
const [a, l] = React.useState(!1), [i, c] = React.useState([]), [d, p] = React.useState(o);
|
|
4781
|
-
useEffect(() => {
|
|
4782
|
-
a || c([]), p(o);
|
|
4783
|
-
}, [a, o]);
|
|
4784
|
-
const u = (x) => Array.isArray(x) ? "array" : typeof x == "object" && x !== null ? "object" : "value", g = React.useCallback(
|
|
4785
|
-
(x) => {
|
|
4786
|
-
const b = (h) => r === "value" ? h === "value" || h === "object" : r === "array" ? h === "array" : h === r;
|
|
4787
|
-
x.type === "object" ? (c((h) => [...h, x.key]), p(x.value)) : b(x.type) && (n([...i, x.key].join(".")), l(!1));
|
|
4788
|
-
},
|
|
4789
|
-
[i, n, r]
|
|
4790
|
-
), m = React.useCallback(() => {
|
|
4791
|
-
if (i.length > 0) {
|
|
4792
|
-
const x = i.slice(0, -1);
|
|
4793
|
-
c(x), p(x.reduce((b, h) => b[h], o));
|
|
4794
|
-
}
|
|
4795
|
-
}, [i, o]), f = React.useMemo(() => Object.entries(d).map(([x, b]) => ({
|
|
4796
|
-
key: x,
|
|
4797
|
-
value: b,
|
|
4798
|
-
type: u(b)
|
|
4799
|
-
})).filter((x) => r === "value" ? x.type === "value" || x.type === "object" : r === "array" ? x.type === "array" || x.type === "object" : r === "object" ? x.type === "object" : !0), [d, r]);
|
|
4800
|
-
return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
|
|
4801
|
-
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4802
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
4803
|
-
Button,
|
|
4804
|
-
{
|
|
4805
|
-
size: "sm",
|
|
4806
|
-
variant: "outline",
|
|
4807
|
-
className: "h-5 px-1 py-0 text-[9px] text-muted-foreground",
|
|
4808
|
-
role: "combobox",
|
|
4809
|
-
"aria-expanded": a,
|
|
4810
|
-
children: /* @__PURE__ */ jsx(DatabaseIcon, { className: "h-3 w-3" })
|
|
4811
|
-
}
|
|
4812
|
-
) }) }),
|
|
4813
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: "Add field" })
|
|
4814
|
-
] }),
|
|
4815
|
-
/* @__PURE__ */ jsx(PopoverContent, { className: "mr-3 w-[300px] p-0", children: /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
|
|
4816
|
-
/* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
|
|
4817
|
-
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
4818
|
-
/* @__PURE__ */ jsx(CommandEmpty, { children: "No option found." }),
|
|
4819
|
-
/* @__PURE__ */ jsxs(CommandGroup, { children: [
|
|
4820
|
-
i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: m, className: "flex items-center text-sm", children: [
|
|
4821
|
-
/* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
|
|
4822
|
-
"Back"
|
|
4823
|
-
] }),
|
|
4824
|
-
f.map((x) => /* @__PURE__ */ jsxs(
|
|
4825
|
-
CommandItem,
|
|
4826
|
-
{
|
|
4827
|
-
value: x.key,
|
|
4828
|
-
disabled: !1,
|
|
4829
|
-
onSelect: () => g(x),
|
|
4830
|
-
className: "flex items-center justify-between",
|
|
4831
|
-
children: [
|
|
4832
|
-
/* @__PURE__ */ jsx("span", { children: x.key }),
|
|
4833
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4834
|
-
r === "object" && x.type === "object" && /* @__PURE__ */ jsx(
|
|
4835
|
-
Button,
|
|
4836
|
-
{
|
|
4837
|
-
size: "sm",
|
|
4838
|
-
variant: "ghost",
|
|
4839
|
-
className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
|
|
4840
|
-
onClick: (b) => {
|
|
4841
|
-
b.stopPropagation(), n([...i, x.key].join(".")), l(!1);
|
|
4842
|
-
},
|
|
4843
|
-
children: "Select"
|
|
4844
|
-
}
|
|
4845
|
-
),
|
|
4846
|
-
(x.type === "object" || x.type === "array") && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 opacity-50" }) })
|
|
4847
|
-
] })
|
|
4848
|
-
]
|
|
4849
|
-
},
|
|
4850
|
-
x.key
|
|
4851
|
-
))
|
|
4852
|
-
] })
|
|
4853
|
-
] })
|
|
4854
|
-
] }) })
|
|
4855
|
-
] });
|
|
4856
|
-
}
|
|
4857
|
-
const CustomFieldTemplate = ({
|
|
5104
|
+
}, CustomFieldTemplate = ({
|
|
4858
5105
|
id: o,
|
|
4859
5106
|
classNames: n,
|
|
4860
5107
|
label: r,
|
|
@@ -4868,77 +5115,56 @@ const CustomFieldTemplate = ({
|
|
|
4868
5115
|
formData: g,
|
|
4869
5116
|
onChange: m
|
|
4870
5117
|
}) => {
|
|
4871
|
-
const { selectedLang: f, fallbackLang:
|
|
5118
|
+
const { selectedLang: f, fallbackLang: h, languages: b } = useLanguages(), x = isEmpty(b) ? "" : isEmpty(f) ? h : f, y = get(LANGUAGES, x, x), A = usePageExternalData(), j = useSelectedBlock(), C = useRegisteredChaiBlocks(), S = get(C, [j == null ? void 0 : j._type, "i18nProps"], []) || [], [B, _] = useState(null), w = useCallback(
|
|
4872
5119
|
(v) => {
|
|
4873
|
-
const N = (
|
|
4874
|
-
let
|
|
4875
|
-
const
|
|
4876
|
-
return
|
|
4877
|
-
text:
|
|
4878
|
-
prefixLength:
|
|
4879
|
-
suffixLength:
|
|
5120
|
+
const N = (E) => /[.,!?;:]/.test(E), I = (E, D, M) => {
|
|
5121
|
+
let R = "", O = "";
|
|
5122
|
+
const $ = D > 0 ? E[D - 1] : "", H = D < E.length ? E[D] : "";
|
|
5123
|
+
return D > 0 && ($ === "." || !N($) && $ !== " ") && (R = " "), D < E.length && !N(H) && H !== " " && (O = " "), {
|
|
5124
|
+
text: R + M + O,
|
|
5125
|
+
prefixLength: R.length,
|
|
5126
|
+
suffixLength: O.length
|
|
4880
5127
|
};
|
|
4881
|
-
},
|
|
4882
|
-
if (!
|
|
4883
|
-
const
|
|
4884
|
-
if (
|
|
4885
|
-
const
|
|
4886
|
-
if (
|
|
4887
|
-
const
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
if (M
|
|
4891
|
-
|
|
4892
|
-
const L = M.index;
|
|
4893
|
-
j.deleteText(M.index, M.length), j.setSelection(L, 0);
|
|
4894
|
-
const $ = j.getText(), {
|
|
4895
|
-
text: O,
|
|
4896
|
-
prefixLength: H,
|
|
4897
|
-
suffixLength: V
|
|
4898
|
-
} = I($, L, R);
|
|
4899
|
-
j.insertText(L, O), j.setSelection(L + H + R.length + V, 0);
|
|
4900
|
-
} else {
|
|
4901
|
-
const L = M.index;
|
|
4902
|
-
j.setSelection(L, 0);
|
|
4903
|
-
const $ = j.getText(), {
|
|
4904
|
-
text: O,
|
|
4905
|
-
prefixLength: H,
|
|
4906
|
-
suffixLength: V
|
|
4907
|
-
} = I($, L, R);
|
|
4908
|
-
j.insertText(L, O), j.setSelection(L + H + R.length + V, 0);
|
|
4909
|
-
}
|
|
5128
|
+
}, L = document.getElementById(o);
|
|
5129
|
+
if (!L) return;
|
|
5130
|
+
const P = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
|
|
5131
|
+
if (P && (P.querySelector(".ProseMirror") || P.__chaiRTE)) {
|
|
5132
|
+
const E = P.__chaiRTE;
|
|
5133
|
+
if (E) {
|
|
5134
|
+
const D = `{{${v}}}`;
|
|
5135
|
+
E.commands.focus();
|
|
5136
|
+
const { from: M, to: R } = E.state.selection;
|
|
5137
|
+
if (M !== R)
|
|
5138
|
+
E.chain().deleteSelection().insertContent(D).run();
|
|
4910
5139
|
else {
|
|
4911
|
-
const
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
|
|
4916
|
-
suffixLength: V
|
|
4917
|
-
} = I($, L - 1, R);
|
|
4918
|
-
j.insertText(L - 1, O), j.setSelection(L - 1 + H + R.length + V, 0);
|
|
5140
|
+
const { state: $ } = E, H = $.selection.from, F = $.doc.textBetween(Math.max(0, H - 1), H), U = $.doc.textBetween(H, Math.min(H + 1, $.doc.content.size));
|
|
5141
|
+
let z = "";
|
|
5142
|
+
H > 0 && F !== " " && !N(F) && (z = " ");
|
|
5143
|
+
let W = "";
|
|
5144
|
+
U && U !== " " && !N(U) && (W = " "), E.chain().insertContent(z + D + W).run();
|
|
4919
5145
|
}
|
|
4920
|
-
setTimeout(() => m(
|
|
5146
|
+
setTimeout(() => m(E.getHTML(), {}, o), 100);
|
|
4921
5147
|
return;
|
|
4922
5148
|
}
|
|
4923
5149
|
} else {
|
|
4924
|
-
const
|
|
4925
|
-
if (
|
|
4926
|
-
const
|
|
5150
|
+
const E = L, D = E.selectionStart || 0, M = E.value || "", R = E.selectionEnd || D;
|
|
5151
|
+
if (R > D) {
|
|
5152
|
+
const U = `{{${v}}}`, { text: z } = I(M, D, U), W = M.slice(0, D) + z + M.slice(R);
|
|
4927
5153
|
m(W, {}, o);
|
|
4928
5154
|
return;
|
|
4929
5155
|
}
|
|
4930
|
-
const
|
|
4931
|
-
m(
|
|
5156
|
+
const $ = `{{${v}}}`, { text: H } = I(M, D, $), F = M.slice(0, D) + H + M.slice(D);
|
|
5157
|
+
m(F, {}, o);
|
|
4932
5158
|
}
|
|
4933
5159
|
},
|
|
4934
|
-
[o, m, g,
|
|
5160
|
+
[o, m, g, j == null ? void 0 : j._id]
|
|
4935
5161
|
);
|
|
4936
5162
|
if (d)
|
|
4937
5163
|
return null;
|
|
4938
5164
|
if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
|
|
4939
5165
|
const k = S == null ? void 0 : S.includes(o.replace("root.", ""));
|
|
4940
5166
|
if (u.type === "array") {
|
|
4941
|
-
const v =
|
|
5167
|
+
const v = B === o;
|
|
4942
5168
|
return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
|
|
4943
5169
|
u.title && /* @__PURE__ */ jsxs(
|
|
4944
5170
|
"label",
|
|
@@ -4974,7 +5200,7 @@ const CustomFieldTemplate = ({
|
|
|
4974
5200
|
] }),
|
|
4975
5201
|
p && u.type !== "object" ? " *" : null
|
|
4976
5202
|
] }),
|
|
4977
|
-
u.type === "string" && !u.enum && !u.oneOf &&
|
|
5203
|
+
u.type === "string" && !u.enum && !u.oneOf && A && /* @__PURE__ */ jsx(NestedPathSelector, { data: A, onSelect: w, dataType: "value" })
|
|
4978
5204
|
] }),
|
|
4979
5205
|
c,
|
|
4980
5206
|
a,
|
|
@@ -5042,35 +5268,35 @@ const CustomFieldTemplate = ({
|
|
|
5042
5268
|
}), a;
|
|
5043
5269
|
};
|
|
5044
5270
|
function BlockSettings() {
|
|
5045
|
-
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), f = formDataWithSelectedLang(g, o, m),
|
|
5046
|
-
_ && (c == null ? void 0 : c._id) === n._id && a([n._id], { [_]: get(
|
|
5271
|
+
const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), f = formDataWithSelectedLang(g, o, m), h = ({ formData: B }, _, w) => {
|
|
5272
|
+
_ && (c == null ? void 0 : c._id) === n._id && a([n._id], { [_]: get(B, _) }, w);
|
|
5047
5273
|
}, b = useCallback(
|
|
5048
|
-
debounce(({ formData:
|
|
5049
|
-
|
|
5274
|
+
debounce(({ formData: B }, _, w) => {
|
|
5275
|
+
h({ formData: B }, _, w), d(B);
|
|
5050
5276
|
}, 1500),
|
|
5051
5277
|
[n == null ? void 0 : n._id, o]
|
|
5052
|
-
),
|
|
5053
|
-
_ && (r([n._id], { [_]: get(
|
|
5054
|
-
}, y = ({ formData:
|
|
5055
|
-
_ && (r([g._id], { [_]: get(
|
|
5278
|
+
), x = ({ formData: B }, _) => {
|
|
5279
|
+
_ && (r([n._id], { [_]: get(B, _) }), b({ formData: B }, _, { [_]: get(c, _) }));
|
|
5280
|
+
}, y = ({ formData: B }, _) => {
|
|
5281
|
+
_ && (r([g._id], { [_]: get(B, _) }), b({ formData: B }, _, { [_]: get(c, _) }));
|
|
5056
5282
|
};
|
|
5057
5283
|
keys(get(i, "_bindings", {}));
|
|
5058
|
-
const { schema:
|
|
5059
|
-
const
|
|
5060
|
-
if (
|
|
5061
|
-
return getBlockFormSchemas(
|
|
5062
|
-
}, [n]), { wrapperSchema:
|
|
5284
|
+
const { schema: A, uiSchema: j } = useMemo(() => {
|
|
5285
|
+
const B = n == null ? void 0 : n._type;
|
|
5286
|
+
if (B)
|
|
5287
|
+
return getBlockFormSchemas(B);
|
|
5288
|
+
}, [n]), { wrapperSchema: C, wrapperUiSchema: S } = useMemo(() => {
|
|
5063
5289
|
if (!g || !(g != null && g._type))
|
|
5064
5290
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5065
|
-
const
|
|
5066
|
-
return { wrapperSchema: _, wrapperUiSchema:
|
|
5291
|
+
const B = g == null ? void 0 : g._type, { schema: _ = {}, uiSchema: w = {} } = getBlockFormSchemas(B);
|
|
5292
|
+
return { wrapperSchema: _, wrapperUiSchema: w };
|
|
5067
5293
|
}, [g]);
|
|
5068
5294
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5069
5295
|
!isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
5070
5296
|
/* @__PURE__ */ jsxs(
|
|
5071
5297
|
"div",
|
|
5072
5298
|
{
|
|
5073
|
-
onClick: () => u((
|
|
5299
|
+
onClick: () => u((B) => !B),
|
|
5074
5300
|
className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
|
|
5075
5301
|
children: [
|
|
5076
5302
|
p ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 stroke-[3] text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 stroke-[3] text-slate-400" }),
|
|
@@ -5091,19 +5317,19 @@ function BlockSettings() {
|
|
|
5091
5317
|
blockId: g == null ? void 0 : g._id,
|
|
5092
5318
|
onChange: y,
|
|
5093
5319
|
formData: f,
|
|
5094
|
-
schema:
|
|
5320
|
+
schema: C,
|
|
5095
5321
|
uiSchema: S
|
|
5096
5322
|
}
|
|
5097
5323
|
) })
|
|
5098
5324
|
] }),
|
|
5099
|
-
isEmpty(
|
|
5325
|
+
isEmpty(A) ? null : /* @__PURE__ */ jsx(
|
|
5100
5326
|
JSONForm,
|
|
5101
5327
|
{
|
|
5102
5328
|
blockId: n == null ? void 0 : n._id,
|
|
5103
|
-
onChange:
|
|
5329
|
+
onChange: x,
|
|
5104
5330
|
formData: i,
|
|
5105
|
-
schema:
|
|
5106
|
-
uiSchema:
|
|
5331
|
+
schema: A,
|
|
5332
|
+
uiSchema: j
|
|
5107
5333
|
}
|
|
5108
5334
|
),
|
|
5109
5335
|
(n == null ? void 0 : n._type) === "GlobalBlock" ? /* @__PURE__ */ jsx(GlobalBlockSettings, {}) : null
|
|
@@ -5194,31 +5420,31 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5194
5420
|
] }) }) })
|
|
5195
5421
|
] });
|
|
5196
5422
|
}, Breakpoints$1 = ({ openDelay: o = 400, canvas: n = !1 }) => {
|
|
5197
|
-
const [r, , a] = useScreenSizeWidth(), [l, i] = useCanvasDisplayWidth(), [c, d] = useSelectedBreakpoints(), p = c, u = d, { t: g } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (
|
|
5198
|
-
p.includes(
|
|
5199
|
-
},
|
|
5200
|
-
n || a(
|
|
5423
|
+
const [r, , a] = useScreenSizeWidth(), [l, i] = useCanvasDisplayWidth(), [c, d] = useSelectedBreakpoints(), p = c, u = d, { t: g } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (x) => {
|
|
5424
|
+
p.includes(x) ? p.length > 2 && u(p.filter((y) => y !== x)) : u((y) => [...y, x]);
|
|
5425
|
+
}, h = (x) => {
|
|
5426
|
+
n || a(x), i(x);
|
|
5201
5427
|
}, b = getBreakpointValue(n ? l : r).toLowerCase();
|
|
5202
|
-
return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (
|
|
5428
|
+
return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (x) => /* @__PURE__ */ createElement(
|
|
5203
5429
|
BreakpointCard,
|
|
5204
5430
|
{
|
|
5205
5431
|
canvas: n,
|
|
5206
|
-
...
|
|
5207
|
-
onClick:
|
|
5208
|
-
key:
|
|
5432
|
+
...x,
|
|
5433
|
+
onClick: h,
|
|
5434
|
+
key: x.breakpoint,
|
|
5209
5435
|
currentBreakpoint: b
|
|
5210
5436
|
}
|
|
5211
5437
|
)) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
|
|
5212
5438
|
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
|
|
5213
|
-
m.filter((
|
|
5214
|
-
(
|
|
5439
|
+
m.filter((x) => includes(p, toUpper(x.breakpoint))),
|
|
5440
|
+
(x) => /* @__PURE__ */ createElement(
|
|
5215
5441
|
BreakpointCard,
|
|
5216
5442
|
{
|
|
5217
5443
|
canvas: n,
|
|
5218
5444
|
openDelay: o,
|
|
5219
|
-
...
|
|
5220
|
-
onClick:
|
|
5221
|
-
key:
|
|
5445
|
+
...x,
|
|
5446
|
+
onClick: h,
|
|
5447
|
+
key: x.breakpoint,
|
|
5222
5448
|
currentBreakpoint: b
|
|
5223
5449
|
}
|
|
5224
5450
|
)
|
|
@@ -5228,15 +5454,15 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5228
5454
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
|
|
5229
5455
|
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: g("Screen sizes") }),
|
|
5230
5456
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
5231
|
-
map(m, (
|
|
5457
|
+
map(m, (x) => /* @__PURE__ */ jsx(
|
|
5232
5458
|
DropdownMenuCheckboxItem,
|
|
5233
5459
|
{
|
|
5234
|
-
disabled:
|
|
5235
|
-
onCheckedChange: () => f(toUpper(
|
|
5236
|
-
checked: includes(p, toUpper(
|
|
5237
|
-
children: g(
|
|
5460
|
+
disabled: x.breakpoint === "xs",
|
|
5461
|
+
onCheckedChange: () => f(toUpper(x.breakpoint)),
|
|
5462
|
+
checked: includes(p, toUpper(x.breakpoint)),
|
|
5463
|
+
children: g(x.title)
|
|
5238
5464
|
},
|
|
5239
|
-
|
|
5465
|
+
x.breakpoint
|
|
5240
5466
|
))
|
|
5241
5467
|
] })
|
|
5242
5468
|
] })
|
|
@@ -5325,8 +5551,8 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5325
5551
|
(f = d.current) == null || f.focus();
|
|
5326
5552
|
}, []);
|
|
5327
5553
|
const m = (f) => {
|
|
5328
|
-
const { usage:
|
|
5329
|
-
!l &&
|
|
5554
|
+
const { usage: h } = f || {};
|
|
5555
|
+
!l && h && g(h), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
5330
5556
|
};
|
|
5331
5557
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
5332
5558
|
/* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: n("Ask AI") }),
|
|
@@ -5382,24 +5608,24 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5382
5608
|
};
|
|
5383
5609
|
function ManualClasses() {
|
|
5384
5610
|
var I;
|
|
5385
|
-
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), f = useBuilderProp("askAiCallBack", null), [
|
|
5386
|
-
const
|
|
5387
|
-
u(m,
|
|
5388
|
-
}, [
|
|
5389
|
-
const
|
|
5390
|
-
let
|
|
5391
|
-
if (
|
|
5392
|
-
const [M] =
|
|
5393
|
-
|
|
5394
|
-
|
|
5395
|
-
item: {
|
|
5611
|
+
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), f = useBuilderProp("askAiCallBack", null), [h, b] = useState(""), x = (I = first(d)) == null ? void 0 : I.prop, { classes: y } = getSplitChaiClasses(get(p, x, "")), A = y.split(" ").filter((L) => !isEmpty(L)), j = () => {
|
|
5612
|
+
const L = h.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5613
|
+
u(m, L, !0), b("");
|
|
5614
|
+
}, [C, S] = useState([]), B = ({ value: L }) => {
|
|
5615
|
+
const P = L.trim().toLowerCase(), E = P.match(/.+:/g);
|
|
5616
|
+
let D = [];
|
|
5617
|
+
if (E && E.length > 0) {
|
|
5618
|
+
const [M] = E, R = P.replace(M, "");
|
|
5619
|
+
D = i.search(R).map(($) => ({
|
|
5620
|
+
...$,
|
|
5621
|
+
item: { ...$.item, name: M + $.item.name }
|
|
5396
5622
|
}));
|
|
5397
5623
|
} else
|
|
5398
|
-
|
|
5399
|
-
return S(map(
|
|
5624
|
+
D = i.search(P);
|
|
5625
|
+
return S(map(D, "item"));
|
|
5400
5626
|
}, _ = () => {
|
|
5401
5627
|
S([]);
|
|
5402
|
-
},
|
|
5628
|
+
}, w = (L) => L.name, T = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), k = useMemo(
|
|
5403
5629
|
() => ({
|
|
5404
5630
|
ref: o,
|
|
5405
5631
|
autoComplete: "off",
|
|
@@ -5407,24 +5633,24 @@ function ManualClasses() {
|
|
|
5407
5633
|
autoCapitalize: "off",
|
|
5408
5634
|
spellCheck: !1,
|
|
5409
5635
|
placeholder: c("Enter classes separated by space"),
|
|
5410
|
-
value:
|
|
5411
|
-
onKeyDown: (
|
|
5412
|
-
|
|
5636
|
+
value: h,
|
|
5637
|
+
onKeyDown: (L) => {
|
|
5638
|
+
L.key === "Enter" && h.trim() !== "" && j();
|
|
5413
5639
|
},
|
|
5414
|
-
onChange: (
|
|
5640
|
+
onChange: (L, { newValue: P }) => b(P),
|
|
5415
5641
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
5416
5642
|
}),
|
|
5417
|
-
[
|
|
5418
|
-
), v = (
|
|
5643
|
+
[h, c, o]
|
|
5644
|
+
), v = (L) => {
|
|
5419
5645
|
debugger;
|
|
5420
|
-
const
|
|
5421
|
-
g(m, [
|
|
5646
|
+
const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5647
|
+
g(m, [L]), u(m, P, !0), r(""), l(-1);
|
|
5422
5648
|
}, N = () => {
|
|
5423
5649
|
if (navigator.clipboard === void 0) {
|
|
5424
5650
|
toast.error(c("Clipboard not supported"));
|
|
5425
5651
|
return;
|
|
5426
5652
|
}
|
|
5427
|
-
navigator.clipboard.writeText(
|
|
5653
|
+
navigator.clipboard.writeText(A.join(" ")), toast.success(c("Classes copied to clipboard"));
|
|
5428
5654
|
};
|
|
5429
5655
|
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
|
|
5430
5656
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
|
|
@@ -5447,10 +5673,10 @@ function ManualClasses() {
|
|
|
5447
5673
|
/* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
|
|
5448
5674
|
Autosuggest,
|
|
5449
5675
|
{
|
|
5450
|
-
suggestions:
|
|
5451
|
-
onSuggestionsFetchRequested:
|
|
5676
|
+
suggestions: C,
|
|
5677
|
+
onSuggestionsFetchRequested: B,
|
|
5452
5678
|
onSuggestionsClearRequested: _,
|
|
5453
|
-
getSuggestionValue:
|
|
5679
|
+
getSuggestionValue: w,
|
|
5454
5680
|
renderSuggestion: T,
|
|
5455
5681
|
inputProps: k,
|
|
5456
5682
|
containerProps: {
|
|
@@ -5468,45 +5694,45 @@ function ManualClasses() {
|
|
|
5468
5694
|
{
|
|
5469
5695
|
variant: "outline",
|
|
5470
5696
|
className: "h-6 border-border",
|
|
5471
|
-
onClick:
|
|
5472
|
-
disabled:
|
|
5697
|
+
onClick: j,
|
|
5698
|
+
disabled: h.trim() === "",
|
|
5473
5699
|
size: "sm",
|
|
5474
5700
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
5475
5701
|
}
|
|
5476
5702
|
)
|
|
5477
5703
|
] }),
|
|
5478
|
-
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children:
|
|
5479
|
-
(
|
|
5704
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: A.map(
|
|
5705
|
+
(L, P) => a === P ? /* @__PURE__ */ jsx(
|
|
5480
5706
|
"input",
|
|
5481
5707
|
{
|
|
5482
5708
|
ref: o,
|
|
5483
5709
|
value: n,
|
|
5484
|
-
onChange: (
|
|
5710
|
+
onChange: (E) => r(E.target.value),
|
|
5485
5711
|
onBlur: () => {
|
|
5486
|
-
v(
|
|
5712
|
+
v(L);
|
|
5487
5713
|
},
|
|
5488
|
-
onKeyDown: (
|
|
5489
|
-
|
|
5714
|
+
onKeyDown: (E) => {
|
|
5715
|
+
E.key === "Enter" && v(L);
|
|
5490
5716
|
},
|
|
5491
5717
|
className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"
|
|
5492
5718
|
},
|
|
5493
|
-
|
|
5719
|
+
L
|
|
5494
5720
|
) : /* @__PURE__ */ jsxs(
|
|
5495
5721
|
"button",
|
|
5496
5722
|
{
|
|
5497
5723
|
className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",
|
|
5498
5724
|
children: [
|
|
5499
|
-
|
|
5500
|
-
n !==
|
|
5725
|
+
L,
|
|
5726
|
+
n !== L && /* @__PURE__ */ jsx(
|
|
5501
5727
|
Cross2Icon,
|
|
5502
5728
|
{
|
|
5503
|
-
onClick: () => g(m, [
|
|
5729
|
+
onClick: () => g(m, [L], !0),
|
|
5504
5730
|
className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
|
|
5505
5731
|
}
|
|
5506
5732
|
)
|
|
5507
5733
|
]
|
|
5508
5734
|
},
|
|
5509
|
-
|
|
5735
|
+
L
|
|
5510
5736
|
)
|
|
5511
5737
|
) })
|
|
5512
5738
|
] });
|
|
@@ -5848,8 +6074,8 @@ const COLOR_PROP = {
|
|
|
5848
6074
|
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
5849
6075
|
const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), m = get(u, "2", ""), f = useCallback(
|
|
5850
6076
|
// eslint-disable-next-line no-shadow
|
|
5851
|
-
(
|
|
5852
|
-
["current", "inherit", "transparent", "black", "white"].includes(
|
|
6077
|
+
(x) => {
|
|
6078
|
+
["current", "inherit", "transparent", "black", "white"].includes(x) ? (c([]), p({ color: x })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((y) => ({ ...y, color: x, shade: y.shade ? y.shade : "500" })));
|
|
5853
6079
|
},
|
|
5854
6080
|
[c, p]
|
|
5855
6081
|
);
|
|
@@ -5858,10 +6084,10 @@ const COLOR_PROP = {
|
|
|
5858
6084
|
return c([]);
|
|
5859
6085
|
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
5860
6086
|
}, [g]);
|
|
5861
|
-
const
|
|
6087
|
+
const h = useCallback(
|
|
5862
6088
|
// eslint-disable-next-line no-shadow
|
|
5863
|
-
(
|
|
5864
|
-
p({ color: g, shade:
|
|
6089
|
+
(x) => {
|
|
6090
|
+
p({ color: g, shade: x });
|
|
5865
6091
|
},
|
|
5866
6092
|
[g]
|
|
5867
6093
|
);
|
|
@@ -5912,7 +6138,7 @@ const COLOR_PROP = {
|
|
|
5912
6138
|
]
|
|
5913
6139
|
}
|
|
5914
6140
|
) }),
|
|
5915
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange:
|
|
6141
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: h, options: i }) })
|
|
5916
6142
|
] });
|
|
5917
6143
|
}, IconChoices = ({ property: o, onChange: n }) => {
|
|
5918
6144
|
const { getClasses: r } = useTailwindClassList(), a = r(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
|
|
@@ -6109,7 +6335,7 @@ const COLOR_PROP = {
|
|
|
6109
6335
|
},
|
|
6110
6336
|
a
|
|
6111
6337
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
6112
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, f] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [
|
|
6338
|
+
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, f] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [h, b] = useState(!1), [x, y] = useState(""), [A, j] = useState(!1), [C, S] = useState(!1);
|
|
6113
6339
|
useEffect(() => {
|
|
6114
6340
|
const { value: k, unit: v } = getClassValueAndUnit(i);
|
|
6115
6341
|
if (v === "") {
|
|
@@ -6118,7 +6344,7 @@ const COLOR_PROP = {
|
|
|
6118
6344
|
}
|
|
6119
6345
|
f(v), l(v === "class" || isEmpty(k) ? "" : k);
|
|
6120
6346
|
}, [i, p, u]);
|
|
6121
|
-
const
|
|
6347
|
+
const B = useThrottledCallback((k) => c(k), [c], THROTTLE_TIME), _ = useThrottledCallback((k) => c(k, !1), [c], THROTTLE_TIME), w = useCallback(
|
|
6122
6348
|
(k = !1) => {
|
|
6123
6349
|
const v = getUserInputValues(`${a}`, u);
|
|
6124
6350
|
if (get(v, "error", !1)) {
|
|
@@ -6127,15 +6353,15 @@ const COLOR_PROP = {
|
|
|
6127
6353
|
}
|
|
6128
6354
|
const N = get(v, "unit") !== "" ? get(v, "unit") : m;
|
|
6129
6355
|
if (N === "auto" || N === "none") {
|
|
6130
|
-
|
|
6356
|
+
B(`${d}${N}`);
|
|
6131
6357
|
return;
|
|
6132
6358
|
}
|
|
6133
6359
|
if (get(v, "value") === "")
|
|
6134
6360
|
return;
|
|
6135
|
-
const
|
|
6136
|
-
k ? _(
|
|
6361
|
+
const L = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
|
|
6362
|
+
k ? _(L) : B(L);
|
|
6137
6363
|
},
|
|
6138
|
-
[
|
|
6364
|
+
[B, _, a, m, d, u]
|
|
6139
6365
|
), T = useCallback(
|
|
6140
6366
|
(k) => {
|
|
6141
6367
|
const v = getUserInputValues(`${a}`, u);
|
|
@@ -6144,15 +6370,15 @@ const COLOR_PROP = {
|
|
|
6144
6370
|
return;
|
|
6145
6371
|
}
|
|
6146
6372
|
if (k === "auto" || k === "none") {
|
|
6147
|
-
|
|
6373
|
+
B(`${d}${k}`);
|
|
6148
6374
|
return;
|
|
6149
6375
|
}
|
|
6150
6376
|
if (get(v, "value") === "")
|
|
6151
6377
|
return;
|
|
6152
|
-
const N = get(v, "unit") !== "" ? get(v, "unit") : k,
|
|
6153
|
-
|
|
6378
|
+
const N = get(v, "unit") !== "" ? get(v, "unit") : k, L = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
|
|
6379
|
+
B(L);
|
|
6154
6380
|
},
|
|
6155
|
-
[
|
|
6381
|
+
[B, a, d, u]
|
|
6156
6382
|
);
|
|
6157
6383
|
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: m === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6158
6384
|
/* @__PURE__ */ jsx(
|
|
@@ -6167,14 +6393,14 @@ const COLOR_PROP = {
|
|
|
6167
6393
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsx(InfoCircledIcon, {}) }) }),
|
|
6168
6394
|
/* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
|
|
6169
6395
|
] })
|
|
6170
|
-
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${
|
|
6396
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${A ? "z-auto" : ""}`, children: [
|
|
6171
6397
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
6172
6398
|
["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
|
|
6173
6399
|
"input",
|
|
6174
6400
|
{
|
|
6175
6401
|
readOnly: m === "class",
|
|
6176
6402
|
onKeyPress: (k) => {
|
|
6177
|
-
k.key === "Enter" &&
|
|
6403
|
+
k.key === "Enter" && w();
|
|
6178
6404
|
},
|
|
6179
6405
|
onKeyDown: (k) => {
|
|
6180
6406
|
if (k.keyCode !== 38 && k.keyCode !== 40)
|
|
@@ -6183,13 +6409,13 @@ const COLOR_PROP = {
|
|
|
6183
6409
|
const v = parseInt$1(k.target.value);
|
|
6184
6410
|
let N = isNaN$1(v) ? 0 : v;
|
|
6185
6411
|
k.keyCode === 38 && (N += 1), k.keyCode === 40 && (N -= 1);
|
|
6186
|
-
const I = `${N}`,
|
|
6187
|
-
_(
|
|
6412
|
+
const I = `${N}`, P = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6413
|
+
_(P);
|
|
6188
6414
|
},
|
|
6189
6415
|
onKeyUp: (k) => {
|
|
6190
|
-
|
|
6416
|
+
C && (k.preventDefault(), S(!1));
|
|
6191
6417
|
},
|
|
6192
|
-
onBlur: () =>
|
|
6418
|
+
onBlur: () => w(),
|
|
6193
6419
|
onChange: (k) => {
|
|
6194
6420
|
b(!1), l(k.target.value);
|
|
6195
6421
|
},
|
|
@@ -6197,10 +6423,10 @@ const COLOR_PROP = {
|
|
|
6197
6423
|
var v;
|
|
6198
6424
|
(v = k == null ? void 0 : k.target) == null || v.select(), r(!1);
|
|
6199
6425
|
},
|
|
6200
|
-
value:
|
|
6426
|
+
value: A ? x : a,
|
|
6201
6427
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
6202
6428
|
" ",
|
|
6203
|
-
|
|
6429
|
+
h ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
6204
6430
|
)
|
|
6205
6431
|
}
|
|
6206
6432
|
),
|
|
@@ -6229,15 +6455,15 @@ const COLOR_PROP = {
|
|
|
6229
6455
|
) }) })
|
|
6230
6456
|
] })
|
|
6231
6457
|
] }),
|
|
6232
|
-
["none", "auto"].indexOf(m) !== -1 ||
|
|
6458
|
+
["none", "auto"].indexOf(m) !== -1 || A ? null : /* @__PURE__ */ jsx(
|
|
6233
6459
|
DragStyleButton,
|
|
6234
6460
|
{
|
|
6235
|
-
onDragStart: () =>
|
|
6461
|
+
onDragStart: () => j(!0),
|
|
6236
6462
|
onDragEnd: (k) => {
|
|
6237
|
-
if (y(() => ""),
|
|
6463
|
+
if (y(() => ""), j(!1), isEmpty(k))
|
|
6238
6464
|
return;
|
|
6239
6465
|
const v = `${k}`, I = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6240
|
-
|
|
6466
|
+
B(I);
|
|
6241
6467
|
},
|
|
6242
6468
|
onDrag: (k) => {
|
|
6243
6469
|
if (isEmpty(k))
|
|
@@ -6341,23 +6567,23 @@ const COLOR_PROP = {
|
|
|
6341
6567
|
"2xl": "1536px"
|
|
6342
6568
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6343
6569
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6344
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), f = useAddClassesToBlocks(),
|
|
6345
|
-
(_,
|
|
6570
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), f = useAddClassesToBlocks(), h = useRemoveClassesFromBlocks(), [b] = useSelectedBlockIds(), x = useMemo(() => get(m, "fullCls", ""), [m]), y = useCallback(
|
|
6571
|
+
(_, w = !0) => {
|
|
6346
6572
|
const T = { dark: p, mq: g, mod: u, cls: _, property: l, fullCls: "" };
|
|
6347
6573
|
(p || u !== "") && (T.mq = "xs");
|
|
6348
6574
|
const k = generateFullClsName(T);
|
|
6349
|
-
f(b, [k],
|
|
6575
|
+
f(b, [k], w);
|
|
6350
6576
|
},
|
|
6351
6577
|
[b, p, g, u, l, f]
|
|
6352
|
-
),
|
|
6353
|
-
|
|
6354
|
-
}, [b,
|
|
6578
|
+
), A = useCallback(() => {
|
|
6579
|
+
h(b, [x], !0);
|
|
6580
|
+
}, [b, x, h]), j = useMemo(() => canChangeClass(m, g), [m, g]);
|
|
6355
6581
|
useEffect(() => {
|
|
6356
|
-
i(
|
|
6357
|
-
}, [
|
|
6358
|
-
const [, ,
|
|
6582
|
+
i(j, m);
|
|
6583
|
+
}, [j, i, m]);
|
|
6584
|
+
const [, , C] = useScreenSizeWidth(), S = useCallback(
|
|
6359
6585
|
(_) => {
|
|
6360
|
-
|
|
6586
|
+
C({
|
|
6361
6587
|
xs: 400,
|
|
6362
6588
|
sm: 640,
|
|
6363
6589
|
md: 800,
|
|
@@ -6366,10 +6592,10 @@ const COLOR_PROP = {
|
|
|
6366
6592
|
"2xl": 1920
|
|
6367
6593
|
}[_]);
|
|
6368
6594
|
},
|
|
6369
|
-
[
|
|
6370
|
-
),
|
|
6371
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange:
|
|
6372
|
-
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !
|
|
6595
|
+
[C]
|
|
6596
|
+
), B = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
|
|
6597
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: j, canReset: m && B, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
6598
|
+
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !B ? "text-foreground" : ""}`, children: n(a) }) }),
|
|
6373
6599
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6374
6600
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
6375
6601
|
r === "arbitrary" ? /* @__PURE__ */ jsx(
|
|
@@ -6388,7 +6614,7 @@ const COLOR_PROP = {
|
|
|
6388
6614
|
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
|
|
6389
6615
|
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
|
|
6390
6616
|
] }),
|
|
6391
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${
|
|
6617
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${x ? "visible" : "invisible"}`, children: B ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => A(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : j && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6392
6618
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6393
6619
|
"button",
|
|
6394
6620
|
{
|
|
@@ -6438,18 +6664,18 @@ const COLOR_PROP = {
|
|
|
6438
6664
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6439
6665
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6440
6666
|
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
|
|
6441
|
-
n.map(({ label: f, key:
|
|
6667
|
+
n.map(({ label: f, key: h }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6442
6668
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6443
6669
|
"button",
|
|
6444
6670
|
{
|
|
6445
6671
|
type: "button",
|
|
6446
|
-
onClick: () => u(
|
|
6447
|
-
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${
|
|
6672
|
+
onClick: () => u(h),
|
|
6673
|
+
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${h === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6448
6674
|
children: [
|
|
6449
6675
|
React__default.createElement("div", {
|
|
6450
|
-
className: m(
|
|
6676
|
+
className: m(h) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6451
6677
|
}),
|
|
6452
|
-
React__default.createElement(get(EDITOR_ICONS,
|
|
6678
|
+
React__default.createElement(get(EDITOR_ICONS, h, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6453
6679
|
]
|
|
6454
6680
|
}
|
|
6455
6681
|
) }),
|
|
@@ -6595,10 +6821,10 @@ function BlockStyling() {
|
|
|
6595
6821
|
const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
|
|
6596
6822
|
let f = parseFloat(i.dragStartValue);
|
|
6597
6823
|
f = isNaN(f) ? 0 : f;
|
|
6598
|
-
let
|
|
6599
|
-
(startsWith(m, "scale") || m === "opacity") && (
|
|
6600
|
-
let
|
|
6601
|
-
g &&
|
|
6824
|
+
let h = MAPPER[i.dragUnit];
|
|
6825
|
+
(startsWith(m, "scale") || m === "opacity") && (h = 10);
|
|
6826
|
+
let x = (i.dragStartY - u.pageY) / h + f;
|
|
6827
|
+
g && x < 0 && (x = 0), m === "opacity" && x > 1 && (x = 1), i.onDrag(`${x}`), l(`${x}`);
|
|
6602
6828
|
},
|
|
6603
6829
|
[i],
|
|
6604
6830
|
50
|
|
@@ -6642,12 +6868,12 @@ const CoreBlock = ({
|
|
|
6642
6868
|
}) => {
|
|
6643
6869
|
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), f = () => {
|
|
6644
6870
|
if (has(o, "blocks")) {
|
|
6645
|
-
const
|
|
6646
|
-
u(syncBlocksWithDefaults(
|
|
6871
|
+
const x = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
|
|
6872
|
+
u(syncBlocksWithDefaults(x), r || null, a);
|
|
6647
6873
|
} else
|
|
6648
6874
|
p(o, r || null, a);
|
|
6649
6875
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6650
|
-
},
|
|
6876
|
+
}, h = useFeature("dnd"), { t: b } = useTranslation();
|
|
6651
6877
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6652
6878
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6653
6879
|
"button",
|
|
@@ -6655,12 +6881,12 @@ const CoreBlock = ({
|
|
|
6655
6881
|
disabled: n,
|
|
6656
6882
|
onClick: f,
|
|
6657
6883
|
type: "button",
|
|
6658
|
-
onDragStart: (
|
|
6659
|
-
|
|
6884
|
+
onDragStart: (x) => {
|
|
6885
|
+
x.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), x.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
6660
6886
|
g([]), m();
|
|
6661
6887
|
}, 200);
|
|
6662
6888
|
},
|
|
6663
|
-
draggable:
|
|
6889
|
+
draggable: h ? "true" : "false",
|
|
6664
6890
|
className: "cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",
|
|
6665
6891
|
children: [
|
|
6666
6892
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
@@ -6853,22 +7079,22 @@ const CoreBlock = ({
|
|
|
6853
7079
|
}
|
|
6854
7080
|
}
|
|
6855
7081
|
}, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
|
|
6856
|
-
var m, f,
|
|
7082
|
+
var m, f, h, b, x, y, A, j;
|
|
6857
7083
|
if (r.type === "comment") return [];
|
|
6858
7084
|
console.log("node ===>", r);
|
|
6859
7085
|
let a = { _id: generateUUID() };
|
|
6860
7086
|
if (n && (a._parent = n.block._id), r.type === "text")
|
|
6861
7087
|
return isEmpty(get(r, "content", "")) ? [] : n && shouldAddText(n.node, n.block) ? (set(n, "block.content", get(r, "content", "")), []) : { ...a, _type: "Text", content: get(r, "content", "") };
|
|
6862
7088
|
const l = get(r, "attributes", []), i = l.find(
|
|
6863
|
-
(
|
|
7089
|
+
(C) => C.key === "data-chai-richtext" || C.key === "chai-richtext"
|
|
6864
7090
|
), c = l.find(
|
|
6865
|
-
(
|
|
7091
|
+
(C) => C.key === "data-chai-lightbox" || C.key === "chai-lightbox"
|
|
6866
7092
|
), d = l.find(
|
|
6867
|
-
(
|
|
7093
|
+
(C) => C.key === "data-chai-dropdown" || C.key === "chai-dropdown"
|
|
6868
7094
|
), p = l.find(
|
|
6869
|
-
(
|
|
7095
|
+
(C) => C.key === "data-chai-dropdown-button" || C.key === "chai-dropdown-button"
|
|
6870
7096
|
), u = l.find(
|
|
6871
|
-
(
|
|
7097
|
+
(C) => C.key === "data-chai-dropdown-content" || C.key === "chai-dropdown-content"
|
|
6872
7098
|
);
|
|
6873
7099
|
if (a = {
|
|
6874
7100
|
...a,
|
|
@@ -6876,13 +7102,13 @@ const CoreBlock = ({
|
|
|
6876
7102
|
...getAttrs(r),
|
|
6877
7103
|
...getStyles(r)
|
|
6878
7104
|
}, r.attributes) {
|
|
6879
|
-
const
|
|
6880
|
-
|
|
7105
|
+
const C = r.attributes.find((S) => includes(NAME_ATTRIBUTES, S.key));
|
|
7106
|
+
C && (a._name = C.value);
|
|
6881
7107
|
}
|
|
6882
7108
|
if (i)
|
|
6883
7109
|
return a.content = stringify(r.children), has(a, "styles_attrs.data-chai-richtext") && delete a.styles_attrs["data-chai-richtext"], has(a, "styles_attrs.chai-richtext") && delete a.styles_attrs["chai-richtext"], [a];
|
|
6884
7110
|
if (c) {
|
|
6885
|
-
const
|
|
7111
|
+
const C = [
|
|
6886
7112
|
"data-chai-lightbox",
|
|
6887
7113
|
"chai-lightbox",
|
|
6888
7114
|
"data-vbtype",
|
|
@@ -6896,42 +7122,42 @@ const CoreBlock = ({
|
|
|
6896
7122
|
...a,
|
|
6897
7123
|
href: ((m = l.find((S) => S.key === "href")) == null ? void 0 : m.value) || "",
|
|
6898
7124
|
hrefType: ((f = l.find((S) => S.key === "data-vbtype")) == null ? void 0 : f.value) || "video",
|
|
6899
|
-
autoplay: ((
|
|
6900
|
-
maxWidth: ((
|
|
7125
|
+
autoplay: ((h = l.find((S) => S.key === "data-autoplay")) == null ? void 0 : h.value) === "true" ? "true" : "false",
|
|
7126
|
+
maxWidth: ((x = (b = l.find((S) => S.key === "data-maxwidth")) == null ? void 0 : b.value) == null ? void 0 : x.replace("px", "")) || "",
|
|
6901
7127
|
backdropColor: ((y = l.find((S) => S.key === "data-overlay")) == null ? void 0 : y.value) || "",
|
|
6902
|
-
galleryName: ((
|
|
6903
|
-
}, forEach(
|
|
7128
|
+
galleryName: ((A = l.find((S) => S.key === "data-gall")) == null ? void 0 : A.value) || ""
|
|
7129
|
+
}, forEach(C, (S) => {
|
|
6904
7130
|
has(a, `styles_attrs.${S}`) && delete a.styles_attrs[S];
|
|
6905
7131
|
});
|
|
6906
7132
|
}
|
|
6907
7133
|
if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
|
|
6908
7134
|
delete a.styles_attrs;
|
|
6909
|
-
const
|
|
6910
|
-
a.content = getTextContent(
|
|
7135
|
+
const C = filter(r.children || [], (B) => (B == null ? void 0 : B.tagName) !== "span");
|
|
7136
|
+
a.content = getTextContent(C);
|
|
6911
7137
|
const S = find(
|
|
6912
7138
|
r.children || [],
|
|
6913
|
-
(
|
|
7139
|
+
(B) => (B == null ? void 0 : B.tagName) === "span" && some(B.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg")
|
|
6914
7140
|
);
|
|
6915
7141
|
if (S) {
|
|
6916
|
-
const
|
|
6917
|
-
if (
|
|
6918
|
-
a.icon = stringify([
|
|
6919
|
-
const { height: _, width:
|
|
6920
|
-
a.iconHeight = _, a.iconWidth =
|
|
7142
|
+
const B = find(S.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg");
|
|
7143
|
+
if (B) {
|
|
7144
|
+
a.icon = stringify([B]);
|
|
7145
|
+
const { height: _, width: w } = getSvgDimensions(B, "16px", "16px");
|
|
7146
|
+
a.iconHeight = _, a.iconWidth = w;
|
|
6921
7147
|
}
|
|
6922
7148
|
}
|
|
6923
7149
|
return [a];
|
|
6924
7150
|
}
|
|
6925
7151
|
if (a._type === "Input") {
|
|
6926
|
-
const
|
|
6927
|
-
|
|
7152
|
+
const C = a.inputType || "text";
|
|
7153
|
+
C === "checkbox" ? set(a, "_type", "Checkbox") : C === "radio" && set(a, "_type", "Radio");
|
|
6928
7154
|
} else if (r.tagName === "video" || r.tagName === "iframe") {
|
|
6929
|
-
const
|
|
6930
|
-
return hasVideoEmbed(
|
|
7155
|
+
const C = stringify([r]);
|
|
7156
|
+
return hasVideoEmbed(C) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(C)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = C, [a];
|
|
6931
7157
|
} else if (r.tagName === "svg") {
|
|
6932
|
-
const
|
|
6933
|
-
return a.styles = `${STYLES_KEY}, ${cn(`w-${_} h-${
|
|
6934
|
-
} else if (r.tagName == "option" && n && ((
|
|
7158
|
+
const C = find(r.attributes, { key: "height" }), S = find(r.attributes, { key: "width" }), B = get(C, "value") ? `[${get(C, "value")}px]` : "24px", _ = get(S, "value") ? `[${get(S, "value")}px]` : "24px", w = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
|
|
7159
|
+
return a.styles = `${STYLES_KEY}, ${cn$1(`w-${_} h-${B}`, w)}`.trim(), r.attributes = filter(r.attributes, (T) => !includes(["style", "width", "height", "class"], T.key)), a.icon = stringify([r]), [a];
|
|
7160
|
+
} else if (r.tagName == "option" && n && ((j = n.block) == null ? void 0 : j._type) === "Select")
|
|
6935
7161
|
return n.block.options.push({
|
|
6936
7162
|
label: getTextContent(r.children),
|
|
6937
7163
|
...getAttrs(r)
|
|
@@ -6981,20 +7207,20 @@ const CoreBlock = ({
|
|
|
6981
7207
|
] });
|
|
6982
7208
|
}, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
6983
7209
|
var b;
|
|
6984
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (b = find(c, (
|
|
7210
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (b = find(c, (x) => x._id === r)) == null ? void 0 : b._type;
|
|
6985
7211
|
useEffect(() => {
|
|
6986
|
-
const
|
|
7212
|
+
const x = setTimeout(() => {
|
|
6987
7213
|
var y;
|
|
6988
7214
|
(y = u.current) == null || y.focus();
|
|
6989
7215
|
}, 0);
|
|
6990
|
-
return () => clearTimeout(
|
|
7216
|
+
return () => clearTimeout(x);
|
|
6991
7217
|
}, [g]);
|
|
6992
7218
|
const f = d ? values(n).filter(
|
|
6993
|
-
(
|
|
6994
|
-
var y,
|
|
6995
|
-
return (((y =
|
|
7219
|
+
(x) => {
|
|
7220
|
+
var y, A;
|
|
7221
|
+
return (((y = x.label) == null ? void 0 : y.toLowerCase()) + " " + ((A = x.type) == null ? void 0 : A.toLowerCase())).includes(d.toLowerCase());
|
|
6996
7222
|
}
|
|
6997
|
-
) : n,
|
|
7223
|
+
) : n, h = d ? o.filter((x) => reject(filter(values(f), { group: x }), { hidden: !0 }).length > 0) : o.filter((x) => reject(filter(values(n), { group: x }), { hidden: !0 }).length > 0);
|
|
6998
7224
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-2xl flex-col", children: [
|
|
6999
7225
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7000
7226
|
Input$1,
|
|
@@ -7003,21 +7229,21 @@ const CoreBlock = ({
|
|
|
7003
7229
|
type: "search",
|
|
7004
7230
|
placeholder: i("Search blocks..."),
|
|
7005
7231
|
value: d,
|
|
7006
|
-
onChange: (
|
|
7232
|
+
onChange: (x) => p(x.target.value)
|
|
7007
7233
|
}
|
|
7008
7234
|
) }),
|
|
7009
|
-
/* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children:
|
|
7235
|
+
/* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: h.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
|
|
7010
7236
|
i("No blocks found matching"),
|
|
7011
7237
|
' "',
|
|
7012
7238
|
d,
|
|
7013
7239
|
'"'
|
|
7014
7240
|
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: sortBy(
|
|
7015
|
-
|
|
7016
|
-
(
|
|
7017
|
-
).map((
|
|
7018
|
-
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(
|
|
7241
|
+
h,
|
|
7242
|
+
(x) => CORE_GROUPS.indexOf(x) === -1 ? 99 : CORE_GROUPS.indexOf(x)
|
|
7243
|
+
).map((x) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7244
|
+
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(x.toLowerCase())) }),
|
|
7019
7245
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: React__default.Children.toArray(
|
|
7020
|
-
reject(filter(values(f), { group:
|
|
7246
|
+
reject(filter(values(f), { group: x }), { hidden: !0 }).map((y) => /* @__PURE__ */ jsx(
|
|
7021
7247
|
CoreBlock,
|
|
7022
7248
|
{
|
|
7023
7249
|
parentId: r,
|
|
@@ -7028,7 +7254,7 @@ const CoreBlock = ({
|
|
|
7028
7254
|
y.type
|
|
7029
7255
|
))
|
|
7030
7256
|
) })
|
|
7031
|
-
] },
|
|
7257
|
+
] }, x)) }) })
|
|
7032
7258
|
] });
|
|
7033
7259
|
}, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
|
|
7034
7260
|
className: o,
|
|
@@ -7039,7 +7265,7 @@ const CoreBlock = ({
|
|
|
7039
7265
|
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), g = useCallback(() => {
|
|
7040
7266
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7041
7267
|
}, []);
|
|
7042
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
7268
|
+
return /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
7043
7269
|
n ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
|
|
7044
7270
|
/* @__PURE__ */ jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: l("Add block") }),
|
|
7045
7271
|
/* @__PURE__ */ jsx("span", { className: "p-0 text-xs font-light leading-3 opacity-80 xl:pl-1", children: l(i === "html" ? "Enter or paste TailwindCSS HTML snippet" : "Click to add block to page") })
|
|
@@ -7078,7 +7304,7 @@ const CoreBlock = ({
|
|
|
7078
7304
|
const u = p.target.value;
|
|
7079
7305
|
c(u), n(u);
|
|
7080
7306
|
};
|
|
7081
|
-
return /* @__PURE__ */ jsx("div", { className: cn("relative inline-block w-full", l), children: /* @__PURE__ */ jsxs(
|
|
7307
|
+
return /* @__PURE__ */ jsx("div", { className: cn$1("relative inline-block w-full", l), children: /* @__PURE__ */ jsxs(
|
|
7082
7308
|
"select",
|
|
7083
7309
|
{
|
|
7084
7310
|
className: "mt-1 flex w-full rounded-md border border-border bg-background px-3 py-1 text-sm text-foreground shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
|
|
@@ -7119,18 +7345,18 @@ const BlockCard = ({
|
|
|
7119
7345
|
parentId: r = void 0,
|
|
7120
7346
|
position: a = -1
|
|
7121
7347
|
}) => {
|
|
7122
|
-
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), f = useFeature("dnd"), [,
|
|
7123
|
-
const
|
|
7124
|
-
return
|
|
7125
|
-
},
|
|
7126
|
-
async (
|
|
7127
|
-
if (
|
|
7348
|
+
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), f = useFeature("dnd"), [, h] = useAtom$1(draggedBlockAtom), b = (A) => {
|
|
7349
|
+
const j = has(A, "styles_attrs.data-page-section");
|
|
7350
|
+
return A._type === "Box" && j;
|
|
7351
|
+
}, x = useCallback(
|
|
7352
|
+
async (A) => {
|
|
7353
|
+
if (A.stopPropagation(), has(o, "component")) {
|
|
7128
7354
|
d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7129
7355
|
return;
|
|
7130
7356
|
}
|
|
7131
7357
|
i(!0);
|
|
7132
|
-
const
|
|
7133
|
-
isEmpty(
|
|
7358
|
+
const j = await c(n, o);
|
|
7359
|
+
isEmpty(j) || p(syncBlocksWithDefaults(j), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7134
7360
|
},
|
|
7135
7361
|
[d, p, o, c, n, r, a]
|
|
7136
7362
|
);
|
|
@@ -7139,26 +7365,26 @@ const BlockCard = ({
|
|
|
7139
7365
|
"div",
|
|
7140
7366
|
{
|
|
7141
7367
|
onClick: l ? () => {
|
|
7142
|
-
} :
|
|
7368
|
+
} : x,
|
|
7143
7369
|
draggable: f ? "true" : "false",
|
|
7144
|
-
onDragStart: async (
|
|
7145
|
-
const
|
|
7146
|
-
let
|
|
7147
|
-
if (b(first(
|
|
7148
|
-
const S = { blocks:
|
|
7149
|
-
if (
|
|
7150
|
-
const
|
|
7151
|
-
|
|
7152
|
-
|
|
7370
|
+
onDragStart: async (A) => {
|
|
7371
|
+
const j = await c(n, o);
|
|
7372
|
+
let C = r;
|
|
7373
|
+
if (b(first(j)) && (C = null), !isEmpty(j)) {
|
|
7374
|
+
const S = { blocks: j, uiLibrary: !0, parent: C };
|
|
7375
|
+
if (A.dataTransfer.setData("text/plain", JSON.stringify(S)), o.preview) {
|
|
7376
|
+
const B = new Image();
|
|
7377
|
+
B.src = o.preview, B.onload = () => {
|
|
7378
|
+
A.dataTransfer.setDragImage(B, 0, 0);
|
|
7153
7379
|
};
|
|
7154
7380
|
} else
|
|
7155
|
-
|
|
7156
|
-
|
|
7381
|
+
A.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7382
|
+
h(S), setTimeout(() => {
|
|
7157
7383
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7158
7384
|
}, 200);
|
|
7159
7385
|
}
|
|
7160
7386
|
},
|
|
7161
|
-
className: clsx(
|
|
7387
|
+
className: clsx$1(
|
|
7162
7388
|
"relative mt-2 cursor-pointer overflow-hidden rounded-md border border-border bg-white duration-200 hover:border-blue-500 hover:shadow-xl"
|
|
7163
7389
|
),
|
|
7164
7390
|
children: [
|
|
@@ -7185,9 +7411,9 @@ const BlockCard = ({
|
|
|
7185
7411
|
})();
|
|
7186
7412
|
}, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
|
|
7187
7413
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
7188
|
-
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((
|
|
7414
|
+
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((C) => C.category === "custom"), d = l.find((C) => C.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [m, f] = useState("Hero"), h = get(g, m, []), b = useRef(null), { t: x } = useTranslation(), y = (C) => {
|
|
7189
7415
|
b.current && (clearTimeout(b.current), b.current = null), b.current = setTimeout(() => {
|
|
7190
|
-
b.current && f(
|
|
7416
|
+
b.current && f(C);
|
|
7191
7417
|
}, 300);
|
|
7192
7418
|
};
|
|
7193
7419
|
if (u)
|
|
@@ -7195,26 +7421,26 @@ const BlockCard = ({
|
|
|
7195
7421
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7196
7422
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7197
7423
|
] });
|
|
7198
|
-
const
|
|
7424
|
+
const A = filter(h, (C, S) => S % 2 === 0), j = filter(h, (C, S) => S % 2 === 1);
|
|
7199
7425
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { className: "relative mt-2 flex h-full max-h-full overflow-hidden bg-background", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full pt-2", children: [
|
|
7200
7426
|
/* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
7201
7427
|
/* @__PURE__ */ jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
|
|
7202
7428
|
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
|
|
7203
|
-
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children:
|
|
7429
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: x("Groups") }),
|
|
7204
7430
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7205
7431
|
/* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: React__default.Children.toArray(
|
|
7206
|
-
map(g, (
|
|
7432
|
+
map(g, (C, S) => /* @__PURE__ */ jsxs(
|
|
7207
7433
|
"div",
|
|
7208
7434
|
{
|
|
7209
7435
|
onMouseEnter: () => y(S),
|
|
7210
7436
|
onMouseLeave: () => clearTimeout(b.current),
|
|
7211
7437
|
onClick: () => f(S),
|
|
7212
|
-
className: cn(
|
|
7438
|
+
className: cn$1(
|
|
7213
7439
|
"flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",
|
|
7214
7440
|
S === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
|
|
7215
7441
|
),
|
|
7216
7442
|
children: [
|
|
7217
|
-
/* @__PURE__ */ jsx("span", { children: capitalize(
|
|
7443
|
+
/* @__PURE__ */ jsx("span", { children: capitalize(x(S.toLowerCase())) }),
|
|
7218
7444
|
/* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
|
|
7219
7445
|
]
|
|
7220
7446
|
},
|
|
@@ -7231,10 +7457,10 @@ const BlockCard = ({
|
|
|
7231
7457
|
children: [
|
|
7232
7458
|
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
|
|
7233
7459
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
7234
|
-
|
|
7460
|
+
A.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
|
|
7235
7461
|
) }),
|
|
7236
7462
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
7237
|
-
|
|
7463
|
+
j.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
|
|
7238
7464
|
) })
|
|
7239
7465
|
] }),
|
|
7240
7466
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -7454,53 +7680,53 @@ function BiExpandVertical(o) {
|
|
|
7454
7680
|
return GenIcon({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "m12 19.24-4.95-4.95-1.41 1.42L12 22.07l6.36-6.36-1.41-1.42L12 19.24zM5.64 8.29l1.41 1.42L12 4.76l4.95 4.95 1.41-1.42L12 1.93 5.64 8.29z" }, child: [] }] })(o);
|
|
7455
7681
|
}
|
|
7456
7682
|
const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
7457
|
-
var
|
|
7683
|
+
var P;
|
|
7458
7684
|
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
|
|
7459
7685
|
let p = null;
|
|
7460
|
-
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: f, data:
|
|
7461
|
-
|
|
7462
|
-
}, S = (
|
|
7463
|
-
|
|
7464
|
-
},
|
|
7465
|
-
|
|
7466
|
-
}, [_,
|
|
7467
|
-
var
|
|
7468
|
-
k(), o.parent.isSelected ||
|
|
7686
|
+
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: f, data: h, isSelected: b, willReceiveDrop: x, isDragging: y, isEditing: A, handleClick: j } = o, C = (E) => {
|
|
7687
|
+
E.stopPropagation(), !i.includes(f) && o.toggle();
|
|
7688
|
+
}, S = (E) => {
|
|
7689
|
+
E.isInternal && (p = E.isOpen, E.isOpen && E.close());
|
|
7690
|
+
}, B = (E) => {
|
|
7691
|
+
E.isInternal && p !== null && (p ? E.open() : E.close(), p = null);
|
|
7692
|
+
}, [_, w] = useAtom$1(currentAddSelection), T = () => {
|
|
7693
|
+
var E;
|
|
7694
|
+
k(), o.parent.isSelected || w((E = o == null ? void 0 : o.parent) == null ? void 0 : E.id);
|
|
7469
7695
|
}, k = () => {
|
|
7470
|
-
|
|
7471
|
-
}, v = (
|
|
7472
|
-
k(),
|
|
7696
|
+
w(null);
|
|
7697
|
+
}, v = (E) => {
|
|
7698
|
+
k(), E.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(), j(E);
|
|
7473
7699
|
};
|
|
7474
7700
|
useEffect(() => {
|
|
7475
|
-
const
|
|
7476
|
-
|
|
7701
|
+
const E = setTimeout(() => {
|
|
7702
|
+
x && !o.isOpen && !y && !i.includes(f) && o.toggle();
|
|
7477
7703
|
}, 500);
|
|
7478
|
-
return () => clearTimeout(
|
|
7479
|
-
}, [
|
|
7704
|
+
return () => clearTimeout(E);
|
|
7705
|
+
}, [x, o, y]);
|
|
7480
7706
|
const N = useMemo(() => {
|
|
7481
|
-
const
|
|
7482
|
-
for (let M = 0; M <
|
|
7483
|
-
if (
|
|
7484
|
-
const
|
|
7485
|
-
|
|
7707
|
+
const E = Object.keys(h), D = [];
|
|
7708
|
+
for (let M = 0; M < E.length; M++)
|
|
7709
|
+
if (E[M].endsWith("_attrs")) {
|
|
7710
|
+
const R = h[E[M]], O = Object.keys(R).join("|");
|
|
7711
|
+
O.match(/x-data/) && D.push("data"), O.match(/x-on/) && D.push("event"), O.match(/x-show|x-if/) && D.push("show");
|
|
7486
7712
|
}
|
|
7487
|
-
return
|
|
7488
|
-
}, [
|
|
7489
|
-
const M = d.contentDocument || d.contentWindow.document,
|
|
7490
|
-
|
|
7491
|
-
const
|
|
7492
|
-
|
|
7493
|
-
},
|
|
7713
|
+
return D;
|
|
7714
|
+
}, [h]), I = (E, D) => {
|
|
7715
|
+
const M = d.contentDocument || d.contentWindow.document, R = M.querySelector(`[data-block-id=${E}]`);
|
|
7716
|
+
R && R.setAttribute("data-drop", D);
|
|
7717
|
+
const O = R.getBoundingClientRect(), $ = d.getBoundingClientRect();
|
|
7718
|
+
O.top >= $.top && O.left >= $.left && O.bottom <= $.bottom && O.right <= $.right || (M.documentElement.scrollTop = R.offsetTop - $.top);
|
|
7719
|
+
}, L = (E) => {
|
|
7494
7720
|
k();
|
|
7495
|
-
const
|
|
7496
|
-
|
|
7721
|
+
const D = get(o, "parent.id");
|
|
7722
|
+
D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: E }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: E });
|
|
7497
7723
|
};
|
|
7498
7724
|
return f === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
|
|
7499
7725
|
/* @__PURE__ */ jsx("br", {}),
|
|
7500
7726
|
/* @__PURE__ */ jsx(
|
|
7501
7727
|
"div",
|
|
7502
7728
|
{
|
|
7503
|
-
onClick: () =>
|
|
7729
|
+
onClick: () => L(-1),
|
|
7504
7730
|
className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
|
|
7505
7731
|
children: /* @__PURE__ */ jsxs("div", { className: "absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-purple-500 px-3 py-1 text-[9px] leading-tight text-white hover:bg-purple-500", children: [
|
|
7506
7732
|
/* @__PURE__ */ jsx(PlusIcon$1, { className: "h-2 w-2 stroke-[3]" }),
|
|
@@ -7520,22 +7746,22 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7520
7746
|
"data-node-id": f,
|
|
7521
7747
|
ref: i.includes(f) ? null : r,
|
|
7522
7748
|
onDragStart: () => S(o),
|
|
7523
|
-
onDragEnd: () =>
|
|
7524
|
-
onDragOver: (
|
|
7525
|
-
|
|
7749
|
+
onDragEnd: () => B(o),
|
|
7750
|
+
onDragOver: (E) => {
|
|
7751
|
+
E.preventDefault(), I(f, "yes");
|
|
7526
7752
|
},
|
|
7527
|
-
onDragLeave: (
|
|
7528
|
-
|
|
7753
|
+
onDragLeave: (E) => {
|
|
7754
|
+
E.preventDefault(), I(f, "no");
|
|
7529
7755
|
},
|
|
7530
|
-
onDrop: (
|
|
7531
|
-
|
|
7756
|
+
onDrop: (E) => {
|
|
7757
|
+
E.preventDefault(), I(f, "no");
|
|
7532
7758
|
},
|
|
7533
7759
|
children: [
|
|
7534
|
-
(o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((
|
|
7760
|
+
(o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((P = o == null ? void 0 : o.parent) == null ? void 0 : P.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
|
|
7535
7761
|
"div",
|
|
7536
7762
|
{
|
|
7537
|
-
onClick: (
|
|
7538
|
-
|
|
7763
|
+
onClick: (E) => {
|
|
7764
|
+
E.stopPropagation(), L(o.childIndex);
|
|
7539
7765
|
},
|
|
7540
7766
|
onMouseEnter: T,
|
|
7541
7767
|
onMouseLeave: k,
|
|
@@ -7546,10 +7772,10 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7546
7772
|
/* @__PURE__ */ jsxs(
|
|
7547
7773
|
"div",
|
|
7548
7774
|
{
|
|
7549
|
-
className: cn(
|
|
7775
|
+
className: cn$1(
|
|
7550
7776
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
|
|
7551
7777
|
b ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
|
|
7552
|
-
|
|
7778
|
+
x && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
|
|
7553
7779
|
(o == null ? void 0 : o.id) === _ ? "bg-purple-100" : "",
|
|
7554
7780
|
y && "opacity-20",
|
|
7555
7781
|
i.includes(f) ? "opacity-50" : ""
|
|
@@ -7560,7 +7786,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7560
7786
|
"div",
|
|
7561
7787
|
{
|
|
7562
7788
|
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
7563
|
-
children: u && /* @__PURE__ */ jsx("button", { onClick:
|
|
7789
|
+
children: u && /* @__PURE__ */ jsx("button", { onClick: C, type: "button", children: /* @__PURE__ */ jsx(
|
|
7564
7790
|
ChevronRight,
|
|
7565
7791
|
{
|
|
7566
7792
|
className: `h-3 w-3 stroke-[3] ${b ? "text-slate-200" : "text-slate-400"}`
|
|
@@ -7569,16 +7795,16 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7569
7795
|
}
|
|
7570
7796
|
),
|
|
7571
7797
|
/* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
|
|
7572
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
7573
|
-
|
|
7798
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
|
|
7799
|
+
A ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
|
|
7574
7800
|
"div",
|
|
7575
7801
|
{
|
|
7576
7802
|
className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
|
|
7577
|
-
onDoubleClick: (
|
|
7578
|
-
|
|
7803
|
+
onDoubleClick: (E) => {
|
|
7804
|
+
E.stopPropagation(), o.edit(), o.deselect();
|
|
7579
7805
|
},
|
|
7580
7806
|
children: [
|
|
7581
|
-
/* @__PURE__ */ jsx("span", { children: (
|
|
7807
|
+
/* @__PURE__ */ jsx("span", { children: (h == null ? void 0 : h._name) || (h == null ? void 0 : h._type.split("/").pop()) }),
|
|
7582
7808
|
N.includes("data") && /* @__PURE__ */ jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
|
|
7583
7809
|
N.includes("event") && /* @__PURE__ */ jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
|
|
7584
7810
|
N.includes("show") && /* @__PURE__ */ jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
|
|
@@ -7588,18 +7814,18 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7588
7814
|
] })
|
|
7589
7815
|
] }),
|
|
7590
7816
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
7591
|
-
!i.includes(f) && a.map((
|
|
7817
|
+
!i.includes(f) && a.map((E) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7592
7818
|
/* @__PURE__ */ jsx(
|
|
7593
7819
|
TooltipTrigger,
|
|
7594
7820
|
{
|
|
7595
7821
|
className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
|
|
7596
7822
|
asChild: !0,
|
|
7597
|
-
children: React__default.createElement(
|
|
7823
|
+
children: React__default.createElement(E.item, { blockId: f })
|
|
7598
7824
|
}
|
|
7599
7825
|
),
|
|
7600
|
-
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children:
|
|
7826
|
+
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: E.tooltip })
|
|
7601
7827
|
] })),
|
|
7602
|
-
canAddChildBlock(
|
|
7828
|
+
canAddChildBlock(h == null ? void 0 : h._type) && !i.includes(f) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7603
7829
|
/* @__PURE__ */ jsx(
|
|
7604
7830
|
TooltipTrigger,
|
|
7605
7831
|
{
|
|
@@ -7615,8 +7841,8 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7615
7841
|
/* @__PURE__ */ jsx(
|
|
7616
7842
|
TooltipTrigger,
|
|
7617
7843
|
{
|
|
7618
|
-
onClick: (
|
|
7619
|
-
|
|
7844
|
+
onClick: (E) => {
|
|
7845
|
+
E.stopPropagation(), c(f), o.isOpen && o.toggle();
|
|
7620
7846
|
},
|
|
7621
7847
|
className: "cursor-pointer rounded bg-transparent hover:text-black",
|
|
7622
7848
|
asChild: !0,
|
|
@@ -7638,7 +7864,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7638
7864
|
"input",
|
|
7639
7865
|
{
|
|
7640
7866
|
autoFocus: !0,
|
|
7641
|
-
className: cn(
|
|
7867
|
+
className: cn$1(
|
|
7642
7868
|
"ml-2 !h-4 w-full rounded-sm border border-border bg-background px-1 text-[11px] leading-tight outline-none",
|
|
7643
7869
|
o.isSelected ? "text-black dark:text-white" : ""
|
|
7644
7870
|
),
|
|
@@ -7737,7 +7963,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7737
7963
|
t("Add Block")
|
|
7738
7964
|
] })
|
|
7739
7965
|
] }) }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7740
|
-
/* @__PURE__ */ jsx("div", { className: cn("flex h-full select-none flex-col space-y-1"), onClick: () => clearSelection(), children: /* @__PURE__ */ jsxs(
|
|
7966
|
+
/* @__PURE__ */ jsx("div", { className: cn$1("flex h-full select-none flex-col space-y-1"), onClick: () => clearSelection(), children: /* @__PURE__ */ jsxs(
|
|
7741
7967
|
"div",
|
|
7742
7968
|
{
|
|
7743
7969
|
id: "outline-view",
|
|
@@ -8281,9 +8507,9 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8281
8507
|
var b;
|
|
8282
8508
|
(b = m.current) == null || b.focus();
|
|
8283
8509
|
}, []);
|
|
8284
|
-
const
|
|
8285
|
-
const { usage:
|
|
8286
|
-
!l &&
|
|
8510
|
+
const h = (b) => {
|
|
8511
|
+
const { usage: x } = b || {};
|
|
8512
|
+
!l && x && g(x), f.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
8287
8513
|
};
|
|
8288
8514
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
8289
8515
|
/* @__PURE__ */ jsxs(
|
|
@@ -8308,7 +8534,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8308
8534
|
className: "w-full",
|
|
8309
8535
|
rows: 3,
|
|
8310
8536
|
onKeyDown: (b) => {
|
|
8311
|
-
b.key === "Enter" && (b.preventDefault(), f.current && clearTimeout(f.current), g(void 0), r("content", o, i,
|
|
8537
|
+
b.key === "Enter" && (b.preventDefault(), f.current && clearTimeout(f.current), g(void 0), r("content", o, i, h));
|
|
8312
8538
|
}
|
|
8313
8539
|
}
|
|
8314
8540
|
),
|
|
@@ -8318,7 +8544,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8318
8544
|
{
|
|
8319
8545
|
disabled: i.trim().length < 5 || a,
|
|
8320
8546
|
onClick: () => {
|
|
8321
|
-
f.current && clearTimeout(f.current), g(void 0), r("content", o, i,
|
|
8547
|
+
f.current && clearTimeout(f.current), g(void 0), r("content", o, i, h);
|
|
8322
8548
|
},
|
|
8323
8549
|
variant: "default",
|
|
8324
8550
|
className: "w-fit",
|
|
@@ -8351,7 +8577,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8351
8577
|
QuickPrompts,
|
|
8352
8578
|
{
|
|
8353
8579
|
onClick: (b) => {
|
|
8354
|
-
f.current && clearTimeout(f.current), g(void 0), r("content", o, b,
|
|
8580
|
+
f.current && clearTimeout(f.current), g(void 0), r("content", o, b, h);
|
|
8355
8581
|
}
|
|
8356
8582
|
}
|
|
8357
8583
|
)
|
|
@@ -8368,8 +8594,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8368
8594
|
const f = async () => {
|
|
8369
8595
|
try {
|
|
8370
8596
|
d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
|
|
8371
|
-
} catch (
|
|
8372
|
-
u(
|
|
8597
|
+
} catch (h) {
|
|
8598
|
+
u(h);
|
|
8373
8599
|
} finally {
|
|
8374
8600
|
d(!1);
|
|
8375
8601
|
}
|
|
@@ -8377,8 +8603,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8377
8603
|
return /* @__PURE__ */ jsx(
|
|
8378
8604
|
Accordion,
|
|
8379
8605
|
{
|
|
8380
|
-
onValueChange: (
|
|
8381
|
-
g(
|
|
8606
|
+
onValueChange: (h) => {
|
|
8607
|
+
g(h !== "");
|
|
8382
8608
|
},
|
|
8383
8609
|
type: "single",
|
|
8384
8610
|
collapsible: !0,
|
|
@@ -8390,12 +8616,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8390
8616
|
{
|
|
8391
8617
|
ref: l,
|
|
8392
8618
|
value: r,
|
|
8393
|
-
onChange: (
|
|
8619
|
+
onChange: (h) => a(h.target.value),
|
|
8394
8620
|
placeholder: o("Tell about this page eg this page is about"),
|
|
8395
8621
|
className: "mt-1 w-full",
|
|
8396
8622
|
rows: 10,
|
|
8397
|
-
onKeyDown: (
|
|
8398
|
-
|
|
8623
|
+
onKeyDown: (h) => {
|
|
8624
|
+
h.key === "Enter" && (h.preventDefault(), f());
|
|
8399
8625
|
}
|
|
8400
8626
|
}
|
|
8401
8627
|
),
|
|
@@ -8559,7 +8785,7 @@ const AiAssistant = () => {
|
|
|
8559
8785
|
}, DataBinding = () => {
|
|
8560
8786
|
const o = usePageExternalData(), [n, r] = useAtom$1(dataBindingActiveAtom), { t: a } = useTranslation();
|
|
8561
8787
|
return isEmpty(o) ? null : /* @__PURE__ */ jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8562
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { className: "rounded-full", variant: "ghost", onClick: () => r(!n), children: /* @__PURE__ */ jsx(DatabaseZapIcon, { className: cn("h-4 w-4", n ? "text-green-500" : "text-gray-500") }) }) }),
|
|
8788
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { className: "rounded-full", variant: "ghost", onClick: () => r(!n), children: /* @__PURE__ */ jsx(DatabaseZapIcon, { className: cn$1("h-4 w-4", n ? "text-green-500" : "text-gray-500") }) }) }),
|
|
8563
8789
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: a("Toggle Data Binding") }) })
|
|
8564
8790
|
] }) });
|
|
8565
8791
|
}, CanvasTopBar = () => {
|
|
@@ -8590,11 +8816,11 @@ const AiAssistant = () => {
|
|
|
8590
8816
|
] })
|
|
8591
8817
|
] });
|
|
8592
8818
|
}, AttrsEditor = React__default.memo(function o({ preloadedAttributes: n = [], onAttributesChange: r }) {
|
|
8593
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, f] = useState(""),
|
|
8819
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, f] = useState(""), h = useRef(null), b = useRef(null);
|
|
8594
8820
|
useEffect(() => {
|
|
8595
8821
|
l(n);
|
|
8596
8822
|
}, [n]);
|
|
8597
|
-
const
|
|
8823
|
+
const x = () => {
|
|
8598
8824
|
if (i.startsWith("@")) {
|
|
8599
8825
|
f("Attribute keys cannot start with '@'");
|
|
8600
8826
|
return;
|
|
@@ -8604,11 +8830,11 @@ const AiAssistant = () => {
|
|
|
8604
8830
|
r(S), l(a), c(""), p(""), f("");
|
|
8605
8831
|
}
|
|
8606
8832
|
}, y = (S) => {
|
|
8607
|
-
const
|
|
8608
|
-
r(
|
|
8609
|
-
},
|
|
8833
|
+
const B = a.filter((_, w) => w !== S);
|
|
8834
|
+
r(B), l(B);
|
|
8835
|
+
}, A = (S) => {
|
|
8610
8836
|
g(S), c(a[S].key), p(a[S].value);
|
|
8611
|
-
},
|
|
8837
|
+
}, j = () => {
|
|
8612
8838
|
if (i.startsWith("@")) {
|
|
8613
8839
|
f("Attribute keys cannot start with '@'");
|
|
8614
8840
|
return;
|
|
@@ -8623,7 +8849,7 @@ const AiAssistant = () => {
|
|
|
8623
8849
|
"form",
|
|
8624
8850
|
{
|
|
8625
8851
|
onSubmit: (S) => {
|
|
8626
|
-
S.preventDefault(), u !== null ?
|
|
8852
|
+
S.preventDefault(), u !== null ? j() : x();
|
|
8627
8853
|
},
|
|
8628
8854
|
className: "space-y-3",
|
|
8629
8855
|
children: [
|
|
@@ -8637,7 +8863,7 @@ const AiAssistant = () => {
|
|
|
8637
8863
|
autoCorrect: "off",
|
|
8638
8864
|
spellCheck: "false",
|
|
8639
8865
|
id: "attrKey",
|
|
8640
|
-
ref:
|
|
8866
|
+
ref: h,
|
|
8641
8867
|
value: i,
|
|
8642
8868
|
onChange: (S) => c(S.target.value),
|
|
8643
8869
|
placeholder: "Enter Key",
|
|
@@ -8659,7 +8885,7 @@ const AiAssistant = () => {
|
|
|
8659
8885
|
value: d,
|
|
8660
8886
|
onChange: (S) => p(S.target.value),
|
|
8661
8887
|
onKeyDown: (S) => {
|
|
8662
|
-
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ?
|
|
8888
|
+
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? j() : x());
|
|
8663
8889
|
},
|
|
8664
8890
|
placeholder: "Enter Value",
|
|
8665
8891
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
@@ -8672,16 +8898,16 @@ const AiAssistant = () => {
|
|
|
8672
8898
|
]
|
|
8673
8899
|
}
|
|
8674
8900
|
),
|
|
8675
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S,
|
|
8901
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, B) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
|
|
8676
8902
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
8677
8903
|
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
|
|
8678
8904
|
/* @__PURE__ */ jsx("span", { className: "text-wrap max-w-[200px] font-normal", children: S.value.toString() })
|
|
8679
8905
|
] }),
|
|
8680
8906
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
8681
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B
|
|
8682
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => y(
|
|
8907
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(B), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
|
|
8908
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => y(B), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
|
|
8683
8909
|
] })
|
|
8684
|
-
] },
|
|
8910
|
+
] }, B)) })
|
|
8685
8911
|
] });
|
|
8686
8912
|
}), BlockAttributesEditor = React.memo(() => {
|
|
8687
8913
|
const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
|
|
@@ -8879,8 +9105,8 @@ const RootLayout = () => {
|
|
|
8879
9105
|
b.preventDefault();
|
|
8880
9106
|
}, u = (b) => {
|
|
8881
9107
|
n(o === b ? null : b);
|
|
8882
|
-
}, g = useSidebarMenuItems(), { t: m } = useTranslation(), f = [...g, ...c],
|
|
8883
|
-
return /* @__PURE__ */ jsx("div", { dir:
|
|
9108
|
+
}, g = useSidebarMenuItems(), { t: m } = useTranslation(), f = [...g, ...c], h = useBuilderProp("htmlDir", "ltr");
|
|
9109
|
+
return /* @__PURE__ */ jsx("div", { dir: h, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
|
|
8884
9110
|
/* @__PURE__ */ jsxs(
|
|
8885
9111
|
"div",
|
|
8886
9112
|
{
|
|
@@ -8890,21 +9116,21 @@ const RootLayout = () => {
|
|
|
8890
9116
|
/* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
|
|
8891
9117
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
8892
9118
|
/* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
8893
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: f.map((b,
|
|
9119
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: f.map((b, x) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8894
9120
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
8895
9121
|
Button,
|
|
8896
9122
|
{
|
|
8897
|
-
variant: o ===
|
|
9123
|
+
variant: o === x ? "default" : "ghost",
|
|
8898
9124
|
className: "mb-2 rounded-lg p-2 transition-colors",
|
|
8899
|
-
onClick: () => u(
|
|
9125
|
+
onClick: () => u(x),
|
|
8900
9126
|
children: get(b, "icon", null)
|
|
8901
9127
|
},
|
|
8902
|
-
|
|
9128
|
+
x
|
|
8903
9129
|
) }),
|
|
8904
9130
|
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(b.label) }) })
|
|
8905
|
-
] }, "button" +
|
|
9131
|
+
] }, "button" + x)) }),
|
|
8906
9132
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
8907
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((b,
|
|
9133
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((b, x) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(b, {}) }, `sidebar-component-${x}`)) })
|
|
8908
9134
|
] }),
|
|
8909
9135
|
/* @__PURE__ */ jsx(
|
|
8910
9136
|
motion.div,
|
|
@@ -8973,7 +9199,7 @@ const RootLayout = () => {
|
|
|
8973
9199
|
] }) });
|
|
8974
9200
|
}, PreviewScreen = () => {
|
|
8975
9201
|
const [o, n] = usePreviewMode(), { t: r } = useTranslation(), a = useBuilderProp("previewComponent", null);
|
|
8976
|
-
return o ? /* @__PURE__ */ jsxs("div", { className: cn("fixed inset-0 z-[999] bg-background", o ? "block" : "hidden"), children: [
|
|
9202
|
+
return o ? /* @__PURE__ */ jsxs("div", { className: cn$1("fixed inset-0 z-[999] bg-background", o ? "block" : "hidden"), children: [
|
|
8977
9203
|
/* @__PURE__ */ jsxs(Button, { size: "sm", className: "absolute right-0 top-0 m-4 space-x-2", onClick: () => n(!1), children: [
|
|
8978
9204
|
/* @__PURE__ */ jsx(EyeClosedIcon, {}),
|
|
8979
9205
|
/* @__PURE__ */ jsx("span", { children: r("Close Preview") })
|
|
@@ -9069,9 +9295,9 @@ export {
|
|
|
9069
9295
|
generateUUID as generateBlockId,
|
|
9070
9296
|
getBlocksFromHTML,
|
|
9071
9297
|
getClassValueAndUnit,
|
|
9072
|
-
|
|
9073
|
-
cn as mergeClasses,
|
|
9074
|
-
|
|
9298
|
+
We as i18n,
|
|
9299
|
+
cn$1 as mergeClasses,
|
|
9300
|
+
Fe as registerChaiBlock,
|
|
9075
9301
|
useAddBlock,
|
|
9076
9302
|
useAddClassesToBlocks,
|
|
9077
9303
|
useAskAi,
|
|
@@ -9114,7 +9340,7 @@ export {
|
|
|
9114
9340
|
useStylingState,
|
|
9115
9341
|
useTheme,
|
|
9116
9342
|
useThemeOptions,
|
|
9117
|
-
|
|
9343
|
+
Ve as useTranslation,
|
|
9118
9344
|
useUILibraryBlocks,
|
|
9119
9345
|
useUndoManager,
|
|
9120
9346
|
useUpdateBlocksProps,
|