@chaibuilder/sdk 2.0.0-beta.104 → 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/{CodeEditor-DyWk02_x.js → CodeEditor-Bv7cAp6l.js} +1 -1
- package/dist/CodeEditor-ol63c03C.cjs +1 -0
- package/dist/{Topbar-BuWEmzZG.js → Topbar-DutZ_viX.js} +1 -1
- package/dist/Topbar-lIu26u9Y.cjs +1 -0
- package/dist/core.cjs +10 -5
- package/dist/core.d.ts +1 -1
- package/dist/core.js +1180 -932
- package/dist/sdk.css +1 -6
- package/dist/tooltip-CuxBhGWF.js +763 -0
- package/dist/tooltip-DHlrjqh8.cjs +1 -0
- package/dist/ui.cjs +1 -1
- package/dist/ui.d.ts +7 -65
- package/dist/ui.js +76 -79
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +92 -88
- package/package.json +10 -2
- package/dist/CodeEditor-BQTYQosF.cjs +0 -1
- package/dist/Topbar-BhwvnJJc.cjs +0 -1
- package/dist/context-menu-CeqJxblw.cjs +0 -1
- package/dist/context-menu-iqXuo9Yt.js +0 -907
package/dist/core.js
CHANGED
|
@@ -1,47 +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 {
|
|
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
|
-
import {
|
|
25
|
-
import
|
|
24
|
+
import { toast } from "sonner";
|
|
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";
|
|
26
30
|
import typography from "@tailwindcss/typography";
|
|
27
31
|
import forms from "@tailwindcss/forms";
|
|
28
32
|
import aspectRatio from "@tailwindcss/aspect-ratio";
|
|
29
33
|
import containerQueries from "@tailwindcss/container-queries";
|
|
30
|
-
import { twMerge } from "tailwind-merge";
|
|
31
34
|
import { S as STYLES_KEY, g as getSplitChaiClasses, R as ROOT_TEMP_KEY } from "./getSplitClasses-DphwgQiE.js";
|
|
32
35
|
import ReactDOM from "react-dom";
|
|
33
36
|
import { ErrorBoundary } from "react-error-boundary";
|
|
34
37
|
import { Resizable } from "re-resizable";
|
|
35
38
|
import RjForm from "@rjsf/core";
|
|
36
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";
|
|
37
43
|
import IconPicker, { IconPickerItem } from "react-icons-picker";
|
|
38
44
|
import Autosuggest from "react-autosuggest";
|
|
39
45
|
import Fuse from "fuse.js";
|
|
40
46
|
import { parse, stringify } from "himalaya";
|
|
41
|
-
import clsx from "clsx";
|
|
42
47
|
import { Tree } from "react-arborist";
|
|
43
48
|
import i18n from "i18next";
|
|
44
|
-
import { default as
|
|
49
|
+
import { default as We } from "i18next";
|
|
45
50
|
import { motion } from "framer-motion";
|
|
46
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) => {
|
|
47
52
|
if ("e" in o)
|
|
@@ -89,37 +94,37 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
89
94
|
for (const i of n.p)
|
|
90
95
|
l.add(i);
|
|
91
96
|
return l;
|
|
92
|
-
}, 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, ...
|
|
93
|
-
var
|
|
94
|
-
return (
|
|
95
|
-
}, g = (f,
|
|
96
|
-
var
|
|
97
|
-
return (
|
|
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) => {
|
|
98
|
+
var b;
|
|
99
|
+
return (b = f.unstable_onInit) == null ? void 0 : b.call(f, h);
|
|
100
|
+
}, g = (f, h) => {
|
|
101
|
+
var b;
|
|
102
|
+
return (b = f.onMount) == null ? void 0 : b.call(f, h);
|
|
98
103
|
}, ...m) => {
|
|
99
|
-
const f = m[0] || ((
|
|
100
|
-
let T = o.get(
|
|
101
|
-
return T || (T = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(
|
|
102
|
-
}),
|
|
103
|
-
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;
|
|
104
109
|
const k = (v) => {
|
|
105
110
|
try {
|
|
106
111
|
v();
|
|
107
112
|
} catch (N) {
|
|
108
|
-
|
|
113
|
+
w || (w = !0, T = N);
|
|
109
114
|
}
|
|
110
115
|
};
|
|
111
116
|
do {
|
|
112
117
|
c.f && k(c.f);
|
|
113
118
|
const v = /* @__PURE__ */ new Set(), N = v.add.bind(v);
|
|
114
119
|
a.forEach((I) => {
|
|
115
|
-
var
|
|
116
|
-
return (
|
|
117
|
-
}), a.clear(), i.forEach(N), i.clear(), l.forEach(N), l.clear(), v.forEach(k), a.size &&
|
|
120
|
+
var L;
|
|
121
|
+
return (L = n.get(I)) == null ? void 0 : L.l.forEach(N);
|
|
122
|
+
}), a.clear(), i.forEach(N), i.clear(), l.forEach(N), l.clear(), v.forEach(k), a.size && b();
|
|
118
123
|
} while (a.size || i.size || l.size);
|
|
119
|
-
if (
|
|
124
|
+
if (w)
|
|
120
125
|
throw T;
|
|
121
|
-
}),
|
|
122
|
-
const
|
|
126
|
+
}), b = m[2] || (() => {
|
|
127
|
+
const w = [], T = /* @__PURE__ */ new WeakSet(), k = /* @__PURE__ */ new WeakSet(), v = Array.from(a);
|
|
123
128
|
for (; v.length; ) {
|
|
124
129
|
const N = v[v.length - 1], I = f(N);
|
|
125
130
|
if (k.has(N)) {
|
|
@@ -127,85 +132,85 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
127
132
|
continue;
|
|
128
133
|
}
|
|
129
134
|
if (T.has(N)) {
|
|
130
|
-
r.get(N) === I.n &&
|
|
135
|
+
r.get(N) === I.n && w.push([N, I]), k.add(N), v.pop();
|
|
131
136
|
continue;
|
|
132
137
|
}
|
|
133
138
|
T.add(N);
|
|
134
|
-
for (const
|
|
135
|
-
T.has(
|
|
139
|
+
for (const L of getMountedOrPendingDependents(N, I, n))
|
|
140
|
+
T.has(L) || v.push(L);
|
|
136
141
|
}
|
|
137
|
-
for (let N =
|
|
138
|
-
const [I,
|
|
142
|
+
for (let N = w.length - 1; N >= 0; --N) {
|
|
143
|
+
const [I, L] = w[N];
|
|
139
144
|
let P = !1;
|
|
140
|
-
for (const
|
|
141
|
-
if (
|
|
145
|
+
for (const E of L.d.keys())
|
|
146
|
+
if (E !== I && a.has(E)) {
|
|
142
147
|
P = !0;
|
|
143
148
|
break;
|
|
144
149
|
}
|
|
145
|
-
P && (
|
|
150
|
+
P && (x(I), j(I)), r.delete(I);
|
|
146
151
|
}
|
|
147
|
-
}),
|
|
152
|
+
}), x = m[3] || ((w) => {
|
|
148
153
|
var T, k;
|
|
149
|
-
const v = f(
|
|
150
|
-
if (isAtomStateInitialized(v) && (n.has(
|
|
151
|
-
([
|
|
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]) => (
|
|
152
157
|
// Recursively, read the atom state of the dependency, and
|
|
153
158
|
// check if the atom epoch number is unchanged
|
|
154
|
-
|
|
159
|
+
x(R).n === O
|
|
155
160
|
)
|
|
156
161
|
)))
|
|
157
162
|
return v;
|
|
158
163
|
v.d.clear();
|
|
159
164
|
let N = !0;
|
|
160
165
|
const I = () => {
|
|
161
|
-
n.has(
|
|
162
|
-
},
|
|
163
|
-
var
|
|
164
|
-
if (isSelfAtom(
|
|
165
|
-
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);
|
|
166
171
|
if (!isAtomStateInitialized(H))
|
|
167
|
-
if (hasInitialValue(
|
|
168
|
-
setAtomStateValueOrPromise(
|
|
172
|
+
if (hasInitialValue(R))
|
|
173
|
+
setAtomStateValueOrPromise(R, R.init, f);
|
|
169
174
|
else
|
|
170
175
|
throw new Error("no atom init");
|
|
171
176
|
return returnAtomValue(H);
|
|
172
177
|
}
|
|
173
|
-
const
|
|
178
|
+
const $ = x(R);
|
|
174
179
|
try {
|
|
175
|
-
return returnAtomValue(
|
|
180
|
+
return returnAtomValue($);
|
|
176
181
|
} finally {
|
|
177
|
-
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();
|
|
178
183
|
}
|
|
179
184
|
};
|
|
180
|
-
let P,
|
|
181
|
-
const
|
|
185
|
+
let P, E;
|
|
186
|
+
const D = {
|
|
182
187
|
get signal() {
|
|
183
188
|
return P || (P = new AbortController()), P.signal;
|
|
184
189
|
},
|
|
185
190
|
get setSelf() {
|
|
186
|
-
return !
|
|
191
|
+
return !E && isActuallyWritableAtom(w) && (E = (...R) => {
|
|
187
192
|
if (!N)
|
|
188
193
|
try {
|
|
189
|
-
return
|
|
194
|
+
return A(w, ...R);
|
|
190
195
|
} finally {
|
|
191
|
-
|
|
196
|
+
b(), h();
|
|
192
197
|
}
|
|
193
|
-
}),
|
|
198
|
+
}), E;
|
|
194
199
|
}
|
|
195
|
-
},
|
|
200
|
+
}, M = v.n;
|
|
196
201
|
try {
|
|
197
|
-
const
|
|
198
|
-
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(
|
|
199
204
|
I,
|
|
200
205
|
I
|
|
201
206
|
)), v;
|
|
202
|
-
} catch (
|
|
203
|
-
return delete v.v, v.e =
|
|
207
|
+
} catch (R) {
|
|
208
|
+
return delete v.v, v.e = R, ++v.n, v;
|
|
204
209
|
} finally {
|
|
205
|
-
N = !1,
|
|
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));
|
|
206
211
|
}
|
|
207
|
-
}), y = m[4] || ((
|
|
208
|
-
const T = [
|
|
212
|
+
}), y = m[4] || ((w) => {
|
|
213
|
+
const T = [w];
|
|
209
214
|
for (; T.length; ) {
|
|
210
215
|
const k = T.pop(), v = f(k);
|
|
211
216
|
for (const N of getMountedOrPendingDependents(k, v, n)) {
|
|
@@ -213,69 +218,69 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
213
218
|
r.set(N, I.n), T.push(N);
|
|
214
219
|
}
|
|
215
220
|
}
|
|
216
|
-
}),
|
|
221
|
+
}), A = m[5] || ((w, ...T) => {
|
|
217
222
|
let k = !0;
|
|
218
|
-
const v = (I) => returnAtomValue(
|
|
223
|
+
const v = (I) => returnAtomValue(x(I)), N = (I, ...L) => {
|
|
219
224
|
var P;
|
|
220
|
-
const
|
|
225
|
+
const E = f(I);
|
|
221
226
|
try {
|
|
222
|
-
if (isSelfAtom(
|
|
227
|
+
if (isSelfAtom(w, I)) {
|
|
223
228
|
if (!hasInitialValue(I))
|
|
224
229
|
throw new Error("atom not writable");
|
|
225
|
-
const
|
|
226
|
-
setAtomStateValueOrPromise(I,
|
|
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));
|
|
227
232
|
return;
|
|
228
233
|
} else
|
|
229
|
-
return
|
|
234
|
+
return A(I, ...L);
|
|
230
235
|
} finally {
|
|
231
|
-
k || (
|
|
236
|
+
k || (b(), h());
|
|
232
237
|
}
|
|
233
238
|
};
|
|
234
239
|
try {
|
|
235
|
-
return p(
|
|
240
|
+
return p(w, v, N, ...T);
|
|
236
241
|
} finally {
|
|
237
242
|
k = !1;
|
|
238
243
|
}
|
|
239
|
-
}),
|
|
244
|
+
}), j = m[6] || ((w) => {
|
|
240
245
|
var T;
|
|
241
|
-
const k = f(
|
|
246
|
+
const k = f(w), v = n.get(w);
|
|
242
247
|
if (v && !isPendingPromise(k.v)) {
|
|
243
248
|
for (const [N, I] of k.d)
|
|
244
249
|
if (!v.d.has(N)) {
|
|
245
|
-
const
|
|
246
|
-
|
|
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));
|
|
247
252
|
}
|
|
248
253
|
for (const N of v.d || [])
|
|
249
254
|
if (!k.d.has(N)) {
|
|
250
255
|
v.d.delete(N);
|
|
251
256
|
const I = S(N);
|
|
252
|
-
I == null || I.t.delete(
|
|
257
|
+
I == null || I.t.delete(w);
|
|
253
258
|
}
|
|
254
259
|
}
|
|
255
|
-
}),
|
|
260
|
+
}), C = m[7] || ((w) => {
|
|
256
261
|
var T;
|
|
257
|
-
const k = f(
|
|
258
|
-
let v = n.get(
|
|
262
|
+
const k = f(w);
|
|
263
|
+
let v = n.get(w);
|
|
259
264
|
if (!v) {
|
|
260
|
-
|
|
265
|
+
x(w);
|
|
261
266
|
for (const N of k.d.keys())
|
|
262
|
-
|
|
267
|
+
C(N).t.add(w);
|
|
263
268
|
if (v = {
|
|
264
269
|
l: /* @__PURE__ */ new Set(),
|
|
265
270
|
d: new Set(k.d.keys()),
|
|
266
271
|
t: /* @__PURE__ */ new Set()
|
|
267
|
-
}, n.set(
|
|
272
|
+
}, n.set(w, v), (T = c.m) == null || T.call(c, w), isActuallyWritableAtom(w)) {
|
|
268
273
|
const N = () => {
|
|
269
274
|
let I = !0;
|
|
270
|
-
const
|
|
275
|
+
const L = (...P) => {
|
|
271
276
|
try {
|
|
272
|
-
return
|
|
277
|
+
return A(w, ...P);
|
|
273
278
|
} finally {
|
|
274
|
-
I || (
|
|
279
|
+
I || (b(), h());
|
|
275
280
|
}
|
|
276
281
|
};
|
|
277
282
|
try {
|
|
278
|
-
const P = g(
|
|
283
|
+
const P = g(w, L);
|
|
279
284
|
P && (v.u = () => {
|
|
280
285
|
I = !0;
|
|
281
286
|
try {
|
|
@@ -292,23 +297,23 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
292
297
|
}
|
|
293
298
|
}
|
|
294
299
|
return v;
|
|
295
|
-
}), S = m[8] || ((
|
|
300
|
+
}), S = m[8] || ((w) => {
|
|
296
301
|
var T;
|
|
297
|
-
const k = f(
|
|
298
|
-
let v = n.get(
|
|
302
|
+
const k = f(w);
|
|
303
|
+
let v = n.get(w);
|
|
299
304
|
if (v && !v.l.size && !Array.from(v.t).some((N) => {
|
|
300
305
|
var I;
|
|
301
|
-
return (I = n.get(N)) == null ? void 0 : I.d.has(
|
|
306
|
+
return (I = n.get(N)) == null ? void 0 : I.d.has(w);
|
|
302
307
|
})) {
|
|
303
|
-
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);
|
|
304
309
|
for (const N of k.d.keys()) {
|
|
305
310
|
const I = S(N);
|
|
306
|
-
I == null || I.t.delete(
|
|
311
|
+
I == null || I.t.delete(w);
|
|
307
312
|
}
|
|
308
313
|
return;
|
|
309
314
|
}
|
|
310
315
|
return v;
|
|
311
|
-
}),
|
|
316
|
+
}), B = [
|
|
312
317
|
// store state
|
|
313
318
|
o,
|
|
314
319
|
n,
|
|
@@ -324,31 +329,31 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
324
329
|
g,
|
|
325
330
|
// building-block functions
|
|
326
331
|
f,
|
|
332
|
+
h,
|
|
327
333
|
b,
|
|
328
334
|
x,
|
|
329
|
-
h,
|
|
330
335
|
y,
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
336
|
+
A,
|
|
337
|
+
j,
|
|
338
|
+
C,
|
|
334
339
|
S
|
|
335
340
|
], _ = {
|
|
336
|
-
get: (
|
|
337
|
-
set: (
|
|
341
|
+
get: (w) => returnAtomValue(x(w)),
|
|
342
|
+
set: (w, ...T) => {
|
|
338
343
|
try {
|
|
339
|
-
return
|
|
344
|
+
return A(w, ...T);
|
|
340
345
|
} finally {
|
|
341
|
-
|
|
346
|
+
b(), h();
|
|
342
347
|
}
|
|
343
348
|
},
|
|
344
|
-
sub: (
|
|
345
|
-
const v = w
|
|
346
|
-
return v.add(T),
|
|
347
|
-
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();
|
|
348
353
|
};
|
|
349
354
|
}
|
|
350
355
|
};
|
|
351
|
-
return Object.defineProperty(_, BUILDING_BLOCKS, { value:
|
|
356
|
+
return Object.defineProperty(_, BUILDING_BLOCKS, { value: B }), _;
|
|
352
357
|
}, INTERNAL_buildStoreRev1 = buildStore;
|
|
353
358
|
let keyCount = 0;
|
|
354
359
|
function atom(o, n) {
|
|
@@ -384,36 +389,36 @@ function splitAtom(o, n) {
|
|
|
384
389
|
if (p)
|
|
385
390
|
return p;
|
|
386
391
|
const u = d && r.get(d), g = [], m = [];
|
|
387
|
-
return c.forEach((f,
|
|
388
|
-
const
|
|
389
|
-
m[
|
|
390
|
-
const
|
|
391
|
-
if (
|
|
392
|
-
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;
|
|
393
398
|
return;
|
|
394
399
|
}
|
|
395
|
-
const y = (
|
|
396
|
-
const
|
|
400
|
+
const y = (j) => {
|
|
401
|
+
const C = j(l), S = j(o), _ = a(S, C == null ? void 0 : C.arr).keyList.indexOf(b);
|
|
397
402
|
if (_ < 0 || _ >= S.length) {
|
|
398
|
-
const
|
|
399
|
-
if (
|
|
400
|
-
return
|
|
403
|
+
const w = c[a(c).keyList.indexOf(b)];
|
|
404
|
+
if (w)
|
|
405
|
+
return w;
|
|
401
406
|
throw new Error("splitAtom: index out of bounds for read");
|
|
402
407
|
}
|
|
403
408
|
return S[_];
|
|
404
|
-
},
|
|
405
|
-
const
|
|
409
|
+
}, A = (j, C, S) => {
|
|
410
|
+
const B = j(l), _ = j(o), T = a(_, B == null ? void 0 : B.arr).keyList.indexOf(b);
|
|
406
411
|
if (T < 0 || T >= _.length)
|
|
407
412
|
throw new Error("splitAtom: index out of bounds for write");
|
|
408
413
|
const k = isFunction(S) ? S(_[T]) : S;
|
|
409
|
-
Object.is(_[T], k) ||
|
|
414
|
+
Object.is(_[T], k) || C(o, [
|
|
410
415
|
..._.slice(0, T),
|
|
411
416
|
k,
|
|
412
417
|
..._.slice(T + 1)
|
|
413
418
|
]);
|
|
414
419
|
};
|
|
415
|
-
g[
|
|
416
|
-
}), 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;
|
|
417
422
|
}, l = atom((c) => {
|
|
418
423
|
const d = c(l), p = c(o);
|
|
419
424
|
return a(p, d == null ? void 0 : d.arr);
|
|
@@ -486,18 +491,18 @@ function createJSONStorage(o = () => {
|
|
|
486
491
|
const i = {
|
|
487
492
|
getItem: (p, u) => {
|
|
488
493
|
var g, m;
|
|
489
|
-
const f = (
|
|
490
|
-
if (
|
|
494
|
+
const f = (b) => {
|
|
495
|
+
if (b = b || "", a !== b) {
|
|
491
496
|
try {
|
|
492
|
-
l = JSON.parse(
|
|
497
|
+
l = JSON.parse(b, n == null ? void 0 : n.reviver);
|
|
493
498
|
} catch {
|
|
494
499
|
return u;
|
|
495
500
|
}
|
|
496
|
-
a =
|
|
501
|
+
a = b;
|
|
497
502
|
}
|
|
498
503
|
return l;
|
|
499
|
-
},
|
|
500
|
-
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);
|
|
501
506
|
},
|
|
502
507
|
setItem: (p, u) => {
|
|
503
508
|
var g;
|
|
@@ -511,13 +516,13 @@ function createJSONStorage(o = () => {
|
|
|
511
516
|
return (u = o()) == null ? void 0 : u.removeItem(p);
|
|
512
517
|
}
|
|
513
518
|
}, c = (p) => (u, g, m) => p(u, (f) => {
|
|
514
|
-
let
|
|
519
|
+
let h;
|
|
515
520
|
try {
|
|
516
|
-
|
|
521
|
+
h = JSON.parse(f || "");
|
|
517
522
|
} catch {
|
|
518
|
-
|
|
523
|
+
h = m;
|
|
519
524
|
}
|
|
520
|
-
g(
|
|
525
|
+
g(h);
|
|
521
526
|
});
|
|
522
527
|
let d;
|
|
523
528
|
try {
|
|
@@ -688,17 +693,17 @@ class Content extends Component {
|
|
|
688
693
|
class Frame extends Component {
|
|
689
694
|
constructor(r, a) {
|
|
690
695
|
super(r, a);
|
|
691
|
-
|
|
696
|
+
V(this, "setRef", (r) => {
|
|
692
697
|
this.nodeRef.current = r;
|
|
693
698
|
const { forwardedRef: a } = this.props;
|
|
694
699
|
typeof a == "function" ? a(r) : a && (a.current = r);
|
|
695
700
|
});
|
|
696
|
-
|
|
701
|
+
V(this, "handleLoad", () => {
|
|
697
702
|
clearInterval(this.loadCheck), this.state.iframeLoaded || this.setState({ iframeLoaded: !0 });
|
|
698
703
|
});
|
|
699
704
|
// In certain situations on a cold cache DOMContentLoaded never gets called
|
|
700
705
|
// fallback to an interval to check if that's the case
|
|
701
|
-
|
|
706
|
+
V(this, "loadCheck", () => setInterval(() => {
|
|
702
707
|
this.handleLoad();
|
|
703
708
|
}, 500));
|
|
704
709
|
this._isMounted = !1, this.nodeRef = React__default.createRef(), this.state = { iframeLoaded: !1 };
|
|
@@ -735,7 +740,7 @@ class Frame extends Component {
|
|
|
735
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() });
|
|
736
741
|
}
|
|
737
742
|
}
|
|
738
|
-
|
|
743
|
+
V(Frame, "defaultProps", {
|
|
739
744
|
style: {},
|
|
740
745
|
head: null,
|
|
741
746
|
children: void 0,
|
|
@@ -1339,65 +1344,65 @@ const useBlocksStoreManager = () => {
|
|
|
1339
1344
|
updateBlocksProps: c
|
|
1340
1345
|
} = useBlocksStoreManager();
|
|
1341
1346
|
return {
|
|
1342
|
-
moveBlocks: (
|
|
1343
|
-
const
|
|
1344
|
-
const
|
|
1345
|
-
return { _id:
|
|
1346
|
-
}),
|
|
1347
|
-
|
|
1348
|
-
undo: () => each(
|
|
1349
|
-
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);
|
|
1350
1355
|
}),
|
|
1351
|
-
redo: () => i(
|
|
1356
|
+
redo: () => i(b, x, y)
|
|
1352
1357
|
}));
|
|
1353
1358
|
},
|
|
1354
|
-
addBlocks: (
|
|
1355
|
-
a(
|
|
1356
|
-
undo: () => l(map(
|
|
1357
|
-
redo: () => a(
|
|
1359
|
+
addBlocks: (b, x, y) => {
|
|
1360
|
+
a(b, x, y), o({
|
|
1361
|
+
undo: () => l(map(b, "_id")),
|
|
1362
|
+
redo: () => a(b, x, y)
|
|
1358
1363
|
});
|
|
1359
1364
|
},
|
|
1360
|
-
removeBlocks: (
|
|
1361
|
-
var
|
|
1362
|
-
const
|
|
1363
|
-
l(map(
|
|
1364
|
-
undo: () => a(
|
|
1365
|
-
redo: () => l(map(
|
|
1365
|
+
removeBlocks: (b) => {
|
|
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));
|
|
1368
|
+
l(map(b, "_id")), o({
|
|
1369
|
+
undo: () => a(b, x, A),
|
|
1370
|
+
redo: () => l(map(b, "_id"))
|
|
1366
1371
|
});
|
|
1367
1372
|
},
|
|
1368
|
-
updateBlocks: (
|
|
1369
|
-
let
|
|
1373
|
+
updateBlocks: (b, x, y) => {
|
|
1374
|
+
let A = [];
|
|
1370
1375
|
if (y)
|
|
1371
|
-
|
|
1376
|
+
A = map(b, (j) => ({ _id: j, ...y }));
|
|
1372
1377
|
else {
|
|
1373
|
-
const
|
|
1374
|
-
|
|
1375
|
-
const S = n.find((_) => _._id ===
|
|
1376
|
-
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;
|
|
1377
1382
|
});
|
|
1378
1383
|
}
|
|
1379
|
-
c(map(
|
|
1380
|
-
undo: () => c(
|
|
1381
|
-
redo: () => c(map(
|
|
1384
|
+
c(map(b, (j) => ({ _id: j, ...x }))), o({
|
|
1385
|
+
undo: () => c(A),
|
|
1386
|
+
redo: () => c(map(b, (j) => ({ _id: j, ...x })))
|
|
1382
1387
|
});
|
|
1383
1388
|
},
|
|
1384
|
-
updateBlocksRuntime: (
|
|
1385
|
-
c(map(
|
|
1389
|
+
updateBlocksRuntime: (b, x) => {
|
|
1390
|
+
c(map(b, (y) => ({ _id: y, ...x })));
|
|
1386
1391
|
},
|
|
1387
|
-
setNewBlocks: (
|
|
1388
|
-
r(
|
|
1392
|
+
setNewBlocks: (b) => {
|
|
1393
|
+
r(b), o({
|
|
1389
1394
|
undo: () => r(n),
|
|
1390
|
-
redo: () => r(
|
|
1395
|
+
redo: () => r(b)
|
|
1391
1396
|
});
|
|
1392
1397
|
},
|
|
1393
|
-
updateMultipleBlocksProps: (
|
|
1394
|
-
let
|
|
1395
|
-
|
|
1396
|
-
const
|
|
1397
|
-
return each(
|
|
1398
|
-
}), c(
|
|
1399
|
-
undo: () => c(
|
|
1400
|
-
redo: () => c(
|
|
1398
|
+
updateMultipleBlocksProps: (b) => {
|
|
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;
|
|
1403
|
+
}), c(b), o({
|
|
1404
|
+
undo: () => c(x),
|
|
1405
|
+
redo: () => c(b)
|
|
1401
1406
|
});
|
|
1402
1407
|
}
|
|
1403
1408
|
};
|
|
@@ -1434,12 +1439,12 @@ const useAddBlock = () => {
|
|
|
1434
1439
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
1435
1440
|
(i, c, d) => {
|
|
1436
1441
|
var f;
|
|
1437
|
-
for (let
|
|
1438
|
-
const { _id:
|
|
1439
|
-
i[
|
|
1440
|
-
const
|
|
1441
|
-
for (let y = 0; y <
|
|
1442
|
-
|
|
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;
|
|
1443
1448
|
}
|
|
1444
1449
|
const p = first(i);
|
|
1445
1450
|
let u, g;
|
|
@@ -1450,8 +1455,8 @@ const useAddBlock = () => {
|
|
|
1450
1455
|
return { addCoreBlock: useCallback(
|
|
1451
1456
|
(i, c, d) => {
|
|
1452
1457
|
if (has(i, "blocks")) {
|
|
1453
|
-
const
|
|
1454
|
-
return a(
|
|
1458
|
+
const x = i.blocks;
|
|
1459
|
+
return a(x, c, d);
|
|
1455
1460
|
}
|
|
1456
1461
|
const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
|
|
1457
1462
|
_type: i.type,
|
|
@@ -2905,43 +2910,43 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2905
2910
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
2906
2911
|
})
|
|
2907
2912
|
), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
|
|
2908
|
-
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,
|
|
2909
|
-
const
|
|
2910
|
-
for (const
|
|
2911
|
-
const y = x
|
|
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];
|
|
2912
2917
|
if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
|
|
2913
|
-
const { baseClasses:
|
|
2914
|
-
x
|
|
2918
|
+
const { baseClasses: A, classes: j } = getSplitChaiClasses(y);
|
|
2919
|
+
b[x] = compact(flattenDeep([A, j])).join(" ");
|
|
2915
2920
|
} else
|
|
2916
|
-
|
|
2921
|
+
x !== "_id" && delete b[x];
|
|
2917
2922
|
}
|
|
2918
|
-
return
|
|
2923
|
+
return b;
|
|
2919
2924
|
};
|
|
2920
2925
|
return {
|
|
2921
2926
|
askAi: useCallback(
|
|
2922
|
-
async (f, b, x
|
|
2927
|
+
async (f, h, b, x) => {
|
|
2923
2928
|
if (l) {
|
|
2924
2929
|
n(!0), a(null);
|
|
2925
2930
|
try {
|
|
2926
|
-
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;
|
|
2927
2932
|
if (S) {
|
|
2928
2933
|
a(S);
|
|
2929
2934
|
return;
|
|
2930
2935
|
}
|
|
2931
2936
|
if (f === "styles") {
|
|
2932
|
-
const
|
|
2933
|
-
for (const
|
|
2934
|
-
|
|
2937
|
+
const B = C.map((_) => {
|
|
2938
|
+
for (const w in _)
|
|
2939
|
+
w !== "_id" && (_[w] = `${STYLES_KEY},${_[w]}`);
|
|
2935
2940
|
return _;
|
|
2936
2941
|
});
|
|
2937
|
-
c(
|
|
2942
|
+
c(B);
|
|
2938
2943
|
} else
|
|
2939
|
-
i(
|
|
2940
|
-
|
|
2944
|
+
i(C);
|
|
2945
|
+
x && x(j);
|
|
2941
2946
|
} catch (y) {
|
|
2942
2947
|
a(y);
|
|
2943
2948
|
} finally {
|
|
2944
|
-
n(!1),
|
|
2949
|
+
n(!1), x && x();
|
|
2945
2950
|
}
|
|
2946
2951
|
}
|
|
2947
2952
|
},
|
|
@@ -3119,17 +3124,17 @@ const useBlockHighlight = () => {
|
|
|
3119
3124
|
[n, o]
|
|
3120
3125
|
);
|
|
3121
3126
|
}, usePasteBlocks = () => {
|
|
3122
|
-
const [o, n] = useCutBlockIds(), r = useMoveCutBlocks(), a = useCanPaste(), {
|
|
3127
|
+
const [o, n] = useCutBlockIds(), r = useMoveCutBlocks(), a = useCanPaste(), { addPredefinedBlock: l } = useAddBlock();
|
|
3123
3128
|
return {
|
|
3124
3129
|
canPaste: useCallback(
|
|
3125
|
-
async (
|
|
3130
|
+
async (c) => {
|
|
3126
3131
|
if (o.length > 0)
|
|
3127
|
-
return a(o,
|
|
3132
|
+
return a(o, c);
|
|
3128
3133
|
try {
|
|
3129
|
-
const
|
|
3130
|
-
if (
|
|
3131
|
-
const
|
|
3132
|
-
return has(
|
|
3134
|
+
const d = await navigator.clipboard.readText();
|
|
3135
|
+
if (d) {
|
|
3136
|
+
const p = JSON.parse(d);
|
|
3137
|
+
return has(p, "_chai_copied_blocks");
|
|
3133
3138
|
}
|
|
3134
3139
|
} catch {
|
|
3135
3140
|
return !1;
|
|
@@ -3139,24 +3144,24 @@ const useBlockHighlight = () => {
|
|
|
3139
3144
|
[a, o]
|
|
3140
3145
|
),
|
|
3141
3146
|
pasteBlocks: useCallback(
|
|
3142
|
-
async (
|
|
3143
|
-
const
|
|
3147
|
+
async (c) => {
|
|
3148
|
+
const d = Array.isArray(c) ? c[0] : c;
|
|
3144
3149
|
if (!isEmpty(o)) {
|
|
3145
|
-
r(o,
|
|
3150
|
+
r(o, c), n([]), await navigator.clipboard.writeText("");
|
|
3146
3151
|
return;
|
|
3147
3152
|
}
|
|
3148
3153
|
try {
|
|
3149
|
-
const
|
|
3150
|
-
if (
|
|
3151
|
-
const
|
|
3152
|
-
has(
|
|
3154
|
+
const p = await navigator.clipboard.readText();
|
|
3155
|
+
if (p) {
|
|
3156
|
+
const u = JSON.parse(p);
|
|
3157
|
+
has(u, "_chai_copied_blocks") ? l(u._chai_copied_blocks, d === "root" ? null : d) : toast.error("Nothing to paste");
|
|
3153
3158
|
} else
|
|
3154
|
-
|
|
3159
|
+
toast.error("Nothing to paste");
|
|
3155
3160
|
} catch {
|
|
3156
|
-
|
|
3161
|
+
toast.error("Failed to paste blocks from clipboard");
|
|
3157
3162
|
}
|
|
3158
3163
|
},
|
|
3159
|
-
[o,
|
|
3164
|
+
[o, l, r, n]
|
|
3160
3165
|
)
|
|
3161
3166
|
};
|
|
3162
3167
|
}, previewModeAtom = atom$1(!1), usePreviewMode = () => {
|
|
@@ -3174,13 +3179,13 @@ const useBlockHighlight = () => {
|
|
|
3174
3179
|
const d = o(c), p = a;
|
|
3175
3180
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
3176
3181
|
return each(p, (m) => {
|
|
3177
|
-
const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
3178
|
-
u = u.replace(
|
|
3179
|
-
const
|
|
3180
|
-
includes(["2xl", "xl", "lg", "md", "sm"],
|
|
3182
|
+
const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
|
|
3183
|
+
u = u.replace(h, " ").replace(/\s+/g, " ").trim();
|
|
3184
|
+
const b = first(m.split(":"));
|
|
3185
|
+
includes(["2xl", "xl", "lg", "md", "sm"], b) && p.push(m.split(":").pop().trim());
|
|
3181
3186
|
}), each(p, (m) => {
|
|
3182
|
-
const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
3183
|
-
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();
|
|
3184
3189
|
}), {
|
|
3185
3190
|
ids: [d._id],
|
|
3186
3191
|
props: {
|
|
@@ -3212,7 +3217,7 @@ const useBlockHighlight = () => {
|
|
|
3212
3217
|
const n = first(o(selectedStylingBlocksAtom)), r = o(selectedBlockAtom);
|
|
3213
3218
|
if (!n || n.blockId !== get(r, "_id", null)) return [];
|
|
3214
3219
|
const a = get(r, n.prop, `${STYLES_KEY},`), { classes: l } = getSplitChaiClasses(a);
|
|
3215
|
-
return
|
|
3220
|
+
return filter(map(l.trim().split(" "), constructClassObject), (i) => !isNull(i));
|
|
3216
3221
|
}), useSelectedBlockAllClasses = () => useAtomValue$1(selectedBlockAllClassesAtom), MQ = { xs: 0, sm: 1, md: 2, lg: 3, xl: 4, "2xl": 5 }, selectedBlockCurrentClassesAtom = atom$1((o) => {
|
|
3217
3222
|
const n = o(canvasBreakpointAtom), r = o(styleStateAtom), a = o(darkModeAtom), l = getQueries(n);
|
|
3218
3223
|
let i = filter(o(selectedBlockAllClassesAtom), { mod: r });
|
|
@@ -3273,7 +3278,7 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), layoutVariantAto
|
|
|
3273
3278
|
};
|
|
3274
3279
|
class PubSub {
|
|
3275
3280
|
constructor() {
|
|
3276
|
-
|
|
3281
|
+
V(this, "subscribers", /* @__PURE__ */ new Map());
|
|
3277
3282
|
}
|
|
3278
3283
|
subscribe(n, r) {
|
|
3279
3284
|
return this.subscribers.has(n) || this.subscribers.set(n, /* @__PURE__ */ new Set()), this.subscribers.get(n).add(r), () => {
|
|
@@ -3321,13 +3326,13 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3321
3326
|
tabIndex: 0,
|
|
3322
3327
|
ref: u.setFloating,
|
|
3323
3328
|
style: p,
|
|
3324
|
-
onClick: (
|
|
3325
|
-
|
|
3329
|
+
onClick: (h) => {
|
|
3330
|
+
h.stopPropagation(), h.preventDefault();
|
|
3326
3331
|
},
|
|
3327
|
-
onMouseEnter: (
|
|
3328
|
-
|
|
3332
|
+
onMouseEnter: (h) => {
|
|
3333
|
+
h.stopPropagation(), i(null);
|
|
3329
3334
|
},
|
|
3330
|
-
onKeyDown: (
|
|
3335
|
+
onKeyDown: (h) => h.stopPropagation(),
|
|
3331
3336
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3332
3337
|
children: [
|
|
3333
3338
|
m && /* @__PURE__ */ jsx(
|
|
@@ -3408,7 +3413,6 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3408
3413
|
</head>
|
|
3409
3414
|
<body class="font-body antialiased h-full">
|
|
3410
3415
|
<div class="frame-root h-full"></div>
|
|
3411
|
-
<script src="https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.js"><\/script>
|
|
3412
3416
|
</body>
|
|
3413
3417
|
</html>`, useKeyEventWatcher = (o) => {
|
|
3414
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 } : {};
|
|
@@ -3424,8 +3428,8 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
|
|
|
3424
3428
|
i
|
|
3425
3429
|
]), useHotkeys(
|
|
3426
3430
|
"del, backspace",
|
|
3427
|
-
(
|
|
3428
|
-
|
|
3431
|
+
(h) => {
|
|
3432
|
+
h.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
|
|
3429
3433
|
},
|
|
3430
3434
|
f,
|
|
3431
3435
|
[n, l]
|
|
@@ -3523,31 +3527,63 @@ const useDnd = () => {
|
|
|
3523
3527
|
},
|
|
3524
3528
|
onDrop: (f) => {
|
|
3525
3529
|
var S;
|
|
3526
|
-
const
|
|
3527
|
-
dropIndex = calculateDropIndex(
|
|
3528
|
-
const y = d,
|
|
3529
|
-
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) {
|
|
3530
3534
|
m();
|
|
3531
3535
|
return;
|
|
3532
3536
|
}
|
|
3533
3537
|
if (!has(y, "_id")) {
|
|
3534
|
-
a(y,
|
|
3538
|
+
a(y, A === "canvas" ? null : A, dropIndex), setTimeout(m, 300);
|
|
3535
3539
|
return;
|
|
3536
3540
|
}
|
|
3537
|
-
let
|
|
3538
|
-
|
|
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);
|
|
3539
3543
|
},
|
|
3540
3544
|
onDragEnter: (f) => {
|
|
3541
|
-
const
|
|
3542
|
-
dropTarget =
|
|
3543
|
-
const
|
|
3544
|
-
u(
|
|
3545
|
+
const h = f, b = h.target;
|
|
3546
|
+
dropTarget = b;
|
|
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([]);
|
|
3545
3549
|
},
|
|
3546
3550
|
onDragLeave: (f) => {
|
|
3547
3551
|
f.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
|
|
3548
3552
|
}
|
|
3549
3553
|
};
|
|
3550
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
|
+
] });
|
|
3551
3587
|
function getTargetedBlock(o) {
|
|
3552
3588
|
if (o.getAttribute("data-block-id") === "canvas")
|
|
3553
3589
|
return null;
|
|
@@ -3556,36 +3592,29 @@ function getTargetedBlock(o) {
|
|
|
3556
3592
|
const n = o.closest("[data-block-id]");
|
|
3557
3593
|
return (n == null ? void 0 : n.getAttribute("data-block-id")) === "canvas" ? null : n;
|
|
3558
3594
|
}
|
|
3559
|
-
|
|
3560
|
-
|
|
3561
|
-
const n = document.querySelector(".ql-toolbar");
|
|
3562
|
-
n && n.parentNode.removeChild(n), o = null;
|
|
3563
|
-
}
|
|
3564
|
-
const useHandleCanvasDblClick = () => {
|
|
3565
|
-
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);
|
|
3566
3597
|
return useCallback(
|
|
3567
|
-
(
|
|
3568
|
-
|
|
3569
|
-
|
|
3570
|
-
|
|
3571
|
-
|
|
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))
|
|
3572
3604
|
return;
|
|
3573
|
-
const
|
|
3574
|
-
|
|
3575
|
-
|
|
3576
|
-
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
const h =
|
|
3580
|
-
|
|
3581
|
-
}
|
|
3582
|
-
|
|
3583
|
-
|
|
3584
|
-
}), m.addEventListener("keydown", (h) => {
|
|
3585
|
-
(h.key === "Enter" || h.key === "Escape") && b();
|
|
3586
|
-
}), f.focus(), (x = m.querySelector(".ql-clipboard")) == null || x.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);
|
|
3587
3616
|
},
|
|
3588
|
-
[
|
|
3617
|
+
[l, c, d, i, a, o, n]
|
|
3589
3618
|
);
|
|
3590
3619
|
}, useHandleCanvasClick = () => {
|
|
3591
3620
|
const [, o] = useSelectedStylingBlocks(), [n, r] = useSelectedBlockIds(), [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(treeRefAtom), { clearHighlight: i } = useBlockHighlight();
|
|
@@ -3622,29 +3651,34 @@ const useHandleCanvasDblClick = () => {
|
|
|
3622
3651
|
setTimeout(() => {
|
|
3623
3652
|
if (!isEmpty(a))
|
|
3624
3653
|
return;
|
|
3625
|
-
const
|
|
3626
|
-
if (
|
|
3627
|
-
const
|
|
3628
|
-
if (
|
|
3629
|
-
const
|
|
3630
|
-
l([{ id:
|
|
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 }]);
|
|
3631
3660
|
}
|
|
3632
3661
|
}
|
|
3633
3662
|
}, 100);
|
|
3634
3663
|
}, [n, r, l, a]);
|
|
3635
|
-
const c =
|
|
3636
|
-
|
|
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(
|
|
3637
3668
|
"div",
|
|
3638
3669
|
{
|
|
3639
3670
|
"data-block-id": "canvas",
|
|
3640
3671
|
id: "canvas",
|
|
3641
|
-
onClick:
|
|
3642
|
-
onDoubleClick:
|
|
3643
|
-
onMouseMove:
|
|
3644
|
-
onMouseLeave:
|
|
3645
|
-
...omit(
|
|
3646
|
-
className: "relative h-full max-w-full p-px " + (
|
|
3647
|
-
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
|
+
]
|
|
3648
3682
|
}
|
|
3649
3683
|
);
|
|
3650
3684
|
}, getElementByDataBlockId = (o, n) => o.querySelector(`[data-block-id="${n}"]`), HeadTags = () => {
|
|
@@ -3677,8 +3711,8 @@ const useHandleCanvasDblClick = () => {
|
|
|
3677
3711
|
forms,
|
|
3678
3712
|
aspectRatio,
|
|
3679
3713
|
containerQueries,
|
|
3680
|
-
plugin(function({ addBase:
|
|
3681
|
-
|
|
3714
|
+
plugin(function({ addBase: x, theme: y }) {
|
|
3715
|
+
x({
|
|
3682
3716
|
"h1,h2,h3,h4,h5,h6": {
|
|
3683
3717
|
fontFamily: y("fontFamily.heading")
|
|
3684
3718
|
},
|
|
@@ -3692,7 +3726,7 @@ const useHandleCanvasDblClick = () => {
|
|
|
3692
3726
|
]
|
|
3693
3727
|
});
|
|
3694
3728
|
}, [o, n, p]), useEffect(() => {
|
|
3695
|
-
g && (g.textContent = `${map(r, (
|
|
3729
|
+
g && (g.textContent = `${map(r, (x) => `[data-block-id="${x}"]`).join(",")}{
|
|
3696
3730
|
outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
|
|
3697
3731
|
}`);
|
|
3698
3732
|
}, [r, g]), useEffect(() => {
|
|
@@ -3700,19 +3734,19 @@ const useHandleCanvasDblClick = () => {
|
|
|
3700
3734
|
}, [i, f]), useEffect(() => {
|
|
3701
3735
|
u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
|
|
3702
3736
|
}, [u]), useEffect(() => {
|
|
3703
|
-
m && (m.textContent = `${map(l, ({ id:
|
|
3737
|
+
m && (m.textContent = `${map(l, ({ id: x }) => `[data-style-id="${x}"]`).join(",")}{
|
|
3704
3738
|
outline: 1px solid orange !important; outline-offset: -1px;
|
|
3705
3739
|
}`);
|
|
3706
3740
|
}, [l, m]), useEffect(() => {
|
|
3707
3741
|
d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
|
|
3708
3742
|
}, [c, d]);
|
|
3709
|
-
const
|
|
3743
|
+
const h = useMemo(
|
|
3710
3744
|
() => getChaiThemeCssVariables(o),
|
|
3711
3745
|
[o]
|
|
3712
|
-
),
|
|
3746
|
+
), b = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
|
|
3713
3747
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3714
|
-
/* @__PURE__ */ jsx("style", { id: "chai-theme", children:
|
|
3715
|
-
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html:
|
|
3748
|
+
/* @__PURE__ */ jsx("style", { id: "chai-theme", children: h }),
|
|
3749
|
+
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: b } })
|
|
3716
3750
|
] });
|
|
3717
3751
|
}, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
|
|
3718
3752
|
const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), c = useDebouncedCallback(
|
|
@@ -3789,10 +3823,10 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3789
3823
|
[o]
|
|
3790
3824
|
);
|
|
3791
3825
|
}, BlockRenderer = ({ blockAtom: o, children: n }) => {
|
|
3792
|
-
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(
|
|
3793
|
-
() =>
|
|
3794
|
-
[r, l, a, d,
|
|
3795
|
-
),
|
|
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(
|
|
3796
3830
|
() => ({
|
|
3797
3831
|
blockProps: {
|
|
3798
3832
|
"data-block-id": r._id,
|
|
@@ -3800,14 +3834,14 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3800
3834
|
},
|
|
3801
3835
|
inBuilder: !0,
|
|
3802
3836
|
lang: l || i,
|
|
3837
|
+
...m,
|
|
3803
3838
|
...f,
|
|
3804
|
-
...
|
|
3805
|
-
...
|
|
3806
|
-
...h
|
|
3839
|
+
...h,
|
|
3840
|
+
...b
|
|
3807
3841
|
}),
|
|
3808
|
-
[r, l, i,
|
|
3842
|
+
[r, l, i, m, f, h, b]
|
|
3809
3843
|
);
|
|
3810
|
-
return isNull(
|
|
3844
|
+
return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...x, children: n }) });
|
|
3811
3845
|
}, GlobalBlocksRenderer = ({ globalBlockId: o }) => {
|
|
3812
3846
|
const { getGlobalBlocks: n } = useGlobalBlocksStore(), r = useMemo(() => n(o), [n, o]), a = useMemo(() => splitAtom(atom$1(r)), [r]);
|
|
3813
3847
|
return isEmpty(r) ? null : /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: r });
|
|
@@ -3857,43 +3891,43 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3857
3891
|
c();
|
|
3858
3892
|
}, [n, o, r, c]), l;
|
|
3859
3893
|
}, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
|
|
3860
|
-
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([]), [,
|
|
3861
|
-
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 }));
|
|
3862
3896
|
};
|
|
3863
|
-
|
|
3897
|
+
useEffect(() => {
|
|
3864
3898
|
if (!c.current) return;
|
|
3865
|
-
const { clientWidth:
|
|
3866
|
-
p({ width:
|
|
3899
|
+
const { clientWidth: B, clientHeight: _ } = c.current;
|
|
3900
|
+
p({ width: B, height: _ });
|
|
3867
3901
|
}, [c, n]);
|
|
3868
|
-
const
|
|
3869
|
-
const { top:
|
|
3870
|
-
return
|
|
3902
|
+
const C = (B, _ = 0) => {
|
|
3903
|
+
const { top: w } = B.getBoundingClientRect();
|
|
3904
|
+
return w + _ >= 0 && w - _ <= window.innerHeight;
|
|
3871
3905
|
};
|
|
3872
3906
|
useEffect(() => {
|
|
3873
|
-
var
|
|
3907
|
+
var B, _;
|
|
3874
3908
|
if (a && a.type !== "Multiple" && i.current) {
|
|
3875
|
-
const
|
|
3876
|
-
|
|
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]));
|
|
3877
3911
|
}
|
|
3878
3912
|
}, [a]), useEffect(() => {
|
|
3879
|
-
if (!isEmpty(
|
|
3880
|
-
const
|
|
3913
|
+
if (!isEmpty(b) && i.current) {
|
|
3914
|
+
const B = getElementByStyleId(
|
|
3881
3915
|
i.current.contentDocument,
|
|
3882
|
-
first(
|
|
3916
|
+
first(b).id
|
|
3883
3917
|
);
|
|
3884
|
-
f(
|
|
3918
|
+
f(B ? [B] : [null]);
|
|
3885
3919
|
} else
|
|
3886
3920
|
f([null]);
|
|
3887
|
-
}, [
|
|
3921
|
+
}, [b]);
|
|
3888
3922
|
const S = useMemo(() => {
|
|
3889
|
-
let
|
|
3890
|
-
return
|
|
3891
|
-
}, [o,
|
|
3892
|
-
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(
|
|
3893
3927
|
"div",
|
|
3894
3928
|
{
|
|
3895
3929
|
onClick: () => {
|
|
3896
|
-
r([]),
|
|
3930
|
+
r([]), x([]);
|
|
3897
3931
|
},
|
|
3898
3932
|
onMouseLeave: () => setTimeout(() => l(""), 300),
|
|
3899
3933
|
className: "relative mx-auto h-full w-full overflow-hidden",
|
|
@@ -3901,7 +3935,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3901
3935
|
children: /* @__PURE__ */ jsxs(
|
|
3902
3936
|
ChaiFrame,
|
|
3903
3937
|
{
|
|
3904
|
-
contentDidMount: () =>
|
|
3938
|
+
contentDidMount: () => h(i.current),
|
|
3905
3939
|
ref: i,
|
|
3906
3940
|
id: "canvas-iframe",
|
|
3907
3941
|
style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
|
|
@@ -4046,7 +4080,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4046
4080
|
l !== o.length - 1 && /* @__PURE__ */ jsx(ChevronRight, { className: "rtl:rotate-180", size: 16 })
|
|
4047
4081
|
] }, l))
|
|
4048
4082
|
] }) });
|
|
4049
|
-
}, CodeEditor$1 = React__default.lazy(() => import("./CodeEditor-
|
|
4083
|
+
}, CodeEditor$1 = React__default.lazy(() => import("./CodeEditor-Bv7cAp6l.js")), CanvasArea = () => {
|
|
4050
4084
|
const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
|
|
4051
4085
|
return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2", children: [
|
|
4052
4086
|
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
|
|
@@ -4160,25 +4194,25 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4160
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) => {
|
|
4161
4195
|
a(y);
|
|
4162
4196
|
}, m = () => {
|
|
4163
|
-
const y = l.find((
|
|
4197
|
+
const y = l.find((A) => Object.keys(A)[0] === r);
|
|
4164
4198
|
if (y) {
|
|
4165
|
-
const
|
|
4166
|
-
|
|
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);
|
|
4167
4201
|
} else
|
|
4168
4202
|
console.error("Preset not found:", r);
|
|
4169
4203
|
}, f = useDebouncedCallback(
|
|
4170
|
-
(y,
|
|
4204
|
+
(y, A) => {
|
|
4171
4205
|
d(() => ({
|
|
4172
4206
|
...c,
|
|
4173
4207
|
fontFamily: {
|
|
4174
4208
|
...c.fontFamily,
|
|
4175
|
-
[y.replace(/font-/g, "")]:
|
|
4209
|
+
[y.replace(/font-/g, "")]: A
|
|
4176
4210
|
}
|
|
4177
4211
|
}));
|
|
4178
4212
|
},
|
|
4179
4213
|
[c],
|
|
4180
4214
|
200
|
|
4181
|
-
),
|
|
4215
|
+
), h = useDebouncedCallback(
|
|
4182
4216
|
(y) => {
|
|
4183
4217
|
d(() => ({
|
|
4184
4218
|
...c,
|
|
@@ -4187,36 +4221,36 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4187
4221
|
},
|
|
4188
4222
|
[c],
|
|
4189
4223
|
200
|
|
4190
|
-
),
|
|
4191
|
-
(y,
|
|
4224
|
+
), b = useDebouncedCallback(
|
|
4225
|
+
(y, A) => {
|
|
4192
4226
|
d(() => {
|
|
4193
|
-
const
|
|
4194
|
-
return n ? set(
|
|
4227
|
+
const j = get(c, `colors.${y}`);
|
|
4228
|
+
return n ? set(j, 1, A) : set(j, 0, A), {
|
|
4195
4229
|
...c,
|
|
4196
4230
|
colors: {
|
|
4197
4231
|
...c.colors,
|
|
4198
|
-
[y]:
|
|
4232
|
+
[y]: j
|
|
4199
4233
|
}
|
|
4200
4234
|
};
|
|
4201
4235
|
});
|
|
4202
4236
|
},
|
|
4203
4237
|
[c],
|
|
4204
4238
|
200
|
|
4205
|
-
),
|
|
4206
|
-
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}`);
|
|
4207
4241
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
4208
4242
|
/* @__PURE__ */ jsx(
|
|
4209
4243
|
ColorPickerInput,
|
|
4210
4244
|
{
|
|
4211
|
-
value:
|
|
4212
|
-
onChange: (
|
|
4245
|
+
value: j,
|
|
4246
|
+
onChange: (C) => b(A, C)
|
|
4213
4247
|
}
|
|
4214
4248
|
),
|
|
4215
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children:
|
|
4216
|
-
] },
|
|
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);
|
|
4217
4251
|
}) });
|
|
4218
4252
|
return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
4219
|
-
/* @__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: [
|
|
4220
4254
|
l.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 py-2", children: [
|
|
4221
4255
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
4222
4256
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Presets") }),
|
|
@@ -4244,26 +4278,26 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4244
4278
|
}
|
|
4245
4279
|
) })
|
|
4246
4280
|
] }),
|
|
4247
|
-
/* @__PURE__ */ jsxs("div", { className: cn("space-y-2", o), children: [
|
|
4248
|
-
(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(
|
|
4249
4283
|
FontSelector,
|
|
4250
4284
|
{
|
|
4251
4285
|
label: y,
|
|
4252
|
-
value: c.fontFamily[y.replace(/font-/g, "")] ||
|
|
4253
|
-
onChange: (
|
|
4286
|
+
value: c.fontFamily[y.replace(/font-/g, "")] || A[Object.keys(A)[0]],
|
|
4287
|
+
onChange: (j) => f(y, j)
|
|
4254
4288
|
},
|
|
4255
4289
|
y
|
|
4256
4290
|
)) }),
|
|
4257
4291
|
(p == null ? void 0 : p.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
|
|
4258
4292
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Border Radius") }),
|
|
4259
4293
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
|
|
4260
|
-
/* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange:
|
|
4294
|
+
/* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange: h }),
|
|
4261
4295
|
/* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: c.borderRadius })
|
|
4262
4296
|
] })
|
|
4263
4297
|
] }),
|
|
4264
4298
|
(p == null ? void 0 : p.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
|
|
4265
4299
|
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Colors") }),
|
|
4266
|
-
/* @__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")
|
|
4267
4301
|
] })
|
|
4268
4302
|
] }),
|
|
4269
4303
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -4429,70 +4463,395 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4429
4463
|
)
|
|
4430
4464
|
] })
|
|
4431
4465
|
] });
|
|
4432
|
-
}
|
|
4433
|
-
|
|
4434
|
-
|
|
4435
|
-
|
|
4436
|
-
|
|
4437
|
-
|
|
4438
|
-
|
|
4439
|
-
|
|
4440
|
-
|
|
4441
|
-
|
|
4442
|
-
|
|
4443
|
-
|
|
4444
|
-
|
|
4445
|
-
|
|
4446
|
-
|
|
4447
|
-
|
|
4448
|
-
"blockquote",
|
|
4449
|
-
"color",
|
|
4450
|
-
"background",
|
|
4451
|
-
"align",
|
|
4452
|
-
"link",
|
|
4453
|
-
"image"
|
|
4454
|
-
], d = useRef(null), p = useRef(null);
|
|
4455
|
-
return useEffect(() => {
|
|
4456
|
-
if (d.current) {
|
|
4457
|
-
const u = d.current.getEditor();
|
|
4458
|
-
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));
|
|
4459
4482
|
}
|
|
4460
|
-
}, []),
|
|
4461
|
-
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4469
|
-
|
|
4470
|
-
|
|
4471
|
-
|
|
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();
|
|
4758
|
+
}
|
|
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
|
+
}
|
|
4472
4804
|
}
|
|
4473
|
-
|
|
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
|
+
] });
|
|
4474
4833
|
}, PageTypeField = ({
|
|
4475
4834
|
href: o,
|
|
4476
4835
|
pageTypes: n,
|
|
4477
4836
|
onChange: r
|
|
4478
4837
|
}) => {
|
|
4479
4838
|
var T;
|
|
4480
|
-
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;
|
|
4481
4840
|
useEffect(() => {
|
|
4482
|
-
if (f(""),
|
|
4841
|
+
if (f(""), b([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4483
4842
|
const k = split(o, ":"), v = get(k, 1, "page") || "page";
|
|
4484
4843
|
g(v), (async () => {
|
|
4485
4844
|
const N = await l(v, [get(k, 2, "page")]);
|
|
4486
4845
|
N && Array.isArray(N) && f(get(N, [0, "name"], ""));
|
|
4487
4846
|
})();
|
|
4488
4847
|
}, [o]);
|
|
4489
|
-
const
|
|
4848
|
+
const C = useDebouncedCallback(
|
|
4490
4849
|
async (k) => {
|
|
4491
4850
|
if (isEmpty(k))
|
|
4492
|
-
|
|
4851
|
+
b([]);
|
|
4493
4852
|
else {
|
|
4494
4853
|
const v = await l(u, k);
|
|
4495
|
-
|
|
4854
|
+
b(v);
|
|
4496
4855
|
}
|
|
4497
4856
|
c(!1), y(-1);
|
|
4498
4857
|
},
|
|
@@ -4500,18 +4859,18 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4500
4859
|
300
|
|
4501
4860
|
), S = (k) => {
|
|
4502
4861
|
const v = ["pageType", u, k.id];
|
|
4503
|
-
v[1] && (r(v.join(":")), f(k.name), p(!1),
|
|
4504
|
-
},
|
|
4862
|
+
v[1] && (r(v.join(":")), f(k.name), p(!1), b([]), y(-1));
|
|
4863
|
+
}, B = (k) => {
|
|
4505
4864
|
switch (k.key) {
|
|
4506
4865
|
case "ArrowDown":
|
|
4507
|
-
k.preventDefault(), y((v) => v <
|
|
4866
|
+
k.preventDefault(), y((v) => v < h.length - 1 ? v + 1 : v);
|
|
4508
4867
|
break;
|
|
4509
4868
|
case "ArrowUp":
|
|
4510
4869
|
k.preventDefault(), y((v) => v > 0 ? v - 1 : v);
|
|
4511
4870
|
break;
|
|
4512
4871
|
case "Enter":
|
|
4513
|
-
if (k.preventDefault(),
|
|
4514
|
-
|
|
4872
|
+
if (k.preventDefault(), h.length === 0) return;
|
|
4873
|
+
x >= 0 && S(h[x]);
|
|
4515
4874
|
break;
|
|
4516
4875
|
case "Escape":
|
|
4517
4876
|
k.preventDefault(), _();
|
|
@@ -4519,15 +4878,15 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4519
4878
|
}
|
|
4520
4879
|
};
|
|
4521
4880
|
useEffect(() => {
|
|
4522
|
-
if (
|
|
4523
|
-
const k =
|
|
4881
|
+
if (x >= 0 && A.current) {
|
|
4882
|
+
const k = A.current.children[x];
|
|
4524
4883
|
k == null || k.scrollIntoView({ block: "nearest" });
|
|
4525
4884
|
}
|
|
4526
|
-
}, [
|
|
4885
|
+
}, [x]);
|
|
4527
4886
|
const _ = () => {
|
|
4528
|
-
f(""),
|
|
4529
|
-
},
|
|
4530
|
-
f(k), p(!isEmpty(k)), c(!0),
|
|
4887
|
+
f(""), b([]), y(-1), p(!1), r("");
|
|
4888
|
+
}, w = (k) => {
|
|
4889
|
+
f(k), p(!isEmpty(k)), c(!0), C(k);
|
|
4531
4890
|
};
|
|
4532
4891
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4533
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)) }),
|
|
@@ -4537,27 +4896,27 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4537
4896
|
{
|
|
4538
4897
|
type: "text",
|
|
4539
4898
|
value: m,
|
|
4540
|
-
onChange: (k) =>
|
|
4541
|
-
onKeyDown:
|
|
4542
|
-
placeholder: a(`Search ${
|
|
4899
|
+
onChange: (k) => w(k.target.value),
|
|
4900
|
+
onKeyDown: B,
|
|
4901
|
+
placeholder: a(`Search ${j ?? ""}`),
|
|
4543
4902
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4544
4903
|
}
|
|
4545
4904
|
),
|
|
4546
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" }) }) })
|
|
4547
4906
|
] }),
|
|
4548
|
-
(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: [
|
|
4549
4908
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
4550
4909
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
4551
|
-
] }) : d && isEmpty(
|
|
4910
|
+
] }) : d && isEmpty(h) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4552
4911
|
a("No results found for"),
|
|
4553
4912
|
' "',
|
|
4554
4913
|
m,
|
|
4555
4914
|
'"'
|
|
4556
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref:
|
|
4915
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(h == null ? void 0 : h.slice(0, 20), (k, v) => /* @__PURE__ */ jsxs(
|
|
4557
4916
|
"li",
|
|
4558
4917
|
{
|
|
4559
4918
|
onClick: () => S(k),
|
|
4560
|
-
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"}`,
|
|
4561
4920
|
children: [
|
|
4562
4921
|
k.name,
|
|
4563
4922
|
" ",
|
|
@@ -4651,25 +5010,25 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4651
5010
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
|
|
4652
5011
|
}, [o, u]);
|
|
4653
5012
|
const m = () => {
|
|
4654
|
-
const
|
|
4655
|
-
if (
|
|
4656
|
-
const
|
|
5013
|
+
const b = findIndex(u, { _id: g });
|
|
5014
|
+
if (b > -1) {
|
|
5015
|
+
const x = (b + 1) % u.length, y = get(u, [x, "_id"]);
|
|
4657
5016
|
if (!y) return;
|
|
4658
5017
|
n({ ...o, currentSlide: y }), c([y]);
|
|
4659
5018
|
}
|
|
4660
5019
|
}, f = () => {
|
|
4661
|
-
const
|
|
4662
|
-
if (
|
|
4663
|
-
const
|
|
5020
|
+
const b = findIndex(u, { _id: g });
|
|
5021
|
+
if (b > -1) {
|
|
5022
|
+
const x = (b - 1 + u.length) % u.length, y = get(u, [x, "_id"]);
|
|
4664
5023
|
if (!y) return;
|
|
4665
5024
|
n({ ...o, currentSlide: y }), c([y]);
|
|
4666
5025
|
}
|
|
4667
|
-
},
|
|
4668
|
-
const
|
|
5026
|
+
}, h = () => {
|
|
5027
|
+
const b = i(
|
|
4669
5028
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4670
5029
|
p == null ? void 0 : p._id
|
|
4671
|
-
),
|
|
4672
|
-
|
|
5030
|
+
), x = b == null ? void 0 : b._id;
|
|
5031
|
+
x && (n({ ...o, currentSlide: x }), c([x]));
|
|
4673
5032
|
};
|
|
4674
5033
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4675
5034
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
@@ -4686,7 +5045,7 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4686
5045
|
/* @__PURE__ */ jsxs(
|
|
4687
5046
|
"button",
|
|
4688
5047
|
{
|
|
4689
|
-
onClick:
|
|
5048
|
+
onClick: h,
|
|
4690
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",
|
|
4691
5050
|
children: [
|
|
4692
5051
|
/* @__PURE__ */ jsx(PlusCircle, { className: "h-3 w-3 stroke-[2]" }),
|
|
@@ -4747,9 +5106,9 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4747
5106
|
value: o == null ? void 0 : o.autoplayInterval,
|
|
4748
5107
|
className: "text-xs",
|
|
4749
5108
|
pattern: "[0-9]*",
|
|
4750
|
-
onChange: (
|
|
4751
|
-
let
|
|
4752
|
-
|
|
5109
|
+
onChange: (b) => {
|
|
5110
|
+
let x = b.target.value;
|
|
5111
|
+
x.length && (x = x.replace("-", "")), n({ ...o, autoplayInterval: x });
|
|
4753
5112
|
}
|
|
4754
5113
|
}
|
|
4755
5114
|
)
|
|
@@ -4774,86 +5133,7 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
|
|
|
4774
5133
|
),
|
|
4775
5134
|
/* @__PURE__ */ jsx(Button, { onClick: d, size: "sm", variant: "outline", className: "w-fit", children: r("Open code editor") })
|
|
4776
5135
|
] });
|
|
4777
|
-
}
|
|
4778
|
-
function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
4779
|
-
const [a, l] = React.useState(!1), [i, c] = React.useState([]), [d, p] = React.useState(o);
|
|
4780
|
-
useEffect(() => {
|
|
4781
|
-
a || c([]), p(o);
|
|
4782
|
-
}, [a, o]);
|
|
4783
|
-
const u = (b) => Array.isArray(b) ? "array" : typeof b == "object" && b !== null ? "object" : "value", g = React.useCallback(
|
|
4784
|
-
(b) => {
|
|
4785
|
-
const x = (h) => r === "value" ? h === "value" || h === "object" : r === "array" ? h === "array" : h === r;
|
|
4786
|
-
b.type === "object" ? (c((h) => [...h, b.key]), p(b.value)) : x(b.type) && (n([...i, b.key].join(".")), l(!1));
|
|
4787
|
-
},
|
|
4788
|
-
[i, n, r]
|
|
4789
|
-
), m = React.useCallback(() => {
|
|
4790
|
-
if (i.length > 0) {
|
|
4791
|
-
const b = i.slice(0, -1);
|
|
4792
|
-
c(b), p(b.reduce((x, h) => x[h], o));
|
|
4793
|
-
}
|
|
4794
|
-
}, [i, o]), f = React.useMemo(() => Object.entries(d).map(([b, x]) => ({
|
|
4795
|
-
key: b,
|
|
4796
|
-
value: x,
|
|
4797
|
-
type: u(x)
|
|
4798
|
-
})).filter((b) => r === "value" ? b.type === "value" || b.type === "object" : r === "array" ? b.type === "array" || b.type === "object" : r === "object" ? b.type === "object" : !0), [d, r]);
|
|
4799
|
-
return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
|
|
4800
|
-
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
4801
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
4802
|
-
Button,
|
|
4803
|
-
{
|
|
4804
|
-
size: "sm",
|
|
4805
|
-
variant: "outline",
|
|
4806
|
-
className: "h-5 px-1 py-0 text-[9px] text-muted-foreground",
|
|
4807
|
-
role: "combobox",
|
|
4808
|
-
"aria-expanded": a,
|
|
4809
|
-
children: /* @__PURE__ */ jsx(DatabaseIcon, { className: "h-3 w-3" })
|
|
4810
|
-
}
|
|
4811
|
-
) }) }),
|
|
4812
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: "Add field" })
|
|
4813
|
-
] }),
|
|
4814
|
-
/* @__PURE__ */ jsx(PopoverContent, { className: "mr-3 w-[300px] p-0", children: /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
|
|
4815
|
-
/* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
|
|
4816
|
-
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
4817
|
-
/* @__PURE__ */ jsx(CommandEmpty, { children: "No option found." }),
|
|
4818
|
-
/* @__PURE__ */ jsxs(CommandGroup, { children: [
|
|
4819
|
-
i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: m, className: "flex items-center text-sm", children: [
|
|
4820
|
-
/* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
|
|
4821
|
-
"Back"
|
|
4822
|
-
] }),
|
|
4823
|
-
f.map((b) => /* @__PURE__ */ jsxs(
|
|
4824
|
-
CommandItem,
|
|
4825
|
-
{
|
|
4826
|
-
value: b.key,
|
|
4827
|
-
disabled: !1,
|
|
4828
|
-
onSelect: () => g(b),
|
|
4829
|
-
className: "flex items-center justify-between",
|
|
4830
|
-
children: [
|
|
4831
|
-
/* @__PURE__ */ jsx("span", { children: b.key }),
|
|
4832
|
-
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
4833
|
-
r === "object" && b.type === "object" && /* @__PURE__ */ jsx(
|
|
4834
|
-
Button,
|
|
4835
|
-
{
|
|
4836
|
-
size: "sm",
|
|
4837
|
-
variant: "ghost",
|
|
4838
|
-
className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
|
|
4839
|
-
onClick: (x) => {
|
|
4840
|
-
x.stopPropagation(), n([...i, b.key].join(".")), l(!1);
|
|
4841
|
-
},
|
|
4842
|
-
children: "Select"
|
|
4843
|
-
}
|
|
4844
|
-
),
|
|
4845
|
-
(b.type === "object" || b.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" }) })
|
|
4846
|
-
] })
|
|
4847
|
-
]
|
|
4848
|
-
},
|
|
4849
|
-
b.key
|
|
4850
|
-
))
|
|
4851
|
-
] })
|
|
4852
|
-
] })
|
|
4853
|
-
] }) })
|
|
4854
|
-
] });
|
|
4855
|
-
}
|
|
4856
|
-
const CustomFieldTemplate = ({
|
|
5136
|
+
}, CustomFieldTemplate = ({
|
|
4857
5137
|
id: o,
|
|
4858
5138
|
classNames: n,
|
|
4859
5139
|
label: r,
|
|
@@ -4867,77 +5147,56 @@ const CustomFieldTemplate = ({
|
|
|
4867
5147
|
formData: g,
|
|
4868
5148
|
onChange: m
|
|
4869
5149
|
}) => {
|
|
4870
|
-
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(
|
|
4871
5151
|
(v) => {
|
|
4872
|
-
const N = (
|
|
4873
|
-
let
|
|
4874
|
-
const
|
|
4875
|
-
return
|
|
4876
|
-
text:
|
|
4877
|
-
prefixLength:
|
|
4878
|
-
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
|
|
4879
5159
|
};
|
|
4880
|
-
},
|
|
4881
|
-
if (!
|
|
4882
|
-
const P = document.getElementById(`
|
|
4883
|
-
if (P && "
|
|
4884
|
-
const
|
|
4885
|
-
if (
|
|
4886
|
-
const
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
if (
|
|
4890
|
-
|
|
4891
|
-
const L = D.index;
|
|
4892
|
-
j.deleteText(D.index, D.length), j.setSelection(L, 0);
|
|
4893
|
-
const $ = j.getText(), {
|
|
4894
|
-
text: O,
|
|
4895
|
-
prefixLength: H,
|
|
4896
|
-
suffixLength: V
|
|
4897
|
-
} = I($, L, R);
|
|
4898
|
-
j.insertText(L, O), j.setSelection(L + H + R.length + V, 0);
|
|
4899
|
-
} else {
|
|
4900
|
-
const L = D.index;
|
|
4901
|
-
j.setSelection(L, 0);
|
|
4902
|
-
const $ = j.getText(), {
|
|
4903
|
-
text: O,
|
|
4904
|
-
prefixLength: H,
|
|
4905
|
-
suffixLength: V
|
|
4906
|
-
} = I($, L, R);
|
|
4907
|
-
j.insertText(L, O), j.setSelection(L + H + R.length + V, 0);
|
|
4908
|
-
}
|
|
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();
|
|
4909
5171
|
else {
|
|
4910
|
-
const
|
|
4911
|
-
|
|
4912
|
-
|
|
4913
|
-
|
|
4914
|
-
|
|
4915
|
-
suffixLength: V
|
|
4916
|
-
} = I($, L - 1, R);
|
|
4917
|
-
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();
|
|
4918
5177
|
}
|
|
4919
|
-
setTimeout(() => m(
|
|
5178
|
+
setTimeout(() => m(E.getHTML(), {}, o), 100);
|
|
4920
5179
|
return;
|
|
4921
5180
|
}
|
|
4922
5181
|
} else {
|
|
4923
|
-
const
|
|
4924
|
-
if (
|
|
4925
|
-
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);
|
|
4926
5185
|
m(W, {}, o);
|
|
4927
5186
|
return;
|
|
4928
5187
|
}
|
|
4929
|
-
const
|
|
4930
|
-
m(
|
|
5188
|
+
const $ = `{{${v}}}`, { text: H } = I(M, D, $), F = M.slice(0, D) + H + M.slice(D);
|
|
5189
|
+
m(F, {}, o);
|
|
4931
5190
|
}
|
|
4932
5191
|
},
|
|
4933
|
-
[o, m, g,
|
|
5192
|
+
[o, m, g, j == null ? void 0 : j._id]
|
|
4934
5193
|
);
|
|
4935
5194
|
if (d)
|
|
4936
5195
|
return null;
|
|
4937
5196
|
if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
|
|
4938
5197
|
const k = S == null ? void 0 : S.includes(o.replace("root.", ""));
|
|
4939
5198
|
if (u.type === "array") {
|
|
4940
|
-
const v =
|
|
5199
|
+
const v = B === o;
|
|
4941
5200
|
return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
|
|
4942
5201
|
u.title && /* @__PURE__ */ jsxs(
|
|
4943
5202
|
"label",
|
|
@@ -4973,7 +5232,7 @@ const CustomFieldTemplate = ({
|
|
|
4973
5232
|
] }),
|
|
4974
5233
|
p && u.type !== "object" ? " *" : null
|
|
4975
5234
|
] }),
|
|
4976
|
-
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" })
|
|
4977
5236
|
] }),
|
|
4978
5237
|
c,
|
|
4979
5238
|
a,
|
|
@@ -5041,35 +5300,35 @@ const CustomFieldTemplate = ({
|
|
|
5041
5300
|
}), a;
|
|
5042
5301
|
};
|
|
5043
5302
|
function BlockSettings() {
|
|
5044
|
-
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),
|
|
5045
|
-
_ && (c == null ? void 0 : c._id) === n._id && a([n._id], { [_]: get(
|
|
5046
|
-
},
|
|
5047
|
-
debounce(({ formData:
|
|
5048
|
-
|
|
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);
|
|
5305
|
+
}, b = useCallback(
|
|
5306
|
+
debounce(({ formData: B }, _, w) => {
|
|
5307
|
+
h({ formData: B }, _, w), d(B);
|
|
5049
5308
|
}, 1500),
|
|
5050
5309
|
[n == null ? void 0 : n._id, o]
|
|
5051
|
-
),
|
|
5052
|
-
_ && (r([n._id], { [_]: get(
|
|
5053
|
-
}, y = ({ formData:
|
|
5054
|
-
_ && (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, _) }));
|
|
5055
5314
|
};
|
|
5056
5315
|
keys(get(i, "_bindings", {}));
|
|
5057
|
-
const { schema:
|
|
5058
|
-
const
|
|
5059
|
-
if (
|
|
5060
|
-
return getBlockFormSchemas(
|
|
5061
|
-
}, [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(() => {
|
|
5062
5321
|
if (!g || !(g != null && g._type))
|
|
5063
5322
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5064
|
-
const
|
|
5065
|
-
return { wrapperSchema: _, wrapperUiSchema:
|
|
5323
|
+
const B = g == null ? void 0 : g._type, { schema: _ = {}, uiSchema: w = {} } = getBlockFormSchemas(B);
|
|
5324
|
+
return { wrapperSchema: _, wrapperUiSchema: w };
|
|
5066
5325
|
}, [g]);
|
|
5067
5326
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5068
5327
|
!isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
5069
5328
|
/* @__PURE__ */ jsxs(
|
|
5070
5329
|
"div",
|
|
5071
5330
|
{
|
|
5072
|
-
onClick: () => u((
|
|
5331
|
+
onClick: () => u((B) => !B),
|
|
5073
5332
|
className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
|
|
5074
5333
|
children: [
|
|
5075
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" }),
|
|
@@ -5090,19 +5349,19 @@ function BlockSettings() {
|
|
|
5090
5349
|
blockId: g == null ? void 0 : g._id,
|
|
5091
5350
|
onChange: y,
|
|
5092
5351
|
formData: f,
|
|
5093
|
-
schema:
|
|
5352
|
+
schema: C,
|
|
5094
5353
|
uiSchema: S
|
|
5095
5354
|
}
|
|
5096
5355
|
) })
|
|
5097
5356
|
] }),
|
|
5098
|
-
isEmpty(
|
|
5357
|
+
isEmpty(A) ? null : /* @__PURE__ */ jsx(
|
|
5099
5358
|
JSONForm,
|
|
5100
5359
|
{
|
|
5101
5360
|
blockId: n == null ? void 0 : n._id,
|
|
5102
|
-
onChange:
|
|
5361
|
+
onChange: x,
|
|
5103
5362
|
formData: i,
|
|
5104
|
-
schema:
|
|
5105
|
-
uiSchema:
|
|
5363
|
+
schema: A,
|
|
5364
|
+
uiSchema: j
|
|
5106
5365
|
}
|
|
5107
5366
|
),
|
|
5108
5367
|
(n == null ? void 0 : n._type) === "GlobalBlock" ? /* @__PURE__ */ jsx(GlobalBlockSettings, {}) : null
|
|
@@ -5193,32 +5452,32 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5193
5452
|
] }) }) })
|
|
5194
5453
|
] });
|
|
5195
5454
|
}, Breakpoints$1 = ({ openDelay: o = 400, canvas: n = !1 }) => {
|
|
5196
|
-
const [r, , a] = useScreenSizeWidth(), [l, i] = useCanvasDisplayWidth(), [c, d] = useSelectedBreakpoints(), p = c, u = d, { t: g } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (
|
|
5197
|
-
p.includes(
|
|
5198
|
-
},
|
|
5199
|
-
n || a(
|
|
5200
|
-
},
|
|
5201
|
-
return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (
|
|
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);
|
|
5459
|
+
}, b = getBreakpointValue(n ? l : r).toLowerCase();
|
|
5460
|
+
return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (x) => /* @__PURE__ */ createElement(
|
|
5202
5461
|
BreakpointCard,
|
|
5203
5462
|
{
|
|
5204
5463
|
canvas: n,
|
|
5205
|
-
...
|
|
5206
|
-
onClick:
|
|
5207
|
-
key:
|
|
5208
|
-
currentBreakpoint:
|
|
5464
|
+
...x,
|
|
5465
|
+
onClick: h,
|
|
5466
|
+
key: x.breakpoint,
|
|
5467
|
+
currentBreakpoint: b
|
|
5209
5468
|
}
|
|
5210
5469
|
)) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
|
|
5211
5470
|
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
|
|
5212
|
-
m.filter((
|
|
5213
|
-
(
|
|
5471
|
+
m.filter((x) => includes(p, toUpper(x.breakpoint))),
|
|
5472
|
+
(x) => /* @__PURE__ */ createElement(
|
|
5214
5473
|
BreakpointCard,
|
|
5215
5474
|
{
|
|
5216
5475
|
canvas: n,
|
|
5217
5476
|
openDelay: o,
|
|
5218
|
-
...
|
|
5219
|
-
onClick:
|
|
5220
|
-
key:
|
|
5221
|
-
currentBreakpoint:
|
|
5477
|
+
...x,
|
|
5478
|
+
onClick: h,
|
|
5479
|
+
key: x.breakpoint,
|
|
5480
|
+
currentBreakpoint: b
|
|
5222
5481
|
}
|
|
5223
5482
|
)
|
|
5224
5483
|
) }),
|
|
@@ -5227,15 +5486,15 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5227
5486
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
|
|
5228
5487
|
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: g("Screen sizes") }),
|
|
5229
5488
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
5230
|
-
map(m, (
|
|
5489
|
+
map(m, (x) => /* @__PURE__ */ jsx(
|
|
5231
5490
|
DropdownMenuCheckboxItem,
|
|
5232
5491
|
{
|
|
5233
|
-
disabled:
|
|
5234
|
-
onCheckedChange: () => f(toUpper(
|
|
5235
|
-
checked: includes(p, toUpper(
|
|
5236
|
-
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)
|
|
5237
5496
|
},
|
|
5238
|
-
|
|
5497
|
+
x.breakpoint
|
|
5239
5498
|
))
|
|
5240
5499
|
] })
|
|
5241
5500
|
] })
|
|
@@ -5324,8 +5583,8 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5324
5583
|
(f = d.current) == null || f.focus();
|
|
5325
5584
|
}, []);
|
|
5326
5585
|
const m = (f) => {
|
|
5327
|
-
const { usage:
|
|
5328
|
-
!l &&
|
|
5586
|
+
const { usage: h } = f || {};
|
|
5587
|
+
!l && h && g(h), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
5329
5588
|
};
|
|
5330
5589
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
5331
5590
|
/* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: n("Ask AI") }),
|
|
@@ -5380,25 +5639,25 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5380
5639
|
] });
|
|
5381
5640
|
};
|
|
5382
5641
|
function ManualClasses() {
|
|
5383
|
-
var
|
|
5384
|
-
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), [
|
|
5385
|
-
const
|
|
5386
|
-
u(m,
|
|
5387
|
-
}, [
|
|
5388
|
-
const
|
|
5642
|
+
var I;
|
|
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);
|
|
5389
5648
|
let D = [];
|
|
5390
|
-
if (
|
|
5391
|
-
const [
|
|
5392
|
-
D = i.search(
|
|
5393
|
-
|
|
5394
|
-
item: {
|
|
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 }
|
|
5395
5654
|
}));
|
|
5396
5655
|
} else
|
|
5397
|
-
D = i.search(
|
|
5398
|
-
return
|
|
5399
|
-
},
|
|
5400
|
-
|
|
5401
|
-
},
|
|
5656
|
+
D = i.search(P);
|
|
5657
|
+
return S(map(D, "item"));
|
|
5658
|
+
}, _ = () => {
|
|
5659
|
+
S([]);
|
|
5660
|
+
}, w = (L) => L.name, T = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), k = useMemo(
|
|
5402
5661
|
() => ({
|
|
5403
5662
|
ref: o,
|
|
5404
5663
|
autoComplete: "off",
|
|
@@ -5406,38 +5665,31 @@ function ManualClasses() {
|
|
|
5406
5665
|
autoCapitalize: "off",
|
|
5407
5666
|
spellCheck: !1,
|
|
5408
5667
|
placeholder: c("Enter classes separated by space"),
|
|
5409
|
-
value:
|
|
5410
|
-
onKeyDown: (
|
|
5411
|
-
|
|
5668
|
+
value: h,
|
|
5669
|
+
onKeyDown: (L) => {
|
|
5670
|
+
L.key === "Enter" && h.trim() !== "" && j();
|
|
5412
5671
|
},
|
|
5413
|
-
onChange: (
|
|
5672
|
+
onChange: (L, { newValue: P }) => b(P),
|
|
5414
5673
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
5415
5674
|
}),
|
|
5416
|
-
[
|
|
5417
|
-
),
|
|
5675
|
+
[h, c, o]
|
|
5676
|
+
), v = (L) => {
|
|
5418
5677
|
debugger;
|
|
5419
|
-
const
|
|
5420
|
-
g(m, [
|
|
5421
|
-
},
|
|
5678
|
+
const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5679
|
+
g(m, [L]), u(m, P, !0), r(""), l(-1);
|
|
5680
|
+
}, N = () => {
|
|
5422
5681
|
if (navigator.clipboard === void 0) {
|
|
5423
|
-
|
|
5424
|
-
title: c("Clipboard not supported"),
|
|
5425
|
-
description: c("Please use Chrome, Firefox or Safari"),
|
|
5426
|
-
variant: "destructive"
|
|
5427
|
-
});
|
|
5682
|
+
toast.error(c("Clipboard not supported"));
|
|
5428
5683
|
return;
|
|
5429
5684
|
}
|
|
5430
|
-
navigator.clipboard.writeText(
|
|
5431
|
-
title: c("Copied"),
|
|
5432
|
-
description: c("Classes copied to clipboard")
|
|
5433
|
-
});
|
|
5685
|
+
navigator.clipboard.writeText(A.join(" ")), toast.success(c("Classes copied to clipboard"));
|
|
5434
5686
|
};
|
|
5435
5687
|
return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
|
|
5436
5688
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
|
|
5437
5689
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
|
|
5438
5690
|
/* @__PURE__ */ jsx("span", { children: c("Classes") }),
|
|
5439
5691
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5440
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick:
|
|
5692
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: N, className: "cursor-pointer" }) }),
|
|
5441
5693
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
|
|
5442
5694
|
] })
|
|
5443
5695
|
] }),
|
|
@@ -5453,12 +5705,12 @@ function ManualClasses() {
|
|
|
5453
5705
|
/* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
|
|
5454
5706
|
Autosuggest,
|
|
5455
5707
|
{
|
|
5456
|
-
suggestions:
|
|
5457
|
-
onSuggestionsFetchRequested:
|
|
5458
|
-
onSuggestionsClearRequested:
|
|
5459
|
-
getSuggestionValue:
|
|
5460
|
-
renderSuggestion:
|
|
5461
|
-
inputProps:
|
|
5708
|
+
suggestions: C,
|
|
5709
|
+
onSuggestionsFetchRequested: B,
|
|
5710
|
+
onSuggestionsClearRequested: _,
|
|
5711
|
+
getSuggestionValue: w,
|
|
5712
|
+
renderSuggestion: T,
|
|
5713
|
+
inputProps: k,
|
|
5462
5714
|
containerProps: {
|
|
5463
5715
|
className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
|
|
5464
5716
|
},
|
|
@@ -5474,45 +5726,45 @@ function ManualClasses() {
|
|
|
5474
5726
|
{
|
|
5475
5727
|
variant: "outline",
|
|
5476
5728
|
className: "h-6 border-border",
|
|
5477
|
-
onClick:
|
|
5478
|
-
disabled:
|
|
5729
|
+
onClick: j,
|
|
5730
|
+
disabled: h.trim() === "",
|
|
5479
5731
|
size: "sm",
|
|
5480
5732
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
5481
5733
|
}
|
|
5482
5734
|
)
|
|
5483
5735
|
] }),
|
|
5484
|
-
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children:
|
|
5485
|
-
(
|
|
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(
|
|
5486
5738
|
"input",
|
|
5487
5739
|
{
|
|
5488
5740
|
ref: o,
|
|
5489
5741
|
value: n,
|
|
5490
|
-
onChange: (
|
|
5742
|
+
onChange: (E) => r(E.target.value),
|
|
5491
5743
|
onBlur: () => {
|
|
5492
|
-
|
|
5744
|
+
v(L);
|
|
5493
5745
|
},
|
|
5494
|
-
onKeyDown: (
|
|
5495
|
-
|
|
5746
|
+
onKeyDown: (E) => {
|
|
5747
|
+
E.key === "Enter" && v(L);
|
|
5496
5748
|
},
|
|
5497
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"
|
|
5498
5750
|
},
|
|
5499
|
-
|
|
5751
|
+
L
|
|
5500
5752
|
) : /* @__PURE__ */ jsxs(
|
|
5501
5753
|
"button",
|
|
5502
5754
|
{
|
|
5503
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",
|
|
5504
5756
|
children: [
|
|
5505
|
-
|
|
5506
|
-
n !==
|
|
5757
|
+
L,
|
|
5758
|
+
n !== L && /* @__PURE__ */ jsx(
|
|
5507
5759
|
Cross2Icon,
|
|
5508
5760
|
{
|
|
5509
|
-
onClick: () => g(m, [
|
|
5761
|
+
onClick: () => g(m, [L], !0),
|
|
5510
5762
|
className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
|
|
5511
5763
|
}
|
|
5512
5764
|
)
|
|
5513
5765
|
]
|
|
5514
5766
|
},
|
|
5515
|
-
|
|
5767
|
+
L
|
|
5516
5768
|
)
|
|
5517
5769
|
) })
|
|
5518
5770
|
] });
|
|
@@ -5854,8 +6106,8 @@ const COLOR_PROP = {
|
|
|
5854
6106
|
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
5855
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(
|
|
5856
6108
|
// eslint-disable-next-line no-shadow
|
|
5857
|
-
(
|
|
5858
|
-
["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" })));
|
|
5859
6111
|
},
|
|
5860
6112
|
[c, p]
|
|
5861
6113
|
);
|
|
@@ -5864,21 +6116,21 @@ const COLOR_PROP = {
|
|
|
5864
6116
|
return c([]);
|
|
5865
6117
|
c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
5866
6118
|
}, [g]);
|
|
5867
|
-
const
|
|
6119
|
+
const h = useCallback(
|
|
5868
6120
|
// eslint-disable-next-line no-shadow
|
|
5869
|
-
(
|
|
5870
|
-
p({ color: g, shade:
|
|
6121
|
+
(x) => {
|
|
6122
|
+
p({ color: g, shade: x });
|
|
5871
6123
|
},
|
|
5872
6124
|
[g]
|
|
5873
6125
|
);
|
|
5874
6126
|
useEffect(() => {
|
|
5875
6127
|
p({ color: "", shade: "" });
|
|
5876
6128
|
}, [r]);
|
|
5877
|
-
const { match:
|
|
6129
|
+
const { match: b } = useTailwindClassList();
|
|
5878
6130
|
return useEffect(() => {
|
|
5879
6131
|
const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
5880
|
-
|
|
5881
|
-
}, [
|
|
6132
|
+
b(o, y) && n(y, o);
|
|
6133
|
+
}, [b, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
|
|
5882
6134
|
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
5883
6135
|
DropDown,
|
|
5884
6136
|
{
|
|
@@ -5918,7 +6170,7 @@ const COLOR_PROP = {
|
|
|
5918
6170
|
]
|
|
5919
6171
|
}
|
|
5920
6172
|
) }),
|
|
5921
|
-
/* @__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 }) })
|
|
5922
6174
|
] });
|
|
5923
6175
|
}, IconChoices = ({ property: o, onChange: n }) => {
|
|
5924
6176
|
const { getClasses: r } = useTailwindClassList(), a = r(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
|
|
@@ -6115,7 +6367,7 @@ const COLOR_PROP = {
|
|
|
6115
6367
|
},
|
|
6116
6368
|
a
|
|
6117
6369
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
6118
|
-
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);
|
|
6119
6371
|
useEffect(() => {
|
|
6120
6372
|
const { value: k, unit: v } = getClassValueAndUnit(i);
|
|
6121
6373
|
if (v === "") {
|
|
@@ -6124,41 +6376,41 @@ const COLOR_PROP = {
|
|
|
6124
6376
|
}
|
|
6125
6377
|
f(v), l(v === "class" || isEmpty(k) ? "" : k);
|
|
6126
6378
|
}, [i, p, u]);
|
|
6127
|
-
const
|
|
6379
|
+
const B = useThrottledCallback((k) => c(k), [c], THROTTLE_TIME), _ = useThrottledCallback((k) => c(k, !1), [c], THROTTLE_TIME), w = useCallback(
|
|
6128
6380
|
(k = !1) => {
|
|
6129
6381
|
const v = getUserInputValues(`${a}`, u);
|
|
6130
6382
|
if (get(v, "error", !1)) {
|
|
6131
|
-
|
|
6383
|
+
b(!0);
|
|
6132
6384
|
return;
|
|
6133
6385
|
}
|
|
6134
6386
|
const N = get(v, "unit") !== "" ? get(v, "unit") : m;
|
|
6135
6387
|
if (N === "auto" || N === "none") {
|
|
6136
|
-
|
|
6388
|
+
B(`${d}${N}`);
|
|
6137
6389
|
return;
|
|
6138
6390
|
}
|
|
6139
6391
|
if (get(v, "value") === "")
|
|
6140
6392
|
return;
|
|
6141
|
-
const
|
|
6142
|
-
k ? _(
|
|
6393
|
+
const L = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
|
|
6394
|
+
k ? _(L) : B(L);
|
|
6143
6395
|
},
|
|
6144
|
-
[
|
|
6396
|
+
[B, _, a, m, d, u]
|
|
6145
6397
|
), T = useCallback(
|
|
6146
6398
|
(k) => {
|
|
6147
6399
|
const v = getUserInputValues(`${a}`, u);
|
|
6148
6400
|
if (get(v, "error", !1)) {
|
|
6149
|
-
|
|
6401
|
+
b(!0);
|
|
6150
6402
|
return;
|
|
6151
6403
|
}
|
|
6152
6404
|
if (k === "auto" || k === "none") {
|
|
6153
|
-
|
|
6405
|
+
B(`${d}${k}`);
|
|
6154
6406
|
return;
|
|
6155
6407
|
}
|
|
6156
6408
|
if (get(v, "value") === "")
|
|
6157
6409
|
return;
|
|
6158
|
-
const N = get(v, "unit") !== "" ? get(v, "unit") : k,
|
|
6159
|
-
|
|
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);
|
|
6160
6412
|
},
|
|
6161
|
-
[
|
|
6413
|
+
[B, a, d, u]
|
|
6162
6414
|
);
|
|
6163
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: [
|
|
6164
6416
|
/* @__PURE__ */ jsx(
|
|
@@ -6173,14 +6425,14 @@ const COLOR_PROP = {
|
|
|
6173
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, {}) }) }),
|
|
6174
6426
|
/* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
|
|
6175
6427
|
] })
|
|
6176
|
-
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${
|
|
6428
|
+
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${A ? "z-auto" : ""}`, children: [
|
|
6177
6429
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
6178
6430
|
["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
|
|
6179
6431
|
"input",
|
|
6180
6432
|
{
|
|
6181
6433
|
readOnly: m === "class",
|
|
6182
6434
|
onKeyPress: (k) => {
|
|
6183
|
-
k.key === "Enter" &&
|
|
6435
|
+
k.key === "Enter" && w();
|
|
6184
6436
|
},
|
|
6185
6437
|
onKeyDown: (k) => {
|
|
6186
6438
|
if (k.keyCode !== 38 && k.keyCode !== 40)
|
|
@@ -6193,20 +6445,20 @@ const COLOR_PROP = {
|
|
|
6193
6445
|
_(P);
|
|
6194
6446
|
},
|
|
6195
6447
|
onKeyUp: (k) => {
|
|
6196
|
-
|
|
6448
|
+
C && (k.preventDefault(), S(!1));
|
|
6197
6449
|
},
|
|
6198
|
-
onBlur: () =>
|
|
6450
|
+
onBlur: () => w(),
|
|
6199
6451
|
onChange: (k) => {
|
|
6200
|
-
|
|
6452
|
+
b(!1), l(k.target.value);
|
|
6201
6453
|
},
|
|
6202
6454
|
onClick: (k) => {
|
|
6203
6455
|
var v;
|
|
6204
6456
|
(v = k == null ? void 0 : k.target) == null || v.select(), r(!1);
|
|
6205
6457
|
},
|
|
6206
|
-
value:
|
|
6458
|
+
value: A ? x : a,
|
|
6207
6459
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
6208
6460
|
" ",
|
|
6209
|
-
|
|
6461
|
+
h ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
6210
6462
|
)
|
|
6211
6463
|
}
|
|
6212
6464
|
),
|
|
@@ -6235,15 +6487,15 @@ const COLOR_PROP = {
|
|
|
6235
6487
|
) }) })
|
|
6236
6488
|
] })
|
|
6237
6489
|
] }),
|
|
6238
|
-
["none", "auto"].indexOf(m) !== -1 ||
|
|
6490
|
+
["none", "auto"].indexOf(m) !== -1 || A ? null : /* @__PURE__ */ jsx(
|
|
6239
6491
|
DragStyleButton,
|
|
6240
6492
|
{
|
|
6241
|
-
onDragStart: () =>
|
|
6493
|
+
onDragStart: () => j(!0),
|
|
6242
6494
|
onDragEnd: (k) => {
|
|
6243
|
-
if (y(() => ""),
|
|
6495
|
+
if (y(() => ""), j(!1), isEmpty(k))
|
|
6244
6496
|
return;
|
|
6245
6497
|
const v = `${k}`, I = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6246
|
-
|
|
6498
|
+
B(I);
|
|
6247
6499
|
},
|
|
6248
6500
|
onDrag: (k) => {
|
|
6249
6501
|
if (isEmpty(k))
|
|
@@ -6347,23 +6599,23 @@ const COLOR_PROP = {
|
|
|
6347
6599
|
"2xl": "1536px"
|
|
6348
6600
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6349
6601
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6350
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), f = useAddClassesToBlocks(),
|
|
6351
|
-
(_,
|
|
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) => {
|
|
6352
6604
|
const T = { dark: p, mq: g, mod: u, cls: _, property: l, fullCls: "" };
|
|
6353
6605
|
(p || u !== "") && (T.mq = "xs");
|
|
6354
6606
|
const k = generateFullClsName(T);
|
|
6355
|
-
f(
|
|
6607
|
+
f(b, [k], w);
|
|
6356
6608
|
},
|
|
6357
|
-
[
|
|
6358
|
-
),
|
|
6359
|
-
b
|
|
6360
|
-
}, [x, h
|
|
6609
|
+
[b, p, g, u, l, f]
|
|
6610
|
+
), A = useCallback(() => {
|
|
6611
|
+
h(b, [x], !0);
|
|
6612
|
+
}, [b, x, h]), j = useMemo(() => canChangeClass(m, g), [m, g]);
|
|
6361
6613
|
useEffect(() => {
|
|
6362
|
-
i(
|
|
6363
|
-
}, [
|
|
6364
|
-
const [, ,
|
|
6614
|
+
i(j, m);
|
|
6615
|
+
}, [j, i, m]);
|
|
6616
|
+
const [, , C] = useScreenSizeWidth(), S = useCallback(
|
|
6365
6617
|
(_) => {
|
|
6366
|
-
|
|
6618
|
+
C({
|
|
6367
6619
|
xs: 400,
|
|
6368
6620
|
sm: 640,
|
|
6369
6621
|
md: 800,
|
|
@@ -6372,10 +6624,10 @@ const COLOR_PROP = {
|
|
|
6372
6624
|
"2xl": 1920
|
|
6373
6625
|
}[_]);
|
|
6374
6626
|
},
|
|
6375
|
-
[
|
|
6376
|
-
),
|
|
6377
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange:
|
|
6378
|
-
/* @__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) }) }),
|
|
6379
6631
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6380
6632
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
6381
6633
|
r === "arbitrary" ? /* @__PURE__ */ jsx(
|
|
@@ -6394,7 +6646,7 @@ const COLOR_PROP = {
|
|
|
6394
6646
|
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
|
|
6395
6647
|
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
|
|
6396
6648
|
] }),
|
|
6397
|
-
/* @__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: [
|
|
6398
6650
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6399
6651
|
"button",
|
|
6400
6652
|
{
|
|
@@ -6444,18 +6696,18 @@ const COLOR_PROP = {
|
|
|
6444
6696
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6445
6697
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6446
6698
|
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
|
|
6447
|
-
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: [
|
|
6448
6700
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6449
6701
|
"button",
|
|
6450
6702
|
{
|
|
6451
6703
|
type: "button",
|
|
6452
|
-
onClick: () => u(
|
|
6453
|
-
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"}`,
|
|
6454
6706
|
children: [
|
|
6455
6707
|
React__default.createElement("div", {
|
|
6456
|
-
className: m(
|
|
6708
|
+
className: m(h) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6457
6709
|
}),
|
|
6458
|
-
React__default.createElement(get(EDITOR_ICONS,
|
|
6710
|
+
React__default.createElement(get(EDITOR_ICONS, h, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6459
6711
|
]
|
|
6460
6712
|
}
|
|
6461
6713
|
) }),
|
|
@@ -6601,10 +6853,10 @@ function BlockStyling() {
|
|
|
6601
6853
|
const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
|
|
6602
6854
|
let f = parseFloat(i.dragStartValue);
|
|
6603
6855
|
f = isNaN(f) ? 0 : f;
|
|
6604
|
-
let
|
|
6605
|
-
(startsWith(m, "scale") || m === "opacity") && (
|
|
6606
|
-
let
|
|
6607
|
-
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}`);
|
|
6608
6860
|
},
|
|
6609
6861
|
[i],
|
|
6610
6862
|
50
|
|
@@ -6648,12 +6900,12 @@ const CoreBlock = ({
|
|
|
6648
6900
|
}) => {
|
|
6649
6901
|
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), f = () => {
|
|
6650
6902
|
if (has(o, "blocks")) {
|
|
6651
|
-
const
|
|
6652
|
-
u(syncBlocksWithDefaults(
|
|
6903
|
+
const x = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
|
|
6904
|
+
u(syncBlocksWithDefaults(x), r || null, a);
|
|
6653
6905
|
} else
|
|
6654
6906
|
p(o, r || null, a);
|
|
6655
6907
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6656
|
-
},
|
|
6908
|
+
}, h = useFeature("dnd"), { t: b } = useTranslation();
|
|
6657
6909
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6658
6910
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6659
6911
|
"button",
|
|
@@ -6661,20 +6913,20 @@ const CoreBlock = ({
|
|
|
6661
6913
|
disabled: n,
|
|
6662
6914
|
onClick: f,
|
|
6663
6915
|
type: "button",
|
|
6664
|
-
onDragStart: (
|
|
6665
|
-
|
|
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(() => {
|
|
6666
6918
|
g([]), m();
|
|
6667
6919
|
}, 200);
|
|
6668
6920
|
},
|
|
6669
|
-
draggable:
|
|
6921
|
+
draggable: h ? "true" : "false",
|
|
6670
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",
|
|
6671
6923
|
children: [
|
|
6672
6924
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
6673
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(
|
|
6925
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(b(d || i)) })
|
|
6674
6926
|
]
|
|
6675
6927
|
}
|
|
6676
6928
|
) }),
|
|
6677
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
6929
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: b(d || i) }) })
|
|
6678
6930
|
] }) });
|
|
6679
6931
|
}, DefaultChaiBlocks = ({
|
|
6680
6932
|
parentId: o,
|
|
@@ -6859,22 +7111,22 @@ const CoreBlock = ({
|
|
|
6859
7111
|
}
|
|
6860
7112
|
}
|
|
6861
7113
|
}, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
|
|
6862
|
-
var m, f, b, x,
|
|
7114
|
+
var m, f, h, b, x, y, A, j;
|
|
6863
7115
|
if (r.type === "comment") return [];
|
|
6864
7116
|
console.log("node ===>", r);
|
|
6865
7117
|
let a = { _id: generateUUID() };
|
|
6866
7118
|
if (n && (a._parent = n.block._id), r.type === "text")
|
|
6867
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", "") };
|
|
6868
7120
|
const l = get(r, "attributes", []), i = l.find(
|
|
6869
|
-
(
|
|
7121
|
+
(C) => C.key === "data-chai-richtext" || C.key === "chai-richtext"
|
|
6870
7122
|
), c = l.find(
|
|
6871
|
-
(
|
|
7123
|
+
(C) => C.key === "data-chai-lightbox" || C.key === "chai-lightbox"
|
|
6872
7124
|
), d = l.find(
|
|
6873
|
-
(
|
|
7125
|
+
(C) => C.key === "data-chai-dropdown" || C.key === "chai-dropdown"
|
|
6874
7126
|
), p = l.find(
|
|
6875
|
-
(
|
|
7127
|
+
(C) => C.key === "data-chai-dropdown-button" || C.key === "chai-dropdown-button"
|
|
6876
7128
|
), u = l.find(
|
|
6877
|
-
(
|
|
7129
|
+
(C) => C.key === "data-chai-dropdown-content" || C.key === "chai-dropdown-content"
|
|
6878
7130
|
);
|
|
6879
7131
|
if (a = {
|
|
6880
7132
|
...a,
|
|
@@ -6882,13 +7134,13 @@ const CoreBlock = ({
|
|
|
6882
7134
|
...getAttrs(r),
|
|
6883
7135
|
...getStyles(r)
|
|
6884
7136
|
}, r.attributes) {
|
|
6885
|
-
const
|
|
6886
|
-
|
|
7137
|
+
const C = r.attributes.find((S) => includes(NAME_ATTRIBUTES, S.key));
|
|
7138
|
+
C && (a._name = C.value);
|
|
6887
7139
|
}
|
|
6888
7140
|
if (i)
|
|
6889
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];
|
|
6890
7142
|
if (c) {
|
|
6891
|
-
const
|
|
7143
|
+
const C = [
|
|
6892
7144
|
"data-chai-lightbox",
|
|
6893
7145
|
"chai-lightbox",
|
|
6894
7146
|
"data-vbtype",
|
|
@@ -6902,42 +7154,42 @@ const CoreBlock = ({
|
|
|
6902
7154
|
...a,
|
|
6903
7155
|
href: ((m = l.find((S) => S.key === "href")) == null ? void 0 : m.value) || "",
|
|
6904
7156
|
hrefType: ((f = l.find((S) => S.key === "data-vbtype")) == null ? void 0 : f.value) || "video",
|
|
6905
|
-
autoplay: ((
|
|
6906
|
-
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", "")) || "",
|
|
6907
7159
|
backdropColor: ((y = l.find((S) => S.key === "data-overlay")) == null ? void 0 : y.value) || "",
|
|
6908
|
-
galleryName: ((
|
|
6909
|
-
}, forEach(
|
|
7160
|
+
galleryName: ((A = l.find((S) => S.key === "data-gall")) == null ? void 0 : A.value) || ""
|
|
7161
|
+
}, forEach(C, (S) => {
|
|
6910
7162
|
has(a, `styles_attrs.${S}`) && delete a.styles_attrs[S];
|
|
6911
7163
|
});
|
|
6912
7164
|
}
|
|
6913
7165
|
if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
|
|
6914
7166
|
delete a.styles_attrs;
|
|
6915
|
-
const
|
|
6916
|
-
a.content = getTextContent(
|
|
7167
|
+
const C = filter(r.children || [], (B) => (B == null ? void 0 : B.tagName) !== "span");
|
|
7168
|
+
a.content = getTextContent(C);
|
|
6917
7169
|
const S = find(
|
|
6918
7170
|
r.children || [],
|
|
6919
|
-
(
|
|
7171
|
+
(B) => (B == null ? void 0 : B.tagName) === "span" && some(B.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg")
|
|
6920
7172
|
);
|
|
6921
7173
|
if (S) {
|
|
6922
|
-
const
|
|
6923
|
-
if (
|
|
6924
|
-
a.icon = stringify([
|
|
6925
|
-
const { height: _, width:
|
|
6926
|
-
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;
|
|
6927
7179
|
}
|
|
6928
7180
|
}
|
|
6929
7181
|
return [a];
|
|
6930
7182
|
}
|
|
6931
7183
|
if (a._type === "Input") {
|
|
6932
|
-
const
|
|
6933
|
-
|
|
7184
|
+
const C = a.inputType || "text";
|
|
7185
|
+
C === "checkbox" ? set(a, "_type", "Checkbox") : C === "radio" && set(a, "_type", "Radio");
|
|
6934
7186
|
} else if (r.tagName === "video" || r.tagName === "iframe") {
|
|
6935
|
-
const
|
|
6936
|
-
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];
|
|
6937
7189
|
} else if (r.tagName === "svg") {
|
|
6938
|
-
const
|
|
6939
|
-
return a.styles = `${STYLES_KEY}, ${cn(`w-${_} h-${
|
|
6940
|
-
} 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")
|
|
6941
7193
|
return n.block.options.push({
|
|
6942
7194
|
label: getTextContent(r.children),
|
|
6943
7195
|
...getAttrs(r)
|
|
@@ -6986,21 +7238,21 @@ const CoreBlock = ({
|
|
|
6986
7238
|
/* @__PURE__ */ jsx(CardFooter, { className: "flex flex-col justify-end p-3", children: /* @__PURE__ */ jsx(Button, { disabled: a.trim() === "", onClick: () => c(), size: "sm", className: "w-fit", children: r("Import HTML") }) })
|
|
6987
7239
|
] });
|
|
6988
7240
|
}, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
6989
|
-
var
|
|
6990
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (
|
|
7241
|
+
var b;
|
|
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;
|
|
6991
7243
|
useEffect(() => {
|
|
6992
|
-
const
|
|
7244
|
+
const x = setTimeout(() => {
|
|
6993
7245
|
var y;
|
|
6994
7246
|
(y = u.current) == null || y.focus();
|
|
6995
7247
|
}, 0);
|
|
6996
|
-
return () => clearTimeout(
|
|
7248
|
+
return () => clearTimeout(x);
|
|
6997
7249
|
}, [g]);
|
|
6998
7250
|
const f = d ? values(n).filter(
|
|
6999
|
-
(
|
|
7000
|
-
var y,
|
|
7001
|
-
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());
|
|
7002
7254
|
}
|
|
7003
|
-
) : 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);
|
|
7004
7256
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-2xl flex-col", children: [
|
|
7005
7257
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7006
7258
|
Input$1,
|
|
@@ -7009,21 +7261,21 @@ const CoreBlock = ({
|
|
|
7009
7261
|
type: "search",
|
|
7010
7262
|
placeholder: i("Search blocks..."),
|
|
7011
7263
|
value: d,
|
|
7012
|
-
onChange: (
|
|
7264
|
+
onChange: (x) => p(x.target.value)
|
|
7013
7265
|
}
|
|
7014
7266
|
) }),
|
|
7015
|
-
/* @__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: [
|
|
7016
7268
|
i("No blocks found matching"),
|
|
7017
7269
|
' "',
|
|
7018
7270
|
d,
|
|
7019
7271
|
'"'
|
|
7020
7272
|
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: sortBy(
|
|
7021
|
-
|
|
7022
|
-
(
|
|
7023
|
-
).map((
|
|
7024
|
-
/* @__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())) }),
|
|
7025
7277
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: React__default.Children.toArray(
|
|
7026
|
-
reject(filter(values(f), { group:
|
|
7278
|
+
reject(filter(values(f), { group: x }), { hidden: !0 }).map((y) => /* @__PURE__ */ jsx(
|
|
7027
7279
|
CoreBlock,
|
|
7028
7280
|
{
|
|
7029
7281
|
parentId: r,
|
|
@@ -7034,7 +7286,7 @@ const CoreBlock = ({
|
|
|
7034
7286
|
y.type
|
|
7035
7287
|
))
|
|
7036
7288
|
) })
|
|
7037
|
-
] },
|
|
7289
|
+
] }, x)) }) })
|
|
7038
7290
|
] });
|
|
7039
7291
|
}, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
|
|
7040
7292
|
className: o,
|
|
@@ -7045,7 +7297,7 @@ const CoreBlock = ({
|
|
|
7045
7297
|
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), g = useCallback(() => {
|
|
7046
7298
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7047
7299
|
}, []);
|
|
7048
|
-
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: [
|
|
7049
7301
|
n ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
|
|
7050
7302
|
/* @__PURE__ */ jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: l("Add block") }),
|
|
7051
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") })
|
|
@@ -7084,7 +7336,7 @@ const CoreBlock = ({
|
|
|
7084
7336
|
const u = p.target.value;
|
|
7085
7337
|
c(u), n(u);
|
|
7086
7338
|
};
|
|
7087
|
-
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(
|
|
7088
7340
|
"select",
|
|
7089
7341
|
{
|
|
7090
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",
|
|
@@ -7125,18 +7377,18 @@ const BlockCard = ({
|
|
|
7125
7377
|
parentId: r = void 0,
|
|
7126
7378
|
position: a = -1
|
|
7127
7379
|
}) => {
|
|
7128
|
-
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"), [,
|
|
7129
|
-
const
|
|
7130
|
-
return
|
|
7131
|
-
},
|
|
7132
|
-
async (
|
|
7133
|
-
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")) {
|
|
7134
7386
|
d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7135
7387
|
return;
|
|
7136
7388
|
}
|
|
7137
7389
|
i(!0);
|
|
7138
|
-
const
|
|
7139
|
-
isEmpty(
|
|
7390
|
+
const j = await c(n, o);
|
|
7391
|
+
isEmpty(j) || p(syncBlocksWithDefaults(j), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7140
7392
|
},
|
|
7141
7393
|
[d, p, o, c, n, r, a]
|
|
7142
7394
|
);
|
|
@@ -7145,26 +7397,26 @@ const BlockCard = ({
|
|
|
7145
7397
|
"div",
|
|
7146
7398
|
{
|
|
7147
7399
|
onClick: l ? () => {
|
|
7148
|
-
} :
|
|
7400
|
+
} : x,
|
|
7149
7401
|
draggable: f ? "true" : "false",
|
|
7150
|
-
onDragStart: async (
|
|
7151
|
-
const
|
|
7152
|
-
let
|
|
7153
|
-
if (
|
|
7154
|
-
const S = { blocks:
|
|
7155
|
-
if (
|
|
7156
|
-
const
|
|
7157
|
-
|
|
7158
|
-
|
|
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);
|
|
7159
7411
|
};
|
|
7160
7412
|
} else
|
|
7161
|
-
|
|
7162
|
-
|
|
7413
|
+
A.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7414
|
+
h(S), setTimeout(() => {
|
|
7163
7415
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7164
7416
|
}, 200);
|
|
7165
7417
|
}
|
|
7166
7418
|
},
|
|
7167
|
-
className: clsx(
|
|
7419
|
+
className: clsx$1(
|
|
7168
7420
|
"relative mt-2 cursor-pointer overflow-hidden rounded-md border border-border bg-white duration-200 hover:border-blue-500 hover:shadow-xl"
|
|
7169
7421
|
),
|
|
7170
7422
|
children: [
|
|
@@ -7191,9 +7443,9 @@ const BlockCard = ({
|
|
|
7191
7443
|
})();
|
|
7192
7444
|
}, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
|
|
7193
7445
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
7194
|
-
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((
|
|
7195
|
-
|
|
7196
|
-
|
|
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) => {
|
|
7447
|
+
b.current && (clearTimeout(b.current), b.current = null), b.current = setTimeout(() => {
|
|
7448
|
+
b.current && f(C);
|
|
7197
7449
|
}, 300);
|
|
7198
7450
|
};
|
|
7199
7451
|
if (u)
|
|
@@ -7201,26 +7453,26 @@ const BlockCard = ({
|
|
|
7201
7453
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7202
7454
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7203
7455
|
] });
|
|
7204
|
-
const
|
|
7456
|
+
const A = filter(h, (C, S) => S % 2 === 0), j = filter(h, (C, S) => S % 2 === 1);
|
|
7205
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: [
|
|
7206
7458
|
/* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
7207
7459
|
/* @__PURE__ */ jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
|
|
7208
7460
|
/* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
|
|
7209
|
-
/* @__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") }),
|
|
7210
7462
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7211
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(
|
|
7212
|
-
map(g, (
|
|
7464
|
+
map(g, (C, S) => /* @__PURE__ */ jsxs(
|
|
7213
7465
|
"div",
|
|
7214
7466
|
{
|
|
7215
7467
|
onMouseEnter: () => y(S),
|
|
7216
|
-
onMouseLeave: () => clearTimeout(
|
|
7468
|
+
onMouseLeave: () => clearTimeout(b.current),
|
|
7217
7469
|
onClick: () => f(S),
|
|
7218
|
-
className: cn(
|
|
7470
|
+
className: cn$1(
|
|
7219
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",
|
|
7220
7472
|
S === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
|
|
7221
7473
|
),
|
|
7222
7474
|
children: [
|
|
7223
|
-
/* @__PURE__ */ jsx("span", { children: capitalize(
|
|
7475
|
+
/* @__PURE__ */ jsx("span", { children: capitalize(x(S.toLowerCase())) }),
|
|
7224
7476
|
/* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
|
|
7225
7477
|
]
|
|
7226
7478
|
},
|
|
@@ -7232,15 +7484,15 @@ const BlockCard = ({
|
|
|
7232
7484
|
/* @__PURE__ */ jsxs(
|
|
7233
7485
|
ScrollArea,
|
|
7234
7486
|
{
|
|
7235
|
-
onMouseEnter: () =>
|
|
7487
|
+
onMouseEnter: () => b.current ? clearTimeout(b.current) : null,
|
|
7236
7488
|
className: "z-10 -mt-2 flex h-full max-h-full w-full flex-col gap-2 border-l border-border transition-all ease-linear",
|
|
7237
7489
|
children: [
|
|
7238
7490
|
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
|
|
7239
7491
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
7240
|
-
|
|
7492
|
+
A.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
|
|
7241
7493
|
) }),
|
|
7242
7494
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
7243
|
-
|
|
7495
|
+
j.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
|
|
7244
7496
|
) })
|
|
7245
7497
|
] }),
|
|
7246
7498
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -7463,50 +7715,50 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7463
7715
|
var P;
|
|
7464
7716
|
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
|
|
7465
7717
|
let p = null;
|
|
7466
|
-
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: f, data:
|
|
7467
|
-
|
|
7468
|
-
}, S = (
|
|
7469
|
-
|
|
7470
|
-
},
|
|
7471
|
-
|
|
7472
|
-
}, [_,
|
|
7473
|
-
var
|
|
7474
|
-
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);
|
|
7475
7727
|
}, k = () => {
|
|
7476
|
-
|
|
7477
|
-
}, v = (
|
|
7478
|
-
k(),
|
|
7728
|
+
w(null);
|
|
7729
|
+
}, v = (E) => {
|
|
7730
|
+
k(), E.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(), j(E);
|
|
7479
7731
|
};
|
|
7480
7732
|
useEffect(() => {
|
|
7481
|
-
const
|
|
7482
|
-
|
|
7733
|
+
const E = setTimeout(() => {
|
|
7734
|
+
x && !o.isOpen && !y && !i.includes(f) && o.toggle();
|
|
7483
7735
|
}, 500);
|
|
7484
|
-
return () => clearTimeout(
|
|
7485
|
-
}, [
|
|
7736
|
+
return () => clearTimeout(E);
|
|
7737
|
+
}, [x, o, y]);
|
|
7486
7738
|
const N = useMemo(() => {
|
|
7487
|
-
const
|
|
7488
|
-
for (let
|
|
7489
|
-
if (
|
|
7490
|
-
const
|
|
7491
|
-
|
|
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");
|
|
7492
7744
|
}
|
|
7493
|
-
return
|
|
7494
|
-
}, [
|
|
7495
|
-
const
|
|
7496
|
-
|
|
7497
|
-
const
|
|
7498
|
-
|
|
7499
|
-
},
|
|
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) => {
|
|
7500
7752
|
k();
|
|
7501
|
-
const
|
|
7502
|
-
|
|
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 });
|
|
7503
7755
|
};
|
|
7504
7756
|
return f === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
|
|
7505
7757
|
/* @__PURE__ */ jsx("br", {}),
|
|
7506
7758
|
/* @__PURE__ */ jsx(
|
|
7507
7759
|
"div",
|
|
7508
7760
|
{
|
|
7509
|
-
onClick: () =>
|
|
7761
|
+
onClick: () => L(-1),
|
|
7510
7762
|
className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
|
|
7511
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: [
|
|
7512
7764
|
/* @__PURE__ */ jsx(PlusIcon$1, { className: "h-2 w-2 stroke-[3]" }),
|
|
@@ -7526,22 +7778,22 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7526
7778
|
"data-node-id": f,
|
|
7527
7779
|
ref: i.includes(f) ? null : r,
|
|
7528
7780
|
onDragStart: () => S(o),
|
|
7529
|
-
onDragEnd: () =>
|
|
7530
|
-
onDragOver: (
|
|
7531
|
-
|
|
7781
|
+
onDragEnd: () => B(o),
|
|
7782
|
+
onDragOver: (E) => {
|
|
7783
|
+
E.preventDefault(), I(f, "yes");
|
|
7532
7784
|
},
|
|
7533
|
-
onDragLeave: (
|
|
7534
|
-
|
|
7785
|
+
onDragLeave: (E) => {
|
|
7786
|
+
E.preventDefault(), I(f, "no");
|
|
7535
7787
|
},
|
|
7536
|
-
onDrop: (
|
|
7537
|
-
|
|
7788
|
+
onDrop: (E) => {
|
|
7789
|
+
E.preventDefault(), I(f, "no");
|
|
7538
7790
|
},
|
|
7539
7791
|
children: [
|
|
7540
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(
|
|
7541
7793
|
"div",
|
|
7542
7794
|
{
|
|
7543
|
-
onClick: (
|
|
7544
|
-
|
|
7795
|
+
onClick: (E) => {
|
|
7796
|
+
E.stopPropagation(), L(o.childIndex);
|
|
7545
7797
|
},
|
|
7546
7798
|
onMouseEnter: T,
|
|
7547
7799
|
onMouseLeave: k,
|
|
@@ -7552,10 +7804,10 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7552
7804
|
/* @__PURE__ */ jsxs(
|
|
7553
7805
|
"div",
|
|
7554
7806
|
{
|
|
7555
|
-
className: cn(
|
|
7807
|
+
className: cn$1(
|
|
7556
7808
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
|
|
7557
|
-
|
|
7558
|
-
|
|
7809
|
+
b ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
|
|
7810
|
+
x && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
|
|
7559
7811
|
(o == null ? void 0 : o.id) === _ ? "bg-purple-100" : "",
|
|
7560
7812
|
y && "opacity-20",
|
|
7561
7813
|
i.includes(f) ? "opacity-50" : ""
|
|
@@ -7566,25 +7818,25 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7566
7818
|
"div",
|
|
7567
7819
|
{
|
|
7568
7820
|
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
7569
|
-
children: u && /* @__PURE__ */ jsx("button", { onClick:
|
|
7821
|
+
children: u && /* @__PURE__ */ jsx("button", { onClick: C, type: "button", children: /* @__PURE__ */ jsx(
|
|
7570
7822
|
ChevronRight,
|
|
7571
7823
|
{
|
|
7572
|
-
className: `h-3 w-3 stroke-[3] ${
|
|
7824
|
+
className: `h-3 w-3 stroke-[3] ${b ? "text-slate-200" : "text-slate-400"}`
|
|
7573
7825
|
}
|
|
7574
7826
|
) })
|
|
7575
7827
|
}
|
|
7576
7828
|
),
|
|
7577
7829
|
/* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
|
|
7578
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
7579
|
-
|
|
7830
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
|
|
7831
|
+
A ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
|
|
7580
7832
|
"div",
|
|
7581
7833
|
{
|
|
7582
7834
|
className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
|
|
7583
|
-
onDoubleClick: (
|
|
7584
|
-
|
|
7835
|
+
onDoubleClick: (E) => {
|
|
7836
|
+
E.stopPropagation(), o.edit(), o.deselect();
|
|
7585
7837
|
},
|
|
7586
7838
|
children: [
|
|
7587
|
-
/* @__PURE__ */ jsx("span", { children: (
|
|
7839
|
+
/* @__PURE__ */ jsx("span", { children: (h == null ? void 0 : h._name) || (h == null ? void 0 : h._type.split("/").pop()) }),
|
|
7588
7840
|
N.includes("data") && /* @__PURE__ */ jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
|
|
7589
7841
|
N.includes("event") && /* @__PURE__ */ jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
|
|
7590
7842
|
N.includes("show") && /* @__PURE__ */ jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
|
|
@@ -7594,18 +7846,18 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7594
7846
|
] })
|
|
7595
7847
|
] }),
|
|
7596
7848
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
7597
|
-
!i.includes(f) && a.map((
|
|
7849
|
+
!i.includes(f) && a.map((E) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7598
7850
|
/* @__PURE__ */ jsx(
|
|
7599
7851
|
TooltipTrigger,
|
|
7600
7852
|
{
|
|
7601
7853
|
className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
|
|
7602
7854
|
asChild: !0,
|
|
7603
|
-
children: React__default.createElement(
|
|
7855
|
+
children: React__default.createElement(E.item, { blockId: f })
|
|
7604
7856
|
}
|
|
7605
7857
|
),
|
|
7606
|
-
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children:
|
|
7858
|
+
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: E.tooltip })
|
|
7607
7859
|
] })),
|
|
7608
|
-
canAddChildBlock(
|
|
7860
|
+
canAddChildBlock(h == null ? void 0 : h._type) && !i.includes(f) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7609
7861
|
/* @__PURE__ */ jsx(
|
|
7610
7862
|
TooltipTrigger,
|
|
7611
7863
|
{
|
|
@@ -7621,8 +7873,8 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7621
7873
|
/* @__PURE__ */ jsx(
|
|
7622
7874
|
TooltipTrigger,
|
|
7623
7875
|
{
|
|
7624
|
-
onClick: (
|
|
7625
|
-
|
|
7876
|
+
onClick: (E) => {
|
|
7877
|
+
E.stopPropagation(), c(f), o.isOpen && o.toggle();
|
|
7626
7878
|
},
|
|
7627
7879
|
className: "cursor-pointer rounded bg-transparent hover:text-black",
|
|
7628
7880
|
asChild: !0,
|
|
@@ -7644,7 +7896,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7644
7896
|
"input",
|
|
7645
7897
|
{
|
|
7646
7898
|
autoFocus: !0,
|
|
7647
|
-
className: cn(
|
|
7899
|
+
className: cn$1(
|
|
7648
7900
|
"ml-2 !h-4 w-full rounded-sm border border-border bg-background px-1 text-[11px] leading-tight outline-none",
|
|
7649
7901
|
o.isSelected ? "text-black dark:text-white" : ""
|
|
7650
7902
|
),
|
|
@@ -7743,7 +7995,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
|
|
|
7743
7995
|
t("Add Block")
|
|
7744
7996
|
] })
|
|
7745
7997
|
] }) }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7746
|
-
/* @__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(
|
|
7747
7999
|
"div",
|
|
7748
8000
|
{
|
|
7749
8001
|
id: "outline-view",
|
|
@@ -8284,12 +8536,12 @@ function QuickPrompts({ onClick: o }) {
|
|
|
8284
8536
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
8285
8537
|
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null), f = useRef(null);
|
|
8286
8538
|
useEffect(() => {
|
|
8287
|
-
var
|
|
8288
|
-
(
|
|
8539
|
+
var b;
|
|
8540
|
+
(b = m.current) == null || b.focus();
|
|
8289
8541
|
}, []);
|
|
8290
|
-
const
|
|
8291
|
-
const { usage:
|
|
8292
|
-
!l &&
|
|
8542
|
+
const h = (b) => {
|
|
8543
|
+
const { usage: x } = b || {};
|
|
8544
|
+
!l && x && g(x), f.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
8293
8545
|
};
|
|
8294
8546
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
8295
8547
|
/* @__PURE__ */ jsxs(
|
|
@@ -8309,12 +8561,12 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8309
8561
|
{
|
|
8310
8562
|
ref: m,
|
|
8311
8563
|
value: i,
|
|
8312
|
-
onChange: (
|
|
8564
|
+
onChange: (b) => c(b.target.value),
|
|
8313
8565
|
placeholder: n("Ask AI to edit content"),
|
|
8314
8566
|
className: "w-full",
|
|
8315
8567
|
rows: 3,
|
|
8316
|
-
onKeyDown: (
|
|
8317
|
-
|
|
8568
|
+
onKeyDown: (b) => {
|
|
8569
|
+
b.key === "Enter" && (b.preventDefault(), f.current && clearTimeout(f.current), g(void 0), r("content", o, i, h));
|
|
8318
8570
|
}
|
|
8319
8571
|
}
|
|
8320
8572
|
),
|
|
@@ -8324,7 +8576,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8324
8576
|
{
|
|
8325
8577
|
disabled: i.trim().length < 5 || a,
|
|
8326
8578
|
onClick: () => {
|
|
8327
|
-
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);
|
|
8328
8580
|
},
|
|
8329
8581
|
variant: "default",
|
|
8330
8582
|
className: "w-fit",
|
|
@@ -8356,8 +8608,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8356
8608
|
/* @__PURE__ */ jsx(
|
|
8357
8609
|
QuickPrompts,
|
|
8358
8610
|
{
|
|
8359
|
-
onClick: (
|
|
8360
|
-
f.current && clearTimeout(f.current), g(void 0), r("content", o,
|
|
8611
|
+
onClick: (b) => {
|
|
8612
|
+
f.current && clearTimeout(f.current), g(void 0), r("content", o, b, h);
|
|
8361
8613
|
}
|
|
8362
8614
|
}
|
|
8363
8615
|
)
|
|
@@ -8367,19 +8619,15 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8367
8619
|
] }) }) : null
|
|
8368
8620
|
] });
|
|
8369
8621
|
}, AISetContext = () => {
|
|
8370
|
-
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1),
|
|
8622
|
+
const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), m = useRef(null);
|
|
8371
8623
|
useEffect(() => {
|
|
8372
8624
|
n && a(n);
|
|
8373
8625
|
}, [n]);
|
|
8374
|
-
const
|
|
8626
|
+
const f = async () => {
|
|
8375
8627
|
try {
|
|
8376
|
-
d(!0), u(null), await i(r), m(
|
|
8377
|
-
|
|
8378
|
-
|
|
8379
|
-
variant: "default"
|
|
8380
|
-
}), f.current.click();
|
|
8381
|
-
} catch (x) {
|
|
8382
|
-
u(x);
|
|
8628
|
+
d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
|
|
8629
|
+
} catch (h) {
|
|
8630
|
+
u(h);
|
|
8383
8631
|
} finally {
|
|
8384
8632
|
d(!1);
|
|
8385
8633
|
}
|
|
@@ -8387,25 +8635,25 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8387
8635
|
return /* @__PURE__ */ jsx(
|
|
8388
8636
|
Accordion,
|
|
8389
8637
|
{
|
|
8390
|
-
onValueChange: (
|
|
8391
|
-
g(
|
|
8638
|
+
onValueChange: (h) => {
|
|
8639
|
+
g(h !== "");
|
|
8392
8640
|
},
|
|
8393
8641
|
type: "single",
|
|
8394
8642
|
collapsible: !0,
|
|
8395
8643
|
children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
|
|
8396
|
-
/* @__PURE__ */ jsx(AccordionTrigger, { ref:
|
|
8644
|
+
/* @__PURE__ */ jsx(AccordionTrigger, { ref: m, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
|
|
8397
8645
|
/* @__PURE__ */ jsxs(AccordionContent, { children: [
|
|
8398
8646
|
/* @__PURE__ */ jsx(
|
|
8399
8647
|
Textarea,
|
|
8400
8648
|
{
|
|
8401
8649
|
ref: l,
|
|
8402
8650
|
value: r,
|
|
8403
|
-
onChange: (
|
|
8651
|
+
onChange: (h) => a(h.target.value),
|
|
8404
8652
|
placeholder: o("Tell about this page eg this page is about"),
|
|
8405
8653
|
className: "mt-1 w-full",
|
|
8406
8654
|
rows: 10,
|
|
8407
|
-
onKeyDown: (
|
|
8408
|
-
|
|
8655
|
+
onKeyDown: (h) => {
|
|
8656
|
+
h.key === "Enter" && (h.preventDefault(), f());
|
|
8409
8657
|
}
|
|
8410
8658
|
}
|
|
8411
8659
|
),
|
|
@@ -8417,7 +8665,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8417
8665
|
Button,
|
|
8418
8666
|
{
|
|
8419
8667
|
disabled: r.trim().length < 5,
|
|
8420
|
-
onClick: () =>
|
|
8668
|
+
onClick: () => f(),
|
|
8421
8669
|
variant: "default",
|
|
8422
8670
|
className: "w-fit",
|
|
8423
8671
|
size: "sm",
|
|
@@ -8446,7 +8694,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8446
8694
|
AlertDialogAction,
|
|
8447
8695
|
{
|
|
8448
8696
|
onClick: () => {
|
|
8449
|
-
a(""),
|
|
8697
|
+
a(""), f();
|
|
8450
8698
|
},
|
|
8451
8699
|
children: o("Yes, Delete")
|
|
8452
8700
|
}
|
|
@@ -8569,7 +8817,7 @@ const AiAssistant = () => {
|
|
|
8569
8817
|
}, DataBinding = () => {
|
|
8570
8818
|
const o = usePageExternalData(), [n, r] = useAtom$1(dataBindingActiveAtom), { t: a } = useTranslation();
|
|
8571
8819
|
return isEmpty(o) ? null : /* @__PURE__ */ jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8572
|
-
/* @__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") }) }) }),
|
|
8573
8821
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: a("Toggle Data Binding") }) })
|
|
8574
8822
|
] }) });
|
|
8575
8823
|
}, CanvasTopBar = () => {
|
|
@@ -8600,11 +8848,11 @@ const AiAssistant = () => {
|
|
|
8600
8848
|
] })
|
|
8601
8849
|
] });
|
|
8602
8850
|
}, AttrsEditor = React__default.memo(function o({ preloadedAttributes: n = [], onAttributesChange: r }) {
|
|
8603
|
-
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);
|
|
8604
8852
|
useEffect(() => {
|
|
8605
8853
|
l(n);
|
|
8606
8854
|
}, [n]);
|
|
8607
|
-
const
|
|
8855
|
+
const x = () => {
|
|
8608
8856
|
if (i.startsWith("@")) {
|
|
8609
8857
|
f("Attribute keys cannot start with '@'");
|
|
8610
8858
|
return;
|
|
@@ -8614,11 +8862,11 @@ const AiAssistant = () => {
|
|
|
8614
8862
|
r(S), l(a), c(""), p(""), f("");
|
|
8615
8863
|
}
|
|
8616
8864
|
}, y = (S) => {
|
|
8617
|
-
const
|
|
8618
|
-
r(
|
|
8619
|
-
},
|
|
8865
|
+
const B = a.filter((_, w) => w !== S);
|
|
8866
|
+
r(B), l(B);
|
|
8867
|
+
}, A = (S) => {
|
|
8620
8868
|
g(S), c(a[S].key), p(a[S].value);
|
|
8621
|
-
},
|
|
8869
|
+
}, j = () => {
|
|
8622
8870
|
if (i.startsWith("@")) {
|
|
8623
8871
|
f("Attribute keys cannot start with '@'");
|
|
8624
8872
|
return;
|
|
@@ -8633,7 +8881,7 @@ const AiAssistant = () => {
|
|
|
8633
8881
|
"form",
|
|
8634
8882
|
{
|
|
8635
8883
|
onSubmit: (S) => {
|
|
8636
|
-
S.preventDefault(), u !== null ?
|
|
8884
|
+
S.preventDefault(), u !== null ? j() : x();
|
|
8637
8885
|
},
|
|
8638
8886
|
className: "space-y-3",
|
|
8639
8887
|
children: [
|
|
@@ -8647,7 +8895,7 @@ const AiAssistant = () => {
|
|
|
8647
8895
|
autoCorrect: "off",
|
|
8648
8896
|
spellCheck: "false",
|
|
8649
8897
|
id: "attrKey",
|
|
8650
|
-
ref:
|
|
8898
|
+
ref: h,
|
|
8651
8899
|
value: i,
|
|
8652
8900
|
onChange: (S) => c(S.target.value),
|
|
8653
8901
|
placeholder: "Enter Key",
|
|
@@ -8665,11 +8913,11 @@ const AiAssistant = () => {
|
|
|
8665
8913
|
spellCheck: "false",
|
|
8666
8914
|
id: "attrValue",
|
|
8667
8915
|
rows: 2,
|
|
8668
|
-
ref:
|
|
8916
|
+
ref: b,
|
|
8669
8917
|
value: d,
|
|
8670
8918
|
onChange: (S) => p(S.target.value),
|
|
8671
8919
|
onKeyDown: (S) => {
|
|
8672
|
-
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ?
|
|
8920
|
+
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? j() : x());
|
|
8673
8921
|
},
|
|
8674
8922
|
placeholder: "Enter Value",
|
|
8675
8923
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
@@ -8682,16 +8930,16 @@ const AiAssistant = () => {
|
|
|
8682
8930
|
]
|
|
8683
8931
|
}
|
|
8684
8932
|
),
|
|
8685
|
-
/* @__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: [
|
|
8686
8934
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
8687
8935
|
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
|
|
8688
8936
|
/* @__PURE__ */ jsx("span", { className: "text-wrap max-w-[200px] font-normal", children: S.value.toString() })
|
|
8689
8937
|
] }),
|
|
8690
8938
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
8691
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B
|
|
8692
|
-
/* @__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" }) })
|
|
8693
8941
|
] })
|
|
8694
|
-
] },
|
|
8942
|
+
] }, B)) })
|
|
8695
8943
|
] });
|
|
8696
8944
|
}), BlockAttributesEditor = React.memo(() => {
|
|
8697
8945
|
const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
|
|
@@ -8869,7 +9117,7 @@ const ChooseLayout = ({ open: o, close: n }) => {
|
|
|
8869
9117
|
)
|
|
8870
9118
|
] }) })
|
|
8871
9119
|
] }) });
|
|
8872
|
-
}, TopBar = lazy(() => import("./Topbar-
|
|
9120
|
+
}, TopBar = lazy(() => import("./Topbar-DutZ_viX.js"));
|
|
8873
9121
|
function useSidebarMenuItems() {
|
|
8874
9122
|
return useMemo(() => compact([
|
|
8875
9123
|
{
|
|
@@ -8885,12 +9133,12 @@ const RootLayout = () => {
|
|
|
8885
9133
|
usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
|
|
8886
9134
|
n(1);
|
|
8887
9135
|
});
|
|
8888
|
-
const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (
|
|
8889
|
-
|
|
8890
|
-
}, u = (
|
|
8891
|
-
n(o ===
|
|
8892
|
-
}, g = useSidebarMenuItems(), { t: m } = useTranslation(), f = [...g, ...c],
|
|
8893
|
-
return /* @__PURE__ */ jsx("div", { dir:
|
|
9136
|
+
const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (b) => {
|
|
9137
|
+
b.preventDefault();
|
|
9138
|
+
}, u = (b) => {
|
|
9139
|
+
n(o === b ? null : b);
|
|
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: [
|
|
8894
9142
|
/* @__PURE__ */ jsxs(
|
|
8895
9143
|
"div",
|
|
8896
9144
|
{
|
|
@@ -8900,21 +9148,21 @@ const RootLayout = () => {
|
|
|
8900
9148
|
/* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
|
|
8901
9149
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
8902
9150
|
/* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
8903
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: f.map((
|
|
9151
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: f.map((b, x) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
8904
9152
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
8905
9153
|
Button,
|
|
8906
9154
|
{
|
|
8907
|
-
variant: o ===
|
|
9155
|
+
variant: o === x ? "default" : "ghost",
|
|
8908
9156
|
className: "mb-2 rounded-lg p-2 transition-colors",
|
|
8909
|
-
onClick: () => u(
|
|
8910
|
-
children: get(
|
|
9157
|
+
onClick: () => u(x),
|
|
9158
|
+
children: get(b, "icon", null)
|
|
8911
9159
|
},
|
|
8912
|
-
|
|
9160
|
+
x
|
|
8913
9161
|
) }),
|
|
8914
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(
|
|
8915
|
-
] }, "button" +
|
|
9162
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(b.label) }) })
|
|
9163
|
+
] }, "button" + x)) }),
|
|
8916
9164
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
8917
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((
|
|
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}`)) })
|
|
8918
9166
|
] }),
|
|
8919
9167
|
/* @__PURE__ */ jsx(
|
|
8920
9168
|
motion.div,
|
|
@@ -8983,7 +9231,7 @@ const RootLayout = () => {
|
|
|
8983
9231
|
] }) });
|
|
8984
9232
|
}, PreviewScreen = () => {
|
|
8985
9233
|
const [o, n] = usePreviewMode(), { t: r } = useTranslation(), a = useBuilderProp("previewComponent", null);
|
|
8986
|
-
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: [
|
|
8987
9235
|
/* @__PURE__ */ jsxs(Button, { size: "sm", className: "absolute right-0 top-0 m-4 space-x-2", onClick: () => n(!1), children: [
|
|
8988
9236
|
/* @__PURE__ */ jsx(EyeClosedIcon, {}),
|
|
8989
9237
|
/* @__PURE__ */ jsx("span", { children: r("Close Preview") })
|
|
@@ -9079,9 +9327,9 @@ export {
|
|
|
9079
9327
|
generateUUID as generateBlockId,
|
|
9080
9328
|
getBlocksFromHTML,
|
|
9081
9329
|
getClassValueAndUnit,
|
|
9082
|
-
|
|
9083
|
-
cn as mergeClasses,
|
|
9084
|
-
|
|
9330
|
+
We as i18n,
|
|
9331
|
+
cn$1 as mergeClasses,
|
|
9332
|
+
Fe as registerChaiBlock,
|
|
9085
9333
|
useAddBlock,
|
|
9086
9334
|
useAddClassesToBlocks,
|
|
9087
9335
|
useAskAi,
|
|
@@ -9124,7 +9372,7 @@ export {
|
|
|
9124
9372
|
useStylingState,
|
|
9125
9373
|
useTheme,
|
|
9126
9374
|
useThemeOptions,
|
|
9127
|
-
|
|
9375
|
+
Ve as useTranslation,
|
|
9128
9376
|
useUILibraryBlocks,
|
|
9129
9377
|
useUndoManager,
|
|
9130
9378
|
useUpdateBlocksProps,
|