@chaibuilder/sdk 2.0.0-beta.105 → 2.0.0-beta.106
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 +1084 -826
- 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,48 +1,52 @@
|
|
|
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, X, Plus,
|
|
26
|
-
import
|
|
25
|
+
import { PlusIcon as PlusIcon$1, Bold, Italic, Strikethrough, PanelRightClose, PanelRightOpen, AppWindowIcon, AlignHorizontalJustifyStart, UnfoldHorizontal, DatabaseIcon, Columns, Rows, GlobeIcon, ChevronRight, ChevronLeft, Underline as Underline$1, 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 { BubbleMenu, EditorContent, useEditor } from "@tiptap/react";
|
|
27
|
+
import StarterKit from "@tiptap/starter-kit";
|
|
28
|
+
import clsx$1, { clsx } from "clsx";
|
|
29
|
+
import { twMerge } from "tailwind-merge";
|
|
27
30
|
import typography from "@tailwindcss/typography";
|
|
28
31
|
import forms from "@tailwindcss/forms";
|
|
29
32
|
import aspectRatio from "@tailwindcss/aspect-ratio";
|
|
30
33
|
import containerQueries from "@tailwindcss/container-queries";
|
|
31
|
-
import { twMerge } from "tailwind-merge";
|
|
32
34
|
import { S as STYLES_KEY, g as getSplitChaiClasses, R as ROOT_TEMP_KEY } from "./getSplitClasses-DphwgQiE.js";
|
|
33
35
|
import ReactDOM from "react-dom";
|
|
34
36
|
import { ErrorBoundary } from "react-error-boundary";
|
|
35
37
|
import { Resizable } from "re-resizable";
|
|
36
38
|
import RjForm from "@rjsf/core";
|
|
37
39
|
import validator from "@rjsf/validator-ajv8";
|
|
40
|
+
import Link from "@tiptap/extension-link";
|
|
41
|
+
import TextAlign from "@tiptap/extension-text-align";
|
|
42
|
+
import Underline from "@tiptap/extension-underline";
|
|
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,31 +3527,63 @@ 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 = []);
|
|
3549
3552
|
}
|
|
3550
3553
|
};
|
|
3551
3554
|
};
|
|
3555
|
+
function cn(...o) {
|
|
3556
|
+
return twMerge(clsx(o));
|
|
3557
|
+
}
|
|
3558
|
+
const TiptapBubbleMenu = ({ editor: o }) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3559
|
+
/* @__PURE__ */ jsx(BubbleMenu, { editor: o, tippyOptions: { duration: 100 }, children: /* @__PURE__ */ jsxs("div", { className: "bubble-menu space-x-2", children: [
|
|
3560
|
+
/* @__PURE__ */ jsx(
|
|
3561
|
+
"button",
|
|
3562
|
+
{
|
|
3563
|
+
onClick: () => o.chain().focus().toggleBold().run(),
|
|
3564
|
+
className: cn(o.isActive("bold") ? "bg-gray-100" : "", "h-3 w-3"),
|
|
3565
|
+
children: /* @__PURE__ */ jsx(Bold, {})
|
|
3566
|
+
}
|
|
3567
|
+
),
|
|
3568
|
+
/* @__PURE__ */ jsx(
|
|
3569
|
+
"button",
|
|
3570
|
+
{
|
|
3571
|
+
onClick: () => o.chain().focus().toggleItalic().run(),
|
|
3572
|
+
className: cn(o.isActive("italic") ? "bg-gray-100" : "", "h-3 w-3"),
|
|
3573
|
+
children: /* @__PURE__ */ jsx(Italic, {})
|
|
3574
|
+
}
|
|
3575
|
+
),
|
|
3576
|
+
/* @__PURE__ */ jsx(
|
|
3577
|
+
"button",
|
|
3578
|
+
{
|
|
3579
|
+
onClick: () => o.chain().focus().toggleStrike().run(),
|
|
3580
|
+
className: cn(o.isActive("strike") ? "bg-gray-100" : "", "h-3 w-3"),
|
|
3581
|
+
children: /* @__PURE__ */ jsx(Strikethrough, {})
|
|
3582
|
+
}
|
|
3583
|
+
)
|
|
3584
|
+
] }) }),
|
|
3585
|
+
/* @__PURE__ */ jsx(EditorContent, { editor: o })
|
|
3586
|
+
] });
|
|
3552
3587
|
function getTargetedBlock(o) {
|
|
3553
3588
|
if (o.getAttribute("data-block-id") === "canvas")
|
|
3554
3589
|
return null;
|
|
@@ -3557,36 +3592,29 @@ function getTargetedBlock(o) {
|
|
|
3557
3592
|
const n = o.closest("[data-block-id]");
|
|
3558
3593
|
return (n == null ? void 0 : n.getAttribute("data-block-id")) === "canvas" ? null : n;
|
|
3559
3594
|
}
|
|
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);
|
|
3595
|
+
const useHandleCanvasDblClick = (o, n) => {
|
|
3596
|
+
const r = [], a = useUpdateBlocksProps(), [l, i] = useAtom$1(inlineEditingActiveAtom), { clearHighlight: c } = useBlockHighlight(), d = useGetBlockAtomValue(pageBlocksAtomsAtom);
|
|
3567
3597
|
return useCallback(
|
|
3568
|
-
(
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
3572
|
-
|
|
3598
|
+
(p) => {
|
|
3599
|
+
if (l) return;
|
|
3600
|
+
const u = getTargetedBlock(p.target);
|
|
3601
|
+
if (!u) return;
|
|
3602
|
+
const g = u.getAttribute("data-block-type");
|
|
3603
|
+
if (!g || !r.includes(g))
|
|
3573
3604
|
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"));
|
|
3605
|
+
const m = u.getAttribute("data-block-id");
|
|
3606
|
+
if (!m) return;
|
|
3607
|
+
o.on("update", ({ editor: h }) => {
|
|
3608
|
+
console.log(h.getHTML());
|
|
3609
|
+
}), o.on("blur", () => {
|
|
3610
|
+
console.log("blur");
|
|
3611
|
+
const h = o.getHTML();
|
|
3612
|
+
a([m], { content: h }), n.style.display = "none", u.style.visibility = "visible";
|
|
3613
|
+
}), i(m);
|
|
3614
|
+
const f = d(m).content;
|
|
3615
|
+
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
3616
|
},
|
|
3589
|
-
[
|
|
3617
|
+
[l, c, d, i, a, o, n]
|
|
3590
3618
|
);
|
|
3591
3619
|
}, useHandleCanvasClick = () => {
|
|
3592
3620
|
const [, o] = useSelectedStylingBlocks(), [n, r] = useSelectedBlockIds(), [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(treeRefAtom), { clearHighlight: i } = useBlockHighlight();
|
|
@@ -3623,29 +3651,34 @@ const useHandleCanvasDblClick = () => {
|
|
|
3623
3651
|
setTimeout(() => {
|
|
3624
3652
|
if (!isEmpty(a))
|
|
3625
3653
|
return;
|
|
3626
|
-
const
|
|
3627
|
-
if (
|
|
3628
|
-
const
|
|
3629
|
-
if (
|
|
3630
|
-
const x =
|
|
3631
|
-
l([{ id: x, prop:
|
|
3654
|
+
const h = getElementByDataBlockId(n, first(r));
|
|
3655
|
+
if (h) {
|
|
3656
|
+
const b = h.getAttribute("data-style-prop");
|
|
3657
|
+
if (b) {
|
|
3658
|
+
const x = h.getAttribute("data-style-id"), y = h.getAttribute("data-block-parent");
|
|
3659
|
+
l([{ id: x, prop: b, blockId: y }]);
|
|
3632
3660
|
}
|
|
3633
3661
|
}
|
|
3634
3662
|
}, 100);
|
|
3635
3663
|
}, [n, r, l, a]);
|
|
3636
|
-
const c =
|
|
3637
|
-
|
|
3664
|
+
const c = useEditor({
|
|
3665
|
+
extensions: [StarterKit]
|
|
3666
|
+
}), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(), f = useDnd();
|
|
3667
|
+
return /* @__PURE__ */ jsxs(
|
|
3638
3668
|
"div",
|
|
3639
3669
|
{
|
|
3640
3670
|
"data-block-id": "canvas",
|
|
3641
3671
|
id: "canvas",
|
|
3642
|
-
onClick:
|
|
3643
|
-
onDoubleClick:
|
|
3644
|
-
onMouseMove:
|
|
3645
|
-
onMouseLeave:
|
|
3646
|
-
...omit(
|
|
3647
|
-
className: "relative h-full max-w-full p-px " + (
|
|
3648
|
-
children:
|
|
3672
|
+
onClick: u,
|
|
3673
|
+
onDoubleClick: p,
|
|
3674
|
+
onMouseMove: g,
|
|
3675
|
+
onMouseLeave: m,
|
|
3676
|
+
...omit(f, "isDragging"),
|
|
3677
|
+
className: "relative h-full max-w-full p-px " + (f.isDragging ? "dragging" : ""),
|
|
3678
|
+
children: [
|
|
3679
|
+
o,
|
|
3680
|
+
/* @__PURE__ */ jsx("div", { ref: d, style: { display: "none" }, children: /* @__PURE__ */ jsx(TiptapBubbleMenu, { editor: c }) })
|
|
3681
|
+
]
|
|
3649
3682
|
}
|
|
3650
3683
|
);
|
|
3651
3684
|
}, getElementByDataBlockId = (o, n) => o.querySelector(`[data-block-id="${n}"]`), HeadTags = () => {
|
|
@@ -3678,8 +3711,8 @@ const useHandleCanvasDblClick = () => {
|
|
|
3678
3711
|
forms,
|
|
3679
3712
|
aspectRatio,
|
|
3680
3713
|
containerQueries,
|
|
3681
|
-
plugin(function({ addBase:
|
|
3682
|
-
|
|
3714
|
+
plugin(function({ addBase: x, theme: y }) {
|
|
3715
|
+
x({
|
|
3683
3716
|
"h1,h2,h3,h4,h5,h6": {
|
|
3684
3717
|
fontFamily: y("fontFamily.heading")
|
|
3685
3718
|
},
|
|
@@ -3693,7 +3726,7 @@ const useHandleCanvasDblClick = () => {
|
|
|
3693
3726
|
]
|
|
3694
3727
|
});
|
|
3695
3728
|
}, [o, n, p]), useEffect(() => {
|
|
3696
|
-
g && (g.textContent = `${map(r, (
|
|
3729
|
+
g && (g.textContent = `${map(r, (x) => `[data-block-id="${x}"]`).join(",")}{
|
|
3697
3730
|
outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
|
|
3698
3731
|
}`);
|
|
3699
3732
|
}, [r, g]), useEffect(() => {
|
|
@@ -3701,18 +3734,18 @@ const useHandleCanvasDblClick = () => {
|
|
|
3701
3734
|
}, [i, f]), useEffect(() => {
|
|
3702
3735
|
u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
|
|
3703
3736
|
}, [u]), useEffect(() => {
|
|
3704
|
-
m && (m.textContent = `${map(l, ({ id:
|
|
3737
|
+
m && (m.textContent = `${map(l, ({ id: x }) => `[data-style-id="${x}"]`).join(",")}{
|
|
3705
3738
|
outline: 1px solid orange !important; outline-offset: -1px;
|
|
3706
3739
|
}`);
|
|
3707
3740
|
}, [l, m]), useEffect(() => {
|
|
3708
3741
|
d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
|
|
3709
3742
|
}, [c, d]);
|
|
3710
|
-
const
|
|
3743
|
+
const h = useMemo(
|
|
3711
3744
|
() => getChaiThemeCssVariables(o),
|
|
3712
3745
|
[o]
|
|
3713
3746
|
), b = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
|
|
3714
3747
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3715
|
-
/* @__PURE__ */ jsx("style", { id: "chai-theme", children:
|
|
3748
|
+
/* @__PURE__ */ jsx("style", { id: "chai-theme", children: h }),
|
|
3716
3749
|
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: b } })
|
|
3717
3750
|
] });
|
|
3718
3751
|
}, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
|
|
@@ -3790,10 +3823,10 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3790
3823
|
[o]
|
|
3791
3824
|
);
|
|
3792
3825
|
}, 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
|
-
),
|
|
3826
|
+
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(
|
|
3827
|
+
() => u ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
|
|
3828
|
+
[r, l, a, d, u]
|
|
3829
|
+
), 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
3830
|
() => ({
|
|
3798
3831
|
blockProps: {
|
|
3799
3832
|
"data-block-id": r._id,
|
|
@@ -3801,14 +3834,14 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3801
3834
|
},
|
|
3802
3835
|
inBuilder: !0,
|
|
3803
3836
|
lang: l || i,
|
|
3837
|
+
...m,
|
|
3804
3838
|
...f,
|
|
3805
|
-
...
|
|
3806
|
-
...b
|
|
3807
|
-
...h
|
|
3839
|
+
...h,
|
|
3840
|
+
...b
|
|
3808
3841
|
}),
|
|
3809
|
-
[r, l, i, f,
|
|
3842
|
+
[r, l, i, m, f, h, b]
|
|
3810
3843
|
);
|
|
3811
|
-
return isNull(
|
|
3844
|
+
return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...x, children: n }) });
|
|
3812
3845
|
}, GlobalBlocksRenderer = ({ globalBlockId: o }) => {
|
|
3813
3846
|
const { getGlobalBlocks: n } = useGlobalBlocksStore(), r = useMemo(() => n(o), [n, o]), a = useMemo(() => splitAtom(atom$1(r)), [r]);
|
|
3814
3847
|
return isEmpty(r) ? null : /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: r });
|
|
@@ -3858,43 +3891,43 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3858
3891
|
c();
|
|
3859
3892
|
}, [n, o, r, c]), l;
|
|
3860
3893
|
}, 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:
|
|
3894
|
+
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) => {
|
|
3895
|
+
p((_) => ({ ..._, width: B }));
|
|
3863
3896
|
};
|
|
3864
3897
|
useEffect(() => {
|
|
3865
3898
|
if (!c.current) return;
|
|
3866
|
-
const { clientWidth:
|
|
3867
|
-
p({ width:
|
|
3899
|
+
const { clientWidth: B, clientHeight: _ } = c.current;
|
|
3900
|
+
p({ width: B, height: _ });
|
|
3868
3901
|
}, [c, n]);
|
|
3869
|
-
const
|
|
3870
|
-
const { top:
|
|
3871
|
-
return
|
|
3902
|
+
const C = (B, _ = 0) => {
|
|
3903
|
+
const { top: w } = B.getBoundingClientRect();
|
|
3904
|
+
return w + _ >= 0 && w - _ <= window.innerHeight;
|
|
3872
3905
|
};
|
|
3873
3906
|
useEffect(() => {
|
|
3874
|
-
var
|
|
3907
|
+
var B, _;
|
|
3875
3908
|
if (a && a.type !== "Multiple" && i.current) {
|
|
3876
|
-
const
|
|
3877
|
-
|
|
3909
|
+
const w = getElementByDataBlockId(i.current.contentDocument, a._id);
|
|
3910
|
+
w && (C(w) || (_ = (B = i.current) == null ? void 0 : B.contentWindow) == null || _.scrollTo({ top: w.offsetTop, behavior: "smooth" }), m([w]));
|
|
3878
3911
|
}
|
|
3879
3912
|
}, [a]), useEffect(() => {
|
|
3880
3913
|
if (!isEmpty(b) && i.current) {
|
|
3881
|
-
const
|
|
3914
|
+
const B = getElementByStyleId(
|
|
3882
3915
|
i.current.contentDocument,
|
|
3883
3916
|
first(b).id
|
|
3884
3917
|
);
|
|
3885
|
-
f(
|
|
3918
|
+
f(B ? [B] : [null]);
|
|
3886
3919
|
} else
|
|
3887
3920
|
f([null]);
|
|
3888
3921
|
}, [b]);
|
|
3889
3922
|
const S = useMemo(() => {
|
|
3890
|
-
let
|
|
3891
|
-
return
|
|
3892
|
-
}, [o,
|
|
3893
|
-
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount:
|
|
3923
|
+
let B = IframeInitialContent;
|
|
3924
|
+
return B = B.replace("__HTML_DIR__", A), o === "offline" && (B = B.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), B;
|
|
3925
|
+
}, [o, A]);
|
|
3926
|
+
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: j, onResize: j, children: /* @__PURE__ */ jsx(
|
|
3894
3927
|
"div",
|
|
3895
3928
|
{
|
|
3896
3929
|
onClick: () => {
|
|
3897
|
-
r([]),
|
|
3930
|
+
r([]), x([]);
|
|
3898
3931
|
},
|
|
3899
3932
|
onMouseLeave: () => setTimeout(() => l(""), 300),
|
|
3900
3933
|
className: "relative mx-auto h-full w-full overflow-hidden",
|
|
@@ -3902,7 +3935,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3902
3935
|
children: /* @__PURE__ */ jsxs(
|
|
3903
3936
|
ChaiFrame,
|
|
3904
3937
|
{
|
|
3905
|
-
contentDidMount: () =>
|
|
3938
|
+
contentDidMount: () => h(i.current),
|
|
3906
3939
|
ref: i,
|
|
3907
3940
|
id: "canvas-iframe",
|
|
3908
3941
|
style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
|
|
@@ -4161,25 +4194,25 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4161
4194
|
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
4195
|
a(y);
|
|
4163
4196
|
}, m = () => {
|
|
4164
|
-
const y = l.find((
|
|
4197
|
+
const y = l.find((A) => Object.keys(A)[0] === r);
|
|
4165
4198
|
if (y) {
|
|
4166
|
-
const
|
|
4167
|
-
|
|
4199
|
+
const A = Object.values(y)[0];
|
|
4200
|
+
A && typeof A == "object" && "fontFamily" in A && "borderRadius" in A && "colors" in A ? d(A) : console.error("Invalid preset structure:", A);
|
|
4168
4201
|
} else
|
|
4169
4202
|
console.error("Preset not found:", r);
|
|
4170
4203
|
}, f = useDebouncedCallback(
|
|
4171
|
-
(y,
|
|
4204
|
+
(y, A) => {
|
|
4172
4205
|
d(() => ({
|
|
4173
4206
|
...c,
|
|
4174
4207
|
fontFamily: {
|
|
4175
4208
|
...c.fontFamily,
|
|
4176
|
-
[y.replace(/font-/g, "")]:
|
|
4209
|
+
[y.replace(/font-/g, "")]: A
|
|
4177
4210
|
}
|
|
4178
4211
|
}));
|
|
4179
4212
|
},
|
|
4180
4213
|
[c],
|
|
4181
4214
|
200
|
|
4182
|
-
),
|
|
4215
|
+
), h = useDebouncedCallback(
|
|
4183
4216
|
(y) => {
|
|
4184
4217
|
d(() => ({
|
|
4185
4218
|
...c,
|
|
@@ -4189,35 +4222,35 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4189
4222
|
[c],
|
|
4190
4223
|
200
|
|
4191
4224
|
), b = useDebouncedCallback(
|
|
4192
|
-
(y,
|
|
4225
|
+
(y, A) => {
|
|
4193
4226
|
d(() => {
|
|
4194
|
-
const
|
|
4195
|
-
return n ? set(
|
|
4227
|
+
const j = get(c, `colors.${y}`);
|
|
4228
|
+
return n ? set(j, 1, A) : set(j, 0, A), {
|
|
4196
4229
|
...c,
|
|
4197
4230
|
colors: {
|
|
4198
4231
|
...c.colors,
|
|
4199
|
-
[y]:
|
|
4232
|
+
[y]: j
|
|
4200
4233
|
}
|
|
4201
4234
|
};
|
|
4202
4235
|
});
|
|
4203
4236
|
},
|
|
4204
4237
|
[c],
|
|
4205
4238
|
200
|
|
4206
|
-
),
|
|
4207
|
-
const
|
|
4239
|
+
), x = (y) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(y.items).map(([A]) => {
|
|
4240
|
+
const j = get(c, `colors.${A}.${n ? 1 : 0}`);
|
|
4208
4241
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
4209
4242
|
/* @__PURE__ */ jsx(
|
|
4210
4243
|
ColorPickerInput,
|
|
4211
4244
|
{
|
|
4212
|
-
value:
|
|
4213
|
-
onChange: (
|
|
4245
|
+
value: j,
|
|
4246
|
+
onChange: (C) => b(A, C)
|
|
4214
4247
|
}
|
|
4215
4248
|
),
|
|
4216
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children:
|
|
4217
|
-
] },
|
|
4249
|
+
/* @__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" : "") })
|
|
4250
|
+
] }, A);
|
|
4218
4251
|
}) });
|
|
4219
4252
|
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: [
|
|
4253
|
+
/* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
4221
4254
|
l.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 py-2", children: [
|
|
4222
4255
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
4223
4256
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Presets") }),
|
|
@@ -4245,26 +4278,26 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4245
4278
|
}
|
|
4246
4279
|
) })
|
|
4247
4280
|
] }),
|
|
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,
|
|
4281
|
+
/* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
|
|
4282
|
+
(p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([y, A]) => /* @__PURE__ */ jsx(
|
|
4250
4283
|
FontSelector,
|
|
4251
4284
|
{
|
|
4252
4285
|
label: y,
|
|
4253
|
-
value: c.fontFamily[y.replace(/font-/g, "")] ||
|
|
4254
|
-
onChange: (
|
|
4286
|
+
value: c.fontFamily[y.replace(/font-/g, "")] || A[Object.keys(A)[0]],
|
|
4287
|
+
onChange: (j) => f(y, j)
|
|
4255
4288
|
},
|
|
4256
4289
|
y
|
|
4257
4290
|
)) }),
|
|
4258
4291
|
(p == null ? void 0 : p.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
|
|
4259
4292
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Border Radius") }),
|
|
4260
4293
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
|
|
4261
|
-
/* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange:
|
|
4294
|
+
/* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange: h }),
|
|
4262
4295
|
/* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: c.borderRadius })
|
|
4263
4296
|
] })
|
|
4264
4297
|
] }),
|
|
4265
4298
|
(p == null ? void 0 : p.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
|
|
4266
4299
|
/* @__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) =>
|
|
4300
|
+
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((y) => x(y)) }, n ? "dark" : "light")
|
|
4268
4301
|
] })
|
|
4269
4302
|
] }),
|
|
4270
4303
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -4430,55 +4463,380 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4430
4463
|
)
|
|
4431
4464
|
] })
|
|
4432
4465
|
] });
|
|
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;
|
|
4466
|
+
};
|
|
4467
|
+
function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
4468
|
+
const [a, l] = React.useState(!1), [i, c] = React.useState([]), [d, p] = React.useState(o);
|
|
4469
|
+
useEffect(() => {
|
|
4470
|
+
a || c([]), p(o);
|
|
4471
|
+
}, [a, o]);
|
|
4472
|
+
const u = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", g = React.useCallback(
|
|
4473
|
+
(h) => {
|
|
4474
|
+
const b = (x) => r === "value" ? x === "value" || x === "object" : r === "array" ? x === "array" : x === r;
|
|
4475
|
+
h.type === "object" ? (c((x) => [...x, h.key]), p(h.value)) : b(h.type) && (n([...i, h.key].join(".")), l(!1));
|
|
4476
|
+
},
|
|
4477
|
+
[i, n, r]
|
|
4478
|
+
), m = React.useCallback(() => {
|
|
4479
|
+
if (i.length > 0) {
|
|
4480
|
+
const h = i.slice(0, -1);
|
|
4481
|
+
c(h), p(h.reduce((b, x) => b[x], o));
|
|
4460
4482
|
}
|
|
4461
|
-
}, []),
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
4472
|
-
|
|
4483
|
+
}, [i, o]), f = React.useMemo(() => Object.entries(d).map(([h, b]) => ({
|
|
4484
|
+
key: h,
|
|
4485
|
+
value: b,
|
|
4486
|
+
type: u(b)
|
|
4487
|
+
})).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]);
|
|
4488
|
+
return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
|
|
4489
|
+
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4490
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
4491
|
+
Button,
|
|
4492
|
+
{
|
|
4493
|
+
size: "sm",
|
|
4494
|
+
variant: "outline",
|
|
4495
|
+
className: "h-5 px-1 py-0 text-[9px] text-muted-foreground",
|
|
4496
|
+
role: "combobox",
|
|
4497
|
+
"aria-expanded": a,
|
|
4498
|
+
children: /* @__PURE__ */ jsx(DatabaseIcon, { className: "h-3 w-3" })
|
|
4499
|
+
}
|
|
4500
|
+
) }) }),
|
|
4501
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: "Add field" })
|
|
4502
|
+
] }),
|
|
4503
|
+
/* @__PURE__ */ jsx(PopoverContent, { className: "z-[1000]! relative mr-3 w-[300px] p-0", children: /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
|
|
4504
|
+
/* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
|
|
4505
|
+
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
4506
|
+
/* @__PURE__ */ jsx(CommandEmpty, { children: "No option found." }),
|
|
4507
|
+
/* @__PURE__ */ jsxs(CommandGroup, { children: [
|
|
4508
|
+
i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: m, className: "flex items-center text-sm", children: [
|
|
4509
|
+
/* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
|
|
4510
|
+
"Back"
|
|
4511
|
+
] }),
|
|
4512
|
+
f.map((h) => /* @__PURE__ */ jsxs(
|
|
4513
|
+
CommandItem,
|
|
4514
|
+
{
|
|
4515
|
+
value: h.key,
|
|
4516
|
+
disabled: !1,
|
|
4517
|
+
onSelect: () => g(h),
|
|
4518
|
+
className: "flex items-center justify-between",
|
|
4519
|
+
children: [
|
|
4520
|
+
/* @__PURE__ */ jsx("span", { children: h.key }),
|
|
4521
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4522
|
+
r === "object" && h.type === "object" && /* @__PURE__ */ jsx(
|
|
4523
|
+
Button,
|
|
4524
|
+
{
|
|
4525
|
+
size: "sm",
|
|
4526
|
+
variant: "ghost",
|
|
4527
|
+
className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
|
|
4528
|
+
onClick: (b) => {
|
|
4529
|
+
b.stopPropagation(), n([...i, h.key].join(".")), l(!1);
|
|
4530
|
+
},
|
|
4531
|
+
children: "Select"
|
|
4532
|
+
}
|
|
4533
|
+
),
|
|
4534
|
+
(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" }) })
|
|
4535
|
+
] })
|
|
4536
|
+
]
|
|
4537
|
+
},
|
|
4538
|
+
h.key
|
|
4539
|
+
))
|
|
4540
|
+
] })
|
|
4541
|
+
] })
|
|
4542
|
+
] }) })
|
|
4543
|
+
] });
|
|
4544
|
+
}
|
|
4545
|
+
const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
4546
|
+
if (!o)
|
|
4547
|
+
return null;
|
|
4548
|
+
const r = () => {
|
|
4549
|
+
const l = window.prompt("URL");
|
|
4550
|
+
l && o.chain().focus().extendMarkRange("link").setLink({ href: l }).run();
|
|
4551
|
+
}, a = () => {
|
|
4552
|
+
o.chain().focus().unsetLink().run();
|
|
4553
|
+
};
|
|
4554
|
+
return /* @__PURE__ */ jsxs("div", { className: "mb-1 flex flex-wrap gap-1 rounded-md border border-border p-1", children: [
|
|
4555
|
+
/* @__PURE__ */ jsx(
|
|
4556
|
+
"button",
|
|
4557
|
+
{
|
|
4558
|
+
type: "button",
|
|
4559
|
+
onClick: () => o.chain().focus().toggleBold().run(),
|
|
4560
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("bold") }),
|
|
4561
|
+
title: "Bold",
|
|
4562
|
+
children: /* @__PURE__ */ jsx(Bold, { className: "h-4 w-4" })
|
|
4563
|
+
}
|
|
4564
|
+
),
|
|
4565
|
+
/* @__PURE__ */ jsx(
|
|
4566
|
+
"button",
|
|
4567
|
+
{
|
|
4568
|
+
type: "button",
|
|
4569
|
+
onClick: () => o.chain().focus().toggleItalic().run(),
|
|
4570
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("italic") }),
|
|
4571
|
+
title: "Italic",
|
|
4572
|
+
children: /* @__PURE__ */ jsx(Italic, { className: "h-4 w-4" })
|
|
4573
|
+
}
|
|
4574
|
+
),
|
|
4575
|
+
/* @__PURE__ */ jsx(
|
|
4576
|
+
"button",
|
|
4577
|
+
{
|
|
4578
|
+
type: "button",
|
|
4579
|
+
onClick: () => o.chain().focus().toggleUnderline().run(),
|
|
4580
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("underline") }),
|
|
4581
|
+
title: "Underline",
|
|
4582
|
+
children: /* @__PURE__ */ jsx(Underline$1, { className: "h-4 w-4" })
|
|
4583
|
+
}
|
|
4584
|
+
),
|
|
4585
|
+
/* @__PURE__ */ jsx(
|
|
4586
|
+
"button",
|
|
4587
|
+
{
|
|
4588
|
+
type: "button",
|
|
4589
|
+
onClick: () => o.chain().focus().toggleStrike().run(),
|
|
4590
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("strike") }),
|
|
4591
|
+
title: "Strike",
|
|
4592
|
+
children: /* @__PURE__ */ jsx(Strikethrough, { className: "h-4 w-4" })
|
|
4593
|
+
}
|
|
4594
|
+
),
|
|
4595
|
+
/* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px self-center bg-border" }),
|
|
4596
|
+
/* @__PURE__ */ jsx(
|
|
4597
|
+
"button",
|
|
4598
|
+
{
|
|
4599
|
+
type: "button",
|
|
4600
|
+
onClick: () => o.chain().focus().toggleBulletList().run(),
|
|
4601
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("bulletList") }),
|
|
4602
|
+
title: "Bullet List",
|
|
4603
|
+
children: /* @__PURE__ */ jsx(List, { className: "h-4 w-4" })
|
|
4604
|
+
}
|
|
4605
|
+
),
|
|
4606
|
+
/* @__PURE__ */ jsx(
|
|
4607
|
+
"button",
|
|
4608
|
+
{
|
|
4609
|
+
type: "button",
|
|
4610
|
+
onClick: () => o.chain().focus().toggleOrderedList().run(),
|
|
4611
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("orderedList") }),
|
|
4612
|
+
title: "Ordered List",
|
|
4613
|
+
children: /* @__PURE__ */ jsx(ListOrdered, { className: "h-4 w-4" })
|
|
4614
|
+
}
|
|
4615
|
+
),
|
|
4616
|
+
/* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px self-center bg-border" }),
|
|
4617
|
+
/* @__PURE__ */ jsx(
|
|
4618
|
+
"button",
|
|
4619
|
+
{
|
|
4620
|
+
type: "button",
|
|
4621
|
+
onClick: () => o.chain().focus().setTextAlign("left").run(),
|
|
4622
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive({ textAlign: "left" }) }),
|
|
4623
|
+
title: "Align Left",
|
|
4624
|
+
children: /* @__PURE__ */ jsx(AlignLeft, { className: "h-4 w-4" })
|
|
4625
|
+
}
|
|
4626
|
+
),
|
|
4627
|
+
/* @__PURE__ */ jsx(
|
|
4628
|
+
"button",
|
|
4629
|
+
{
|
|
4630
|
+
type: "button",
|
|
4631
|
+
onClick: () => o.chain().focus().setTextAlign("center").run(),
|
|
4632
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive({ textAlign: "center" }) }),
|
|
4633
|
+
title: "Align Center",
|
|
4634
|
+
children: /* @__PURE__ */ jsx(AlignCenter, { className: "h-4 w-4" })
|
|
4635
|
+
}
|
|
4636
|
+
),
|
|
4637
|
+
/* @__PURE__ */ jsx(
|
|
4638
|
+
"button",
|
|
4639
|
+
{
|
|
4640
|
+
type: "button",
|
|
4641
|
+
onClick: () => o.chain().focus().setTextAlign("right").run(),
|
|
4642
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive({ textAlign: "right" }) }),
|
|
4643
|
+
title: "Align Right",
|
|
4644
|
+
children: /* @__PURE__ */ jsx(AlignRight, { className: "h-4 w-4" })
|
|
4645
|
+
}
|
|
4646
|
+
),
|
|
4647
|
+
/* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px self-center bg-border" }),
|
|
4648
|
+
/* @__PURE__ */ jsx(
|
|
4649
|
+
"button",
|
|
4650
|
+
{
|
|
4651
|
+
type: "button",
|
|
4652
|
+
onClick: r,
|
|
4653
|
+
className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("link") }),
|
|
4654
|
+
title: "Add Link",
|
|
4655
|
+
children: /* @__PURE__ */ jsx(Link$1, { className: "h-4 w-4" })
|
|
4656
|
+
}
|
|
4657
|
+
),
|
|
4658
|
+
/* @__PURE__ */ jsx(
|
|
4659
|
+
"button",
|
|
4660
|
+
{
|
|
4661
|
+
type: "button",
|
|
4662
|
+
onClick: a,
|
|
4663
|
+
className: cn("rounded p-1 hover:bg-muted"),
|
|
4664
|
+
title: "Remove Link",
|
|
4665
|
+
disabled: !o.isActive("link"),
|
|
4666
|
+
children: /* @__PURE__ */ jsx(Unlink, { className: "h-4 w-4" })
|
|
4667
|
+
}
|
|
4668
|
+
),
|
|
4669
|
+
n && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4670
|
+
/* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px self-center bg-border" }),
|
|
4671
|
+
/* @__PURE__ */ jsx(
|
|
4672
|
+
"button",
|
|
4673
|
+
{
|
|
4674
|
+
type: "button",
|
|
4675
|
+
onClick: n,
|
|
4676
|
+
className: "rounded p-1 hover:bg-muted",
|
|
4677
|
+
title: "Open in full screen mode",
|
|
4678
|
+
children: /* @__PURE__ */ jsx(Maximize2, { className: "h-4 w-4" })
|
|
4679
|
+
}
|
|
4680
|
+
)
|
|
4681
|
+
] })
|
|
4682
|
+
] });
|
|
4683
|
+
}, RTEModal = ({
|
|
4684
|
+
isOpen: o,
|
|
4685
|
+
onClose: n,
|
|
4686
|
+
id: r,
|
|
4687
|
+
value: a,
|
|
4688
|
+
onChange: l,
|
|
4689
|
+
onBlur: i
|
|
4690
|
+
}) => {
|
|
4691
|
+
const c = useRef(null), d = useRef(a || ""), p = usePageExternalData();
|
|
4692
|
+
useEffect(() => {
|
|
4693
|
+
if (o) {
|
|
4694
|
+
const m = document.createElement("style");
|
|
4695
|
+
return m.id = "rte-modal-styles", m.innerHTML = `
|
|
4696
|
+
/* Ensure the NestedPathSelector popover appears above the dialog */
|
|
4697
|
+
.rte-path-selector + [data-radix-popper-content-wrapper],
|
|
4698
|
+
[data-radix-popper-content-wrapper] {
|
|
4699
|
+
z-index: 9999 !important;
|
|
4700
|
+
}
|
|
4701
|
+
`, document.head.appendChild(m), () => {
|
|
4702
|
+
const f = document.getElementById("rte-modal-styles");
|
|
4703
|
+
f && f.remove();
|
|
4704
|
+
};
|
|
4705
|
+
}
|
|
4706
|
+
}, [o]);
|
|
4707
|
+
const u = useEditor({
|
|
4708
|
+
extensions: [
|
|
4709
|
+
StarterKit,
|
|
4710
|
+
Link.configure({
|
|
4711
|
+
openOnClick: !1,
|
|
4712
|
+
HTMLAttributes: {
|
|
4713
|
+
class: "text-primary underline"
|
|
4714
|
+
}
|
|
4715
|
+
}),
|
|
4716
|
+
TextAlign.configure({
|
|
4717
|
+
types: ["heading", "paragraph"],
|
|
4718
|
+
alignments: ["left", "center", "right"],
|
|
4719
|
+
defaultAlignment: "left"
|
|
4720
|
+
}),
|
|
4721
|
+
Underline
|
|
4722
|
+
],
|
|
4723
|
+
content: a || "",
|
|
4724
|
+
onUpdate: ({ editor: m }) => {
|
|
4725
|
+
const f = m.getHTML();
|
|
4726
|
+
l(f);
|
|
4727
|
+
},
|
|
4728
|
+
onBlur: ({ editor: m }) => {
|
|
4729
|
+
const f = m.getHTML();
|
|
4730
|
+
i(r, f);
|
|
4731
|
+
},
|
|
4732
|
+
editorProps: {
|
|
4733
|
+
attributes: {
|
|
4734
|
+
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"
|
|
4735
|
+
}
|
|
4736
|
+
}
|
|
4737
|
+
});
|
|
4738
|
+
useEffect(() => {
|
|
4739
|
+
o && u && (d.current !== a && (d.current = a || "", u.commands.setContent(a || "")), setTimeout(() => {
|
|
4740
|
+
u.commands.focus();
|
|
4741
|
+
}, 100));
|
|
4742
|
+
}, [o, u]), useEffect(() => {
|
|
4743
|
+
c.current && u && (c.current.__chaiRTE = u);
|
|
4744
|
+
}, [u, o]);
|
|
4745
|
+
const g = (m) => {
|
|
4746
|
+
if (!u) return;
|
|
4747
|
+
const f = `{{${m}}}`;
|
|
4748
|
+
u.commands.focus();
|
|
4749
|
+
const { from: h, to: b } = u.state.selection;
|
|
4750
|
+
if (h !== b)
|
|
4751
|
+
u.chain().deleteSelection().insertContent(f).run();
|
|
4752
|
+
else {
|
|
4753
|
+
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));
|
|
4754
|
+
let S = "";
|
|
4755
|
+
A > 0 && j !== " " && !/[.,!?;:]/.test(j) && (S = " ");
|
|
4756
|
+
let B = "";
|
|
4757
|
+
C && C !== " " && !/[.,!?;:]/.test(C) && (B = " "), u.chain().insertContent(S + f + B).run();
|
|
4473
4758
|
}
|
|
4474
|
-
|
|
4759
|
+
};
|
|
4760
|
+
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: [
|
|
4761
|
+
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center justify-between pr-8", children: [
|
|
4762
|
+
/* @__PURE__ */ jsx("span", { children: "Rich Text Editor" }),
|
|
4763
|
+
p && Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
4764
|
+
/* @__PURE__ */ jsx("span", { className: "mr-2 text-sm text-muted-foreground", children: "Add field:" }),
|
|
4765
|
+
/* @__PURE__ */ jsx("div", { className: "rte-path-selector", children: /* @__PURE__ */ jsx(NestedPathSelector, { data: p, onSelect: g }) })
|
|
4766
|
+
] })
|
|
4767
|
+
] }) }),
|
|
4768
|
+
/* @__PURE__ */ jsxs("div", { id: `chai-rte-modal-${r}`, ref: c, className: "rounded-md border border-input", children: [
|
|
4769
|
+
/* @__PURE__ */ jsx(MenuBar, { editor: u }),
|
|
4770
|
+
/* @__PURE__ */ jsx(EditorContent, { editor: u, id: `modal-${r}`, className: "p-2" })
|
|
4771
|
+
] }),
|
|
4772
|
+
/* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-end", children: /* @__PURE__ */ jsx(Button, { onClick: n, children: "Done" }) })
|
|
4773
|
+
] }) });
|
|
4774
|
+
}, RichTextEditorField = ({ id: o, placeholder: n, value: r, onChange: a, onBlur: l }) => {
|
|
4775
|
+
const i = useRef(null), [c, d] = useState(!1), [p, u] = useState(""), g = useEditor({
|
|
4776
|
+
extensions: [
|
|
4777
|
+
StarterKit,
|
|
4778
|
+
Link.configure({
|
|
4779
|
+
openOnClick: !1,
|
|
4780
|
+
HTMLAttributes: {
|
|
4781
|
+
class: "text-primary underline"
|
|
4782
|
+
}
|
|
4783
|
+
}),
|
|
4784
|
+
TextAlign.configure({
|
|
4785
|
+
types: ["heading", "paragraph"],
|
|
4786
|
+
alignments: ["left", "center", "right"],
|
|
4787
|
+
defaultAlignment: "left"
|
|
4788
|
+
}),
|
|
4789
|
+
Underline
|
|
4790
|
+
],
|
|
4791
|
+
content: r || "",
|
|
4792
|
+
onUpdate: ({ editor: h }) => {
|
|
4793
|
+
const b = h.getHTML();
|
|
4794
|
+
a(b), c || u(b);
|
|
4795
|
+
},
|
|
4796
|
+
onBlur: ({ editor: h }) => {
|
|
4797
|
+
const b = h.getHTML();
|
|
4798
|
+
l(o, b);
|
|
4799
|
+
},
|
|
4800
|
+
editorProps: {
|
|
4801
|
+
attributes: {
|
|
4802
|
+
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"
|
|
4803
|
+
}
|
|
4804
|
+
}
|
|
4805
|
+
});
|
|
4806
|
+
useEffect(() => {
|
|
4807
|
+
i.current.__chaiRTE = g;
|
|
4808
|
+
}, [g]), useEffect(() => {
|
|
4809
|
+
u(r || "");
|
|
4810
|
+
}, [r]);
|
|
4811
|
+
const m = (h) => {
|
|
4812
|
+
a(h);
|
|
4813
|
+
}, f = () => {
|
|
4814
|
+
d(!1), g && g.commands.setContent(p);
|
|
4815
|
+
};
|
|
4816
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4817
|
+
/* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsxs("div", { id: `chai-rte-${o}`, ref: i, className: "mt-1 rounded-md border border-input", children: [
|
|
4818
|
+
/* @__PURE__ */ jsx(MenuBar, { editor: g, onExpand: () => d(!0) }),
|
|
4819
|
+
/* @__PURE__ */ jsx(EditorContent, { editor: g, id: o, placeholder: n })
|
|
4820
|
+
] }) }),
|
|
4821
|
+
c && /* @__PURE__ */ jsx(
|
|
4822
|
+
RTEModal,
|
|
4823
|
+
{
|
|
4824
|
+
isOpen: c,
|
|
4825
|
+
onClose: f,
|
|
4826
|
+
id: o,
|
|
4827
|
+
value: p,
|
|
4828
|
+
onChange: m,
|
|
4829
|
+
onBlur: l
|
|
4830
|
+
}
|
|
4831
|
+
)
|
|
4832
|
+
] });
|
|
4475
4833
|
}, PageTypeField = ({
|
|
4476
4834
|
href: o,
|
|
4477
4835
|
pageTypes: n,
|
|
4478
4836
|
onChange: r
|
|
4479
4837
|
}) => {
|
|
4480
4838
|
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(""), [
|
|
4839
|
+
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
4840
|
useEffect(() => {
|
|
4483
4841
|
if (f(""), b([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4484
4842
|
const k = split(o, ":"), v = get(k, 1, "page") || "page";
|
|
@@ -4487,7 +4845,7 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4487
4845
|
N && Array.isArray(N) && f(get(N, [0, "name"], ""));
|
|
4488
4846
|
})();
|
|
4489
4847
|
}, [o]);
|
|
4490
|
-
const
|
|
4848
|
+
const C = useDebouncedCallback(
|
|
4491
4849
|
async (k) => {
|
|
4492
4850
|
if (isEmpty(k))
|
|
4493
4851
|
b([]);
|
|
@@ -4502,17 +4860,17 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4502
4860
|
), S = (k) => {
|
|
4503
4861
|
const v = ["pageType", u, k.id];
|
|
4504
4862
|
v[1] && (r(v.join(":")), f(k.name), p(!1), b([]), y(-1));
|
|
4505
|
-
},
|
|
4863
|
+
}, B = (k) => {
|
|
4506
4864
|
switch (k.key) {
|
|
4507
4865
|
case "ArrowDown":
|
|
4508
|
-
k.preventDefault(), y((v) => v <
|
|
4866
|
+
k.preventDefault(), y((v) => v < h.length - 1 ? v + 1 : v);
|
|
4509
4867
|
break;
|
|
4510
4868
|
case "ArrowUp":
|
|
4511
4869
|
k.preventDefault(), y((v) => v > 0 ? v - 1 : v);
|
|
4512
4870
|
break;
|
|
4513
4871
|
case "Enter":
|
|
4514
|
-
if (k.preventDefault(),
|
|
4515
|
-
|
|
4872
|
+
if (k.preventDefault(), h.length === 0) return;
|
|
4873
|
+
x >= 0 && S(h[x]);
|
|
4516
4874
|
break;
|
|
4517
4875
|
case "Escape":
|
|
4518
4876
|
k.preventDefault(), _();
|
|
@@ -4520,15 +4878,15 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4520
4878
|
}
|
|
4521
4879
|
};
|
|
4522
4880
|
useEffect(() => {
|
|
4523
|
-
if (
|
|
4524
|
-
const k =
|
|
4881
|
+
if (x >= 0 && A.current) {
|
|
4882
|
+
const k = A.current.children[x];
|
|
4525
4883
|
k == null || k.scrollIntoView({ block: "nearest" });
|
|
4526
4884
|
}
|
|
4527
|
-
}, [
|
|
4885
|
+
}, [x]);
|
|
4528
4886
|
const _ = () => {
|
|
4529
4887
|
f(""), b([]), y(-1), p(!1), r("");
|
|
4530
|
-
},
|
|
4531
|
-
f(k), p(!isEmpty(k)), c(!0),
|
|
4888
|
+
}, w = (k) => {
|
|
4889
|
+
f(k), p(!isEmpty(k)), c(!0), C(k);
|
|
4532
4890
|
};
|
|
4533
4891
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4534
4892
|
/* @__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 +4896,27 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4538
4896
|
{
|
|
4539
4897
|
type: "text",
|
|
4540
4898
|
value: m,
|
|
4541
|
-
onChange: (k) =>
|
|
4542
|
-
onKeyDown:
|
|
4543
|
-
placeholder: a(`Search ${
|
|
4899
|
+
onChange: (k) => w(k.target.value),
|
|
4900
|
+
onKeyDown: B,
|
|
4901
|
+
placeholder: a(`Search ${j ?? ""}`),
|
|
4544
4902
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4545
4903
|
}
|
|
4546
4904
|
),
|
|
4547
4905
|
/* @__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
4906
|
] }),
|
|
4549
|
-
(i || !isEmpty(
|
|
4907
|
+
(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
4908
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
4551
4909
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
4552
|
-
] }) : d && isEmpty(
|
|
4910
|
+
] }) : d && isEmpty(h) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4553
4911
|
a("No results found for"),
|
|
4554
4912
|
' "',
|
|
4555
4913
|
m,
|
|
4556
4914
|
'"'
|
|
4557
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref:
|
|
4915
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(h == null ? void 0 : h.slice(0, 20), (k, v) => /* @__PURE__ */ jsxs(
|
|
4558
4916
|
"li",
|
|
4559
4917
|
{
|
|
4560
4918
|
onClick: () => S(k),
|
|
4561
|
-
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(k.id) ? "bg-blue-200" : v ===
|
|
4919
|
+
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
4920
|
children: [
|
|
4563
4921
|
k.name,
|
|
4564
4922
|
" ",
|
|
@@ -4654,23 +5012,23 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4654
5012
|
const m = () => {
|
|
4655
5013
|
const b = findIndex(u, { _id: g });
|
|
4656
5014
|
if (b > -1) {
|
|
4657
|
-
const
|
|
5015
|
+
const x = (b + 1) % u.length, y = get(u, [x, "_id"]);
|
|
4658
5016
|
if (!y) return;
|
|
4659
5017
|
n({ ...o, currentSlide: y }), c([y]);
|
|
4660
5018
|
}
|
|
4661
5019
|
}, f = () => {
|
|
4662
5020
|
const b = findIndex(u, { _id: g });
|
|
4663
5021
|
if (b > -1) {
|
|
4664
|
-
const
|
|
5022
|
+
const x = (b - 1 + u.length) % u.length, y = get(u, [x, "_id"]);
|
|
4665
5023
|
if (!y) return;
|
|
4666
5024
|
n({ ...o, currentSlide: y }), c([y]);
|
|
4667
5025
|
}
|
|
4668
|
-
},
|
|
5026
|
+
}, h = () => {
|
|
4669
5027
|
const b = i(
|
|
4670
5028
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4671
5029
|
p == null ? void 0 : p._id
|
|
4672
|
-
),
|
|
4673
|
-
|
|
5030
|
+
), x = b == null ? void 0 : b._id;
|
|
5031
|
+
x && (n({ ...o, currentSlide: x }), c([x]));
|
|
4674
5032
|
};
|
|
4675
5033
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4676
5034
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
@@ -4687,7 +5045,7 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4687
5045
|
/* @__PURE__ */ jsxs(
|
|
4688
5046
|
"button",
|
|
4689
5047
|
{
|
|
4690
|
-
onClick:
|
|
5048
|
+
onClick: h,
|
|
4691
5049
|
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
5050
|
children: [
|
|
4693
5051
|
/* @__PURE__ */ jsx(PlusCircle, { className: "h-3 w-3 stroke-[2]" }),
|
|
@@ -4749,8 +5107,8 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4749
5107
|
className: "text-xs",
|
|
4750
5108
|
pattern: "[0-9]*",
|
|
4751
5109
|
onChange: (b) => {
|
|
4752
|
-
let
|
|
4753
|
-
|
|
5110
|
+
let x = b.target.value;
|
|
5111
|
+
x.length && (x = x.replace("-", "")), n({ ...o, autoplayInterval: x });
|
|
4754
5112
|
}
|
|
4755
5113
|
}
|
|
4756
5114
|
)
|
|
@@ -4775,86 +5133,7 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4775
5133
|
),
|
|
4776
5134
|
/* @__PURE__ */ jsx(Button, { onClick: d, size: "sm", variant: "outline", className: "w-fit", children: r("Open code editor") })
|
|
4777
5135
|
] });
|
|
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 = ({
|
|
5136
|
+
}, CustomFieldTemplate = ({
|
|
4858
5137
|
id: o,
|
|
4859
5138
|
classNames: n,
|
|
4860
5139
|
label: r,
|
|
@@ -4868,77 +5147,56 @@ const CustomFieldTemplate = ({
|
|
|
4868
5147
|
formData: g,
|
|
4869
5148
|
onChange: m
|
|
4870
5149
|
}) => {
|
|
4871
|
-
const { selectedLang: f, fallbackLang:
|
|
5150
|
+
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
5151
|
(v) => {
|
|
4873
|
-
const N = (
|
|
4874
|
-
let
|
|
4875
|
-
const
|
|
4876
|
-
return
|
|
4877
|
-
text:
|
|
4878
|
-
prefixLength:
|
|
4879
|
-
suffixLength:
|
|
5152
|
+
const N = (E) => /[.,!?;:]/.test(E), I = (E, D, M) => {
|
|
5153
|
+
let R = "", O = "";
|
|
5154
|
+
const $ = D > 0 ? E[D - 1] : "", H = D < E.length ? E[D] : "";
|
|
5155
|
+
return D > 0 && ($ === "." || !N($) && $ !== " ") && (R = " "), D < E.length && !N(H) && H !== " " && (O = " "), {
|
|
5156
|
+
text: R + M + O,
|
|
5157
|
+
prefixLength: R.length,
|
|
5158
|
+
suffixLength: O.length
|
|
4880
5159
|
};
|
|
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
|
-
}
|
|
5160
|
+
}, L = document.getElementById(o);
|
|
5161
|
+
if (!L) return;
|
|
5162
|
+
const P = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
|
|
5163
|
+
if (P && (P.querySelector(".ProseMirror") || P.__chaiRTE)) {
|
|
5164
|
+
const E = P.__chaiRTE;
|
|
5165
|
+
if (E) {
|
|
5166
|
+
const D = `{{${v}}}`;
|
|
5167
|
+
E.commands.focus();
|
|
5168
|
+
const { from: M, to: R } = E.state.selection;
|
|
5169
|
+
if (M !== R)
|
|
5170
|
+
E.chain().deleteSelection().insertContent(D).run();
|
|
4910
5171
|
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);
|
|
5172
|
+
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));
|
|
5173
|
+
let z = "";
|
|
5174
|
+
H > 0 && F !== " " && !N(F) && (z = " ");
|
|
5175
|
+
let W = "";
|
|
5176
|
+
U && U !== " " && !N(U) && (W = " "), E.chain().insertContent(z + D + W).run();
|
|
4919
5177
|
}
|
|
4920
|
-
setTimeout(() => m(
|
|
5178
|
+
setTimeout(() => m(E.getHTML(), {}, o), 100);
|
|
4921
5179
|
return;
|
|
4922
5180
|
}
|
|
4923
5181
|
} else {
|
|
4924
|
-
const
|
|
4925
|
-
if (
|
|
4926
|
-
const
|
|
5182
|
+
const E = L, D = E.selectionStart || 0, M = E.value || "", R = E.selectionEnd || D;
|
|
5183
|
+
if (R > D) {
|
|
5184
|
+
const U = `{{${v}}}`, { text: z } = I(M, D, U), W = M.slice(0, D) + z + M.slice(R);
|
|
4927
5185
|
m(W, {}, o);
|
|
4928
5186
|
return;
|
|
4929
5187
|
}
|
|
4930
|
-
const
|
|
4931
|
-
m(
|
|
5188
|
+
const $ = `{{${v}}}`, { text: H } = I(M, D, $), F = M.slice(0, D) + H + M.slice(D);
|
|
5189
|
+
m(F, {}, o);
|
|
4932
5190
|
}
|
|
4933
5191
|
},
|
|
4934
|
-
[o, m, g,
|
|
5192
|
+
[o, m, g, j == null ? void 0 : j._id]
|
|
4935
5193
|
);
|
|
4936
5194
|
if (d)
|
|
4937
5195
|
return null;
|
|
4938
5196
|
if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
|
|
4939
5197
|
const k = S == null ? void 0 : S.includes(o.replace("root.", ""));
|
|
4940
5198
|
if (u.type === "array") {
|
|
4941
|
-
const v =
|
|
5199
|
+
const v = B === o;
|
|
4942
5200
|
return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
|
|
4943
5201
|
u.title && /* @__PURE__ */ jsxs(
|
|
4944
5202
|
"label",
|
|
@@ -4974,7 +5232,7 @@ const CustomFieldTemplate = ({
|
|
|
4974
5232
|
] }),
|
|
4975
5233
|
p && u.type !== "object" ? " *" : null
|
|
4976
5234
|
] }),
|
|
4977
|
-
u.type === "string" && !u.enum && !u.oneOf &&
|
|
5235
|
+
u.type === "string" && !u.enum && !u.oneOf && A && /* @__PURE__ */ jsx(NestedPathSelector, { data: A, onSelect: w, dataType: "value" })
|
|
4978
5236
|
] }),
|
|
4979
5237
|
c,
|
|
4980
5238
|
a,
|
|
@@ -5042,35 +5300,35 @@ const CustomFieldTemplate = ({
|
|
|
5042
5300
|
}), a;
|
|
5043
5301
|
};
|
|
5044
5302
|
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(
|
|
5303
|
+
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) => {
|
|
5304
|
+
_ && (c == null ? void 0 : c._id) === n._id && a([n._id], { [_]: get(B, _) }, w);
|
|
5047
5305
|
}, b = useCallback(
|
|
5048
|
-
debounce(({ formData:
|
|
5049
|
-
|
|
5306
|
+
debounce(({ formData: B }, _, w) => {
|
|
5307
|
+
h({ formData: B }, _, w), d(B);
|
|
5050
5308
|
}, 1500),
|
|
5051
5309
|
[n == null ? void 0 : n._id, o]
|
|
5052
|
-
),
|
|
5053
|
-
_ && (r([n._id], { [_]: get(
|
|
5054
|
-
}, y = ({ formData:
|
|
5055
|
-
_ && (r([g._id], { [_]: get(
|
|
5310
|
+
), x = ({ formData: B }, _) => {
|
|
5311
|
+
_ && (r([n._id], { [_]: get(B, _) }), b({ formData: B }, _, { [_]: get(c, _) }));
|
|
5312
|
+
}, y = ({ formData: B }, _) => {
|
|
5313
|
+
_ && (r([g._id], { [_]: get(B, _) }), b({ formData: B }, _, { [_]: get(c, _) }));
|
|
5056
5314
|
};
|
|
5057
5315
|
keys(get(i, "_bindings", {}));
|
|
5058
|
-
const { schema:
|
|
5059
|
-
const
|
|
5060
|
-
if (
|
|
5061
|
-
return getBlockFormSchemas(
|
|
5062
|
-
}, [n]), { wrapperSchema:
|
|
5316
|
+
const { schema: A, uiSchema: j } = useMemo(() => {
|
|
5317
|
+
const B = n == null ? void 0 : n._type;
|
|
5318
|
+
if (B)
|
|
5319
|
+
return getBlockFormSchemas(B);
|
|
5320
|
+
}, [n]), { wrapperSchema: C, wrapperUiSchema: S } = useMemo(() => {
|
|
5063
5321
|
if (!g || !(g != null && g._type))
|
|
5064
5322
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5065
|
-
const
|
|
5066
|
-
return { wrapperSchema: _, wrapperUiSchema:
|
|
5323
|
+
const B = g == null ? void 0 : g._type, { schema: _ = {}, uiSchema: w = {} } = getBlockFormSchemas(B);
|
|
5324
|
+
return { wrapperSchema: _, wrapperUiSchema: w };
|
|
5067
5325
|
}, [g]);
|
|
5068
5326
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5069
5327
|
!isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
5070
5328
|
/* @__PURE__ */ jsxs(
|
|
5071
5329
|
"div",
|
|
5072
5330
|
{
|
|
5073
|
-
onClick: () => u((
|
|
5331
|
+
onClick: () => u((B) => !B),
|
|
5074
5332
|
className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
|
|
5075
5333
|
children: [
|
|
5076
5334
|
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 +5349,19 @@ function BlockSettings() {
|
|
|
5091
5349
|
blockId: g == null ? void 0 : g._id,
|
|
5092
5350
|
onChange: y,
|
|
5093
5351
|
formData: f,
|
|
5094
|
-
schema:
|
|
5352
|
+
schema: C,
|
|
5095
5353
|
uiSchema: S
|
|
5096
5354
|
}
|
|
5097
5355
|
) })
|
|
5098
5356
|
] }),
|
|
5099
|
-
isEmpty(
|
|
5357
|
+
isEmpty(A) ? null : /* @__PURE__ */ jsx(
|
|
5100
5358
|
JSONForm,
|
|
5101
5359
|
{
|
|
5102
5360
|
blockId: n == null ? void 0 : n._id,
|
|
5103
|
-
onChange:
|
|
5361
|
+
onChange: x,
|
|
5104
5362
|
formData: i,
|
|
5105
|
-
schema:
|
|
5106
|
-
uiSchema:
|
|
5363
|
+
schema: A,
|
|
5364
|
+
uiSchema: j
|
|
5107
5365
|
}
|
|
5108
5366
|
),
|
|
5109
5367
|
(n == null ? void 0 : n._type) === "GlobalBlock" ? /* @__PURE__ */ jsx(GlobalBlockSettings, {}) : null
|
|
@@ -5194,31 +5452,31 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5194
5452
|
] }) }) })
|
|
5195
5453
|
] });
|
|
5196
5454
|
}, 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(
|
|
5455
|
+
const [r, , a] = useScreenSizeWidth(), [l, i] = useCanvasDisplayWidth(), [c, d] = useSelectedBreakpoints(), p = c, u = d, { t: g } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (x) => {
|
|
5456
|
+
p.includes(x) ? p.length > 2 && u(p.filter((y) => y !== x)) : u((y) => [...y, x]);
|
|
5457
|
+
}, h = (x) => {
|
|
5458
|
+
n || a(x), i(x);
|
|
5201
5459
|
}, b = getBreakpointValue(n ? l : r).toLowerCase();
|
|
5202
|
-
return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (
|
|
5460
|
+
return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (x) => /* @__PURE__ */ createElement(
|
|
5203
5461
|
BreakpointCard,
|
|
5204
5462
|
{
|
|
5205
5463
|
canvas: n,
|
|
5206
|
-
...
|
|
5207
|
-
onClick:
|
|
5208
|
-
key:
|
|
5464
|
+
...x,
|
|
5465
|
+
onClick: h,
|
|
5466
|
+
key: x.breakpoint,
|
|
5209
5467
|
currentBreakpoint: b
|
|
5210
5468
|
}
|
|
5211
5469
|
)) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
|
|
5212
5470
|
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
|
|
5213
|
-
m.filter((
|
|
5214
|
-
(
|
|
5471
|
+
m.filter((x) => includes(p, toUpper(x.breakpoint))),
|
|
5472
|
+
(x) => /* @__PURE__ */ createElement(
|
|
5215
5473
|
BreakpointCard,
|
|
5216
5474
|
{
|
|
5217
5475
|
canvas: n,
|
|
5218
5476
|
openDelay: o,
|
|
5219
|
-
...
|
|
5220
|
-
onClick:
|
|
5221
|
-
key:
|
|
5477
|
+
...x,
|
|
5478
|
+
onClick: h,
|
|
5479
|
+
key: x.breakpoint,
|
|
5222
5480
|
currentBreakpoint: b
|
|
5223
5481
|
}
|
|
5224
5482
|
)
|
|
@@ -5228,15 +5486,15 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5228
5486
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
|
|
5229
5487
|
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: g("Screen sizes") }),
|
|
5230
5488
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
5231
|
-
map(m, (
|
|
5489
|
+
map(m, (x) => /* @__PURE__ */ jsx(
|
|
5232
5490
|
DropdownMenuCheckboxItem,
|
|
5233
5491
|
{
|
|
5234
|
-
disabled:
|
|
5235
|
-
onCheckedChange: () => f(toUpper(
|
|
5236
|
-
checked: includes(p, toUpper(
|
|
5237
|
-
children: g(
|
|
5492
|
+
disabled: x.breakpoint === "xs",
|
|
5493
|
+
onCheckedChange: () => f(toUpper(x.breakpoint)),
|
|
5494
|
+
checked: includes(p, toUpper(x.breakpoint)),
|
|
5495
|
+
children: g(x.title)
|
|
5238
5496
|
},
|
|
5239
|
-
|
|
5497
|
+
x.breakpoint
|
|
5240
5498
|
))
|
|
5241
5499
|
] })
|
|
5242
5500
|
] })
|
|
@@ -5325,8 +5583,8 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5325
5583
|
(f = d.current) == null || f.focus();
|
|
5326
5584
|
}, []);
|
|
5327
5585
|
const m = (f) => {
|
|
5328
|
-
const { usage:
|
|
5329
|
-
!l &&
|
|
5586
|
+
const { usage: h } = f || {};
|
|
5587
|
+
!l && h && g(h), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
5330
5588
|
};
|
|
5331
5589
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
5332
5590
|
/* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: n("Ask AI") }),
|
|
@@ -5382,24 +5640,24 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5382
5640
|
};
|
|
5383
5641
|
function ManualClasses() {
|
|
5384
5642
|
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: {
|
|
5643
|
+
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 = () => {
|
|
5644
|
+
const L = h.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5645
|
+
u(m, L, !0), b("");
|
|
5646
|
+
}, [C, S] = useState([]), B = ({ value: L }) => {
|
|
5647
|
+
const P = L.trim().toLowerCase(), E = P.match(/.+:/g);
|
|
5648
|
+
let D = [];
|
|
5649
|
+
if (E && E.length > 0) {
|
|
5650
|
+
const [M] = E, R = P.replace(M, "");
|
|
5651
|
+
D = i.search(R).map(($) => ({
|
|
5652
|
+
...$,
|
|
5653
|
+
item: { ...$.item, name: M + $.item.name }
|
|
5396
5654
|
}));
|
|
5397
5655
|
} else
|
|
5398
|
-
|
|
5399
|
-
return S(map(
|
|
5656
|
+
D = i.search(P);
|
|
5657
|
+
return S(map(D, "item"));
|
|
5400
5658
|
}, _ = () => {
|
|
5401
5659
|
S([]);
|
|
5402
|
-
},
|
|
5660
|
+
}, w = (L) => L.name, T = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), k = useMemo(
|
|
5403
5661
|
() => ({
|
|
5404
5662
|
ref: o,
|
|
5405
5663
|
autoComplete: "off",
|
|
@@ -5407,24 +5665,24 @@ function ManualClasses() {
|
|
|
5407
5665
|
autoCapitalize: "off",
|
|
5408
5666
|
spellCheck: !1,
|
|
5409
5667
|
placeholder: c("Enter classes separated by space"),
|
|
5410
|
-
value:
|
|
5411
|
-
onKeyDown: (
|
|
5412
|
-
|
|
5668
|
+
value: h,
|
|
5669
|
+
onKeyDown: (L) => {
|
|
5670
|
+
L.key === "Enter" && h.trim() !== "" && j();
|
|
5413
5671
|
},
|
|
5414
|
-
onChange: (
|
|
5672
|
+
onChange: (L, { newValue: P }) => b(P),
|
|
5415
5673
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
5416
5674
|
}),
|
|
5417
|
-
[
|
|
5418
|
-
), v = (
|
|
5675
|
+
[h, c, o]
|
|
5676
|
+
), v = (L) => {
|
|
5419
5677
|
debugger;
|
|
5420
|
-
const
|
|
5421
|
-
g(m, [
|
|
5678
|
+
const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5679
|
+
g(m, [L]), u(m, P, !0), r(""), l(-1);
|
|
5422
5680
|
}, N = () => {
|
|
5423
5681
|
if (navigator.clipboard === void 0) {
|
|
5424
5682
|
toast.error(c("Clipboard not supported"));
|
|
5425
5683
|
return;
|
|
5426
5684
|
}
|
|
5427
|
-
navigator.clipboard.writeText(
|
|
5685
|
+
navigator.clipboard.writeText(A.join(" ")), toast.success(c("Classes copied to clipboard"));
|
|
5428
5686
|
};
|
|
5429
5687
|
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
|
|
5430
5688
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
|
|
@@ -5447,10 +5705,10 @@ function ManualClasses() {
|
|
|
5447
5705
|
/* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
|
|
5448
5706
|
Autosuggest,
|
|
5449
5707
|
{
|
|
5450
|
-
suggestions:
|
|
5451
|
-
onSuggestionsFetchRequested:
|
|
5708
|
+
suggestions: C,
|
|
5709
|
+
onSuggestionsFetchRequested: B,
|
|
5452
5710
|
onSuggestionsClearRequested: _,
|
|
5453
|
-
getSuggestionValue:
|
|
5711
|
+
getSuggestionValue: w,
|
|
5454
5712
|
renderSuggestion: T,
|
|
5455
5713
|
inputProps: k,
|
|
5456
5714
|
containerProps: {
|
|
@@ -5468,45 +5726,45 @@ function ManualClasses() {
|
|
|
5468
5726
|
{
|
|
5469
5727
|
variant: "outline",
|
|
5470
5728
|
className: "h-6 border-border",
|
|
5471
|
-
onClick:
|
|
5472
|
-
disabled:
|
|
5729
|
+
onClick: j,
|
|
5730
|
+
disabled: h.trim() === "",
|
|
5473
5731
|
size: "sm",
|
|
5474
5732
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
5475
5733
|
}
|
|
5476
5734
|
)
|
|
5477
5735
|
] }),
|
|
5478
|
-
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children:
|
|
5479
|
-
(
|
|
5736
|
+
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: A.map(
|
|
5737
|
+
(L, P) => a === P ? /* @__PURE__ */ jsx(
|
|
5480
5738
|
"input",
|
|
5481
5739
|
{
|
|
5482
5740
|
ref: o,
|
|
5483
5741
|
value: n,
|
|
5484
|
-
onChange: (
|
|
5742
|
+
onChange: (E) => r(E.target.value),
|
|
5485
5743
|
onBlur: () => {
|
|
5486
|
-
v(
|
|
5744
|
+
v(L);
|
|
5487
5745
|
},
|
|
5488
|
-
onKeyDown: (
|
|
5489
|
-
|
|
5746
|
+
onKeyDown: (E) => {
|
|
5747
|
+
E.key === "Enter" && v(L);
|
|
5490
5748
|
},
|
|
5491
5749
|
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
5750
|
},
|
|
5493
|
-
|
|
5751
|
+
L
|
|
5494
5752
|
) : /* @__PURE__ */ jsxs(
|
|
5495
5753
|
"button",
|
|
5496
5754
|
{
|
|
5497
5755
|
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
5756
|
children: [
|
|
5499
|
-
|
|
5500
|
-
n !==
|
|
5757
|
+
L,
|
|
5758
|
+
n !== L && /* @__PURE__ */ jsx(
|
|
5501
5759
|
Cross2Icon,
|
|
5502
5760
|
{
|
|
5503
|
-
onClick: () => g(m, [
|
|
5761
|
+
onClick: () => g(m, [L], !0),
|
|
5504
5762
|
className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
|
|
5505
5763
|
}
|
|
5506
5764
|
)
|
|
5507
5765
|
]
|
|
5508
5766
|
},
|
|
5509
|
-
|
|
5767
|
+
L
|
|
5510
5768
|
)
|
|
5511
5769
|
) })
|
|
5512
5770
|
] });
|
|
@@ -5848,8 +6106,8 @@ const COLOR_PROP = {
|
|
|
5848
6106
|
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
5849
6107
|
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
6108
|
// eslint-disable-next-line no-shadow
|
|
5851
|
-
(
|
|
5852
|
-
["current", "inherit", "transparent", "black", "white"].includes(
|
|
6109
|
+
(x) => {
|
|
6110
|
+
["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
6111
|
},
|
|
5854
6112
|
[c, p]
|
|
5855
6113
|
);
|
|
@@ -5858,10 +6116,10 @@ const COLOR_PROP = {
|
|
|
5858
6116
|
return c([]);
|
|
5859
6117
|
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
5860
6118
|
}, [g]);
|
|
5861
|
-
const
|
|
6119
|
+
const h = useCallback(
|
|
5862
6120
|
// eslint-disable-next-line no-shadow
|
|
5863
|
-
(
|
|
5864
|
-
p({ color: g, shade:
|
|
6121
|
+
(x) => {
|
|
6122
|
+
p({ color: g, shade: x });
|
|
5865
6123
|
},
|
|
5866
6124
|
[g]
|
|
5867
6125
|
);
|
|
@@ -5912,7 +6170,7 @@ const COLOR_PROP = {
|
|
|
5912
6170
|
]
|
|
5913
6171
|
}
|
|
5914
6172
|
) }),
|
|
5915
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange:
|
|
6173
|
+
/* @__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
6174
|
] });
|
|
5917
6175
|
}, IconChoices = ({ property: o, onChange: n }) => {
|
|
5918
6176
|
const { getClasses: r } = useTailwindClassList(), a = r(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
|
|
@@ -6109,7 +6367,7 @@ const COLOR_PROP = {
|
|
|
6109
6367
|
},
|
|
6110
6368
|
a
|
|
6111
6369
|
)) }), 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]), [
|
|
6370
|
+
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
6371
|
useEffect(() => {
|
|
6114
6372
|
const { value: k, unit: v } = getClassValueAndUnit(i);
|
|
6115
6373
|
if (v === "") {
|
|
@@ -6118,7 +6376,7 @@ const COLOR_PROP = {
|
|
|
6118
6376
|
}
|
|
6119
6377
|
f(v), l(v === "class" || isEmpty(k) ? "" : k);
|
|
6120
6378
|
}, [i, p, u]);
|
|
6121
|
-
const
|
|
6379
|
+
const B = useThrottledCallback((k) => c(k), [c], THROTTLE_TIME), _ = useThrottledCallback((k) => c(k, !1), [c], THROTTLE_TIME), w = useCallback(
|
|
6122
6380
|
(k = !1) => {
|
|
6123
6381
|
const v = getUserInputValues(`${a}`, u);
|
|
6124
6382
|
if (get(v, "error", !1)) {
|
|
@@ -6127,15 +6385,15 @@ const COLOR_PROP = {
|
|
|
6127
6385
|
}
|
|
6128
6386
|
const N = get(v, "unit") !== "" ? get(v, "unit") : m;
|
|
6129
6387
|
if (N === "auto" || N === "none") {
|
|
6130
|
-
|
|
6388
|
+
B(`${d}${N}`);
|
|
6131
6389
|
return;
|
|
6132
6390
|
}
|
|
6133
6391
|
if (get(v, "value") === "")
|
|
6134
6392
|
return;
|
|
6135
|
-
const
|
|
6136
|
-
k ? _(
|
|
6393
|
+
const L = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
|
|
6394
|
+
k ? _(L) : B(L);
|
|
6137
6395
|
},
|
|
6138
|
-
[
|
|
6396
|
+
[B, _, a, m, d, u]
|
|
6139
6397
|
), T = useCallback(
|
|
6140
6398
|
(k) => {
|
|
6141
6399
|
const v = getUserInputValues(`${a}`, u);
|
|
@@ -6144,15 +6402,15 @@ const COLOR_PROP = {
|
|
|
6144
6402
|
return;
|
|
6145
6403
|
}
|
|
6146
6404
|
if (k === "auto" || k === "none") {
|
|
6147
|
-
|
|
6405
|
+
B(`${d}${k}`);
|
|
6148
6406
|
return;
|
|
6149
6407
|
}
|
|
6150
6408
|
if (get(v, "value") === "")
|
|
6151
6409
|
return;
|
|
6152
|
-
const N = get(v, "unit") !== "" ? get(v, "unit") : k,
|
|
6153
|
-
|
|
6410
|
+
const N = get(v, "unit") !== "" ? get(v, "unit") : k, L = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
|
|
6411
|
+
B(L);
|
|
6154
6412
|
},
|
|
6155
|
-
[
|
|
6413
|
+
[B, a, d, u]
|
|
6156
6414
|
);
|
|
6157
6415
|
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
6416
|
/* @__PURE__ */ jsx(
|
|
@@ -6167,14 +6425,14 @@ const COLOR_PROP = {
|
|
|
6167
6425
|
/* @__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
6426
|
/* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
|
|
6169
6427
|
] })
|
|
6170
|
-
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${
|
|
6428
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${A ? "z-auto" : ""}`, children: [
|
|
6171
6429
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
6172
6430
|
["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
|
|
6173
6431
|
"input",
|
|
6174
6432
|
{
|
|
6175
6433
|
readOnly: m === "class",
|
|
6176
6434
|
onKeyPress: (k) => {
|
|
6177
|
-
k.key === "Enter" &&
|
|
6435
|
+
k.key === "Enter" && w();
|
|
6178
6436
|
},
|
|
6179
6437
|
onKeyDown: (k) => {
|
|
6180
6438
|
if (k.keyCode !== 38 && k.keyCode !== 40)
|
|
@@ -6183,13 +6441,13 @@ const COLOR_PROP = {
|
|
|
6183
6441
|
const v = parseInt$1(k.target.value);
|
|
6184
6442
|
let N = isNaN$1(v) ? 0 : v;
|
|
6185
6443
|
k.keyCode === 38 && (N += 1), k.keyCode === 40 && (N -= 1);
|
|
6186
|
-
const I = `${N}`,
|
|
6187
|
-
_(
|
|
6444
|
+
const I = `${N}`, P = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6445
|
+
_(P);
|
|
6188
6446
|
},
|
|
6189
6447
|
onKeyUp: (k) => {
|
|
6190
|
-
|
|
6448
|
+
C && (k.preventDefault(), S(!1));
|
|
6191
6449
|
},
|
|
6192
|
-
onBlur: () =>
|
|
6450
|
+
onBlur: () => w(),
|
|
6193
6451
|
onChange: (k) => {
|
|
6194
6452
|
b(!1), l(k.target.value);
|
|
6195
6453
|
},
|
|
@@ -6197,10 +6455,10 @@ const COLOR_PROP = {
|
|
|
6197
6455
|
var v;
|
|
6198
6456
|
(v = k == null ? void 0 : k.target) == null || v.select(), r(!1);
|
|
6199
6457
|
},
|
|
6200
|
-
value:
|
|
6458
|
+
value: A ? x : a,
|
|
6201
6459
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
6202
6460
|
" ",
|
|
6203
|
-
|
|
6461
|
+
h ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
6204
6462
|
)
|
|
6205
6463
|
}
|
|
6206
6464
|
),
|
|
@@ -6229,15 +6487,15 @@ const COLOR_PROP = {
|
|
|
6229
6487
|
) }) })
|
|
6230
6488
|
] })
|
|
6231
6489
|
] }),
|
|
6232
|
-
["none", "auto"].indexOf(m) !== -1 ||
|
|
6490
|
+
["none", "auto"].indexOf(m) !== -1 || A ? null : /* @__PURE__ */ jsx(
|
|
6233
6491
|
DragStyleButton,
|
|
6234
6492
|
{
|
|
6235
|
-
onDragStart: () =>
|
|
6493
|
+
onDragStart: () => j(!0),
|
|
6236
6494
|
onDragEnd: (k) => {
|
|
6237
|
-
if (y(() => ""),
|
|
6495
|
+
if (y(() => ""), j(!1), isEmpty(k))
|
|
6238
6496
|
return;
|
|
6239
6497
|
const v = `${k}`, I = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6240
|
-
|
|
6498
|
+
B(I);
|
|
6241
6499
|
},
|
|
6242
6500
|
onDrag: (k) => {
|
|
6243
6501
|
if (isEmpty(k))
|
|
@@ -6341,23 +6599,23 @@ const COLOR_PROP = {
|
|
|
6341
6599
|
"2xl": "1536px"
|
|
6342
6600
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6343
6601
|
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
|
-
(_,
|
|
6602
|
+
}, 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(
|
|
6603
|
+
(_, w = !0) => {
|
|
6346
6604
|
const T = { dark: p, mq: g, mod: u, cls: _, property: l, fullCls: "" };
|
|
6347
6605
|
(p || u !== "") && (T.mq = "xs");
|
|
6348
6606
|
const k = generateFullClsName(T);
|
|
6349
|
-
f(b, [k],
|
|
6607
|
+
f(b, [k], w);
|
|
6350
6608
|
},
|
|
6351
6609
|
[b, p, g, u, l, f]
|
|
6352
|
-
),
|
|
6353
|
-
|
|
6354
|
-
}, [b,
|
|
6610
|
+
), A = useCallback(() => {
|
|
6611
|
+
h(b, [x], !0);
|
|
6612
|
+
}, [b, x, h]), j = useMemo(() => canChangeClass(m, g), [m, g]);
|
|
6355
6613
|
useEffect(() => {
|
|
6356
|
-
i(
|
|
6357
|
-
}, [
|
|
6358
|
-
const [, ,
|
|
6614
|
+
i(j, m);
|
|
6615
|
+
}, [j, i, m]);
|
|
6616
|
+
const [, , C] = useScreenSizeWidth(), S = useCallback(
|
|
6359
6617
|
(_) => {
|
|
6360
|
-
|
|
6618
|
+
C({
|
|
6361
6619
|
xs: 400,
|
|
6362
6620
|
sm: 640,
|
|
6363
6621
|
md: 800,
|
|
@@ -6366,10 +6624,10 @@ const COLOR_PROP = {
|
|
|
6366
6624
|
"2xl": 1920
|
|
6367
6625
|
}[_]);
|
|
6368
6626
|
},
|
|
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 && !
|
|
6627
|
+
[C]
|
|
6628
|
+
), B = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
|
|
6629
|
+
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: [
|
|
6630
|
+
/* @__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
6631
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6374
6632
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
6375
6633
|
r === "arbitrary" ? /* @__PURE__ */ jsx(
|
|
@@ -6388,7 +6646,7 @@ const COLOR_PROP = {
|
|
|
6388
6646
|
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
|
|
6389
6647
|
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
|
|
6390
6648
|
] }),
|
|
6391
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${
|
|
6649
|
+
/* @__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
6650
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6393
6651
|
"button",
|
|
6394
6652
|
{
|
|
@@ -6438,18 +6696,18 @@ const COLOR_PROP = {
|
|
|
6438
6696
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6439
6697
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6440
6698
|
/* @__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:
|
|
6699
|
+
n.map(({ label: f, key: h }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6442
6700
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6443
6701
|
"button",
|
|
6444
6702
|
{
|
|
6445
6703
|
type: "button",
|
|
6446
|
-
onClick: () => u(
|
|
6447
|
-
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${
|
|
6704
|
+
onClick: () => u(h),
|
|
6705
|
+
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${h === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6448
6706
|
children: [
|
|
6449
6707
|
React__default.createElement("div", {
|
|
6450
|
-
className: m(
|
|
6708
|
+
className: m(h) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6451
6709
|
}),
|
|
6452
|
-
React__default.createElement(get(EDITOR_ICONS,
|
|
6710
|
+
React__default.createElement(get(EDITOR_ICONS, h, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6453
6711
|
]
|
|
6454
6712
|
}
|
|
6455
6713
|
) }),
|
|
@@ -6595,10 +6853,10 @@ function BlockStyling() {
|
|
|
6595
6853
|
const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
|
|
6596
6854
|
let f = parseFloat(i.dragStartValue);
|
|
6597
6855
|
f = isNaN(f) ? 0 : f;
|
|
6598
|
-
let
|
|
6599
|
-
(startsWith(m, "scale") || m === "opacity") && (
|
|
6600
|
-
let
|
|
6601
|
-
g &&
|
|
6856
|
+
let h = MAPPER[i.dragUnit];
|
|
6857
|
+
(startsWith(m, "scale") || m === "opacity") && (h = 10);
|
|
6858
|
+
let x = (i.dragStartY - u.pageY) / h + f;
|
|
6859
|
+
g && x < 0 && (x = 0), m === "opacity" && x > 1 && (x = 1), i.onDrag(`${x}`), l(`${x}`);
|
|
6602
6860
|
},
|
|
6603
6861
|
[i],
|
|
6604
6862
|
50
|
|
@@ -6642,12 +6900,12 @@ const CoreBlock = ({
|
|
|
6642
6900
|
}) => {
|
|
6643
6901
|
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), f = () => {
|
|
6644
6902
|
if (has(o, "blocks")) {
|
|
6645
|
-
const
|
|
6646
|
-
u(syncBlocksWithDefaults(
|
|
6903
|
+
const x = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
|
|
6904
|
+
u(syncBlocksWithDefaults(x), r || null, a);
|
|
6647
6905
|
} else
|
|
6648
6906
|
p(o, r || null, a);
|
|
6649
6907
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6650
|
-
},
|
|
6908
|
+
}, h = useFeature("dnd"), { t: b } = useTranslation();
|
|
6651
6909
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6652
6910
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6653
6911
|
"button",
|
|
@@ -6655,12 +6913,12 @@ const CoreBlock = ({
|
|
|
6655
6913
|
disabled: n,
|
|
6656
6914
|
onClick: f,
|
|
6657
6915
|
type: "button",
|
|
6658
|
-
onDragStart: (
|
|
6659
|
-
|
|
6916
|
+
onDragStart: (x) => {
|
|
6917
|
+
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
6918
|
g([]), m();
|
|
6661
6919
|
}, 200);
|
|
6662
6920
|
},
|
|
6663
|
-
draggable:
|
|
6921
|
+
draggable: h ? "true" : "false",
|
|
6664
6922
|
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
6923
|
children: [
|
|
6666
6924
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
@@ -6853,22 +7111,22 @@ const CoreBlock = ({
|
|
|
6853
7111
|
}
|
|
6854
7112
|
}
|
|
6855
7113
|
}, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
|
|
6856
|
-
var m, f,
|
|
7114
|
+
var m, f, h, b, x, y, A, j;
|
|
6857
7115
|
if (r.type === "comment") return [];
|
|
6858
7116
|
console.log("node ===>", r);
|
|
6859
7117
|
let a = { _id: generateUUID() };
|
|
6860
7118
|
if (n && (a._parent = n.block._id), r.type === "text")
|
|
6861
7119
|
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
7120
|
const l = get(r, "attributes", []), i = l.find(
|
|
6863
|
-
(
|
|
7121
|
+
(C) => C.key === "data-chai-richtext" || C.key === "chai-richtext"
|
|
6864
7122
|
), c = l.find(
|
|
6865
|
-
(
|
|
7123
|
+
(C) => C.key === "data-chai-lightbox" || C.key === "chai-lightbox"
|
|
6866
7124
|
), d = l.find(
|
|
6867
|
-
(
|
|
7125
|
+
(C) => C.key === "data-chai-dropdown" || C.key === "chai-dropdown"
|
|
6868
7126
|
), p = l.find(
|
|
6869
|
-
(
|
|
7127
|
+
(C) => C.key === "data-chai-dropdown-button" || C.key === "chai-dropdown-button"
|
|
6870
7128
|
), u = l.find(
|
|
6871
|
-
(
|
|
7129
|
+
(C) => C.key === "data-chai-dropdown-content" || C.key === "chai-dropdown-content"
|
|
6872
7130
|
);
|
|
6873
7131
|
if (a = {
|
|
6874
7132
|
...a,
|
|
@@ -6876,13 +7134,13 @@ const CoreBlock = ({
|
|
|
6876
7134
|
...getAttrs(r),
|
|
6877
7135
|
...getStyles(r)
|
|
6878
7136
|
}, r.attributes) {
|
|
6879
|
-
const
|
|
6880
|
-
|
|
7137
|
+
const C = r.attributes.find((S) => includes(NAME_ATTRIBUTES, S.key));
|
|
7138
|
+
C && (a._name = C.value);
|
|
6881
7139
|
}
|
|
6882
7140
|
if (i)
|
|
6883
7141
|
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
7142
|
if (c) {
|
|
6885
|
-
const
|
|
7143
|
+
const C = [
|
|
6886
7144
|
"data-chai-lightbox",
|
|
6887
7145
|
"chai-lightbox",
|
|
6888
7146
|
"data-vbtype",
|
|
@@ -6896,42 +7154,42 @@ const CoreBlock = ({
|
|
|
6896
7154
|
...a,
|
|
6897
7155
|
href: ((m = l.find((S) => S.key === "href")) == null ? void 0 : m.value) || "",
|
|
6898
7156
|
hrefType: ((f = l.find((S) => S.key === "data-vbtype")) == null ? void 0 : f.value) || "video",
|
|
6899
|
-
autoplay: ((
|
|
6900
|
-
maxWidth: ((
|
|
7157
|
+
autoplay: ((h = l.find((S) => S.key === "data-autoplay")) == null ? void 0 : h.value) === "true" ? "true" : "false",
|
|
7158
|
+
maxWidth: ((x = (b = l.find((S) => S.key === "data-maxwidth")) == null ? void 0 : b.value) == null ? void 0 : x.replace("px", "")) || "",
|
|
6901
7159
|
backdropColor: ((y = l.find((S) => S.key === "data-overlay")) == null ? void 0 : y.value) || "",
|
|
6902
|
-
galleryName: ((
|
|
6903
|
-
}, forEach(
|
|
7160
|
+
galleryName: ((A = l.find((S) => S.key === "data-gall")) == null ? void 0 : A.value) || ""
|
|
7161
|
+
}, forEach(C, (S) => {
|
|
6904
7162
|
has(a, `styles_attrs.${S}`) && delete a.styles_attrs[S];
|
|
6905
7163
|
});
|
|
6906
7164
|
}
|
|
6907
7165
|
if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
|
|
6908
7166
|
delete a.styles_attrs;
|
|
6909
|
-
const
|
|
6910
|
-
a.content = getTextContent(
|
|
7167
|
+
const C = filter(r.children || [], (B) => (B == null ? void 0 : B.tagName) !== "span");
|
|
7168
|
+
a.content = getTextContent(C);
|
|
6911
7169
|
const S = find(
|
|
6912
7170
|
r.children || [],
|
|
6913
|
-
(
|
|
7171
|
+
(B) => (B == null ? void 0 : B.tagName) === "span" && some(B.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg")
|
|
6914
7172
|
);
|
|
6915
7173
|
if (S) {
|
|
6916
|
-
const
|
|
6917
|
-
if (
|
|
6918
|
-
a.icon = stringify([
|
|
6919
|
-
const { height: _, width:
|
|
6920
|
-
a.iconHeight = _, a.iconWidth =
|
|
7174
|
+
const B = find(S.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg");
|
|
7175
|
+
if (B) {
|
|
7176
|
+
a.icon = stringify([B]);
|
|
7177
|
+
const { height: _, width: w } = getSvgDimensions(B, "16px", "16px");
|
|
7178
|
+
a.iconHeight = _, a.iconWidth = w;
|
|
6921
7179
|
}
|
|
6922
7180
|
}
|
|
6923
7181
|
return [a];
|
|
6924
7182
|
}
|
|
6925
7183
|
if (a._type === "Input") {
|
|
6926
|
-
const
|
|
6927
|
-
|
|
7184
|
+
const C = a.inputType || "text";
|
|
7185
|
+
C === "checkbox" ? set(a, "_type", "Checkbox") : C === "radio" && set(a, "_type", "Radio");
|
|
6928
7186
|
} else if (r.tagName === "video" || r.tagName === "iframe") {
|
|
6929
|
-
const
|
|
6930
|
-
return hasVideoEmbed(
|
|
7187
|
+
const C = stringify([r]);
|
|
7188
|
+
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
7189
|
} else if (r.tagName === "svg") {
|
|
6932
|
-
const
|
|
6933
|
-
return a.styles = `${STYLES_KEY}, ${cn(`w-${_} h-${
|
|
6934
|
-
} else if (r.tagName == "option" && n && ((
|
|
7190
|
+
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");
|
|
7191
|
+
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];
|
|
7192
|
+
} else if (r.tagName == "option" && n && ((j = n.block) == null ? void 0 : j._type) === "Select")
|
|
6935
7193
|
return n.block.options.push({
|
|
6936
7194
|
label: getTextContent(r.children),
|
|
6937
7195
|
...getAttrs(r)
|
|
@@ -6981,20 +7239,20 @@ const CoreBlock = ({
|
|
|
6981
7239
|
] });
|
|
6982
7240
|
}, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
6983
7241
|
var b;
|
|
6984
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (b = find(c, (
|
|
7242
|
+
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
7243
|
useEffect(() => {
|
|
6986
|
-
const
|
|
7244
|
+
const x = setTimeout(() => {
|
|
6987
7245
|
var y;
|
|
6988
7246
|
(y = u.current) == null || y.focus();
|
|
6989
7247
|
}, 0);
|
|
6990
|
-
return () => clearTimeout(
|
|
7248
|
+
return () => clearTimeout(x);
|
|
6991
7249
|
}, [g]);
|
|
6992
7250
|
const f = d ? values(n).filter(
|
|
6993
|
-
(
|
|
6994
|
-
var y,
|
|
6995
|
-
return (((y =
|
|
7251
|
+
(x) => {
|
|
7252
|
+
var y, A;
|
|
7253
|
+
return (((y = x.label) == null ? void 0 : y.toLowerCase()) + " " + ((A = x.type) == null ? void 0 : A.toLowerCase())).includes(d.toLowerCase());
|
|
6996
7254
|
}
|
|
6997
|
-
) : n,
|
|
7255
|
+
) : 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
7256
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-2xl flex-col", children: [
|
|
6999
7257
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7000
7258
|
Input$1,
|
|
@@ -7003,21 +7261,21 @@ const CoreBlock = ({
|
|
|
7003
7261
|
type: "search",
|
|
7004
7262
|
placeholder: i("Search blocks..."),
|
|
7005
7263
|
value: d,
|
|
7006
|
-
onChange: (
|
|
7264
|
+
onChange: (x) => p(x.target.value)
|
|
7007
7265
|
}
|
|
7008
7266
|
) }),
|
|
7009
|
-
/* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children:
|
|
7267
|
+
/* @__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
7268
|
i("No blocks found matching"),
|
|
7011
7269
|
' "',
|
|
7012
7270
|
d,
|
|
7013
7271
|
'"'
|
|
7014
7272
|
] }) }) : /* @__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(
|
|
7273
|
+
h,
|
|
7274
|
+
(x) => CORE_GROUPS.indexOf(x) === -1 ? 99 : CORE_GROUPS.indexOf(x)
|
|
7275
|
+
).map((x) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7276
|
+
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(x.toLowerCase())) }),
|
|
7019
7277
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: React__default.Children.toArray(
|
|
7020
|
-
reject(filter(values(f), { group:
|
|
7278
|
+
reject(filter(values(f), { group: x }), { hidden: !0 }).map((y) => /* @__PURE__ */ jsx(
|
|
7021
7279
|
CoreBlock,
|
|
7022
7280
|
{
|
|
7023
7281
|
parentId: r,
|
|
@@ -7028,7 +7286,7 @@ const CoreBlock = ({
|
|
|
7028
7286
|
y.type
|
|
7029
7287
|
))
|
|
7030
7288
|
) })
|
|
7031
|
-
] },
|
|
7289
|
+
] }, x)) }) })
|
|
7032
7290
|
] });
|
|
7033
7291
|
}, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
|
|
7034
7292
|
className: o,
|
|
@@ -7039,7 +7297,7 @@ const CoreBlock = ({
|
|
|
7039
7297
|
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), g = useCallback(() => {
|
|
7040
7298
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7041
7299
|
}, []);
|
|
7042
|
-
return /* @__PURE__ */ jsxs("div", { className: cn("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
7300
|
+
return /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
7043
7301
|
n ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
|
|
7044
7302
|
/* @__PURE__ */ jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: l("Add block") }),
|
|
7045
7303
|
/* @__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 +7336,7 @@ const CoreBlock = ({
|
|
|
7078
7336
|
const u = p.target.value;
|
|
7079
7337
|
c(u), n(u);
|
|
7080
7338
|
};
|
|
7081
|
-
return /* @__PURE__ */ jsx("div", { className: cn("relative inline-block w-full", l), children: /* @__PURE__ */ jsxs(
|
|
7339
|
+
return /* @__PURE__ */ jsx("div", { className: cn$1("relative inline-block w-full", l), children: /* @__PURE__ */ jsxs(
|
|
7082
7340
|
"select",
|
|
7083
7341
|
{
|
|
7084
7342
|
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 +7377,18 @@ const BlockCard = ({
|
|
|
7119
7377
|
parentId: r = void 0,
|
|
7120
7378
|
position: a = -1
|
|
7121
7379
|
}) => {
|
|
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 (
|
|
7380
|
+
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) => {
|
|
7381
|
+
const j = has(A, "styles_attrs.data-page-section");
|
|
7382
|
+
return A._type === "Box" && j;
|
|
7383
|
+
}, x = useCallback(
|
|
7384
|
+
async (A) => {
|
|
7385
|
+
if (A.stopPropagation(), has(o, "component")) {
|
|
7128
7386
|
d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7129
7387
|
return;
|
|
7130
7388
|
}
|
|
7131
7389
|
i(!0);
|
|
7132
|
-
const
|
|
7133
|
-
isEmpty(
|
|
7390
|
+
const j = await c(n, o);
|
|
7391
|
+
isEmpty(j) || p(syncBlocksWithDefaults(j), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7134
7392
|
},
|
|
7135
7393
|
[d, p, o, c, n, r, a]
|
|
7136
7394
|
);
|
|
@@ -7139,26 +7397,26 @@ const BlockCard = ({
|
|
|
7139
7397
|
"div",
|
|
7140
7398
|
{
|
|
7141
7399
|
onClick: l ? () => {
|
|
7142
|
-
} :
|
|
7400
|
+
} : x,
|
|
7143
7401
|
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
|
-
|
|
7402
|
+
onDragStart: async (A) => {
|
|
7403
|
+
const j = await c(n, o);
|
|
7404
|
+
let C = r;
|
|
7405
|
+
if (b(first(j)) && (C = null), !isEmpty(j)) {
|
|
7406
|
+
const S = { blocks: j, uiLibrary: !0, parent: C };
|
|
7407
|
+
if (A.dataTransfer.setData("text/plain", JSON.stringify(S)), o.preview) {
|
|
7408
|
+
const B = new Image();
|
|
7409
|
+
B.src = o.preview, B.onload = () => {
|
|
7410
|
+
A.dataTransfer.setDragImage(B, 0, 0);
|
|
7153
7411
|
};
|
|
7154
7412
|
} else
|
|
7155
|
-
|
|
7156
|
-
|
|
7413
|
+
A.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7414
|
+
h(S), setTimeout(() => {
|
|
7157
7415
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7158
7416
|
}, 200);
|
|
7159
7417
|
}
|
|
7160
7418
|
},
|
|
7161
|
-
className: clsx(
|
|
7419
|
+
className: clsx$1(
|
|
7162
7420
|
"relative mt-2 cursor-pointer overflow-hidden rounded-md border border-border bg-white duration-200 hover:border-blue-500 hover:shadow-xl"
|
|
7163
7421
|
),
|
|
7164
7422
|
children: [
|
|
@@ -7185,9 +7443,9 @@ const BlockCard = ({
|
|
|
7185
7443
|
})();
|
|
7186
7444
|
}, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
|
|
7187
7445
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
7188
|
-
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((
|
|
7446
|
+
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
7447
|
b.current && (clearTimeout(b.current), b.current = null), b.current = setTimeout(() => {
|
|
7190
|
-
b.current && f(
|
|
7448
|
+
b.current && f(C);
|
|
7191
7449
|
}, 300);
|
|
7192
7450
|
};
|
|
7193
7451
|
if (u)
|
|
@@ -7195,26 +7453,26 @@ const BlockCard = ({
|
|
|
7195
7453
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7196
7454
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7197
7455
|
] });
|
|
7198
|
-
const
|
|
7456
|
+
const A = filter(h, (C, S) => S % 2 === 0), j = filter(h, (C, S) => S % 2 === 1);
|
|
7199
7457
|
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
7458
|
/* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
7201
7459
|
/* @__PURE__ */ jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
|
|
7202
7460
|
/* @__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:
|
|
7461
|
+
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: x("Groups") }),
|
|
7204
7462
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7205
7463
|
/* @__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, (
|
|
7464
|
+
map(g, (C, S) => /* @__PURE__ */ jsxs(
|
|
7207
7465
|
"div",
|
|
7208
7466
|
{
|
|
7209
7467
|
onMouseEnter: () => y(S),
|
|
7210
7468
|
onMouseLeave: () => clearTimeout(b.current),
|
|
7211
7469
|
onClick: () => f(S),
|
|
7212
|
-
className: cn(
|
|
7470
|
+
className: cn$1(
|
|
7213
7471
|
"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
7472
|
S === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
|
|
7215
7473
|
),
|
|
7216
7474
|
children: [
|
|
7217
|
-
/* @__PURE__ */ jsx("span", { children: capitalize(
|
|
7475
|
+
/* @__PURE__ */ jsx("span", { children: capitalize(x(S.toLowerCase())) }),
|
|
7218
7476
|
/* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
|
|
7219
7477
|
]
|
|
7220
7478
|
},
|
|
@@ -7231,10 +7489,10 @@ const BlockCard = ({
|
|
|
7231
7489
|
children: [
|
|
7232
7490
|
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
|
|
7233
7491
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
7234
|
-
|
|
7492
|
+
A.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
|
|
7235
7493
|
) }),
|
|
7236
7494
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
7237
|
-
|
|
7495
|
+
j.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
|
|
7238
7496
|
) })
|
|
7239
7497
|
] }),
|
|
7240
7498
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -7454,53 +7712,53 @@ function BiExpandVertical(o) {
|
|
|
7454
7712
|
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
7713
|
}
|
|
7456
7714
|
const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
7457
|
-
var
|
|
7715
|
+
var P;
|
|
7458
7716
|
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
|
|
7459
7717
|
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 ||
|
|
7718
|
+
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) => {
|
|
7719
|
+
E.stopPropagation(), !i.includes(f) && o.toggle();
|
|
7720
|
+
}, S = (E) => {
|
|
7721
|
+
E.isInternal && (p = E.isOpen, E.isOpen && E.close());
|
|
7722
|
+
}, B = (E) => {
|
|
7723
|
+
E.isInternal && p !== null && (p ? E.open() : E.close(), p = null);
|
|
7724
|
+
}, [_, w] = useAtom$1(currentAddSelection), T = () => {
|
|
7725
|
+
var E;
|
|
7726
|
+
k(), o.parent.isSelected || w((E = o == null ? void 0 : o.parent) == null ? void 0 : E.id);
|
|
7469
7727
|
}, k = () => {
|
|
7470
|
-
|
|
7471
|
-
}, v = (
|
|
7472
|
-
k(),
|
|
7728
|
+
w(null);
|
|
7729
|
+
}, v = (E) => {
|
|
7730
|
+
k(), E.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(), j(E);
|
|
7473
7731
|
};
|
|
7474
7732
|
useEffect(() => {
|
|
7475
|
-
const
|
|
7476
|
-
|
|
7733
|
+
const E = setTimeout(() => {
|
|
7734
|
+
x && !o.isOpen && !y && !i.includes(f) && o.toggle();
|
|
7477
7735
|
}, 500);
|
|
7478
|
-
return () => clearTimeout(
|
|
7479
|
-
}, [
|
|
7736
|
+
return () => clearTimeout(E);
|
|
7737
|
+
}, [x, o, y]);
|
|
7480
7738
|
const N = useMemo(() => {
|
|
7481
|
-
const
|
|
7482
|
-
for (let M = 0; M <
|
|
7483
|
-
if (
|
|
7484
|
-
const
|
|
7485
|
-
|
|
7739
|
+
const E = Object.keys(h), D = [];
|
|
7740
|
+
for (let M = 0; M < E.length; M++)
|
|
7741
|
+
if (E[M].endsWith("_attrs")) {
|
|
7742
|
+
const R = h[E[M]], O = Object.keys(R).join("|");
|
|
7743
|
+
O.match(/x-data/) && D.push("data"), O.match(/x-on/) && D.push("event"), O.match(/x-show|x-if/) && D.push("show");
|
|
7486
7744
|
}
|
|
7487
|
-
return
|
|
7488
|
-
}, [
|
|
7489
|
-
const M = d.contentDocument || d.contentWindow.document,
|
|
7490
|
-
|
|
7491
|
-
const
|
|
7492
|
-
|
|
7493
|
-
},
|
|
7745
|
+
return D;
|
|
7746
|
+
}, [h]), I = (E, D) => {
|
|
7747
|
+
const M = d.contentDocument || d.contentWindow.document, R = M.querySelector(`[data-block-id=${E}]`);
|
|
7748
|
+
R && R.setAttribute("data-drop", D);
|
|
7749
|
+
const O = R.getBoundingClientRect(), $ = d.getBoundingClientRect();
|
|
7750
|
+
O.top >= $.top && O.left >= $.left && O.bottom <= $.bottom && O.right <= $.right || (M.documentElement.scrollTop = R.offsetTop - $.top);
|
|
7751
|
+
}, L = (E) => {
|
|
7494
7752
|
k();
|
|
7495
|
-
const
|
|
7496
|
-
|
|
7753
|
+
const D = get(o, "parent.id");
|
|
7754
|
+
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
7755
|
};
|
|
7498
7756
|
return f === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
|
|
7499
7757
|
/* @__PURE__ */ jsx("br", {}),
|
|
7500
7758
|
/* @__PURE__ */ jsx(
|
|
7501
7759
|
"div",
|
|
7502
7760
|
{
|
|
7503
|
-
onClick: () =>
|
|
7761
|
+
onClick: () => L(-1),
|
|
7504
7762
|
className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
|
|
7505
7763
|
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
7764
|
/* @__PURE__ */ jsx(PlusIcon$1, { className: "h-2 w-2 stroke-[3]" }),
|
|
@@ -7520,22 +7778,22 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7520
7778
|
"data-node-id": f,
|
|
7521
7779
|
ref: i.includes(f) ? null : r,
|
|
7522
7780
|
onDragStart: () => S(o),
|
|
7523
|
-
onDragEnd: () =>
|
|
7524
|
-
onDragOver: (
|
|
7525
|
-
|
|
7781
|
+
onDragEnd: () => B(o),
|
|
7782
|
+
onDragOver: (E) => {
|
|
7783
|
+
E.preventDefault(), I(f, "yes");
|
|
7526
7784
|
},
|
|
7527
|
-
onDragLeave: (
|
|
7528
|
-
|
|
7785
|
+
onDragLeave: (E) => {
|
|
7786
|
+
E.preventDefault(), I(f, "no");
|
|
7529
7787
|
},
|
|
7530
|
-
onDrop: (
|
|
7531
|
-
|
|
7788
|
+
onDrop: (E) => {
|
|
7789
|
+
E.preventDefault(), I(f, "no");
|
|
7532
7790
|
},
|
|
7533
7791
|
children: [
|
|
7534
|
-
(o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((
|
|
7792
|
+
(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
7793
|
"div",
|
|
7536
7794
|
{
|
|
7537
|
-
onClick: (
|
|
7538
|
-
|
|
7795
|
+
onClick: (E) => {
|
|
7796
|
+
E.stopPropagation(), L(o.childIndex);
|
|
7539
7797
|
},
|
|
7540
7798
|
onMouseEnter: T,
|
|
7541
7799
|
onMouseLeave: k,
|
|
@@ -7546,10 +7804,10 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7546
7804
|
/* @__PURE__ */ jsxs(
|
|
7547
7805
|
"div",
|
|
7548
7806
|
{
|
|
7549
|
-
className: cn(
|
|
7807
|
+
className: cn$1(
|
|
7550
7808
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
|
|
7551
7809
|
b ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
|
|
7552
|
-
|
|
7810
|
+
x && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
|
|
7553
7811
|
(o == null ? void 0 : o.id) === _ ? "bg-purple-100" : "",
|
|
7554
7812
|
y && "opacity-20",
|
|
7555
7813
|
i.includes(f) ? "opacity-50" : ""
|
|
@@ -7560,7 +7818,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7560
7818
|
"div",
|
|
7561
7819
|
{
|
|
7562
7820
|
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:
|
|
7821
|
+
children: u && /* @__PURE__ */ jsx("button", { onClick: C, type: "button", children: /* @__PURE__ */ jsx(
|
|
7564
7822
|
ChevronRight,
|
|
7565
7823
|
{
|
|
7566
7824
|
className: `h-3 w-3 stroke-[3] ${b ? "text-slate-200" : "text-slate-400"}`
|
|
@@ -7569,16 +7827,16 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7569
7827
|
}
|
|
7570
7828
|
),
|
|
7571
7829
|
/* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
|
|
7572
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
7573
|
-
|
|
7830
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
|
|
7831
|
+
A ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
|
|
7574
7832
|
"div",
|
|
7575
7833
|
{
|
|
7576
7834
|
className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
|
|
7577
|
-
onDoubleClick: (
|
|
7578
|
-
|
|
7835
|
+
onDoubleClick: (E) => {
|
|
7836
|
+
E.stopPropagation(), o.edit(), o.deselect();
|
|
7579
7837
|
},
|
|
7580
7838
|
children: [
|
|
7581
|
-
/* @__PURE__ */ jsx("span", { children: (
|
|
7839
|
+
/* @__PURE__ */ jsx("span", { children: (h == null ? void 0 : h._name) || (h == null ? void 0 : h._type.split("/").pop()) }),
|
|
7582
7840
|
N.includes("data") && /* @__PURE__ */ jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
|
|
7583
7841
|
N.includes("event") && /* @__PURE__ */ jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
|
|
7584
7842
|
N.includes("show") && /* @__PURE__ */ jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
|
|
@@ -7588,18 +7846,18 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7588
7846
|
] })
|
|
7589
7847
|
] }),
|
|
7590
7848
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
7591
|
-
!i.includes(f) && a.map((
|
|
7849
|
+
!i.includes(f) && a.map((E) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7592
7850
|
/* @__PURE__ */ jsx(
|
|
7593
7851
|
TooltipTrigger,
|
|
7594
7852
|
{
|
|
7595
7853
|
className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
|
|
7596
7854
|
asChild: !0,
|
|
7597
|
-
children: React__default.createElement(
|
|
7855
|
+
children: React__default.createElement(E.item, { blockId: f })
|
|
7598
7856
|
}
|
|
7599
7857
|
),
|
|
7600
|
-
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children:
|
|
7858
|
+
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: E.tooltip })
|
|
7601
7859
|
] })),
|
|
7602
|
-
canAddChildBlock(
|
|
7860
|
+
canAddChildBlock(h == null ? void 0 : h._type) && !i.includes(f) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7603
7861
|
/* @__PURE__ */ jsx(
|
|
7604
7862
|
TooltipTrigger,
|
|
7605
7863
|
{
|
|
@@ -7615,8 +7873,8 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7615
7873
|
/* @__PURE__ */ jsx(
|
|
7616
7874
|
TooltipTrigger,
|
|
7617
7875
|
{
|
|
7618
|
-
onClick: (
|
|
7619
|
-
|
|
7876
|
+
onClick: (E) => {
|
|
7877
|
+
E.stopPropagation(), c(f), o.isOpen && o.toggle();
|
|
7620
7878
|
},
|
|
7621
7879
|
className: "cursor-pointer rounded bg-transparent hover:text-black",
|
|
7622
7880
|
asChild: !0,
|
|
@@ -7638,7 +7896,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7638
7896
|
"input",
|
|
7639
7897
|
{
|
|
7640
7898
|
autoFocus: !0,
|
|
7641
|
-
className: cn(
|
|
7899
|
+
className: cn$1(
|
|
7642
7900
|
"ml-2 !h-4 w-full rounded-sm border border-border bg-background px-1 text-[11px] leading-tight outline-none",
|
|
7643
7901
|
o.isSelected ? "text-black dark:text-white" : ""
|
|
7644
7902
|
),
|
|
@@ -7737,7 +7995,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7737
7995
|
t("Add Block")
|
|
7738
7996
|
] })
|
|
7739
7997
|
] }) }) }) : /* @__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(
|
|
7998
|
+
/* @__PURE__ */ jsx("div", { className: cn$1("flex h-full select-none flex-col space-y-1"), onClick: () => clearSelection(), children: /* @__PURE__ */ jsxs(
|
|
7741
7999
|
"div",
|
|
7742
8000
|
{
|
|
7743
8001
|
id: "outline-view",
|
|
@@ -8281,9 +8539,9 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8281
8539
|
var b;
|
|
8282
8540
|
(b = m.current) == null || b.focus();
|
|
8283
8541
|
}, []);
|
|
8284
|
-
const
|
|
8285
|
-
const { usage:
|
|
8286
|
-
!l &&
|
|
8542
|
+
const h = (b) => {
|
|
8543
|
+
const { usage: x } = b || {};
|
|
8544
|
+
!l && x && g(x), f.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
8287
8545
|
};
|
|
8288
8546
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
8289
8547
|
/* @__PURE__ */ jsxs(
|
|
@@ -8308,7 +8566,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8308
8566
|
className: "w-full",
|
|
8309
8567
|
rows: 3,
|
|
8310
8568
|
onKeyDown: (b) => {
|
|
8311
|
-
b.key === "Enter" && (b.preventDefault(), f.current && clearTimeout(f.current), g(void 0), r("content", o, i,
|
|
8569
|
+
b.key === "Enter" && (b.preventDefault(), f.current && clearTimeout(f.current), g(void 0), r("content", o, i, h));
|
|
8312
8570
|
}
|
|
8313
8571
|
}
|
|
8314
8572
|
),
|
|
@@ -8318,7 +8576,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8318
8576
|
{
|
|
8319
8577
|
disabled: i.trim().length < 5 || a,
|
|
8320
8578
|
onClick: () => {
|
|
8321
|
-
f.current && clearTimeout(f.current), g(void 0), r("content", o, i,
|
|
8579
|
+
f.current && clearTimeout(f.current), g(void 0), r("content", o, i, h);
|
|
8322
8580
|
},
|
|
8323
8581
|
variant: "default",
|
|
8324
8582
|
className: "w-fit",
|
|
@@ -8351,7 +8609,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8351
8609
|
QuickPrompts,
|
|
8352
8610
|
{
|
|
8353
8611
|
onClick: (b) => {
|
|
8354
|
-
f.current && clearTimeout(f.current), g(void 0), r("content", o, b,
|
|
8612
|
+
f.current && clearTimeout(f.current), g(void 0), r("content", o, b, h);
|
|
8355
8613
|
}
|
|
8356
8614
|
}
|
|
8357
8615
|
)
|
|
@@ -8368,8 +8626,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8368
8626
|
const f = async () => {
|
|
8369
8627
|
try {
|
|
8370
8628
|
d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
|
|
8371
|
-
} catch (
|
|
8372
|
-
u(
|
|
8629
|
+
} catch (h) {
|
|
8630
|
+
u(h);
|
|
8373
8631
|
} finally {
|
|
8374
8632
|
d(!1);
|
|
8375
8633
|
}
|
|
@@ -8377,8 +8635,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8377
8635
|
return /* @__PURE__ */ jsx(
|
|
8378
8636
|
Accordion,
|
|
8379
8637
|
{
|
|
8380
|
-
onValueChange: (
|
|
8381
|
-
g(
|
|
8638
|
+
onValueChange: (h) => {
|
|
8639
|
+
g(h !== "");
|
|
8382
8640
|
},
|
|
8383
8641
|
type: "single",
|
|
8384
8642
|
collapsible: !0,
|
|
@@ -8390,12 +8648,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8390
8648
|
{
|
|
8391
8649
|
ref: l,
|
|
8392
8650
|
value: r,
|
|
8393
|
-
onChange: (
|
|
8651
|
+
onChange: (h) => a(h.target.value),
|
|
8394
8652
|
placeholder: o("Tell about this page eg this page is about"),
|
|
8395
8653
|
className: "mt-1 w-full",
|
|
8396
8654
|
rows: 10,
|
|
8397
|
-
onKeyDown: (
|
|
8398
|
-
|
|
8655
|
+
onKeyDown: (h) => {
|
|
8656
|
+
h.key === "Enter" && (h.preventDefault(), f());
|
|
8399
8657
|
}
|
|
8400
8658
|
}
|
|
8401
8659
|
),
|
|
@@ -8559,7 +8817,7 @@ const AiAssistant = () => {
|
|
|
8559
8817
|
}, DataBinding = () => {
|
|
8560
8818
|
const o = usePageExternalData(), [n, r] = useAtom$1(dataBindingActiveAtom), { t: a } = useTranslation();
|
|
8561
8819
|
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") }) }) }),
|
|
8820
|
+
/* @__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
8821
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: a("Toggle Data Binding") }) })
|
|
8564
8822
|
] }) });
|
|
8565
8823
|
}, CanvasTopBar = () => {
|
|
@@ -8590,11 +8848,11 @@ const AiAssistant = () => {
|
|
|
8590
8848
|
] })
|
|
8591
8849
|
] });
|
|
8592
8850
|
}, 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(""),
|
|
8851
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, f] = useState(""), h = useRef(null), b = useRef(null);
|
|
8594
8852
|
useEffect(() => {
|
|
8595
8853
|
l(n);
|
|
8596
8854
|
}, [n]);
|
|
8597
|
-
const
|
|
8855
|
+
const x = () => {
|
|
8598
8856
|
if (i.startsWith("@")) {
|
|
8599
8857
|
f("Attribute keys cannot start with '@'");
|
|
8600
8858
|
return;
|
|
@@ -8604,11 +8862,11 @@ const AiAssistant = () => {
|
|
|
8604
8862
|
r(S), l(a), c(""), p(""), f("");
|
|
8605
8863
|
}
|
|
8606
8864
|
}, y = (S) => {
|
|
8607
|
-
const
|
|
8608
|
-
r(
|
|
8609
|
-
},
|
|
8865
|
+
const B = a.filter((_, w) => w !== S);
|
|
8866
|
+
r(B), l(B);
|
|
8867
|
+
}, A = (S) => {
|
|
8610
8868
|
g(S), c(a[S].key), p(a[S].value);
|
|
8611
|
-
},
|
|
8869
|
+
}, j = () => {
|
|
8612
8870
|
if (i.startsWith("@")) {
|
|
8613
8871
|
f("Attribute keys cannot start with '@'");
|
|
8614
8872
|
return;
|
|
@@ -8623,7 +8881,7 @@ const AiAssistant = () => {
|
|
|
8623
8881
|
"form",
|
|
8624
8882
|
{
|
|
8625
8883
|
onSubmit: (S) => {
|
|
8626
|
-
S.preventDefault(), u !== null ?
|
|
8884
|
+
S.preventDefault(), u !== null ? j() : x();
|
|
8627
8885
|
},
|
|
8628
8886
|
className: "space-y-3",
|
|
8629
8887
|
children: [
|
|
@@ -8637,7 +8895,7 @@ const AiAssistant = () => {
|
|
|
8637
8895
|
autoCorrect: "off",
|
|
8638
8896
|
spellCheck: "false",
|
|
8639
8897
|
id: "attrKey",
|
|
8640
|
-
ref:
|
|
8898
|
+
ref: h,
|
|
8641
8899
|
value: i,
|
|
8642
8900
|
onChange: (S) => c(S.target.value),
|
|
8643
8901
|
placeholder: "Enter Key",
|
|
@@ -8659,7 +8917,7 @@ const AiAssistant = () => {
|
|
|
8659
8917
|
value: d,
|
|
8660
8918
|
onChange: (S) => p(S.target.value),
|
|
8661
8919
|
onKeyDown: (S) => {
|
|
8662
|
-
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ?
|
|
8920
|
+
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? j() : x());
|
|
8663
8921
|
},
|
|
8664
8922
|
placeholder: "Enter Value",
|
|
8665
8923
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
@@ -8672,16 +8930,16 @@ const AiAssistant = () => {
|
|
|
8672
8930
|
]
|
|
8673
8931
|
}
|
|
8674
8932
|
),
|
|
8675
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S,
|
|
8933
|
+
/* @__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
8934
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
8677
8935
|
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
|
|
8678
8936
|
/* @__PURE__ */ jsx("span", { className: "text-wrap max-w-[200px] font-normal", children: S.value.toString() })
|
|
8679
8937
|
] }),
|
|
8680
8938
|
/* @__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(
|
|
8939
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(B), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
|
|
8940
|
+
/* @__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
8941
|
] })
|
|
8684
|
-
] },
|
|
8942
|
+
] }, B)) })
|
|
8685
8943
|
] });
|
|
8686
8944
|
}), BlockAttributesEditor = React.memo(() => {
|
|
8687
8945
|
const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
|
|
@@ -8879,8 +9137,8 @@ const RootLayout = () => {
|
|
|
8879
9137
|
b.preventDefault();
|
|
8880
9138
|
}, u = (b) => {
|
|
8881
9139
|
n(o === b ? null : b);
|
|
8882
|
-
}, g = useSidebarMenuItems(), { t: m } = useTranslation(), f = [...g, ...c],
|
|
8883
|
-
return /* @__PURE__ */ jsx("div", { dir:
|
|
9140
|
+
}, g = useSidebarMenuItems(), { t: m } = useTranslation(), f = [...g, ...c], h = useBuilderProp("htmlDir", "ltr");
|
|
9141
|
+
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
9142
|
/* @__PURE__ */ jsxs(
|
|
8885
9143
|
"div",
|
|
8886
9144
|
{
|
|
@@ -8890,21 +9148,21 @@ const RootLayout = () => {
|
|
|
8890
9148
|
/* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
|
|
8891
9149
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
8892
9150
|
/* @__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,
|
|
9151
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: f.map((b, x) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8894
9152
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
8895
9153
|
Button,
|
|
8896
9154
|
{
|
|
8897
|
-
variant: o ===
|
|
9155
|
+
variant: o === x ? "default" : "ghost",
|
|
8898
9156
|
className: "mb-2 rounded-lg p-2 transition-colors",
|
|
8899
|
-
onClick: () => u(
|
|
9157
|
+
onClick: () => u(x),
|
|
8900
9158
|
children: get(b, "icon", null)
|
|
8901
9159
|
},
|
|
8902
|
-
|
|
9160
|
+
x
|
|
8903
9161
|
) }),
|
|
8904
9162
|
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(b.label) }) })
|
|
8905
|
-
] }, "button" +
|
|
9163
|
+
] }, "button" + x)) }),
|
|
8906
9164
|
/* @__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,
|
|
9165
|
+
/* @__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
9166
|
] }),
|
|
8909
9167
|
/* @__PURE__ */ jsx(
|
|
8910
9168
|
motion.div,
|
|
@@ -8973,7 +9231,7 @@ const RootLayout = () => {
|
|
|
8973
9231
|
] }) });
|
|
8974
9232
|
}, PreviewScreen = () => {
|
|
8975
9233
|
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: [
|
|
9234
|
+
return o ? /* @__PURE__ */ jsxs("div", { className: cn$1("fixed inset-0 z-[999] bg-background", o ? "block" : "hidden"), children: [
|
|
8977
9235
|
/* @__PURE__ */ jsxs(Button, { size: "sm", className: "absolute right-0 top-0 m-4 space-x-2", onClick: () => n(!1), children: [
|
|
8978
9236
|
/* @__PURE__ */ jsx(EyeClosedIcon, {}),
|
|
8979
9237
|
/* @__PURE__ */ jsx("span", { children: r("Close Preview") })
|
|
@@ -9069,9 +9327,9 @@ export {
|
|
|
9069
9327
|
generateUUID as generateBlockId,
|
|
9070
9328
|
getBlocksFromHTML,
|
|
9071
9329
|
getClassValueAndUnit,
|
|
9072
|
-
|
|
9073
|
-
cn as mergeClasses,
|
|
9074
|
-
|
|
9330
|
+
We as i18n,
|
|
9331
|
+
cn$1 as mergeClasses,
|
|
9332
|
+
Fe as registerChaiBlock,
|
|
9075
9333
|
useAddBlock,
|
|
9076
9334
|
useAddClassesToBlocks,
|
|
9077
9335
|
useAskAi,
|
|
@@ -9114,7 +9372,7 @@ export {
|
|
|
9114
9372
|
useStylingState,
|
|
9115
9373
|
useTheme,
|
|
9116
9374
|
useThemeOptions,
|
|
9117
|
-
|
|
9375
|
+
Ve as useTranslation,
|
|
9118
9376
|
useUILibraryBlocks,
|
|
9119
9377
|
useUndoManager,
|
|
9120
9378
|
useUpdateBlocksProps,
|