@chaibuilder/sdk 2.0.1 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +5 -5
- package/dist/core.d.ts +30 -3
- package/dist/core.js +1242 -1187
- package/dist/render.cjs +2 -2
- package/dist/render.d.ts +1 -3
- package/dist/render.js +88 -90
- package/package.json +1 -1
package/dist/core.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
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
3
|
var V = (o, n, r) => K(o, typeof n != "symbol" ? n + "" : n, r);
|
|
4
|
-
import { jsx,
|
|
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
7
|
import { O as DropdownMenu, P as DropdownMenuTrigger, Q as DropdownMenuContent, R as DropdownMenuItem, S as Skeleton, B as Button, a6 as Label, H as Dialog, I as DialogTrigger, J as DialogContent, a7 as Popover, ak as Tooltip, al as TooltipTrigger, a8 as PopoverTrigger, am as TooltipContent, a9 as PopoverContent, v as Command, x as CommandInput, y as CommandList, z as CommandEmpty, D as CommandGroup, E as CommandItem, K as DialogHeader, M as DialogTitle, n as Badge, V as DropdownMenuLabel, W as DropdownMenuSeparator, T as DropdownMenuCheckboxItem, a2 as HoverCard, a3 as HoverCardTrigger, a4 as HoverCardContent, aj as Textarea, a5 as Input$1, ao as TooltipPortal, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, aa as ScrollArea, Y as DropdownMenuGroup, X as DropdownMenuShortcut, A as Accordion, C as Card, q as CardHeader, t as CardDescription, u as CardContent, r as CardFooter, af as Tabs, ag as TabsList, ah as TabsTrigger, ai as TabsContent, 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, ae as Switch, ac as Separator, an as TooltipProvider, ad as Toaster } from "./tooltip-PKiP886L.js";
|
|
8
|
-
import { atom as atom$1,
|
|
9
|
-
import { find, filter, flatten, map, omit, isString, has, isObject, memoize,
|
|
8
|
+
import { atom as atom$1, useAtomValue as useAtomValue$1, useAtom as useAtom$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
|
|
9
|
+
import { find, filter, flatten, map, omit, isString, has, get, isObject, memoize, compact, isEmpty, noop, includes, without, each, first, keys, range, values, flattenDeep, set, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, findIndex, throttle, isFunction as isFunction$1, reverse, startCase, debounce, capitalize, split, 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
|
|
12
|
+
import { useTranslation as Ve } from "react-i18next";
|
|
13
13
|
import { g as generateUUID, a as getBreakpointValue, c as cn$1 } from "./Functions-BGzDsf1z.js";
|
|
14
14
|
import { flip } from "@floating-ui/dom";
|
|
15
15
|
import { useFloating, shift } from "@floating-ui/react-dom";
|
|
@@ -17,7 +17,7 @@ import { PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, Plus
|
|
|
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";
|
|
@@ -36,6 +36,7 @@ import { ErrorBoundary } from "react-error-boundary";
|
|
|
36
36
|
import { Resizable } from "re-resizable";
|
|
37
37
|
import RjForm from "@rjsf/core";
|
|
38
38
|
import validator from "@rjsf/validator-ajv8";
|
|
39
|
+
import { isEmpty as isEmpty$1, get as get$1 } from "lodash";
|
|
39
40
|
import Link from "@tiptap/extension-link";
|
|
40
41
|
import TextAlign from "@tiptap/extension-text-align";
|
|
41
42
|
import Underline from "@tiptap/extension-underline";
|
|
@@ -45,7 +46,7 @@ import Fuse from "fuse.js";
|
|
|
45
46
|
import { parse, stringify } from "himalaya";
|
|
46
47
|
import { Tree } from "react-arborist";
|
|
47
48
|
import i18n from "i18next";
|
|
48
|
-
import { default as
|
|
49
|
+
import { default as We } from "i18next";
|
|
49
50
|
import { motion } from "framer-motion";
|
|
50
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) => {
|
|
51
52
|
if ("e" in o)
|
|
@@ -93,197 +94,197 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
93
94
|
for (const i of n.p)
|
|
94
95
|
l.add(i);
|
|
95
96
|
return l;
|
|
96
|
-
}, 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 = (
|
|
97
|
-
var
|
|
98
|
-
return (
|
|
99
|
-
}, g = (
|
|
100
|
-
var
|
|
101
|
-
return (
|
|
102
|
-
}, ...
|
|
103
|
-
const
|
|
104
|
-
let L = o.get(
|
|
105
|
-
return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(
|
|
106
|
-
}), f =
|
|
107
|
-
let
|
|
108
|
-
const v = (
|
|
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 = (x, ...f) => x.read(...f), p = (x, ...f) => x.write(...f), u = (x, f) => {
|
|
98
|
+
var h;
|
|
99
|
+
return (h = x.unstable_onInit) == null ? void 0 : h.call(x, f);
|
|
100
|
+
}, g = (x, f) => {
|
|
101
|
+
var h;
|
|
102
|
+
return (h = x.onMount) == null ? void 0 : h.call(x, f);
|
|
103
|
+
}, ...m) => {
|
|
104
|
+
const x = m[0] || ((w) => {
|
|
105
|
+
let L = o.get(w);
|
|
106
|
+
return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(w, L), u == null || u(w, S)), L;
|
|
107
|
+
}), f = m[1] || (() => {
|
|
108
|
+
let w, L;
|
|
109
|
+
const v = (y) => {
|
|
109
110
|
try {
|
|
110
|
-
|
|
111
|
-
} catch (
|
|
112
|
-
|
|
111
|
+
y();
|
|
112
|
+
} catch (E) {
|
|
113
|
+
w || (w = !0, L = E);
|
|
113
114
|
}
|
|
114
115
|
};
|
|
115
116
|
do {
|
|
116
117
|
c.f && v(c.f);
|
|
117
|
-
const
|
|
118
|
+
const y = /* @__PURE__ */ new Set(), E = y.add.bind(y);
|
|
118
119
|
a.forEach((T) => {
|
|
119
120
|
var I;
|
|
120
|
-
return (I = n.get(T)) == null ? void 0 : I.l.forEach(
|
|
121
|
-
}), a.clear(), i.forEach(
|
|
121
|
+
return (I = n.get(T)) == null ? void 0 : I.l.forEach(E);
|
|
122
|
+
}), a.clear(), i.forEach(E), i.clear(), l.forEach(E), l.clear(), y.forEach(v), a.size && h();
|
|
122
123
|
} while (a.size || i.size || l.size);
|
|
123
|
-
if (
|
|
124
|
+
if (w)
|
|
124
125
|
throw L;
|
|
125
|
-
}),
|
|
126
|
-
const
|
|
127
|
-
for (;
|
|
128
|
-
const
|
|
129
|
-
if (v.has(
|
|
130
|
-
|
|
126
|
+
}), h = m[2] || (() => {
|
|
127
|
+
const w = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), y = Array.from(a);
|
|
128
|
+
for (; y.length; ) {
|
|
129
|
+
const E = y[y.length - 1], T = x(E);
|
|
130
|
+
if (v.has(E)) {
|
|
131
|
+
y.pop();
|
|
131
132
|
continue;
|
|
132
133
|
}
|
|
133
|
-
if (L.has(
|
|
134
|
-
r.get(
|
|
134
|
+
if (L.has(E)) {
|
|
135
|
+
r.get(E) === T.n && w.push([E, T]), v.add(E), y.pop();
|
|
135
136
|
continue;
|
|
136
137
|
}
|
|
137
|
-
L.add(
|
|
138
|
-
for (const I of getMountedOrPendingDependents(
|
|
139
|
-
L.has(I) ||
|
|
138
|
+
L.add(E);
|
|
139
|
+
for (const I of getMountedOrPendingDependents(E, T, n))
|
|
140
|
+
L.has(I) || y.push(I);
|
|
140
141
|
}
|
|
141
|
-
for (let
|
|
142
|
-
const [T, I] =
|
|
143
|
-
let
|
|
144
|
-
for (const
|
|
145
|
-
if (
|
|
146
|
-
|
|
142
|
+
for (let E = w.length - 1; E >= 0; --E) {
|
|
143
|
+
const [T, I] = w[E];
|
|
144
|
+
let R = !1;
|
|
145
|
+
for (const P of I.d.keys())
|
|
146
|
+
if (P !== T && a.has(P)) {
|
|
147
|
+
R = !0;
|
|
147
148
|
break;
|
|
148
149
|
}
|
|
149
|
-
|
|
150
|
+
R && (b(T), B(T)), r.delete(T);
|
|
150
151
|
}
|
|
151
|
-
}), b =
|
|
152
|
+
}), b = m[3] || ((w) => {
|
|
152
153
|
var L, v;
|
|
153
|
-
const
|
|
154
|
-
if (isAtomStateInitialized(
|
|
155
|
-
([
|
|
154
|
+
const y = x(w);
|
|
155
|
+
if (isAtomStateInitialized(y) && (n.has(w) && r.get(w) !== y.n || Array.from(y.d).every(
|
|
156
|
+
([D, O]) => (
|
|
156
157
|
// Recursively, read the atom state of the dependency, and
|
|
157
158
|
// check if the atom epoch number is unchanged
|
|
158
|
-
b(
|
|
159
|
+
b(D).n === O
|
|
159
160
|
)
|
|
160
161
|
)))
|
|
161
|
-
return
|
|
162
|
-
|
|
163
|
-
let
|
|
162
|
+
return y;
|
|
163
|
+
y.d.clear();
|
|
164
|
+
let E = !0;
|
|
164
165
|
const T = () => {
|
|
165
|
-
n.has(
|
|
166
|
-
}, I = (
|
|
166
|
+
n.has(w) && (B(w), h(), f());
|
|
167
|
+
}, I = (D) => {
|
|
167
168
|
var O;
|
|
168
|
-
if (isSelfAtom(
|
|
169
|
-
const H =
|
|
169
|
+
if (isSelfAtom(w, D)) {
|
|
170
|
+
const H = x(D);
|
|
170
171
|
if (!isAtomStateInitialized(H))
|
|
171
|
-
if (hasInitialValue(
|
|
172
|
-
setAtomStateValueOrPromise(
|
|
172
|
+
if (hasInitialValue(D))
|
|
173
|
+
setAtomStateValueOrPromise(D, D.init, x);
|
|
173
174
|
else
|
|
174
175
|
throw new Error("no atom init");
|
|
175
176
|
return returnAtomValue(H);
|
|
176
177
|
}
|
|
177
|
-
const $ = b(
|
|
178
|
+
const $ = b(D);
|
|
178
179
|
try {
|
|
179
180
|
return returnAtomValue($);
|
|
180
181
|
} finally {
|
|
181
|
-
|
|
182
|
+
y.d.set(D, $.n), isPendingPromise(y.v) && addPendingPromiseToDependency(w, y.v, $), (O = n.get(D)) == null || O.t.add(w), E || T();
|
|
182
183
|
}
|
|
183
184
|
};
|
|
184
|
-
let
|
|
185
|
-
const
|
|
185
|
+
let R, P;
|
|
186
|
+
const N = {
|
|
186
187
|
get signal() {
|
|
187
|
-
return
|
|
188
|
+
return R || (R = new AbortController()), R.signal;
|
|
188
189
|
},
|
|
189
190
|
get setSelf() {
|
|
190
|
-
return !
|
|
191
|
-
if (!
|
|
191
|
+
return !P && isActuallyWritableAtom(w) && (P = (...D) => {
|
|
192
|
+
if (!E)
|
|
192
193
|
try {
|
|
193
|
-
return A(
|
|
194
|
+
return A(w, ...D);
|
|
194
195
|
} finally {
|
|
195
|
-
|
|
196
|
+
h(), f();
|
|
196
197
|
}
|
|
197
|
-
}),
|
|
198
|
+
}), P;
|
|
198
199
|
}
|
|
199
|
-
}, M =
|
|
200
|
+
}, M = y.n;
|
|
200
201
|
try {
|
|
201
|
-
const
|
|
202
|
-
return setAtomStateValueOrPromise(
|
|
202
|
+
const D = d(w, I, N);
|
|
203
|
+
return setAtomStateValueOrPromise(w, D, x), isPromiseLike$2(D) && ((L = D.onCancel) == null || L.call(D, () => R == null ? void 0 : R.abort()), D.then(
|
|
203
204
|
T,
|
|
204
205
|
T
|
|
205
|
-
)),
|
|
206
|
-
} catch (
|
|
207
|
-
return delete
|
|
206
|
+
)), y;
|
|
207
|
+
} catch (D) {
|
|
208
|
+
return delete y.v, y.e = D, ++y.n, y;
|
|
208
209
|
} finally {
|
|
209
|
-
|
|
210
|
+
E = !1, M !== y.n && r.get(w) === M && (r.set(w, y.n), a.add(w), (v = c.c) == null || v.call(c, w));
|
|
210
211
|
}
|
|
211
|
-
}),
|
|
212
|
-
const L = [
|
|
212
|
+
}), k = m[4] || ((w) => {
|
|
213
|
+
const L = [w];
|
|
213
214
|
for (; L.length; ) {
|
|
214
|
-
const v = L.pop(),
|
|
215
|
-
for (const
|
|
216
|
-
const T =
|
|
217
|
-
r.set(
|
|
215
|
+
const v = L.pop(), y = x(v);
|
|
216
|
+
for (const E of getMountedOrPendingDependents(v, y, n)) {
|
|
217
|
+
const T = x(E);
|
|
218
|
+
r.set(E, T.n), L.push(E);
|
|
218
219
|
}
|
|
219
220
|
}
|
|
220
|
-
}), A =
|
|
221
|
+
}), A = m[5] || ((w, ...L) => {
|
|
221
222
|
let v = !0;
|
|
222
|
-
const
|
|
223
|
-
var
|
|
224
|
-
const
|
|
223
|
+
const y = (T) => returnAtomValue(b(T)), E = (T, ...I) => {
|
|
224
|
+
var R;
|
|
225
|
+
const P = x(T);
|
|
225
226
|
try {
|
|
226
|
-
if (isSelfAtom(
|
|
227
|
+
if (isSelfAtom(w, T)) {
|
|
227
228
|
if (!hasInitialValue(T))
|
|
228
229
|
throw new Error("atom not writable");
|
|
229
|
-
const
|
|
230
|
-
setAtomStateValueOrPromise(T, M,
|
|
230
|
+
const N = P.n, M = I[0];
|
|
231
|
+
setAtomStateValueOrPromise(T, M, x), B(T), N !== P.n && (a.add(T), (R = c.c) == null || R.call(c, T), k(T));
|
|
231
232
|
return;
|
|
232
233
|
} else
|
|
233
234
|
return A(T, ...I);
|
|
234
235
|
} finally {
|
|
235
|
-
v || (
|
|
236
|
+
v || (h(), f());
|
|
236
237
|
}
|
|
237
238
|
};
|
|
238
239
|
try {
|
|
239
|
-
return p(
|
|
240
|
+
return p(w, y, E, ...L);
|
|
240
241
|
} finally {
|
|
241
242
|
v = !1;
|
|
242
243
|
}
|
|
243
|
-
}),
|
|
244
|
+
}), B = m[6] || ((w) => {
|
|
244
245
|
var L;
|
|
245
|
-
const v =
|
|
246
|
-
if (
|
|
247
|
-
for (const [
|
|
248
|
-
if (!
|
|
249
|
-
const I =
|
|
250
|
-
|
|
246
|
+
const v = x(w), y = n.get(w);
|
|
247
|
+
if (y && !isPendingPromise(v.v)) {
|
|
248
|
+
for (const [E, T] of v.d)
|
|
249
|
+
if (!y.d.has(E)) {
|
|
250
|
+
const I = x(E);
|
|
251
|
+
C(E).t.add(w), y.d.add(E), T !== I.n && (a.add(E), (L = c.c) == null || L.call(c, E), k(E));
|
|
251
252
|
}
|
|
252
|
-
for (const
|
|
253
|
-
if (!v.d.has(
|
|
254
|
-
|
|
255
|
-
const T =
|
|
256
|
-
T == null || T.t.delete(
|
|
253
|
+
for (const E of y.d || [])
|
|
254
|
+
if (!v.d.has(E)) {
|
|
255
|
+
y.d.delete(E);
|
|
256
|
+
const T = j(E);
|
|
257
|
+
T == null || T.t.delete(w);
|
|
257
258
|
}
|
|
258
259
|
}
|
|
259
|
-
}),
|
|
260
|
+
}), C = m[7] || ((w) => {
|
|
260
261
|
var L;
|
|
261
|
-
const v =
|
|
262
|
-
let
|
|
263
|
-
if (!
|
|
264
|
-
b(
|
|
265
|
-
for (const
|
|
266
|
-
|
|
267
|
-
if (
|
|
262
|
+
const v = x(w);
|
|
263
|
+
let y = n.get(w);
|
|
264
|
+
if (!y) {
|
|
265
|
+
b(w);
|
|
266
|
+
for (const E of v.d.keys())
|
|
267
|
+
C(E).t.add(w);
|
|
268
|
+
if (y = {
|
|
268
269
|
l: /* @__PURE__ */ new Set(),
|
|
269
270
|
d: new Set(v.d.keys()),
|
|
270
271
|
t: /* @__PURE__ */ new Set()
|
|
271
|
-
}, n.set(
|
|
272
|
-
const
|
|
272
|
+
}, n.set(w, y), (L = c.m) == null || L.call(c, w), isActuallyWritableAtom(w)) {
|
|
273
|
+
const E = () => {
|
|
273
274
|
let T = !0;
|
|
274
|
-
const I = (...
|
|
275
|
+
const I = (...R) => {
|
|
275
276
|
try {
|
|
276
|
-
return A(
|
|
277
|
+
return A(w, ...R);
|
|
277
278
|
} finally {
|
|
278
|
-
T || (
|
|
279
|
+
T || (h(), f());
|
|
279
280
|
}
|
|
280
281
|
};
|
|
281
282
|
try {
|
|
282
|
-
const
|
|
283
|
-
|
|
283
|
+
const R = g(w, I);
|
|
284
|
+
R && (y.u = () => {
|
|
284
285
|
T = !0;
|
|
285
286
|
try {
|
|
286
|
-
|
|
287
|
+
R();
|
|
287
288
|
} finally {
|
|
288
289
|
T = !1;
|
|
289
290
|
}
|
|
@@ -292,27 +293,27 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
292
293
|
T = !1;
|
|
293
294
|
}
|
|
294
295
|
};
|
|
295
|
-
l.add(
|
|
296
|
+
l.add(E);
|
|
296
297
|
}
|
|
297
298
|
}
|
|
298
|
-
return
|
|
299
|
-
}),
|
|
299
|
+
return y;
|
|
300
|
+
}), j = m[8] || ((w) => {
|
|
300
301
|
var L;
|
|
301
|
-
const v =
|
|
302
|
-
let
|
|
303
|
-
if (
|
|
302
|
+
const v = x(w);
|
|
303
|
+
let y = n.get(w);
|
|
304
|
+
if (y && !y.l.size && !Array.from(y.t).some((E) => {
|
|
304
305
|
var T;
|
|
305
|
-
return (T = n.get(
|
|
306
|
+
return (T = n.get(E)) == null ? void 0 : T.d.has(w);
|
|
306
307
|
})) {
|
|
307
|
-
|
|
308
|
-
for (const
|
|
309
|
-
const T =
|
|
310
|
-
T == null || T.t.delete(
|
|
308
|
+
y.u && i.add(y.u), y = void 0, n.delete(w), (L = c.u) == null || L.call(c, w);
|
|
309
|
+
for (const E of v.d.keys()) {
|
|
310
|
+
const T = j(E);
|
|
311
|
+
T == null || T.t.delete(w);
|
|
311
312
|
}
|
|
312
313
|
return;
|
|
313
314
|
}
|
|
314
|
-
return
|
|
315
|
-
}),
|
|
315
|
+
return y;
|
|
316
|
+
}), _ = [
|
|
316
317
|
// store state
|
|
317
318
|
o,
|
|
318
319
|
n,
|
|
@@ -327,32 +328,32 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
|
|
|
327
328
|
u,
|
|
328
329
|
g,
|
|
329
330
|
// building-block functions
|
|
330
|
-
m,
|
|
331
|
-
f,
|
|
332
331
|
x,
|
|
332
|
+
f,
|
|
333
|
+
h,
|
|
333
334
|
b,
|
|
334
|
-
|
|
335
|
+
k,
|
|
335
336
|
A,
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
337
|
+
B,
|
|
338
|
+
C,
|
|
339
|
+
j
|
|
339
340
|
], S = {
|
|
340
|
-
get: (
|
|
341
|
-
set: (
|
|
341
|
+
get: (w) => returnAtomValue(b(w)),
|
|
342
|
+
set: (w, ...L) => {
|
|
342
343
|
try {
|
|
343
|
-
return A(
|
|
344
|
+
return A(w, ...L);
|
|
344
345
|
} finally {
|
|
345
|
-
|
|
346
|
+
h(), f();
|
|
346
347
|
}
|
|
347
348
|
},
|
|
348
|
-
sub: (
|
|
349
|
-
const
|
|
350
|
-
return
|
|
351
|
-
|
|
349
|
+
sub: (w, L) => {
|
|
350
|
+
const y = C(w).l;
|
|
351
|
+
return y.add(L), f(), () => {
|
|
352
|
+
y.delete(L), j(w), f();
|
|
352
353
|
};
|
|
353
354
|
}
|
|
354
355
|
};
|
|
355
|
-
return Object.defineProperty(S, BUILDING_BLOCKS, { value:
|
|
356
|
+
return Object.defineProperty(S, BUILDING_BLOCKS, { value: _ }), S;
|
|
356
357
|
}, INTERNAL_buildStoreRev1 = buildStore;
|
|
357
358
|
let keyCount = 0;
|
|
358
359
|
function atom(o, n) {
|
|
@@ -387,37 +388,37 @@ function splitAtom(o, n) {
|
|
|
387
388
|
let p = r.get(c);
|
|
388
389
|
if (p)
|
|
389
390
|
return p;
|
|
390
|
-
const u = d && r.get(d), g = [],
|
|
391
|
-
return c.forEach((
|
|
392
|
-
const
|
|
393
|
-
|
|
394
|
-
const b = u && u.atomList[u.keyList.indexOf(
|
|
391
|
+
const u = d && r.get(d), g = [], m = [];
|
|
392
|
+
return c.forEach((x, f) => {
|
|
393
|
+
const h = f;
|
|
394
|
+
m[f] = h;
|
|
395
|
+
const b = u && u.atomList[u.keyList.indexOf(h)];
|
|
395
396
|
if (b) {
|
|
396
397
|
g[f] = b;
|
|
397
398
|
return;
|
|
398
399
|
}
|
|
399
|
-
const
|
|
400
|
-
const
|
|
401
|
-
if (S < 0 || S >=
|
|
402
|
-
const
|
|
403
|
-
if (
|
|
404
|
-
return
|
|
400
|
+
const k = (B) => {
|
|
401
|
+
const C = B(l), j = B(o), S = a(j, C == null ? void 0 : C.arr).keyList.indexOf(h);
|
|
402
|
+
if (S < 0 || S >= j.length) {
|
|
403
|
+
const w = c[a(c).keyList.indexOf(h)];
|
|
404
|
+
if (w)
|
|
405
|
+
return w;
|
|
405
406
|
throw new Error("splitAtom: index out of bounds for read");
|
|
406
407
|
}
|
|
407
|
-
return
|
|
408
|
-
}, A = (
|
|
409
|
-
const
|
|
408
|
+
return j[S];
|
|
409
|
+
}, A = (B, C, j) => {
|
|
410
|
+
const _ = B(l), S = B(o), L = a(S, _ == null ? void 0 : _.arr).keyList.indexOf(h);
|
|
410
411
|
if (L < 0 || L >= S.length)
|
|
411
412
|
throw new Error("splitAtom: index out of bounds for write");
|
|
412
|
-
const v = isFunction(
|
|
413
|
-
Object.is(S[L], v) ||
|
|
413
|
+
const v = isFunction(j) ? j(S[L]) : j;
|
|
414
|
+
Object.is(S[L], v) || C(o, [
|
|
414
415
|
...S.slice(0, L),
|
|
415
416
|
v,
|
|
416
417
|
...S.slice(L + 1)
|
|
417
418
|
]);
|
|
418
419
|
};
|
|
419
|
-
g[f] = isWritable(o) ? atom(
|
|
420
|
-
}), u && u.keyList.length ===
|
|
420
|
+
g[f] = isWritable(o) ? atom(k, A) : atom(k);
|
|
421
|
+
}), u && u.keyList.length === m.length && u.keyList.every((x, f) => x === m[f]) ? p = u : p = { arr: c, atomList: g, keyList: m }, r.set(c, p), p;
|
|
421
422
|
}, l = atom((c) => {
|
|
422
423
|
const d = c(l), p = c(o);
|
|
423
424
|
return a(p, d == null ? void 0 : d.arr);
|
|
@@ -453,17 +454,17 @@ function splitAtom(o, n) {
|
|
|
453
454
|
case "move": {
|
|
454
455
|
const u = c(i).indexOf(p.atom), g = p.before ? c(i).indexOf(p.before) : c(i).length;
|
|
455
456
|
if (u >= 0 && g >= 0) {
|
|
456
|
-
const
|
|
457
|
+
const m = c(o);
|
|
457
458
|
u < g ? d(o, [
|
|
458
|
-
...
|
|
459
|
-
...
|
|
460
|
-
|
|
461
|
-
...
|
|
459
|
+
...m.slice(0, u),
|
|
460
|
+
...m.slice(u + 1, g),
|
|
461
|
+
m[u],
|
|
462
|
+
...m.slice(g)
|
|
462
463
|
]) : d(o, [
|
|
463
|
-
...
|
|
464
|
-
|
|
465
|
-
...
|
|
466
|
-
...
|
|
464
|
+
...m.slice(0, g),
|
|
465
|
+
m[u],
|
|
466
|
+
...m.slice(g, u),
|
|
467
|
+
...m.slice(u + 1)
|
|
467
468
|
]);
|
|
468
469
|
}
|
|
469
470
|
break;
|
|
@@ -489,19 +490,19 @@ function createJSONStorage(o = () => {
|
|
|
489
490
|
let a, l;
|
|
490
491
|
const i = {
|
|
491
492
|
getItem: (p, u) => {
|
|
492
|
-
var g,
|
|
493
|
-
const
|
|
494
|
-
if (
|
|
493
|
+
var g, m;
|
|
494
|
+
const x = (h) => {
|
|
495
|
+
if (h = h || "", a !== h) {
|
|
495
496
|
try {
|
|
496
|
-
l = JSON.parse(
|
|
497
|
+
l = JSON.parse(h, n == null ? void 0 : n.reviver);
|
|
497
498
|
} catch {
|
|
498
499
|
return u;
|
|
499
500
|
}
|
|
500
|
-
a =
|
|
501
|
+
a = h;
|
|
501
502
|
}
|
|
502
503
|
return l;
|
|
503
|
-
}, f = (
|
|
504
|
-
return isPromiseLike$1(f) ? f.then(
|
|
504
|
+
}, f = (m = (g = o()) == null ? void 0 : g.getItem(p)) != null ? m : null;
|
|
505
|
+
return isPromiseLike$1(f) ? f.then(x) : x(f);
|
|
505
506
|
},
|
|
506
507
|
setItem: (p, u) => {
|
|
507
508
|
var g;
|
|
@@ -514,12 +515,12 @@ function createJSONStorage(o = () => {
|
|
|
514
515
|
var u;
|
|
515
516
|
return (u = o()) == null ? void 0 : u.removeItem(p);
|
|
516
517
|
}
|
|
517
|
-
}, c = (p) => (u, g,
|
|
518
|
+
}, c = (p) => (u, g, m) => p(u, (x) => {
|
|
518
519
|
let f;
|
|
519
520
|
try {
|
|
520
|
-
f = JSON.parse(
|
|
521
|
+
f = JSON.parse(x || "");
|
|
521
522
|
} catch {
|
|
522
|
-
f =
|
|
523
|
+
f = m;
|
|
523
524
|
}
|
|
524
525
|
g(f);
|
|
525
526
|
});
|
|
@@ -532,8 +533,8 @@ function createJSONStorage(o = () => {
|
|
|
532
533
|
if (!(o() instanceof window.Storage))
|
|
533
534
|
return () => {
|
|
534
535
|
};
|
|
535
|
-
const g = (
|
|
536
|
-
|
|
536
|
+
const g = (m) => {
|
|
537
|
+
m.storageArea === o() && m.key === p && u(m.newValue);
|
|
537
538
|
};
|
|
538
539
|
return window.addEventListener("storage", g), () => {
|
|
539
540
|
window.removeEventListener("storage", g);
|
|
@@ -652,8 +653,6 @@ const activePanelAtom = atom$1("outline");
|
|
|
652
653
|
activePanelAtom.debugLabel = "activePanelAtom";
|
|
653
654
|
const showPredefinedBlockCategoryAtom = atom$1("");
|
|
654
655
|
showPredefinedBlockCategoryAtom.debugLabel = "showPredefinedBlockCategoryAtom";
|
|
655
|
-
const historyStatesAtom = atom$1({ undoCount: 0, redoCount: 0 });
|
|
656
|
-
historyStatesAtom.debugLabel = "historyStatesAtom";
|
|
657
656
|
const inlineEditingActiveAtom = atom$1("");
|
|
658
657
|
inlineEditingActiveAtom.debugLabel = "inlineEditingActiveAtom";
|
|
659
658
|
const draggingFlagAtom = atom$1(!1);
|
|
@@ -929,7 +928,22 @@ function requireUndomanager() {
|
|
|
929
928
|
}(undomanager)), undomanager.exports;
|
|
930
929
|
}
|
|
931
930
|
var undomanagerExports = requireUndomanager();
|
|
932
|
-
const UndoManager = /* @__PURE__ */ getDefaultExportFromCjs(undomanagerExports),
|
|
931
|
+
const UndoManager = /* @__PURE__ */ getDefaultExportFromCjs(undomanagerExports), chaiBuilderPropsAtom = atom$1(null);
|
|
932
|
+
chaiBuilderPropsAtom.debugLabel = "chaiBuilderPropsAtom";
|
|
933
|
+
const chaiExternalDataAtom = atom$1({});
|
|
934
|
+
chaiExternalDataAtom.debugLabel = "chaiExternalDataAtom";
|
|
935
|
+
const chaiRjsfFieldsAtom = atom$1({});
|
|
936
|
+
chaiRjsfFieldsAtom.debugLabel = "chaiRjsfFieldsAtom";
|
|
937
|
+
const chaiRjsfWidgetsAtom = atom$1({});
|
|
938
|
+
chaiRjsfWidgetsAtom.debugLabel = "chaiRjsfWidgetsAtom";
|
|
939
|
+
const chaiRjsfTemplatesAtom = atom$1({});
|
|
940
|
+
chaiRjsfTemplatesAtom.debugLabel = "chaiRjsfTemplatesAtom";
|
|
941
|
+
const chaiPageExternalDataAtom = atom$1({});
|
|
942
|
+
chaiPageExternalDataAtom.debugLabel = "chaiPageExternalDataAtom";
|
|
943
|
+
const usePageExternalData = () => useAtomValue$1(chaiPageExternalDataAtom), useBuilderProp = (o, n = void 0) => {
|
|
944
|
+
const r = useAtomValue$1(chaiBuilderPropsAtom);
|
|
945
|
+
return get(r, o, n);
|
|
946
|
+
}, MODIFIERS = [
|
|
933
947
|
"hover",
|
|
934
948
|
"focus",
|
|
935
949
|
"focus-within",
|
|
@@ -1002,21 +1016,12 @@ const useBrandingOptions = () => {
|
|
|
1002
1016
|
blocks: a
|
|
1003
1017
|
};
|
|
1004
1018
|
}, [o, n, r]);
|
|
1005
|
-
},
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
const chaiRjsfWidgetsAtom = atom$1({});
|
|
1012
|
-
chaiRjsfWidgetsAtom.debugLabel = "chaiRjsfWidgetsAtom";
|
|
1013
|
-
const chaiRjsfTemplatesAtom = atom$1({});
|
|
1014
|
-
chaiRjsfTemplatesAtom.debugLabel = "chaiRjsfTemplatesAtom";
|
|
1015
|
-
const chaiPageExternalDataAtom = atom$1({});
|
|
1016
|
-
chaiPageExternalDataAtom.debugLabel = "chaiPageExternalDataAtom";
|
|
1017
|
-
const usePageExternalData = () => useAtomValue$1(chaiPageExternalDataAtom), useBuilderProp = (o, n = void 0) => {
|
|
1018
|
-
const r = useAtomValue$1(chaiBuilderPropsAtom);
|
|
1019
|
-
return get(r, o, n);
|
|
1019
|
+
}, usePermissions = () => {
|
|
1020
|
+
const o = useBuilderProp("permissions", void 0);
|
|
1021
|
+
return { hasPermission: useCallback(
|
|
1022
|
+
(r) => o ? o.includes(r) : !0,
|
|
1023
|
+
[o]
|
|
1024
|
+
) };
|
|
1020
1025
|
}, getDefaultThemeValues = (o = defaultThemeOptions) => {
|
|
1021
1026
|
const n = {};
|
|
1022
1027
|
return o.fontFamily && (n.fontFamily = Object.entries(o.fontFamily).reduce(
|
|
@@ -1043,15 +1048,17 @@ const usePageExternalData = () => useAtomValue$1(chaiPageExternalDataAtom), useB
|
|
|
1043
1048
|
}, rightPanelAtom = atom$1("block"), useRightPanel = () => useAtom$1(rightPanelAtom), builderSaveStateAtom = atom$1("SAVED");
|
|
1044
1049
|
builderSaveStateAtom.debugLabel = "builderSaveStateAtom";
|
|
1045
1050
|
const useSavePage = () => {
|
|
1046
|
-
const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (
|
|
1047
|
-
}), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme();
|
|
1051
|
+
const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (p) => {
|
|
1052
|
+
}), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions();
|
|
1048
1053
|
return { savePage: useThrottledCallback(
|
|
1049
|
-
async (
|
|
1054
|
+
async (p = !1) => {
|
|
1055
|
+
if (!c("save_page"))
|
|
1056
|
+
return;
|
|
1050
1057
|
n("SAVING"), a("SAVING");
|
|
1051
|
-
const
|
|
1058
|
+
const u = l();
|
|
1052
1059
|
return await r({
|
|
1053
|
-
autoSave:
|
|
1054
|
-
blocks:
|
|
1060
|
+
autoSave: p,
|
|
1061
|
+
blocks: u.blocks,
|
|
1055
1062
|
theme: i
|
|
1056
1063
|
}), setTimeout(() => {
|
|
1057
1064
|
n("SAVED"), a("SAVED");
|
|
@@ -1147,36 +1154,37 @@ const useSelectedBlocksDisplayChild = () => ({
|
|
|
1147
1154
|
}, removeNestedBlocks = (o, n) => {
|
|
1148
1155
|
let r = [...o], a = [];
|
|
1149
1156
|
n.forEach((d) => {
|
|
1150
|
-
const p = r.find((
|
|
1157
|
+
const p = r.find((m) => m._id === d);
|
|
1151
1158
|
if (!p || !p._parent) return;
|
|
1152
|
-
const u = p._parent, g = r.filter((
|
|
1159
|
+
const u = p._parent, g = r.filter((m) => m._parent === u);
|
|
1153
1160
|
if (g.length === 2) {
|
|
1154
|
-
const
|
|
1155
|
-
if (
|
|
1156
|
-
const
|
|
1157
|
-
|
|
1161
|
+
const m = g.find((x) => x._id !== d);
|
|
1162
|
+
if (m && m._type === "Text") {
|
|
1163
|
+
const x = r.find((f) => f._id === u);
|
|
1164
|
+
x && "content" in x && (r = r.map((f) => {
|
|
1158
1165
|
if (f._id === u) {
|
|
1159
|
-
const
|
|
1160
|
-
return Object.keys(
|
|
1161
|
-
b.startsWith("content-") && (
|
|
1162
|
-
}),
|
|
1166
|
+
const h = { ...f, content: m.content };
|
|
1167
|
+
return Object.keys(m).forEach((b) => {
|
|
1168
|
+
b.startsWith("content-") && (h[b] = m[b]);
|
|
1169
|
+
}), h;
|
|
1163
1170
|
}
|
|
1164
1171
|
return f;
|
|
1165
|
-
}), a.push(
|
|
1172
|
+
}), a.push(m._id));
|
|
1166
1173
|
}
|
|
1167
1174
|
}
|
|
1168
1175
|
});
|
|
1169
1176
|
const l = [...n, ...a], i = [], c = filter(r, (d) => includes(l, d._id) || includes(l, d._parent) ? (i.push(d._id), !1) : !0);
|
|
1170
1177
|
return isEmpty(i) ? c : removeNestedBlocks(c, i);
|
|
1171
1178
|
}, useRemoveBlocks = () => {
|
|
1172
|
-
const [o] = useBlocksStore(), [n, r] = useSelectedBlockIds(), { setNewBlocks: a } = useBlocksStoreUndoableActions();
|
|
1179
|
+
const [o] = useBlocksStore(), [n, r] = useSelectedBlockIds(), { setNewBlocks: a } = useBlocksStoreUndoableActions(), { hasPermission: l } = usePermissions();
|
|
1173
1180
|
return useCallback(
|
|
1174
|
-
(
|
|
1175
|
-
var
|
|
1176
|
-
|
|
1177
|
-
|
|
1181
|
+
(i) => {
|
|
1182
|
+
var d;
|
|
1183
|
+
if (!l(PERMISSIONS.DELETE_BLOCK)) return;
|
|
1184
|
+
const c = ((d = find(o, { _id: i[0] })) == null ? void 0 : d._parent) || null;
|
|
1185
|
+
a(removeNestedBlocks(o, i)), setTimeout(() => r(c ? [c] : []), 200);
|
|
1178
1186
|
},
|
|
1179
|
-
[o, r, n]
|
|
1187
|
+
[o, r, n, l]
|
|
1180
1188
|
);
|
|
1181
1189
|
}, builderStore = getDefaultStore$1(), writeAtomValue = atom$1(
|
|
1182
1190
|
null,
|
|
@@ -1225,21 +1233,21 @@ function insertBlocksAtPosition(o, n, r, a) {
|
|
|
1225
1233
|
let i = [...o];
|
|
1226
1234
|
if (r) {
|
|
1227
1235
|
const u = o.find((g) => g._id === r);
|
|
1228
|
-
if (u && u.content !== void 0 && u.content !== "" && !o.some((
|
|
1229
|
-
const
|
|
1236
|
+
if (u && u.content !== void 0 && u.content !== "" && !o.some((m) => m._parent === r)) {
|
|
1237
|
+
const x = {
|
|
1230
1238
|
_id: generateUUID(),
|
|
1231
1239
|
_parent: r,
|
|
1232
1240
|
_type: "Text",
|
|
1233
1241
|
content: u.content
|
|
1234
1242
|
};
|
|
1235
1243
|
Object.keys(u).forEach((f) => {
|
|
1236
|
-
f.startsWith("content-") && (
|
|
1237
|
-
}), l.unshift(
|
|
1244
|
+
f.startsWith("content-") && (x[f] = u[f]);
|
|
1245
|
+
}), l.unshift(x), i = i.map((f) => {
|
|
1238
1246
|
if (f._id === r) {
|
|
1239
|
-
const
|
|
1240
|
-
return Object.keys(
|
|
1241
|
-
b.startsWith("content-") && (
|
|
1242
|
-
}),
|
|
1247
|
+
const h = { ...f, content: "" };
|
|
1248
|
+
return Object.keys(h).forEach((b) => {
|
|
1249
|
+
b.startsWith("content-") && (h[b] = "");
|
|
1250
|
+
}), h;
|
|
1243
1251
|
}
|
|
1244
1252
|
return f;
|
|
1245
1253
|
});
|
|
@@ -1274,13 +1282,13 @@ function moveNode(o, n, r, a) {
|
|
|
1274
1282
|
const l = findNodeById(o, n), i = findNodeById(o, r);
|
|
1275
1283
|
if (!l || !i) return !1;
|
|
1276
1284
|
i.children || (i.model.children = []);
|
|
1277
|
-
let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((
|
|
1285
|
+
let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((m) => m.model._id === n);
|
|
1278
1286
|
l.drop(), c = Math.max(c, 0);
|
|
1279
1287
|
const p = (((g = l == null ? void 0 : l.model) == null ? void 0 : g._parent) || "root") === r && c <= a ? a - 1 : a;
|
|
1280
1288
|
try {
|
|
1281
1289
|
i.addChildAtIndex(l, p);
|
|
1282
|
-
} catch (
|
|
1283
|
-
return console.error("Error adding child to parent:",
|
|
1290
|
+
} catch (m) {
|
|
1291
|
+
return console.error("Error adding child to parent:", m), !1;
|
|
1284
1292
|
}
|
|
1285
1293
|
return !0;
|
|
1286
1294
|
}
|
|
@@ -1321,8 +1329,8 @@ function handleNewParentTextBlock(o, n, r) {
|
|
|
1321
1329
|
const d = o.map((u) => {
|
|
1322
1330
|
if (u._id === r) {
|
|
1323
1331
|
const g = { ...u, content: "" };
|
|
1324
|
-
return Object.keys(g).forEach((
|
|
1325
|
-
|
|
1332
|
+
return Object.keys(g).forEach((m) => {
|
|
1333
|
+
m.startsWith("content-") && (g[m] = "");
|
|
1326
1334
|
}), g;
|
|
1327
1335
|
}
|
|
1328
1336
|
return u;
|
|
@@ -1339,7 +1347,7 @@ function moveBlocksWithChildren(o, n, r, a) {
|
|
|
1339
1347
|
const c = r || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
|
|
1340
1348
|
if (moveNode(p, n, c, a)) {
|
|
1341
1349
|
let u = flattenTree(p);
|
|
1342
|
-
const g = u.find((
|
|
1350
|
+
const g = u.find((m) => m._id === n);
|
|
1343
1351
|
return g && (g._parent = c === "root" ? null : c), u.shift(), r && (u = handleNewParentTextBlock(u, l, r)), u;
|
|
1344
1352
|
}
|
|
1345
1353
|
return i;
|
|
@@ -1389,65 +1397,65 @@ const useBlocksStoreManager = () => {
|
|
|
1389
1397
|
updateBlocksProps: c
|
|
1390
1398
|
} = useBlocksStoreManager();
|
|
1391
1399
|
return {
|
|
1392
|
-
moveBlocks: (
|
|
1393
|
-
const A = map(
|
|
1394
|
-
const
|
|
1395
|
-
return { _id:
|
|
1396
|
-
}),
|
|
1397
|
-
|
|
1398
|
-
undo: () => each(A, ({ _id:
|
|
1399
|
-
i([
|
|
1400
|
+
moveBlocks: (h, b, k) => {
|
|
1401
|
+
const A = map(h, (C) => {
|
|
1402
|
+
const _ = n.find((L) => L._id === C)._parent || null, w = n.filter((L) => _ ? L._parent === _ : !L._parent).map((L) => L._id).indexOf(C);
|
|
1403
|
+
return { _id: C, oldParent: _, oldPosition: w };
|
|
1404
|
+
}), B = A.find(({ _id: C }) => C === h[0]);
|
|
1405
|
+
B && B.oldParent === b && B.oldPosition === k || (i(h, b, k), o({
|
|
1406
|
+
undo: () => each(A, ({ _id: C, oldParent: j, oldPosition: _ }) => {
|
|
1407
|
+
i([C], j, _);
|
|
1400
1408
|
}),
|
|
1401
|
-
redo: () => i(
|
|
1409
|
+
redo: () => i(h, b, k)
|
|
1402
1410
|
}));
|
|
1403
1411
|
},
|
|
1404
|
-
addBlocks: (
|
|
1405
|
-
a(
|
|
1406
|
-
undo: () => l(map(
|
|
1407
|
-
redo: () => a(
|
|
1412
|
+
addBlocks: (h, b, k) => {
|
|
1413
|
+
a(h, b, k), o({
|
|
1414
|
+
undo: () => l(map(h, "_id")),
|
|
1415
|
+
redo: () => a(h, b, k)
|
|
1408
1416
|
});
|
|
1409
1417
|
},
|
|
1410
|
-
removeBlocks: (
|
|
1411
|
-
var
|
|
1412
|
-
const b = (
|
|
1413
|
-
l(map(
|
|
1414
|
-
undo: () => a(
|
|
1415
|
-
redo: () => l(map(
|
|
1418
|
+
removeBlocks: (h) => {
|
|
1419
|
+
var B;
|
|
1420
|
+
const b = (B = first(h)) == null ? void 0 : B._parent, A = n.filter((C) => b ? C._parent === b : !C._parent).indexOf(first(h));
|
|
1421
|
+
l(map(h, "_id")), o({
|
|
1422
|
+
undo: () => a(h, b, A),
|
|
1423
|
+
redo: () => l(map(h, "_id"))
|
|
1416
1424
|
});
|
|
1417
1425
|
},
|
|
1418
|
-
updateBlocks: (
|
|
1426
|
+
updateBlocks: (h, b, k) => {
|
|
1419
1427
|
let A = [];
|
|
1420
|
-
if (
|
|
1421
|
-
A = map(
|
|
1428
|
+
if (k)
|
|
1429
|
+
A = map(h, (B) => ({ _id: B, ...k }));
|
|
1422
1430
|
else {
|
|
1423
|
-
const
|
|
1424
|
-
A = map(
|
|
1425
|
-
const
|
|
1426
|
-
return each(
|
|
1431
|
+
const B = keys(b);
|
|
1432
|
+
A = map(h, (C) => {
|
|
1433
|
+
const j = n.find((S) => S._id === C), _ = { _id: C };
|
|
1434
|
+
return each(B, (S) => _[S] = j[S]), _;
|
|
1427
1435
|
});
|
|
1428
1436
|
}
|
|
1429
|
-
c(map(
|
|
1437
|
+
c(map(h, (B) => ({ _id: B, ...b }))), o({
|
|
1430
1438
|
undo: () => c(A),
|
|
1431
|
-
redo: () => c(map(
|
|
1439
|
+
redo: () => c(map(h, (B) => ({ _id: B, ...b })))
|
|
1432
1440
|
});
|
|
1433
1441
|
},
|
|
1434
|
-
updateBlocksRuntime: (
|
|
1435
|
-
c(map(
|
|
1442
|
+
updateBlocksRuntime: (h, b) => {
|
|
1443
|
+
c(map(h, (k) => ({ _id: k, ...b })));
|
|
1436
1444
|
},
|
|
1437
|
-
setNewBlocks: (
|
|
1438
|
-
r(
|
|
1445
|
+
setNewBlocks: (h) => {
|
|
1446
|
+
r(h), o({
|
|
1439
1447
|
undo: () => r(n),
|
|
1440
|
-
redo: () => r(
|
|
1448
|
+
redo: () => r(h)
|
|
1441
1449
|
});
|
|
1442
1450
|
},
|
|
1443
|
-
updateMultipleBlocksProps: (
|
|
1451
|
+
updateMultipleBlocksProps: (h) => {
|
|
1444
1452
|
let b = [];
|
|
1445
|
-
b = map(
|
|
1446
|
-
const A = keys(
|
|
1447
|
-
return each(A, (
|
|
1448
|
-
}), c(
|
|
1453
|
+
b = map(h, (k) => {
|
|
1454
|
+
const A = keys(k), B = n.find((j) => j._id === k._id), C = {};
|
|
1455
|
+
return each(A, (j) => C[j] = B[j]), C;
|
|
1456
|
+
}), c(h), o({
|
|
1449
1457
|
undo: () => c(b),
|
|
1450
|
-
redo: () => c(
|
|
1458
|
+
redo: () => c(h)
|
|
1451
1459
|
});
|
|
1452
1460
|
}
|
|
1453
1461
|
};
|
|
@@ -1483,17 +1491,17 @@ import.meta.vitest && describe("canDropBlock Function", () => {
|
|
|
1483
1491
|
const useAddBlock = () => {
|
|
1484
1492
|
const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
1485
1493
|
(i, c, d) => {
|
|
1486
|
-
var
|
|
1494
|
+
var x;
|
|
1487
1495
|
for (let f = 0; f < i.length; f++) {
|
|
1488
|
-
const { _id:
|
|
1496
|
+
const { _id: h } = i[f];
|
|
1489
1497
|
i[f]._id = generateUUID();
|
|
1490
|
-
const b = filter(i, { _parent:
|
|
1491
|
-
for (let
|
|
1492
|
-
b[
|
|
1498
|
+
const b = filter(i, { _parent: h });
|
|
1499
|
+
for (let k = 0; k < b.length; k++)
|
|
1500
|
+
b[k]._parent = i[f]._id;
|
|
1493
1501
|
}
|
|
1494
1502
|
const p = first(i);
|
|
1495
1503
|
let u, g;
|
|
1496
|
-
return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(
|
|
1504
|
+
return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(x = first(i)) == null ? void 0 : x._id]), first(i);
|
|
1497
1505
|
},
|
|
1498
1506
|
[r, o, n]
|
|
1499
1507
|
);
|
|
@@ -1510,8 +1518,8 @@ const useAddBlock = () => {
|
|
|
1510
1518
|
...has(i, "_name") && { _name: i._name },
|
|
1511
1519
|
...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
|
|
1512
1520
|
};
|
|
1513
|
-
let
|
|
1514
|
-
return c && (
|
|
1521
|
+
let m, x;
|
|
1522
|
+
return c && (m = find(o, { _id: c }), g._parent = c, x = c), !canAcceptChildBlock(m == null ? void 0 : m._type, g._type) && m && (g._parent = m._parent, x = m._parent), r([g], x, d), n([g._id]), g;
|
|
1515
1523
|
},
|
|
1516
1524
|
[r, a, o, n]
|
|
1517
1525
|
), addPredefinedBlock: a };
|
|
@@ -2957,41 +2965,41 @@ const getBlockWithChildren = (o, n) => {
|
|
|
2957
2965
|
return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
|
|
2958
2966
|
})
|
|
2959
2967
|
), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
|
|
2960
|
-
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,
|
|
2961
|
-
const
|
|
2962
|
-
for (const b in
|
|
2963
|
-
const
|
|
2964
|
-
if (typeof
|
|
2965
|
-
const { baseClasses: A, classes:
|
|
2966
|
-
|
|
2968
|
+
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 = (x, f) => {
|
|
2969
|
+
const h = cloneDeep(f.find((b) => b._id === x));
|
|
2970
|
+
for (const b in h) {
|
|
2971
|
+
const k = h[b];
|
|
2972
|
+
if (typeof k == "string" && startsWith(k, STYLES_KEY)) {
|
|
2973
|
+
const { baseClasses: A, classes: B } = getSplitChaiClasses(k);
|
|
2974
|
+
h[b] = compact(flattenDeep([A, B])).join(" ");
|
|
2967
2975
|
} else
|
|
2968
|
-
b !== "_id" && delete
|
|
2976
|
+
b !== "_id" && delete h[b];
|
|
2969
2977
|
}
|
|
2970
|
-
return
|
|
2978
|
+
return h;
|
|
2971
2979
|
};
|
|
2972
2980
|
return {
|
|
2973
2981
|
askAi: useCallback(
|
|
2974
|
-
async (
|
|
2982
|
+
async (x, f, h, b) => {
|
|
2975
2983
|
if (l) {
|
|
2976
2984
|
n(!0), a(null);
|
|
2977
2985
|
try {
|
|
2978
|
-
const
|
|
2979
|
-
if (
|
|
2980
|
-
a(
|
|
2986
|
+
const k = p === u ? "" : p, A = x === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [m(f, d)], B = await l(x, addLangToPrompt(h, g, x), A, k), { blocks: C, error: j } = B;
|
|
2987
|
+
if (j) {
|
|
2988
|
+
a(j);
|
|
2981
2989
|
return;
|
|
2982
2990
|
}
|
|
2983
|
-
if (
|
|
2984
|
-
const
|
|
2985
|
-
for (const
|
|
2986
|
-
|
|
2991
|
+
if (x === "styles") {
|
|
2992
|
+
const _ = C.map((S) => {
|
|
2993
|
+
for (const w in S)
|
|
2994
|
+
w !== "_id" && (S[w] = `${STYLES_KEY},${S[w]}`);
|
|
2987
2995
|
return S;
|
|
2988
2996
|
});
|
|
2989
|
-
c(
|
|
2997
|
+
c(_);
|
|
2990
2998
|
} else
|
|
2991
|
-
i(
|
|
2992
|
-
b && b(
|
|
2993
|
-
} catch (
|
|
2994
|
-
a(
|
|
2999
|
+
i(C);
|
|
3000
|
+
b && b(B);
|
|
3001
|
+
} catch (k) {
|
|
3002
|
+
a(k);
|
|
2995
3003
|
} finally {
|
|
2996
3004
|
n(!1), b && b();
|
|
2997
3005
|
}
|
|
@@ -3082,9 +3090,9 @@ const useBlockHighlight = () => {
|
|
|
3082
3090
|
d();
|
|
3083
3091
|
}, []), { data: l, isLoading: o, refetch: d, error: r };
|
|
3084
3092
|
}, useBuilderReset = () => {
|
|
3085
|
-
const
|
|
3093
|
+
const { clear: o } = useUndoManager(), [, n] = useSelectedBlockIds(), { clearHighlight: r } = useBlockHighlight(), [, a] = useSelectedStylingBlocks(), [, l] = useAtom(aiAssistantActiveAtom), { reset: i } = usePartailBlocksStore(), { setSaveState: c } = useSavePage();
|
|
3086
3094
|
return () => {
|
|
3087
|
-
|
|
3095
|
+
n([]), a([]), r(), o(), l(!1), i(), c("SAVED");
|
|
3088
3096
|
};
|
|
3089
3097
|
}, canvasZoomAtom = atomWithStorage("canvasZoom", 100), useCanvasZoom = () => useAtom$1(canvasZoomAtom), codeEditorAtom = atom$1(null), useCodeEditor = () => useAtom$1(codeEditorAtom), cutBlockIdsAtom = atom$1([]), useCutBlockIds = () => {
|
|
3090
3098
|
const [o, n] = useAtom$1(cutBlockIdsAtom), r = useSetAtom$1(copiedBlockIdsAtom), a = useCallback(
|
|
@@ -3130,13 +3138,13 @@ const useBlockHighlight = () => {
|
|
|
3130
3138
|
(a, l = null) => {
|
|
3131
3139
|
const i = [];
|
|
3132
3140
|
each(a, (c) => {
|
|
3133
|
-
const d = o.find((
|
|
3141
|
+
const d = o.find((x) => x._id === c);
|
|
3134
3142
|
l ? l === "root" && (l = null) : l = d._parent;
|
|
3135
3143
|
const g = filter(
|
|
3136
3144
|
o,
|
|
3137
|
-
(
|
|
3138
|
-
).indexOf(d) + 1,
|
|
3139
|
-
r(
|
|
3145
|
+
(x) => isString(l) ? x._parent === l : !x._parent
|
|
3146
|
+
).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
|
|
3147
|
+
r(m, l, g), i.push(get(m, "0._id", ""));
|
|
3140
3148
|
}), n(i);
|
|
3141
3149
|
},
|
|
3142
3150
|
[o, n]
|
|
@@ -3229,13 +3237,13 @@ const useBlockHighlight = () => {
|
|
|
3229
3237
|
return map(i, (c) => {
|
|
3230
3238
|
const d = o(c), p = a;
|
|
3231
3239
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
|
|
3232
|
-
return each(p, (
|
|
3233
|
-
const
|
|
3240
|
+
return each(p, (m) => {
|
|
3241
|
+
const x = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${x}(?=\\s|$)`, "g");
|
|
3234
3242
|
u = u.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
3235
|
-
const
|
|
3236
|
-
includes(["2xl", "xl", "lg", "md", "sm"],
|
|
3237
|
-
}), each(p, (
|
|
3238
|
-
const
|
|
3243
|
+
const h = first(m.split(":"));
|
|
3244
|
+
includes(["2xl", "xl", "lg", "md", "sm"], h) && p.push(m.split(":").pop().trim());
|
|
3245
|
+
}), each(p, (m) => {
|
|
3246
|
+
const x = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${x}(?=\\s|$)`, "g");
|
|
3239
3247
|
g = g.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
3240
3248
|
}), {
|
|
3241
3249
|
ids: [d._id],
|
|
@@ -3322,102 +3330,104 @@ wrapperBlockAtom.debugLabel = "wrapperBlockAtom";
|
|
|
3322
3330
|
const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), layoutVariantAtom = atomWithStorage("_layout_variant_mode", "DUAL_SIDE_PANEL"), useLayoutVariant = () => {
|
|
3323
3331
|
const [o, n] = useAtom$1(layoutVariantAtom), r = useBuilderProp("layoutVariant", "DUAL_SIDE_PANEL");
|
|
3324
3332
|
return [o || r, n];
|
|
3325
|
-
}, draggedBlockAtom = atom$1(null), dropTargetBlockIdAtom = atom$1(null);
|
|
3326
|
-
class PubSub {
|
|
3327
|
-
constructor() {
|
|
3328
|
-
V(this, "subscribers", /* @__PURE__ */ new Map());
|
|
3329
|
-
}
|
|
3330
|
-
subscribe(n, r) {
|
|
3331
|
-
return this.subscribers.has(n) || this.subscribers.set(n, /* @__PURE__ */ new Set()), this.subscribers.get(n).add(r), () => {
|
|
3332
|
-
const a = this.subscribers.get(n);
|
|
3333
|
-
a && (a.delete(r), a.size === 0 && this.subscribers.delete(n));
|
|
3334
|
-
};
|
|
3335
|
-
}
|
|
3336
|
-
publish(n, r) {
|
|
3337
|
-
const a = this.subscribers.get(n);
|
|
3338
|
-
a && a.forEach((l) => l(r));
|
|
3339
|
-
}
|
|
3340
|
-
}
|
|
3341
|
-
const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
3342
|
-
const [r] = useBlocksStore(), a = get(o, "_id"), l = get(o, "_parent"), i = filter(r, (u) => l ? get(u, "_parent") === l : !get(u, "_parent")), c = canAddChildBlock(get(o, "_type", "")), d = findIndex(i, { _id: a }), p = (u) => {
|
|
3343
|
-
if (u === "CHILD")
|
|
3344
|
-
pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
|
|
3345
|
-
else {
|
|
3346
|
-
const g = { _id: l || "", position: i == null ? void 0 : i.length };
|
|
3347
|
-
u === "BEFORE" ? g.position = Math.max(d, 0) : u === "AFTER" && (g.position = d + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, g);
|
|
3348
|
-
}
|
|
3349
|
-
};
|
|
3350
|
-
return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
3351
|
-
/* @__PURE__ */ jsx(DropdownMenuTrigger, { children: n }),
|
|
3352
|
-
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "border border-blue-200 shadow-2xl", children: [
|
|
3353
|
-
c && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer", onClick: () => p("CHILD"), children: "Add child block" }),
|
|
3354
|
-
/* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer", onClick: () => p("BEFORE"), children: "Add block before" }),
|
|
3355
|
-
/* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer", onClick: () => p("AFTER"), children: "Add block after" })
|
|
3356
|
-
] })
|
|
3357
|
-
] });
|
|
3358
3333
|
};
|
|
3359
|
-
function getOrientation(o) {
|
|
3360
|
-
const
|
|
3361
|
-
if (
|
|
3362
|
-
const
|
|
3363
|
-
return
|
|
3364
|
-
} else if (
|
|
3365
|
-
const
|
|
3366
|
-
return
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3334
|
+
function getOrientation(o, n = null) {
|
|
3335
|
+
const r = window.getComputedStyle(o), a = n ? window.getComputedStyle(n) : null, l = r.display, i = a ? a.display : null;
|
|
3336
|
+
if (l === "flex" || l === "inline-flex") {
|
|
3337
|
+
const c = r.flexDirection;
|
|
3338
|
+
return c === "column" || c === "column-reverse" ? "vertical" : "horizontal";
|
|
3339
|
+
} else if (l === "grid") {
|
|
3340
|
+
const c = r.gridAutoFlow, d = r.gridTemplateColumns;
|
|
3341
|
+
return c.includes("column") || d && d !== "none" && d !== "" && !d.includes("calc") && // Handle calc expressions
|
|
3342
|
+
d.split(" ").length <= 1 ? "vertical" : "horizontal";
|
|
3343
|
+
} else if (i === "inline-block" || i === "inline")
|
|
3344
|
+
return "horizontal";
|
|
3345
|
+
return "vertical";
|
|
3370
3346
|
}
|
|
3371
3347
|
const CONTROLS = [
|
|
3372
3348
|
{ ControlIcon: PinTopIcon, dir: "VERTICAL", key: "UP" },
|
|
3373
3349
|
{ ControlIcon: PinBottomIcon, dir: "VERTICAL", key: "DOWN" },
|
|
3374
3350
|
{ ControlIcon: PinLeftIcon, dir: "HORIZONTAL", key: "LEFT" },
|
|
3375
3351
|
{ ControlIcon: PinRightIcon, dir: "HORIZONTAL", key: "RIGHT" }
|
|
3376
|
-
], getParentBlockOrientation = (o, n) => {
|
|
3352
|
+
], getParentBlockOrientation = (o, n, r) => {
|
|
3377
3353
|
try {
|
|
3378
|
-
if (!o || !
|
|
3379
|
-
const
|
|
3380
|
-
|
|
3354
|
+
if (!o || !r) return "VERTICAL";
|
|
3355
|
+
const a = `[data-block-id='${o}']`, l = r == null ? void 0 : r.querySelector(a);
|
|
3356
|
+
if (l) {
|
|
3357
|
+
const i = r == null ? void 0 : r.querySelector(`[data-block-id='${n}']`);
|
|
3358
|
+
return getOrientation(l, i).toUpperCase();
|
|
3359
|
+
}
|
|
3360
|
+
return "VERTICAL";
|
|
3381
3361
|
} catch {
|
|
3382
3362
|
return "VERTICAL";
|
|
3383
3363
|
}
|
|
3384
3364
|
}, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
|
|
3385
|
-
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (
|
|
3386
|
-
(
|
|
3387
|
-
isDisabledControl(g,
|
|
3365
|
+
const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (h) => c ? get(h, "_parent") === c : !get(h, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, m = u + 1 === (d == null ? void 0 : d.length), x = getParentBlockOrientation(c, i, a), f = useCallback(
|
|
3366
|
+
(h) => {
|
|
3367
|
+
isDisabledControl(g, m, h) || p || (h === "UP" || h === "LEFT" ? l([i], c || null, u - 1) : (h === "DOWN" || h === "RIGHT") && l([i], c || null, u + 2), n());
|
|
3388
3368
|
},
|
|
3389
|
-
[g,
|
|
3369
|
+
[g, m, p, u, i, c, n]
|
|
3390
3370
|
);
|
|
3391
3371
|
return useHotkeys(
|
|
3392
3372
|
"shift+up, shift+down, shift+left, shift+right",
|
|
3393
|
-
({ key:
|
|
3373
|
+
({ key: h }) => {
|
|
3394
3374
|
var b;
|
|
3395
|
-
f((b =
|
|
3375
|
+
f((b = h == null ? void 0 : h.replace("Arrow", "")) == null ? void 0 : b.toUpperCase());
|
|
3396
3376
|
},
|
|
3397
3377
|
{ document: a == null ? void 0 : a.contentDocument },
|
|
3398
3378
|
[f]
|
|
3399
|
-
), { isOnlyChild: p, isFirstBlock: g, isLastBlock:
|
|
3379
|
+
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: f, orientation: x };
|
|
3400
3380
|
}, BlockController = ({ block: o, updateFloatingBar: n }) => {
|
|
3401
3381
|
const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
|
|
3402
3382
|
o,
|
|
3403
3383
|
n
|
|
3404
3384
|
);
|
|
3405
|
-
return r ? null : /* @__PURE__ */
|
|
3406
|
-
|
|
3407
|
-
|
|
3408
|
-
|
|
3409
|
-
|
|
3410
|
-
|
|
3411
|
-
|
|
3412
|
-
{
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
|
|
3420
|
-
|
|
3385
|
+
return r ? null : /* @__PURE__ */ jsx(Fragment, { children: CONTROLS.map(({ ControlIcon: d, dir: p, key: u }) => {
|
|
3386
|
+
if (c !== p) return null;
|
|
3387
|
+
const g = isDisabledControl(a, l, u);
|
|
3388
|
+
return g ? null : /* @__PURE__ */ jsx(
|
|
3389
|
+
d,
|
|
3390
|
+
{
|
|
3391
|
+
onClick: () => i(u),
|
|
3392
|
+
className: `${g ? "pointer-events-none cursor-not-allowed opacity-50" : "duration-300 hover:scale-95 hover:opacity-80"}`
|
|
3393
|
+
},
|
|
3394
|
+
u
|
|
3395
|
+
);
|
|
3396
|
+
}) });
|
|
3397
|
+
};
|
|
3398
|
+
class PubSub {
|
|
3399
|
+
constructor() {
|
|
3400
|
+
V(this, "subscribers", /* @__PURE__ */ new Map());
|
|
3401
|
+
}
|
|
3402
|
+
subscribe(n, r) {
|
|
3403
|
+
return this.subscribers.has(n) || this.subscribers.set(n, /* @__PURE__ */ new Set()), this.subscribers.get(n).add(r), () => {
|
|
3404
|
+
const a = this.subscribers.get(n);
|
|
3405
|
+
a && (a.delete(r), a.size === 0 && this.subscribers.delete(n));
|
|
3406
|
+
};
|
|
3407
|
+
}
|
|
3408
|
+
publish(n, r) {
|
|
3409
|
+
const a = this.subscribers.get(n);
|
|
3410
|
+
a && a.forEach((l) => l(r));
|
|
3411
|
+
}
|
|
3412
|
+
}
|
|
3413
|
+
const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
|
|
3414
|
+
const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (m) => c ? get(m, "_parent") === c : !get(m, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), g = (m) => {
|
|
3415
|
+
if (m === "CHILD")
|
|
3416
|
+
pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
|
|
3417
|
+
else {
|
|
3418
|
+
const x = { _id: c || "", position: d == null ? void 0 : d.length };
|
|
3419
|
+
m === "BEFORE" ? x.position = Math.max(u, 0) : m === "AFTER" && (x.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, x);
|
|
3420
|
+
}
|
|
3421
|
+
};
|
|
3422
|
+
return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
3423
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { children: n }),
|
|
3424
|
+
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "border border-blue-500 bg-blue-500 text-white shadow-2xl", children: [
|
|
3425
|
+
p && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("CHILD"), children: r("Add inside") }),
|
|
3426
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("BEFORE"), children: r("Add before") }),
|
|
3427
|
+
/* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("AFTER"), children: r("Add after") })
|
|
3428
|
+
] })
|
|
3429
|
+
] }) : null;
|
|
3430
|
+
}, draggedBlockAtom = atom$1(null), dropTargetBlockIdAtom = atom$1(null), BlockActionLabel = ({ block: o, label: n }) => {
|
|
3421
3431
|
const [, r] = useSelectedBlockIds(), [, a] = useHighlightBlockId(), [, l] = useAtom$1(draggedBlockAtom), i = useFeature("dnd");
|
|
3422
3432
|
return /* @__PURE__ */ jsxs(
|
|
3423
3433
|
"div",
|
|
@@ -3436,46 +3446,46 @@ const CONTROLS = [
|
|
|
3436
3446
|
}
|
|
3437
3447
|
);
|
|
3438
3448
|
}, BlockFloatingSelector = ({ selectedBlockElement: o, block: n }) => {
|
|
3439
|
-
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), [
|
|
3449
|
+
const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: g, refs: m, update: x } = useFloating({
|
|
3440
3450
|
placement: "top-start",
|
|
3441
3451
|
middleware: [shift(), flip()],
|
|
3442
3452
|
elements: {
|
|
3443
3453
|
reference: o
|
|
3444
3454
|
}
|
|
3445
3455
|
});
|
|
3446
|
-
useResizeObserver(o, () =>
|
|
3447
|
-
const
|
|
3448
|
-
return !o || !n ||
|
|
3456
|
+
useResizeObserver(o, () => x(), o !== null), useResizeObserver(u == null ? void 0 : u.body, () => x(), (u == null ? void 0 : u.body) !== null);
|
|
3457
|
+
const f = get(n, "_parent", null), h = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
|
|
3458
|
+
return !o || !n || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
3449
3459
|
"div",
|
|
3450
3460
|
{
|
|
3451
3461
|
role: "button",
|
|
3452
3462
|
tabIndex: 0,
|
|
3453
|
-
ref:
|
|
3454
|
-
style:
|
|
3455
|
-
onClick: (
|
|
3456
|
-
|
|
3463
|
+
ref: m.setFloating,
|
|
3464
|
+
style: g,
|
|
3465
|
+
onClick: (b) => {
|
|
3466
|
+
b.stopPropagation(), b.preventDefault();
|
|
3457
3467
|
},
|
|
3458
|
-
onMouseEnter: (
|
|
3459
|
-
|
|
3468
|
+
onMouseEnter: (b) => {
|
|
3469
|
+
b.stopPropagation(), i(null);
|
|
3460
3470
|
},
|
|
3461
|
-
onKeyDown: (
|
|
3471
|
+
onKeyDown: (b) => b.stopPropagation(),
|
|
3462
3472
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
3463
3473
|
children: [
|
|
3464
|
-
|
|
3474
|
+
f && /* @__PURE__ */ jsx(
|
|
3465
3475
|
ArrowUpIcon,
|
|
3466
3476
|
{
|
|
3467
3477
|
className: "hover:scale-105",
|
|
3468
3478
|
onClick: () => {
|
|
3469
|
-
c([]), l([
|
|
3479
|
+
c([]), l([f]);
|
|
3470
3480
|
}
|
|
3471
3481
|
}
|
|
3472
3482
|
),
|
|
3473
|
-
/* @__PURE__ */ jsx(BlockActionLabel, { label:
|
|
3483
|
+
/* @__PURE__ */ jsx(BlockActionLabel, { label: h, block: n }),
|
|
3474
3484
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 pl-1 pr-1.5", children: [
|
|
3475
3485
|
/* @__PURE__ */ jsx(AddBlockDropdown, { block: n, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
|
|
3476
|
-
canDuplicateBlock(get(n, "_type", "")) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([n == null ? void 0 : n._id]) }) : null,
|
|
3477
|
-
canDeleteBlock(get(n, "_type", "")) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([n == null ? void 0 : n._id]) }) : null,
|
|
3478
|
-
/* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar:
|
|
3486
|
+
canDuplicateBlock(get(n, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([n == null ? void 0 : n._id]) }) : null,
|
|
3487
|
+
canDeleteBlock(get(n, "_type", "")) && d(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([n == null ? void 0 : n._id]) }) : null,
|
|
3488
|
+
d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar: x })
|
|
3479
3489
|
] })
|
|
3480
3490
|
]
|
|
3481
3491
|
}
|
|
@@ -3536,15 +3546,15 @@ const CONTROLS = [
|
|
|
3536
3546
|
<div class="frame-root h-full"></div>
|
|
3537
3547
|
</body>
|
|
3538
3548
|
</html>`, useKeyEventWatcher = (o) => {
|
|
3539
|
-
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks:
|
|
3549
|
+
const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), x = o ? { document: o } : {};
|
|
3540
3550
|
useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys("ctrl+c,command+c", () => u(n), {}, [n, u]), useHotkeys(
|
|
3541
3551
|
"ctrl+v,command+v",
|
|
3542
3552
|
() => {
|
|
3543
|
-
g(n[0]) &&
|
|
3553
|
+
g(n[0]) && m(n);
|
|
3544
3554
|
},
|
|
3545
|
-
{ ...
|
|
3546
|
-
[n, g,
|
|
3547
|
-
), useHotkeys("esc", () => r([]),
|
|
3555
|
+
{ ...x, preventDefault: !0 },
|
|
3556
|
+
[n, g, m]
|
|
3557
|
+
), useHotkeys("esc", () => r([]), x, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...x, preventDefault: !0 }, [
|
|
3548
3558
|
n,
|
|
3549
3559
|
i
|
|
3550
3560
|
]), useHotkeys(
|
|
@@ -3552,25 +3562,22 @@ const CONTROLS = [
|
|
|
3552
3562
|
(f) => {
|
|
3553
3563
|
f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
|
|
3554
3564
|
},
|
|
3555
|
-
|
|
3565
|
+
x,
|
|
3556
3566
|
[n, l]
|
|
3557
3567
|
);
|
|
3558
3568
|
}, KeyboardHandler = () => {
|
|
3559
3569
|
const { document: o } = useFrame();
|
|
3560
3570
|
return useKeyEventWatcher(o), null;
|
|
3561
|
-
}, CHAI_BUILDER_EVENTS = {
|
|
3562
|
-
OPEN_ADD_BLOCK: "OPEN_ADD_BLOCK",
|
|
3563
|
-
CLOSE_ADD_BLOCK: "CLOSE_ADD_BLOCK",
|
|
3564
|
-
SHOW_BLOCK_SETTINGS: "SHOW_BLOCK_SETTINGS"
|
|
3565
3571
|
}, AddBlockAtBottom = () => {
|
|
3566
|
-
const { t: o } = useTranslation();
|
|
3567
|
-
return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer py-2", children: [
|
|
3572
|
+
const { t: o } = useTranslation(), { hasPermission: n } = usePermissions();
|
|
3573
|
+
return n(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer py-2", children: [
|
|
3568
3574
|
/* @__PURE__ */ jsx("br", {}),
|
|
3569
3575
|
/* @__PURE__ */ jsx(
|
|
3570
3576
|
"div",
|
|
3571
3577
|
{
|
|
3578
|
+
role: "button",
|
|
3572
3579
|
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK),
|
|
3573
|
-
className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
|
|
3580
|
+
className: "block h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
|
|
3574
3581
|
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-xs leading-tight text-white hover:bg-purple-500", children: [
|
|
3575
3582
|
/* @__PURE__ */ jsx(PlusIcon$1, { className: "size-2.5 stroke-[3]" }),
|
|
3576
3583
|
" ",
|
|
@@ -3579,7 +3586,7 @@ const CONTROLS = [
|
|
|
3579
3586
|
}
|
|
3580
3587
|
),
|
|
3581
3588
|
/* @__PURE__ */ jsx("br", {})
|
|
3582
|
-
] });
|
|
3589
|
+
] }) : null;
|
|
3583
3590
|
};
|
|
3584
3591
|
let iframeDocument = null, possiblePositions = [], dropTarget = null, dropIndex = null;
|
|
3585
3592
|
const positionPlaceholder = (o, n, r) => {
|
|
@@ -3630,38 +3637,38 @@ function removeDataDrop() {
|
|
|
3630
3637
|
const useDnd = () => {
|
|
3631
3638
|
const { document: o } = useFrame(), [n, r] = useAtom$1(draggingFlagAtom), { addCoreBlock: a } = useAddBlock(), [, l] = useHighlightBlockId(), [, i] = useSelectedBlockIds(), { moveBlocks: c } = useBlocksStoreUndoableActions(), [d, p] = useAtom$1(draggedBlockAtom), [, u] = useAtom$1(dropTargetBlockIdAtom);
|
|
3632
3639
|
if (!useFeature("dnd")) return {};
|
|
3633
|
-
const
|
|
3640
|
+
const m = () => {
|
|
3634
3641
|
removePlaceholder(), r(!1), p(null), u(null), possiblePositions = [];
|
|
3635
3642
|
};
|
|
3636
3643
|
return iframeDocument = o, {
|
|
3637
3644
|
isDragging: n,
|
|
3638
|
-
onDragOver: (
|
|
3639
|
-
|
|
3645
|
+
onDragOver: (x) => {
|
|
3646
|
+
x.preventDefault(), x.stopPropagation(), throttledDragOver(x);
|
|
3640
3647
|
},
|
|
3641
|
-
onDrop: (
|
|
3642
|
-
var
|
|
3643
|
-
const f = dropTarget, b = getOrientation(f) === "vertical" ?
|
|
3648
|
+
onDrop: (x) => {
|
|
3649
|
+
var j;
|
|
3650
|
+
const f = dropTarget, b = getOrientation(f) === "vertical" ? x.clientY + ((j = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : j.scrollY) : x.clientX;
|
|
3644
3651
|
dropIndex = calculateDropIndex(b, possiblePositions);
|
|
3645
|
-
const
|
|
3646
|
-
if ((
|
|
3647
|
-
|
|
3652
|
+
const k = d, A = f.getAttribute("data-block-id"), B = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
|
|
3653
|
+
if ((k == null ? void 0 : k._id) === A || !B) {
|
|
3654
|
+
m();
|
|
3648
3655
|
return;
|
|
3649
3656
|
}
|
|
3650
|
-
if (!has(
|
|
3651
|
-
a(
|
|
3657
|
+
if (!has(k, "_id")) {
|
|
3658
|
+
a(k, A === "canvas" ? null : A, dropIndex), setTimeout(m, 300);
|
|
3652
3659
|
return;
|
|
3653
3660
|
}
|
|
3654
|
-
let
|
|
3655
|
-
|
|
3661
|
+
let C = f.getAttribute("data-block-id");
|
|
3662
|
+
C === null && (C = x.target.parentElement.getAttribute("data-block-id")), c([k._id], C === "canvas" ? null : C, dropIndex), m(), setTimeout(removePlaceholder, 300);
|
|
3656
3663
|
},
|
|
3657
|
-
onDragEnter: (
|
|
3658
|
-
const f =
|
|
3659
|
-
dropTarget =
|
|
3660
|
-
const b =
|
|
3661
|
-
u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [],
|
|
3664
|
+
onDragEnter: (x) => {
|
|
3665
|
+
const f = x, h = f.target;
|
|
3666
|
+
dropTarget = h;
|
|
3667
|
+
const b = h.getAttribute("data-block-id"), k = h.getAttribute("data-dnd-dragged") !== "yes";
|
|
3668
|
+
u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [], k && calculatePossiblePositions(h), r(!0), l(""), i([]);
|
|
3662
3669
|
},
|
|
3663
|
-
onDragLeave: (
|
|
3664
|
-
|
|
3670
|
+
onDragLeave: (x) => {
|
|
3671
|
+
x.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
|
|
3665
3672
|
}
|
|
3666
3673
|
};
|
|
3667
3674
|
};
|
|
@@ -3683,17 +3690,17 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3683
3690
|
const g = u.getAttribute("data-block-type");
|
|
3684
3691
|
if (!g || !r.includes(g))
|
|
3685
3692
|
return;
|
|
3686
|
-
const
|
|
3687
|
-
if (!
|
|
3693
|
+
const m = u.getAttribute("data-block-id");
|
|
3694
|
+
if (!m) return;
|
|
3688
3695
|
o.on("update", ({ editor: f }) => {
|
|
3689
3696
|
console.log(f.getHTML());
|
|
3690
3697
|
}), o.on("blur", () => {
|
|
3691
3698
|
console.log("blur");
|
|
3692
3699
|
const f = o.getHTML();
|
|
3693
|
-
a([
|
|
3694
|
-
}), i(
|
|
3695
|
-
const
|
|
3696
|
-
o.commands.setContent(
|
|
3700
|
+
a([m], { content: f }), n.style.display = "none", u.style.visibility = "visible";
|
|
3701
|
+
}), i(m);
|
|
3702
|
+
const x = d(m).content;
|
|
3703
|
+
o.commands.setContent(x), 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);
|
|
3697
3704
|
},
|
|
3698
3705
|
[l, c, d, i, a, o, n]
|
|
3699
3706
|
);
|
|
@@ -3734,17 +3741,17 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3734
3741
|
return;
|
|
3735
3742
|
const f = getElementByDataBlockId(n, first(r));
|
|
3736
3743
|
if (f) {
|
|
3737
|
-
const
|
|
3738
|
-
if (
|
|
3739
|
-
const b = f.getAttribute("data-style-id"),
|
|
3740
|
-
l([{ id: b, prop:
|
|
3744
|
+
const h = f.getAttribute("data-style-prop");
|
|
3745
|
+
if (h) {
|
|
3746
|
+
const b = f.getAttribute("data-style-id"), k = f.getAttribute("data-block-parent");
|
|
3747
|
+
l([{ id: b, prop: h, blockId: k }]);
|
|
3741
3748
|
}
|
|
3742
3749
|
}
|
|
3743
3750
|
}, 100);
|
|
3744
3751
|
}, [n, r, l, a]);
|
|
3745
3752
|
const c = useEditor({
|
|
3746
3753
|
extensions: [StarterKit]
|
|
3747
|
-
}), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(),
|
|
3754
|
+
}), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(), x = useDnd();
|
|
3748
3755
|
return /* @__PURE__ */ jsx(
|
|
3749
3756
|
"div",
|
|
3750
3757
|
{
|
|
@@ -3753,18 +3760,18 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3753
3760
|
onClick: u,
|
|
3754
3761
|
onDoubleClick: p,
|
|
3755
3762
|
onMouseMove: g,
|
|
3756
|
-
onMouseLeave:
|
|
3757
|
-
...omit(
|
|
3758
|
-
className: "relative h-full max-w-full p-px " + (
|
|
3763
|
+
onMouseLeave: m,
|
|
3764
|
+
...omit(x, "isDragging"),
|
|
3765
|
+
className: "relative h-full max-w-full p-px " + (x.isDragging ? "dragging" : ""),
|
|
3759
3766
|
children: o
|
|
3760
3767
|
}
|
|
3761
3768
|
);
|
|
3762
3769
|
}, getElementByDataBlockId = (o, n) => o.querySelector(`[data-block-id="${n}"]`), HeadTags = () => {
|
|
3763
3770
|
const [o] = useTheme(), n = useThemeOptions(), [r] = useSelectedBlockIds(), [a] = useDarkMode(), [l] = useSelectedStylingBlocks(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), { document: d, window: p } = useFrame(), [u] = useState(d == null ? void 0 : d.getElementById("highlighted-block")), [g] = useState(
|
|
3764
3771
|
d == null ? void 0 : d.getElementById("selected-block")
|
|
3765
|
-
), [h] = useState(
|
|
3766
|
-
d == null ? void 0 : d.getElementById("selected-styling-block")
|
|
3767
3772
|
), [m] = useState(
|
|
3773
|
+
d == null ? void 0 : d.getElementById("selected-styling-block")
|
|
3774
|
+
), [x] = useState(
|
|
3768
3775
|
d == null ? void 0 : d.getElementById("dragged-block")
|
|
3769
3776
|
);
|
|
3770
3777
|
useEffect(() => {
|
|
@@ -3789,15 +3796,15 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3789
3796
|
forms,
|
|
3790
3797
|
aspectRatio,
|
|
3791
3798
|
containerQueries,
|
|
3792
|
-
plugin(function({ addBase: b, theme:
|
|
3799
|
+
plugin(function({ addBase: b, theme: k }) {
|
|
3793
3800
|
b({
|
|
3794
3801
|
"h1,h2,h3,h4,h5,h6": {
|
|
3795
|
-
fontFamily:
|
|
3802
|
+
fontFamily: k("fontFamily.heading")
|
|
3796
3803
|
},
|
|
3797
3804
|
body: {
|
|
3798
|
-
fontFamily:
|
|
3799
|
-
color:
|
|
3800
|
-
backgroundColor:
|
|
3805
|
+
fontFamily: k("fontFamily.body"),
|
|
3806
|
+
color: k("colors.foreground"),
|
|
3807
|
+
backgroundColor: k("colors.background")
|
|
3801
3808
|
}
|
|
3802
3809
|
});
|
|
3803
3810
|
})
|
|
@@ -3808,23 +3815,23 @@ const useHandleCanvasDblClick = (o, n) => {
|
|
|
3808
3815
|
outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
|
|
3809
3816
|
}`);
|
|
3810
3817
|
}, [r, g]), useEffect(() => {
|
|
3811
|
-
|
|
3812
|
-
}, [i,
|
|
3818
|
+
x.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
|
|
3819
|
+
}, [i, x]), useEffect(() => {
|
|
3813
3820
|
u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
|
|
3814
3821
|
}, [u]), useEffect(() => {
|
|
3815
|
-
|
|
3822
|
+
m && (m.textContent = `${map(l, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
|
|
3816
3823
|
outline: 1px solid orange !important; outline-offset: -1px;
|
|
3817
3824
|
}`);
|
|
3818
|
-
}, [l,
|
|
3825
|
+
}, [l, m]), useEffect(() => {
|
|
3819
3826
|
d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
|
|
3820
3827
|
}, [c, d]);
|
|
3821
3828
|
const f = useMemo(
|
|
3822
3829
|
() => getChaiThemeCssVariables(o),
|
|
3823
3830
|
[o]
|
|
3824
|
-
),
|
|
3831
|
+
), h = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
|
|
3825
3832
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3826
3833
|
/* @__PURE__ */ jsx("style", { id: "chai-theme", children: f }),
|
|
3827
|
-
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html:
|
|
3834
|
+
/* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: h } })
|
|
3828
3835
|
] });
|
|
3829
3836
|
}, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
|
|
3830
3837
|
const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), c = useDebouncedCallback(
|
|
@@ -3901,13 +3908,13 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3901
3908
|
[o]
|
|
3902
3909
|
);
|
|
3903
3910
|
}, BlockRenderer = ({ blockAtom: o, children: n }) => {
|
|
3904
|
-
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),
|
|
3911
|
+
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(
|
|
3905
3912
|
() => u ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
|
|
3906
3913
|
[r, l, a, d, u]
|
|
3907
|
-
),
|
|
3914
|
+
), x = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), f = useMemo(
|
|
3908
3915
|
() => c(r._id, getBlockRuntimeProps(r._type)),
|
|
3909
3916
|
[r._id, r._type, c, getBlockRuntimeProps]
|
|
3910
|
-
),
|
|
3917
|
+
), h = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), b = useMemo(
|
|
3911
3918
|
() => ({
|
|
3912
3919
|
blockProps: {
|
|
3913
3920
|
"data-block-id": r._id,
|
|
@@ -3915,20 +3922,20 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3915
3922
|
},
|
|
3916
3923
|
inBuilder: !0,
|
|
3917
3924
|
lang: l || i,
|
|
3918
|
-
...h,
|
|
3919
3925
|
...m,
|
|
3926
|
+
...x,
|
|
3920
3927
|
...f,
|
|
3921
|
-
...
|
|
3928
|
+
...h
|
|
3922
3929
|
}),
|
|
3923
3930
|
[
|
|
3924
3931
|
r._id,
|
|
3925
3932
|
r._type,
|
|
3926
3933
|
l,
|
|
3927
3934
|
i,
|
|
3928
|
-
h,
|
|
3929
3935
|
m,
|
|
3936
|
+
x,
|
|
3930
3937
|
f,
|
|
3931
|
-
|
|
3938
|
+
h
|
|
3932
3939
|
]
|
|
3933
3940
|
);
|
|
3934
3941
|
return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...b, children: n }) });
|
|
@@ -3960,11 +3967,11 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3960
3967
|
if (d < n) {
|
|
3961
3968
|
const u = parseFloat((d / n).toFixed(2).toString());
|
|
3962
3969
|
let g = {};
|
|
3963
|
-
const
|
|
3970
|
+
const m = p * u, x = d * u;
|
|
3964
3971
|
p && (g = {
|
|
3965
3972
|
// Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
|
|
3966
|
-
height: 100 + (p -
|
|
3967
|
-
width: 100 + (d -
|
|
3973
|
+
height: 100 + (p - m) / m * 100 + "%",
|
|
3974
|
+
width: 100 + (d - x) / x * 100 + "%"
|
|
3968
3975
|
}), i({
|
|
3969
3976
|
position: "relative",
|
|
3970
3977
|
top: 0,
|
|
@@ -3981,39 +3988,39 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
3981
3988
|
c();
|
|
3982
3989
|
}, [n, o, r, c]), l;
|
|
3983
3990
|
}, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
|
|
3984
|
-
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,
|
|
3985
|
-
p((S) => ({ ...S, width:
|
|
3991
|
+
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([]), [, x] = useState([]), [, f] = useAtom$1(canvasIframeAtom), [h, b] = useSelectedStylingBlocks(), k = useBuilderProp("loading", !1), A = useBuilderProp("htmlDir", "ltr"), B = (_) => {
|
|
3992
|
+
p((S) => ({ ...S, width: _ }));
|
|
3986
3993
|
};
|
|
3987
3994
|
useEffect(() => {
|
|
3988
3995
|
if (!c.current) return;
|
|
3989
|
-
const { clientWidth:
|
|
3990
|
-
p({ width:
|
|
3996
|
+
const { clientWidth: _, clientHeight: S } = c.current;
|
|
3997
|
+
p({ width: _, height: S });
|
|
3991
3998
|
}, [c, n]);
|
|
3992
|
-
const
|
|
3993
|
-
const { top:
|
|
3994
|
-
return
|
|
3999
|
+
const C = (_, S = 0) => {
|
|
4000
|
+
const { top: w } = _.getBoundingClientRect();
|
|
4001
|
+
return w + S >= 0 && w - S <= window.innerHeight;
|
|
3995
4002
|
};
|
|
3996
4003
|
useEffect(() => {
|
|
3997
|
-
var
|
|
4004
|
+
var _, S;
|
|
3998
4005
|
if (a && a.type !== "Multiple" && i.current) {
|
|
3999
|
-
const
|
|
4000
|
-
|
|
4006
|
+
const w = getElementByDataBlockId(i.current.contentDocument, a._id);
|
|
4007
|
+
w && (C(w) || (S = (_ = i.current) == null ? void 0 : _.contentWindow) == null || S.scrollTo({ top: w.offsetTop, behavior: "smooth" }), m([w]));
|
|
4001
4008
|
}
|
|
4002
4009
|
}, [a]), useEffect(() => {
|
|
4003
|
-
if (!isEmpty(
|
|
4004
|
-
const
|
|
4010
|
+
if (!isEmpty(h) && i.current) {
|
|
4011
|
+
const _ = getElementByStyleId(
|
|
4005
4012
|
i.current.contentDocument,
|
|
4006
|
-
first(
|
|
4013
|
+
first(h).id
|
|
4007
4014
|
);
|
|
4008
|
-
|
|
4015
|
+
x(_ ? [_] : [null]);
|
|
4009
4016
|
} else
|
|
4010
|
-
|
|
4011
|
-
}, [
|
|
4012
|
-
const
|
|
4013
|
-
let
|
|
4014
|
-
return
|
|
4017
|
+
x([null]);
|
|
4018
|
+
}, [h]);
|
|
4019
|
+
const j = useMemo(() => {
|
|
4020
|
+
let _ = IframeInitialContent;
|
|
4021
|
+
return _ = _.replace("__HTML_DIR__", A), o === "offline" && (_ = _.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), _;
|
|
4015
4022
|
}, [o, A]);
|
|
4016
|
-
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount:
|
|
4023
|
+
return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: B, onResize: B, children: /* @__PURE__ */ jsx(
|
|
4017
4024
|
"div",
|
|
4018
4025
|
{
|
|
4019
4026
|
onClick: () => {
|
|
@@ -4030,7 +4037,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4030
4037
|
id: "canvas-iframe",
|
|
4031
4038
|
style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
|
|
4032
4039
|
className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
|
|
4033
|
-
initialContent:
|
|
4040
|
+
initialContent: j,
|
|
4034
4041
|
children: [
|
|
4035
4042
|
/* @__PURE__ */ jsx(KeyboardHandler, {}),
|
|
4036
4043
|
/* @__PURE__ */ jsx(
|
|
@@ -4042,7 +4049,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4042
4049
|
),
|
|
4043
4050
|
/* @__PURE__ */ jsx(HeadTags, {}),
|
|
4044
4051
|
/* @__PURE__ */ jsx(Provider$1, { children: /* @__PURE__ */ jsxs(Canvas, { children: [
|
|
4045
|
-
|
|
4052
|
+
k ? /* @__PURE__ */ jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsx(StaticBlocksRenderer, {}),
|
|
4046
4053
|
/* @__PURE__ */ jsx(AddBlockAtBottom, {}),
|
|
4047
4054
|
/* @__PURE__ */ jsx("br", {}),
|
|
4048
4055
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -4203,78 +4210,78 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4203
4210
|
}
|
|
4204
4211
|
);
|
|
4205
4212
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
4206
|
-
const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null),
|
|
4207
|
-
a(
|
|
4208
|
-
},
|
|
4209
|
-
const
|
|
4210
|
-
if (
|
|
4211
|
-
const
|
|
4212
|
-
|
|
4213
|
+
const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), m = (A) => {
|
|
4214
|
+
a(A);
|
|
4215
|
+
}, x = () => {
|
|
4216
|
+
const A = l.find((B) => Object.keys(B)[0] === r);
|
|
4217
|
+
if (A) {
|
|
4218
|
+
const B = Object.values(A)[0];
|
|
4219
|
+
B && typeof B == "object" && "fontFamily" in B && "borderRadius" in B && "colors" in B ? p(B) : console.error("Invalid preset structure:", B);
|
|
4213
4220
|
} else
|
|
4214
4221
|
console.error("Preset not found:", r);
|
|
4215
|
-
},
|
|
4216
|
-
(
|
|
4217
|
-
|
|
4218
|
-
...
|
|
4222
|
+
}, f = useDebouncedCallback(
|
|
4223
|
+
(A, B) => {
|
|
4224
|
+
p(() => ({
|
|
4225
|
+
...d,
|
|
4219
4226
|
fontFamily: {
|
|
4220
|
-
...
|
|
4221
|
-
[
|
|
4227
|
+
...d.fontFamily,
|
|
4228
|
+
[A.replace(/font-/g, "")]: B
|
|
4222
4229
|
}
|
|
4223
4230
|
}));
|
|
4224
4231
|
},
|
|
4225
|
-
[
|
|
4232
|
+
[d],
|
|
4226
4233
|
200
|
|
4227
|
-
),
|
|
4228
|
-
(
|
|
4229
|
-
|
|
4230
|
-
...
|
|
4231
|
-
borderRadius: `${
|
|
4234
|
+
), h = useDebouncedCallback(
|
|
4235
|
+
(A) => {
|
|
4236
|
+
p(() => ({
|
|
4237
|
+
...d,
|
|
4238
|
+
borderRadius: `${A}px`
|
|
4232
4239
|
}));
|
|
4233
4240
|
},
|
|
4234
|
-
[
|
|
4241
|
+
[d],
|
|
4235
4242
|
200
|
|
4236
|
-
),
|
|
4237
|
-
(
|
|
4238
|
-
|
|
4239
|
-
const
|
|
4240
|
-
return n ? set(
|
|
4241
|
-
...
|
|
4243
|
+
), b = useDebouncedCallback(
|
|
4244
|
+
(A, B) => {
|
|
4245
|
+
p(() => {
|
|
4246
|
+
const C = get(d, `colors.${A}`);
|
|
4247
|
+
return n ? set(C, 1, B) : set(C, 0, B), {
|
|
4248
|
+
...d,
|
|
4242
4249
|
colors: {
|
|
4243
|
-
...
|
|
4244
|
-
[
|
|
4250
|
+
...d.colors,
|
|
4251
|
+
[A]: C
|
|
4245
4252
|
}
|
|
4246
4253
|
};
|
|
4247
4254
|
});
|
|
4248
4255
|
},
|
|
4249
|
-
[
|
|
4256
|
+
[d],
|
|
4250
4257
|
200
|
|
4251
|
-
),
|
|
4252
|
-
const
|
|
4258
|
+
), k = (A) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(A.items).map(([B]) => {
|
|
4259
|
+
const C = get(d, `colors.${B}.${n ? 1 : 0}`);
|
|
4253
4260
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
|
|
4254
4261
|
/* @__PURE__ */ jsx(
|
|
4255
4262
|
ColorPickerInput,
|
|
4256
4263
|
{
|
|
4257
|
-
value:
|
|
4258
|
-
onChange: (
|
|
4264
|
+
value: C,
|
|
4265
|
+
onChange: (j) => b(B, j)
|
|
4259
4266
|
}
|
|
4260
4267
|
),
|
|
4261
|
-
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children:
|
|
4262
|
-
] },
|
|
4268
|
+
/* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((j) => j.charAt(0).toUpperCase() + j.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
|
|
4269
|
+
] }, B);
|
|
4263
4270
|
}) });
|
|
4264
|
-
return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
4271
|
+
return c("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
|
|
4265
4272
|
/* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
|
|
4266
4273
|
l.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 py-2", children: [
|
|
4267
4274
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
4268
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children:
|
|
4275
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Presets") }),
|
|
4269
4276
|
/* @__PURE__ */ jsxs(
|
|
4270
4277
|
"select",
|
|
4271
4278
|
{
|
|
4272
4279
|
value: r,
|
|
4273
|
-
onChange: (
|
|
4280
|
+
onChange: (A) => m(A.target.value),
|
|
4274
4281
|
className: "w-full space-y-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
|
|
4275
4282
|
children: [
|
|
4276
4283
|
/* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
|
|
4277
|
-
Array.isArray(l) && l.map((
|
|
4284
|
+
Array.isArray(l) && l.map((A) => /* @__PURE__ */ jsx("option", { value: Object.keys(A)[0], children: capitalize(Object.keys(A)[0]) }, Object.keys(A)[0]))
|
|
4278
4285
|
]
|
|
4279
4286
|
}
|
|
4280
4287
|
)
|
|
@@ -4285,31 +4292,31 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4285
4292
|
className: "w-full text-sm",
|
|
4286
4293
|
disabled: r === "",
|
|
4287
4294
|
variant: "default",
|
|
4288
|
-
onClick:
|
|
4289
|
-
children:
|
|
4295
|
+
onClick: x,
|
|
4296
|
+
children: g("Apply")
|
|
4290
4297
|
}
|
|
4291
4298
|
) })
|
|
4292
4299
|
] }),
|
|
4293
4300
|
/* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
|
|
4294
|
-
(
|
|
4301
|
+
(u == null ? void 0 : u.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(u.fontFamily).map(([A, B]) => /* @__PURE__ */ jsx(
|
|
4295
4302
|
FontSelector,
|
|
4296
4303
|
{
|
|
4297
|
-
label:
|
|
4298
|
-
value:
|
|
4299
|
-
onChange: (
|
|
4304
|
+
label: A,
|
|
4305
|
+
value: d.fontFamily[A.replace(/font-/g, "")] || B[Object.keys(B)[0]],
|
|
4306
|
+
onChange: (C) => f(A, C)
|
|
4300
4307
|
},
|
|
4301
|
-
|
|
4308
|
+
A
|
|
4302
4309
|
)) }),
|
|
4303
|
-
(
|
|
4304
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children:
|
|
4310
|
+
(u == null ? void 0 : u.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
|
|
4311
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Border Radius") }),
|
|
4305
4312
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
|
|
4306
|
-
/* @__PURE__ */ jsx(BorderRadiusInput, { value:
|
|
4307
|
-
/* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children:
|
|
4313
|
+
/* @__PURE__ */ jsx(BorderRadiusInput, { value: d.borderRadius, onChange: h }),
|
|
4314
|
+
/* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: d.borderRadius })
|
|
4308
4315
|
] })
|
|
4309
4316
|
] }),
|
|
4310
|
-
(
|
|
4311
|
-
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children:
|
|
4312
|
-
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children:
|
|
4317
|
+
(u == null ? void 0 : u.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
|
|
4318
|
+
/* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: g("Colors") }),
|
|
4319
|
+
/* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: u.colors.map((A) => k(A)) }, n ? "dark" : "light")
|
|
4313
4320
|
] })
|
|
4314
4321
|
] }),
|
|
4315
4322
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -4318,7 +4325,7 @@ const getBlockRuntimeProps = memoize((o) => {
|
|
|
4318
4325
|
/* @__PURE__ */ jsx("br", {})
|
|
4319
4326
|
] }),
|
|
4320
4327
|
i && /* @__PURE__ */ jsx("div", { className: "absolute bottom-4 w-full", children: React.createElement(i) })
|
|
4321
|
-
] });
|
|
4328
|
+
] }) : /* @__PURE__ */ jsx("div", { className: "relative w-full", children: /* @__PURE__ */ jsx("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto text-center", o), children: /* @__PURE__ */ jsx("div", { className: "mt-10 h-full items-center justify-center gap-2 text-muted-foreground", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: "You don't have permission to edit the theme. Please contact your administrator to get access." }) }) }) });
|
|
4322
4329
|
}), removeSizeAttributes = (o) => {
|
|
4323
4330
|
try {
|
|
4324
4331
|
return o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi, "<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi, "<svg$1$2>");
|
|
@@ -4402,19 +4409,19 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4402
4409
|
}, [a, o]);
|
|
4403
4410
|
const u = (f) => Array.isArray(f) ? "array" : typeof f == "object" && f !== null ? "object" : "value", g = React.useCallback(
|
|
4404
4411
|
(f) => {
|
|
4405
|
-
const
|
|
4406
|
-
f.type === "object" ? (c((b) => [...b, f.key]), p(f.value)) :
|
|
4412
|
+
const h = (b) => r === "value" ? b === "value" || b === "object" : r === "array" ? b === "array" : b === r;
|
|
4413
|
+
f.type === "object" ? (c((b) => [...b, f.key]), p(f.value)) : h(f.type) && (n([...i, f.key].join(".")), l(!1));
|
|
4407
4414
|
},
|
|
4408
4415
|
[i, n, r]
|
|
4409
|
-
),
|
|
4416
|
+
), m = React.useCallback(() => {
|
|
4410
4417
|
if (i.length > 0) {
|
|
4411
4418
|
const f = i.slice(0, -1);
|
|
4412
|
-
c(f), p(f.reduce((
|
|
4419
|
+
c(f), p(f.reduce((h, b) => h[b], o));
|
|
4413
4420
|
}
|
|
4414
|
-
}, [i, o]),
|
|
4421
|
+
}, [i, o]), x = React.useMemo(() => Object.entries(d).map(([f, h]) => ({
|
|
4415
4422
|
key: f,
|
|
4416
|
-
value:
|
|
4417
|
-
type: u(
|
|
4423
|
+
value: h,
|
|
4424
|
+
type: u(h)
|
|
4418
4425
|
})).filter((f) => r === "value" ? f.type === "value" || f.type === "object" : r === "array" ? f.type === "array" || f.type === "object" : r === "object" ? f.type === "object" : !0), [d, r]);
|
|
4419
4426
|
return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
|
|
4420
4427
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
@@ -4436,11 +4443,11 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4436
4443
|
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
4437
4444
|
/* @__PURE__ */ jsx(CommandEmpty, { children: "No option found." }),
|
|
4438
4445
|
/* @__PURE__ */ jsxs(CommandGroup, { children: [
|
|
4439
|
-
i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect:
|
|
4446
|
+
i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: m, className: "flex items-center text-sm", children: [
|
|
4440
4447
|
/* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
|
|
4441
4448
|
"Back"
|
|
4442
4449
|
] }),
|
|
4443
|
-
|
|
4450
|
+
x.map((f) => /* @__PURE__ */ jsxs(
|
|
4444
4451
|
CommandItem,
|
|
4445
4452
|
{
|
|
4446
4453
|
value: f.key,
|
|
@@ -4456,8 +4463,8 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
|
|
|
4456
4463
|
size: "sm",
|
|
4457
4464
|
variant: "ghost",
|
|
4458
4465
|
className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
|
|
4459
|
-
onClick: (
|
|
4460
|
-
|
|
4466
|
+
onClick: (h) => {
|
|
4467
|
+
h.stopPropagation(), n([...i, f.key].join(".")), l(!1);
|
|
4461
4468
|
},
|
|
4462
4469
|
children: "Select"
|
|
4463
4470
|
}
|
|
@@ -4625,16 +4632,16 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4625
4632
|
const c = useRef(null), d = useRef(a || ""), p = usePageExternalData();
|
|
4626
4633
|
useEffect(() => {
|
|
4627
4634
|
if (o) {
|
|
4628
|
-
const
|
|
4629
|
-
return
|
|
4635
|
+
const m = document.createElement("style");
|
|
4636
|
+
return m.id = "rte-modal-styles", m.innerHTML = `
|
|
4630
4637
|
/* Ensure the NestedPathSelector popover appears above the dialog */
|
|
4631
4638
|
.rte-path-selector + [data-radix-popper-content-wrapper],
|
|
4632
4639
|
[data-radix-popper-content-wrapper] {
|
|
4633
4640
|
z-index: 9999 !important;
|
|
4634
4641
|
}
|
|
4635
|
-
`, document.head.appendChild(
|
|
4636
|
-
const
|
|
4637
|
-
|
|
4642
|
+
`, document.head.appendChild(m), () => {
|
|
4643
|
+
const x = document.getElementById("rte-modal-styles");
|
|
4644
|
+
x && x.remove();
|
|
4638
4645
|
};
|
|
4639
4646
|
}
|
|
4640
4647
|
}, [o]);
|
|
@@ -4655,13 +4662,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4655
4662
|
Underline
|
|
4656
4663
|
],
|
|
4657
4664
|
content: a || "",
|
|
4658
|
-
onUpdate: ({ editor:
|
|
4659
|
-
const
|
|
4660
|
-
l(
|
|
4665
|
+
onUpdate: ({ editor: m }) => {
|
|
4666
|
+
const x = m.getHTML();
|
|
4667
|
+
l(x);
|
|
4661
4668
|
},
|
|
4662
|
-
onBlur: ({ editor:
|
|
4663
|
-
const
|
|
4664
|
-
i(r,
|
|
4669
|
+
onBlur: ({ editor: m }) => {
|
|
4670
|
+
const x = m.getHTML();
|
|
4671
|
+
i(r, x);
|
|
4665
4672
|
},
|
|
4666
4673
|
editorProps: {
|
|
4667
4674
|
attributes: {
|
|
@@ -4676,22 +4683,22 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4676
4683
|
}, [o, u]), useEffect(() => {
|
|
4677
4684
|
c.current && u && (c.current.__chaiRTE = u);
|
|
4678
4685
|
}, [u, o]);
|
|
4679
|
-
const g = (
|
|
4686
|
+
const g = (m) => {
|
|
4680
4687
|
if (!u) return;
|
|
4681
|
-
const
|
|
4688
|
+
const x = `{{${m}}}`;
|
|
4682
4689
|
u.commands.focus();
|
|
4683
|
-
const { from: f, to:
|
|
4684
|
-
if (f !==
|
|
4685
|
-
u.chain().deleteSelection().insertContent(
|
|
4690
|
+
const { from: f, to: h } = u.state.selection;
|
|
4691
|
+
if (f !== h)
|
|
4692
|
+
u.chain().deleteSelection().insertContent(x).run();
|
|
4686
4693
|
else {
|
|
4687
|
-
const { state:
|
|
4688
|
-
let _ = "";
|
|
4689
|
-
A > 0 && E !== " " && !/[.,!?;:]/.test(E) && (_ = " ");
|
|
4694
|
+
const { state: k } = u, A = k.selection.from, B = k.doc.textBetween(Math.max(0, A - 1), A), C = k.doc.textBetween(A, Math.min(A + 1, k.doc.content.size));
|
|
4690
4695
|
let j = "";
|
|
4691
|
-
|
|
4696
|
+
A > 0 && B !== " " && !/[.,!?;:]/.test(B) && (j = " ");
|
|
4697
|
+
let _ = "";
|
|
4698
|
+
C && C !== " " && !/[.,!?;:]/.test(C) && (_ = " "), u.chain().insertContent(j + x + _).run();
|
|
4692
4699
|
}
|
|
4693
4700
|
};
|
|
4694
|
-
return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (
|
|
4701
|
+
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: [
|
|
4695
4702
|
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center justify-between pr-8", children: [
|
|
4696
4703
|
/* @__PURE__ */ jsx("span", { children: "Rich Text Editor" }),
|
|
4697
4704
|
p && Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -4724,12 +4731,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4724
4731
|
],
|
|
4725
4732
|
content: r || "",
|
|
4726
4733
|
onUpdate: ({ editor: f }) => {
|
|
4727
|
-
const
|
|
4728
|
-
a(
|
|
4734
|
+
const h = f.getHTML();
|
|
4735
|
+
a(h), c || u(h);
|
|
4729
4736
|
},
|
|
4730
4737
|
onBlur: ({ editor: f }) => {
|
|
4731
|
-
const
|
|
4732
|
-
l(o,
|
|
4738
|
+
const h = f.getHTML();
|
|
4739
|
+
l(o, h);
|
|
4733
4740
|
},
|
|
4734
4741
|
editorProps: {
|
|
4735
4742
|
attributes: {
|
|
@@ -4742,9 +4749,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4742
4749
|
}, [g]), useEffect(() => {
|
|
4743
4750
|
u(r || "");
|
|
4744
4751
|
}, [r]);
|
|
4745
|
-
const
|
|
4752
|
+
const m = (f) => {
|
|
4746
4753
|
a(f);
|
|
4747
|
-
},
|
|
4754
|
+
}, x = () => {
|
|
4748
4755
|
d(!1), g && g.commands.setContent(p);
|
|
4749
4756
|
};
|
|
4750
4757
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -4756,10 +4763,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4756
4763
|
RTEModal,
|
|
4757
4764
|
{
|
|
4758
4765
|
isOpen: c,
|
|
4759
|
-
onClose:
|
|
4766
|
+
onClose: x,
|
|
4760
4767
|
id: o,
|
|
4761
4768
|
value: p,
|
|
4762
|
-
onChange:
|
|
4769
|
+
onChange: m,
|
|
4763
4770
|
onBlur: l
|
|
4764
4771
|
}
|
|
4765
4772
|
)
|
|
@@ -4770,41 +4777,41 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4770
4777
|
onChange: r
|
|
4771
4778
|
}) => {
|
|
4772
4779
|
var L;
|
|
4773
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v,
|
|
4780
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, y) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, x] = useState(""), [f, h] = useState([]), [b, k] = useState(-1), A = useRef(null), B = (L = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : L.name;
|
|
4774
4781
|
useEffect(() => {
|
|
4775
|
-
if (
|
|
4776
|
-
const v = split(o, ":"),
|
|
4777
|
-
g(
|
|
4778
|
-
const
|
|
4779
|
-
|
|
4782
|
+
if (x(""), h([]), k(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
4783
|
+
const v = split(o, ":"), y = get(v, 1, "page") || "page";
|
|
4784
|
+
g(y), (async () => {
|
|
4785
|
+
const E = await l(y, [get(v, 2, "page")]);
|
|
4786
|
+
E && Array.isArray(E) && x(get(E, [0, "name"], ""));
|
|
4780
4787
|
})();
|
|
4781
4788
|
}, [o]);
|
|
4782
|
-
const
|
|
4789
|
+
const C = useDebouncedCallback(
|
|
4783
4790
|
async (v) => {
|
|
4784
4791
|
if (isEmpty(v))
|
|
4785
|
-
|
|
4792
|
+
h([]);
|
|
4786
4793
|
else {
|
|
4787
|
-
const
|
|
4788
|
-
|
|
4794
|
+
const y = await l(u, v);
|
|
4795
|
+
h(y);
|
|
4789
4796
|
}
|
|
4790
|
-
c(!1),
|
|
4797
|
+
c(!1), k(-1);
|
|
4791
4798
|
},
|
|
4792
4799
|
[u],
|
|
4793
4800
|
300
|
|
4794
|
-
),
|
|
4795
|
-
const
|
|
4796
|
-
|
|
4797
|
-
},
|
|
4801
|
+
), j = (v) => {
|
|
4802
|
+
const y = ["pageType", u, v.id];
|
|
4803
|
+
y[1] && (r(y.join(":")), x(v.name), p(!1), h([]), k(-1));
|
|
4804
|
+
}, _ = (v) => {
|
|
4798
4805
|
switch (v.key) {
|
|
4799
4806
|
case "ArrowDown":
|
|
4800
|
-
v.preventDefault(),
|
|
4807
|
+
v.preventDefault(), k((y) => y < f.length - 1 ? y + 1 : y);
|
|
4801
4808
|
break;
|
|
4802
4809
|
case "ArrowUp":
|
|
4803
|
-
v.preventDefault(),
|
|
4810
|
+
v.preventDefault(), k((y) => y > 0 ? y - 1 : y);
|
|
4804
4811
|
break;
|
|
4805
4812
|
case "Enter":
|
|
4806
4813
|
if (v.preventDefault(), f.length === 0) return;
|
|
4807
|
-
b >= 0 &&
|
|
4814
|
+
b >= 0 && j(f[b]);
|
|
4808
4815
|
break;
|
|
4809
4816
|
case "Escape":
|
|
4810
4817
|
v.preventDefault(), S();
|
|
@@ -4818,9 +4825,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4818
4825
|
}
|
|
4819
4826
|
}, [b]);
|
|
4820
4827
|
const S = () => {
|
|
4821
|
-
|
|
4822
|
-
},
|
|
4823
|
-
|
|
4828
|
+
x(""), h([]), k(-1), p(!1), r("");
|
|
4829
|
+
}, w = (v) => {
|
|
4830
|
+
x(v), p(!isEmpty(v)), c(!0), C(v);
|
|
4824
4831
|
};
|
|
4825
4832
|
return /* @__PURE__ */ jsxs("div", { children: [
|
|
4826
4833
|
/* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (v) => g(v.target.value), children: map(n, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
|
|
@@ -4829,14 +4836,14 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4829
4836
|
"input",
|
|
4830
4837
|
{
|
|
4831
4838
|
type: "text",
|
|
4832
|
-
value:
|
|
4833
|
-
onChange: (v) =>
|
|
4834
|
-
onKeyDown:
|
|
4835
|
-
placeholder: a(`Search ${
|
|
4839
|
+
value: m,
|
|
4840
|
+
onChange: (v) => w(v.target.value),
|
|
4841
|
+
onKeyDown: _,
|
|
4842
|
+
placeholder: a(`Search ${B ?? ""}`),
|
|
4836
4843
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
4837
4844
|
}
|
|
4838
4845
|
),
|
|
4839
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children:
|
|
4846
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
|
|
4840
4847
|
] }),
|
|
4841
4848
|
(i || !isEmpty(f) || d && isEmpty(f)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
|
|
4842
4849
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
@@ -4844,13 +4851,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4844
4851
|
] }) : d && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
4845
4852
|
a("No results found for"),
|
|
4846
4853
|
' "',
|
|
4847
|
-
|
|
4854
|
+
m,
|
|
4848
4855
|
'"'
|
|
4849
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(f == null ? void 0 : f.slice(0, 20), (v,
|
|
4856
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(f == null ? void 0 : f.slice(0, 20), (v, y) => /* @__PURE__ */ jsxs(
|
|
4850
4857
|
"li",
|
|
4851
4858
|
{
|
|
4852
|
-
onClick: () =>
|
|
4853
|
-
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" :
|
|
4859
|
+
onClick: () => j(v),
|
|
4860
|
+
className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : y === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
|
|
4854
4861
|
children: [
|
|
4855
4862
|
v.name,
|
|
4856
4863
|
" ",
|
|
@@ -4943,30 +4950,30 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4943
4950
|
}, [a]), useEffect(() => {
|
|
4944
4951
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
|
|
4945
4952
|
}, [o, u]);
|
|
4946
|
-
const
|
|
4947
|
-
const
|
|
4948
|
-
if (
|
|
4949
|
-
const b = (
|
|
4950
|
-
if (!
|
|
4951
|
-
n({ ...o, currentSlide:
|
|
4953
|
+
const m = () => {
|
|
4954
|
+
const h = findIndex(u, { _id: g });
|
|
4955
|
+
if (h > -1) {
|
|
4956
|
+
const b = (h + 1) % u.length, k = get(u, [b, "_id"]);
|
|
4957
|
+
if (!k) return;
|
|
4958
|
+
n({ ...o, currentSlide: k }), c([k]);
|
|
4952
4959
|
}
|
|
4953
|
-
},
|
|
4954
|
-
const
|
|
4955
|
-
if (
|
|
4956
|
-
const b = (
|
|
4957
|
-
if (!
|
|
4958
|
-
n({ ...o, currentSlide:
|
|
4960
|
+
}, x = () => {
|
|
4961
|
+
const h = findIndex(u, { _id: g });
|
|
4962
|
+
if (h > -1) {
|
|
4963
|
+
const b = (h - 1 + u.length) % u.length, k = get(u, [b, "_id"]);
|
|
4964
|
+
if (!k) return;
|
|
4965
|
+
n({ ...o, currentSlide: k }), c([k]);
|
|
4959
4966
|
}
|
|
4960
4967
|
}, f = () => {
|
|
4961
|
-
const
|
|
4968
|
+
const h = i(
|
|
4962
4969
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4963
4970
|
p == null ? void 0 : p._id
|
|
4964
|
-
), b =
|
|
4971
|
+
), b = h == null ? void 0 : h._id;
|
|
4965
4972
|
b && (n({ ...o, currentSlide: b }), c([b]));
|
|
4966
4973
|
};
|
|
4967
4974
|
return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
|
|
4968
4975
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
|
|
4969
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
4976
|
+
/* @__PURE__ */ jsx("button", { onClick: x, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
|
|
4970
4977
|
/* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
|
|
4971
4978
|
/* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
|
|
4972
4979
|
" ",
|
|
@@ -4975,7 +4982,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
4975
4982
|
"/",
|
|
4976
4983
|
u.length
|
|
4977
4984
|
] }) : "-" }),
|
|
4978
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
4985
|
+
/* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
|
|
4979
4986
|
/* @__PURE__ */ jsxs(
|
|
4980
4987
|
"button",
|
|
4981
4988
|
{
|
|
@@ -5040,8 +5047,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5040
5047
|
value: o == null ? void 0 : o.autoplayInterval,
|
|
5041
5048
|
className: "text-xs",
|
|
5042
5049
|
pattern: "[0-9]*",
|
|
5043
|
-
onChange: (
|
|
5044
|
-
let b =
|
|
5050
|
+
onChange: (h) => {
|
|
5051
|
+
let b = h.target.value;
|
|
5045
5052
|
b.length && (b = b.replace("-", "")), n({ ...o, autoplayInterval: b });
|
|
5046
5053
|
}
|
|
5047
5054
|
}
|
|
@@ -5067,7 +5074,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5067
5074
|
),
|
|
5068
5075
|
/* @__PURE__ */ jsx(Button, { onClick: d, size: "sm", variant: "outline", className: "w-fit", children: r("Open code editor") })
|
|
5069
5076
|
] });
|
|
5070
|
-
},
|
|
5077
|
+
}, JSONFormFieldTemplate = ({
|
|
5071
5078
|
id: o,
|
|
5072
5079
|
classNames: n,
|
|
5073
5080
|
label: r,
|
|
@@ -5079,67 +5086,67 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5079
5086
|
required: p,
|
|
5080
5087
|
schema: u,
|
|
5081
5088
|
formData: g,
|
|
5082
|
-
onChange:
|
|
5089
|
+
onChange: m
|
|
5083
5090
|
}) => {
|
|
5084
|
-
const { selectedLang:
|
|
5085
|
-
(
|
|
5086
|
-
const
|
|
5087
|
-
let
|
|
5088
|
-
const $ =
|
|
5089
|
-
return
|
|
5090
|
-
text:
|
|
5091
|
-
prefixLength:
|
|
5091
|
+
const { selectedLang: x, fallbackLang: f, languages: h } = useLanguages(), b = isEmpty$1(h) ? "" : isEmpty$1(x) ? f : x, k = get$1(LANGUAGES, b, b), A = usePageExternalData(), B = useSelectedBlock(), C = useRegisteredChaiBlocks(), j = get$1(C, [B == null ? void 0 : B._type, "i18nProps"], []) || [], [_, S] = useState(null), w = useCallback(
|
|
5092
|
+
(y) => {
|
|
5093
|
+
const E = (P) => /[.,!?;:]/.test(P), T = (P, N, M) => {
|
|
5094
|
+
let D = "", O = "";
|
|
5095
|
+
const $ = N > 0 ? P[N - 1] : "", H = N < P.length ? P[N] : "";
|
|
5096
|
+
return N > 0 && ($ === "." || !E($) && $ !== " ") && (D = " "), N < P.length && !E(H) && H !== " " && (O = " "), {
|
|
5097
|
+
text: D + M + O,
|
|
5098
|
+
prefixLength: D.length,
|
|
5092
5099
|
suffixLength: O.length
|
|
5093
5100
|
};
|
|
5094
5101
|
}, I = document.getElementById(o);
|
|
5095
5102
|
if (!I) return;
|
|
5096
|
-
const
|
|
5097
|
-
if (
|
|
5098
|
-
const
|
|
5099
|
-
if (
|
|
5100
|
-
const
|
|
5101
|
-
|
|
5102
|
-
const { from: M, to:
|
|
5103
|
-
if (M !==
|
|
5104
|
-
|
|
5103
|
+
const R = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
|
|
5104
|
+
if (R && (R.querySelector(".ProseMirror") || R.__chaiRTE)) {
|
|
5105
|
+
const P = R.__chaiRTE;
|
|
5106
|
+
if (P) {
|
|
5107
|
+
const N = `{{${y}}}`;
|
|
5108
|
+
P.commands.focus();
|
|
5109
|
+
const { from: M, to: D } = P.state.selection;
|
|
5110
|
+
if (M !== D)
|
|
5111
|
+
P.chain().deleteSelection().insertContent(N).run();
|
|
5105
5112
|
else {
|
|
5106
|
-
const { state: $ } =
|
|
5113
|
+
const { state: $ } = P, H = $.selection.from, U = $.doc.textBetween(Math.max(0, H - 1), H), F = $.doc.textBetween(H, Math.min(H + 1, $.doc.content.size));
|
|
5107
5114
|
let z = "";
|
|
5108
|
-
H > 0 &&
|
|
5115
|
+
H > 0 && U !== " " && !E(U) && (z = " ");
|
|
5109
5116
|
let W = "";
|
|
5110
|
-
|
|
5117
|
+
F && F !== " " && !E(F) && (W = " "), P.chain().insertContent(z + N + W).run();
|
|
5111
5118
|
}
|
|
5112
|
-
setTimeout(() =>
|
|
5119
|
+
setTimeout(() => m(P.getHTML(), {}, o), 100);
|
|
5113
5120
|
return;
|
|
5114
5121
|
}
|
|
5115
5122
|
} else {
|
|
5116
|
-
const
|
|
5117
|
-
if (
|
|
5118
|
-
const
|
|
5119
|
-
|
|
5123
|
+
const P = I, N = P.selectionStart || 0, M = P.value || "", D = P.selectionEnd || N;
|
|
5124
|
+
if (D > N) {
|
|
5125
|
+
const F = `{{${y}}}`, { text: z } = T(M, N, F), W = M.slice(0, N) + z + M.slice(D);
|
|
5126
|
+
m(W, {}, o);
|
|
5120
5127
|
return;
|
|
5121
5128
|
}
|
|
5122
|
-
const $ = `{{${
|
|
5123
|
-
|
|
5129
|
+
const $ = `{{${y}}}`, { text: H } = T(M, N, $), U = M.slice(0, N) + H + M.slice(N);
|
|
5130
|
+
m(U, {}, o);
|
|
5124
5131
|
}
|
|
5125
5132
|
},
|
|
5126
|
-
[o,
|
|
5133
|
+
[o, m, g, B == null ? void 0 : B._id]
|
|
5127
5134
|
);
|
|
5128
5135
|
if (d)
|
|
5129
5136
|
return null;
|
|
5130
5137
|
if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
|
|
5131
|
-
const v =
|
|
5138
|
+
const v = j == null ? void 0 : j.includes(o.replace("root.", ""));
|
|
5132
5139
|
if (u.type === "array") {
|
|
5133
|
-
const
|
|
5140
|
+
const y = _ === o;
|
|
5134
5141
|
return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
|
|
5135
5142
|
u.title && /* @__PURE__ */ jsxs(
|
|
5136
5143
|
"label",
|
|
5137
5144
|
{
|
|
5138
5145
|
htmlFor: o,
|
|
5139
|
-
onClick: () => S(
|
|
5146
|
+
onClick: () => S(y ? null : o),
|
|
5140
5147
|
className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
|
|
5141
5148
|
children: [
|
|
5142
|
-
|
|
5149
|
+
y ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
|
|
5143
5150
|
/* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
|
|
5144
5151
|
/* @__PURE__ */ jsx("span", { className: "leading-tight", children: r }),
|
|
5145
5152
|
" ",
|
|
@@ -5147,7 +5154,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5147
5154
|
]
|
|
5148
5155
|
}
|
|
5149
5156
|
),
|
|
5150
|
-
(g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${
|
|
5157
|
+
(g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${y ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
|
|
5151
5158
|
c,
|
|
5152
5159
|
a,
|
|
5153
5160
|
l,
|
|
@@ -5162,11 +5169,11 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5162
5169
|
" ",
|
|
5163
5170
|
v && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
|
|
5164
5171
|
" ",
|
|
5165
|
-
|
|
5172
|
+
k
|
|
5166
5173
|
] }),
|
|
5167
5174
|
p && u.type !== "object" ? " *" : null
|
|
5168
5175
|
] }),
|
|
5169
|
-
u.type === "string" && !u.enum && !u.oneOf && A && /* @__PURE__ */ jsx(NestedPathSelector, { data: A, onSelect:
|
|
5176
|
+
u.type === "string" && !u.enum && !u.oneOf && A && /* @__PURE__ */ jsx(NestedPathSelector, { data: A, onSelect: w, dataType: "value" })
|
|
5170
5177
|
] }),
|
|
5171
5178
|
c,
|
|
5172
5179
|
a,
|
|
@@ -5179,8 +5186,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5179
5186
|
/* @__PURE__ */ jsx("span", { children: "Add" })
|
|
5180
5187
|
] }) }), JSONForm = memo(({ blockId: o, schema: n, uiSchema: r, formData: a, onChange: l }) => {
|
|
5181
5188
|
const { selectedLang: i } = useLanguages(), [c] = useAtom$1(chaiRjsfWidgetsAtom), [d] = useAtom$1(chaiRjsfFieldsAtom), [p] = useAtom$1(chaiRjsfTemplatesAtom), u = useThrottledCallback(
|
|
5182
|
-
async ({ formData: g },
|
|
5183
|
-
l({ formData: g },
|
|
5189
|
+
async ({ formData: g }, m) => {
|
|
5190
|
+
l({ formData: g }, m);
|
|
5184
5191
|
},
|
|
5185
5192
|
[l, i],
|
|
5186
5193
|
400
|
|
@@ -5204,7 +5211,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5204
5211
|
...d
|
|
5205
5212
|
},
|
|
5206
5213
|
templates: {
|
|
5207
|
-
FieldTemplate:
|
|
5214
|
+
FieldTemplate: JSONFormFieldTemplate,
|
|
5208
5215
|
ButtonTemplates: {
|
|
5209
5216
|
AddButton: CustomAddButton
|
|
5210
5217
|
},
|
|
@@ -5219,10 +5226,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5219
5226
|
uiSchema: r,
|
|
5220
5227
|
schema: n,
|
|
5221
5228
|
formData: a,
|
|
5222
|
-
onChange: ({ formData: g },
|
|
5223
|
-
if (!
|
|
5224
|
-
const
|
|
5225
|
-
u({ formData: g },
|
|
5229
|
+
onChange: ({ formData: g }, m) => {
|
|
5230
|
+
if (!m || o !== (g == null ? void 0 : g._id)) return;
|
|
5231
|
+
const x = take(m.split("."), 2).join(".").replace("root.", "");
|
|
5232
|
+
u({ formData: g }, x);
|
|
5226
5233
|
}
|
|
5227
5234
|
},
|
|
5228
5235
|
i
|
|
@@ -5265,35 +5272,35 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
|
|
|
5265
5272
|
}), a;
|
|
5266
5273
|
};
|
|
5267
5274
|
function BlockSettings() {
|
|
5268
|
-
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(),
|
|
5269
|
-
S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(
|
|
5270
|
-
},
|
|
5271
|
-
debounce(({ formData:
|
|
5272
|
-
f({ formData:
|
|
5275
|
+
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), x = formDataWithSelectedLang(g, o, m), f = ({ formData: _ }, S, w) => {
|
|
5276
|
+
S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(_, S) }, w);
|
|
5277
|
+
}, h = useCallback(
|
|
5278
|
+
debounce(({ formData: _ }, S, w) => {
|
|
5279
|
+
f({ formData: _ }, S, w), d(_);
|
|
5273
5280
|
}, 1500),
|
|
5274
5281
|
[n == null ? void 0 : n._id, o]
|
|
5275
|
-
), b = ({ formData:
|
|
5276
|
-
S && (r([n._id], { [S]: get(
|
|
5277
|
-
},
|
|
5278
|
-
S && (r([g._id], { [S]: get(
|
|
5282
|
+
), b = ({ formData: _ }, S) => {
|
|
5283
|
+
S && (r([n._id], { [S]: get(_, S) }), h({ formData: _ }, S, { [S]: get(c, S) }));
|
|
5284
|
+
}, k = ({ formData: _ }, S) => {
|
|
5285
|
+
S && (r([g._id], { [S]: get(_, S) }), h({ formData: _ }, S, { [S]: get(c, S) }));
|
|
5279
5286
|
};
|
|
5280
5287
|
keys(get(i, "_bindings", {}));
|
|
5281
|
-
const { schema: A, uiSchema:
|
|
5282
|
-
const
|
|
5283
|
-
if (
|
|
5284
|
-
return getBlockFormSchemas(
|
|
5285
|
-
}, [n]), { wrapperSchema:
|
|
5288
|
+
const { schema: A, uiSchema: B } = useMemo(() => {
|
|
5289
|
+
const _ = n == null ? void 0 : n._type;
|
|
5290
|
+
if (_)
|
|
5291
|
+
return getBlockFormSchemas(_);
|
|
5292
|
+
}, [n]), { wrapperSchema: C, wrapperUiSchema: j } = useMemo(() => {
|
|
5286
5293
|
if (!g || !(g != null && g._type))
|
|
5287
5294
|
return { wrapperSchema: {}, wrapperUiSchema: {} };
|
|
5288
|
-
const
|
|
5289
|
-
return { wrapperSchema: S, wrapperUiSchema:
|
|
5295
|
+
const _ = g == null ? void 0 : g._type, { schema: S = {}, uiSchema: w = {} } = getBlockFormSchemas(_);
|
|
5296
|
+
return { wrapperSchema: S, wrapperUiSchema: w };
|
|
5290
5297
|
}, [g]);
|
|
5291
5298
|
return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
|
|
5292
5299
|
!isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
|
|
5293
5300
|
/* @__PURE__ */ jsxs(
|
|
5294
5301
|
"div",
|
|
5295
5302
|
{
|
|
5296
|
-
onClick: () => u((
|
|
5303
|
+
onClick: () => u((_) => !_),
|
|
5297
5304
|
className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
|
|
5298
5305
|
children: [
|
|
5299
5306
|
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" }),
|
|
@@ -5312,10 +5319,10 @@ function BlockSettings() {
|
|
|
5312
5319
|
JSONForm,
|
|
5313
5320
|
{
|
|
5314
5321
|
blockId: g == null ? void 0 : g._id,
|
|
5315
|
-
onChange:
|
|
5316
|
-
formData:
|
|
5317
|
-
schema:
|
|
5318
|
-
uiSchema:
|
|
5322
|
+
onChange: k,
|
|
5323
|
+
formData: x,
|
|
5324
|
+
schema: C,
|
|
5325
|
+
uiSchema: j
|
|
5319
5326
|
}
|
|
5320
5327
|
) })
|
|
5321
5328
|
] }),
|
|
@@ -5326,7 +5333,7 @@ function BlockSettings() {
|
|
|
5326
5333
|
onChange: b,
|
|
5327
5334
|
formData: i,
|
|
5328
5335
|
schema: A,
|
|
5329
|
-
uiSchema:
|
|
5336
|
+
uiSchema: B
|
|
5330
5337
|
}
|
|
5331
5338
|
),
|
|
5332
5339
|
(n == null ? void 0 : n._type) === "GlobalBlock" ? /* @__PURE__ */ jsx(GlobalBlockSettings, {}) : null
|
|
@@ -5431,32 +5438,32 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5431
5438
|
canvas: n = !1,
|
|
5432
5439
|
tooltip: r = !0
|
|
5433
5440
|
}) => {
|
|
5434
|
-
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t:
|
|
5435
|
-
u.includes(
|
|
5436
|
-
},
|
|
5437
|
-
n || l(
|
|
5441
|
+
const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), x = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (k) => {
|
|
5442
|
+
u.includes(k) ? u.length > 2 && g(u.filter((A) => A !== k)) : g((A) => [...A, k]);
|
|
5443
|
+
}, h = (k) => {
|
|
5444
|
+
n || l(k), c(k);
|
|
5438
5445
|
}, b = getBreakpointValue(n ? i : a).toLowerCase();
|
|
5439
|
-
return
|
|
5446
|
+
return x.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(x, (k) => /* @__PURE__ */ createElement(
|
|
5440
5447
|
BreakpointCard,
|
|
5441
5448
|
{
|
|
5442
5449
|
canvas: n,
|
|
5443
|
-
...
|
|
5444
|
-
onClick:
|
|
5445
|
-
key:
|
|
5450
|
+
...k,
|
|
5451
|
+
onClick: h,
|
|
5452
|
+
key: k.breakpoint,
|
|
5446
5453
|
currentBreakpoint: b
|
|
5447
5454
|
}
|
|
5448
5455
|
)) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
|
|
5449
5456
|
/* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
|
|
5450
|
-
|
|
5451
|
-
(
|
|
5457
|
+
x.filter((k) => includes(u, toUpper(k.breakpoint))),
|
|
5458
|
+
(k) => /* @__PURE__ */ createElement(
|
|
5452
5459
|
BreakpointCard,
|
|
5453
5460
|
{
|
|
5454
5461
|
canvas: n,
|
|
5455
5462
|
openDelay: o,
|
|
5456
5463
|
tooltip: r,
|
|
5457
|
-
...
|
|
5458
|
-
onClick:
|
|
5459
|
-
key:
|
|
5464
|
+
...k,
|
|
5465
|
+
onClick: h,
|
|
5466
|
+
key: k.breakpoint,
|
|
5460
5467
|
currentBreakpoint: b
|
|
5461
5468
|
}
|
|
5462
5469
|
)
|
|
@@ -5464,17 +5471,17 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
|
|
|
5464
5471
|
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
5465
5472
|
/* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-pointer px-2.5 hover:opacity-80", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "scale-90 transform" }) }) }),
|
|
5466
5473
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
|
|
5467
|
-
/* @__PURE__ */ jsx(DropdownMenuLabel, { children:
|
|
5474
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: m("Screen sizes") }),
|
|
5468
5475
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
5469
|
-
map(
|
|
5476
|
+
map(x, (k) => /* @__PURE__ */ jsx(
|
|
5470
5477
|
DropdownMenuCheckboxItem,
|
|
5471
5478
|
{
|
|
5472
|
-
disabled:
|
|
5473
|
-
onCheckedChange: () => f(toUpper(
|
|
5474
|
-
checked: includes(u, toUpper(
|
|
5475
|
-
children:
|
|
5479
|
+
disabled: k.breakpoint === "xs",
|
|
5480
|
+
onCheckedChange: () => f(toUpper(k.breakpoint)),
|
|
5481
|
+
checked: includes(u, toUpper(k.breakpoint)),
|
|
5482
|
+
children: m(k.title)
|
|
5476
5483
|
},
|
|
5477
|
-
|
|
5484
|
+
k.breakpoint
|
|
5478
5485
|
))
|
|
5479
5486
|
] })
|
|
5480
5487
|
] })
|
|
@@ -5551,11 +5558,11 @@ function Countdown() {
|
|
|
5551
5558
|
const AskAIStyles = ({ blockId: o }) => {
|
|
5552
5559
|
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
|
|
5553
5560
|
useEffect(() => {
|
|
5554
|
-
var
|
|
5555
|
-
(
|
|
5561
|
+
var x;
|
|
5562
|
+
(x = d.current) == null || x.focus();
|
|
5556
5563
|
}, []);
|
|
5557
|
-
const
|
|
5558
|
-
const { usage: f } =
|
|
5564
|
+
const m = (x) => {
|
|
5565
|
+
const { usage: f } = x || {};
|
|
5559
5566
|
!l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
5560
5567
|
};
|
|
5561
5568
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
@@ -5565,12 +5572,12 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5565
5572
|
{
|
|
5566
5573
|
ref: d,
|
|
5567
5574
|
value: i,
|
|
5568
|
-
onChange: (
|
|
5575
|
+
onChange: (x) => c(x.target.value),
|
|
5569
5576
|
placeholder: n("Ask AI to edit styles"),
|
|
5570
5577
|
className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
|
|
5571
5578
|
rows: 4,
|
|
5572
|
-
onKeyDown: (
|
|
5573
|
-
|
|
5579
|
+
onKeyDown: (x) => {
|
|
5580
|
+
x.key === "Enter" && (x.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
|
|
5574
5581
|
}
|
|
5575
5582
|
}
|
|
5576
5583
|
),
|
|
@@ -5580,7 +5587,7 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5580
5587
|
{
|
|
5581
5588
|
disabled: i.trim().length < 5 || a,
|
|
5582
5589
|
onClick: () => {
|
|
5583
|
-
p.current && clearTimeout(p.current), g(void 0), r("styles", o, i,
|
|
5590
|
+
p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m);
|
|
5584
5591
|
},
|
|
5585
5592
|
variant: "default",
|
|
5586
5593
|
className: "w-fit",
|
|
@@ -5612,24 +5619,24 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5612
5619
|
};
|
|
5613
5620
|
function ManualClasses() {
|
|
5614
5621
|
var T;
|
|
5615
|
-
const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [
|
|
5622
|
+
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(), x = useBuilderProp("askAiCallBack", null), [f, h] = useState(""), b = (T = first(d)) == null ? void 0 : T.prop, { classes: k } = getSplitChaiClasses(get(p, b, "")), A = k.split(" ").filter((I) => !isEmpty(I)), B = () => {
|
|
5616
5623
|
const I = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5617
|
-
u(
|
|
5618
|
-
}, [
|
|
5619
|
-
const
|
|
5620
|
-
let
|
|
5621
|
-
if (
|
|
5622
|
-
const [M] =
|
|
5623
|
-
|
|
5624
|
+
u(m, I, !0), h("");
|
|
5625
|
+
}, [C, j] = useState([]), _ = ({ value: I }) => {
|
|
5626
|
+
const R = I.trim().toLowerCase(), P = R.match(/.+:/g);
|
|
5627
|
+
let N = [];
|
|
5628
|
+
if (P && P.length > 0) {
|
|
5629
|
+
const [M] = P, D = R.replace(M, "");
|
|
5630
|
+
N = i.search(D).map(($) => ({
|
|
5624
5631
|
...$,
|
|
5625
5632
|
item: { ...$.item, name: M + $.item.name }
|
|
5626
5633
|
}));
|
|
5627
5634
|
} else
|
|
5628
|
-
|
|
5629
|
-
return
|
|
5635
|
+
N = i.search(R);
|
|
5636
|
+
return j(map(N, "item"));
|
|
5630
5637
|
}, S = () => {
|
|
5631
|
-
|
|
5632
|
-
},
|
|
5638
|
+
j([]);
|
|
5639
|
+
}, w = (I) => I.name, L = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), v = useMemo(
|
|
5633
5640
|
() => ({
|
|
5634
5641
|
ref: o,
|
|
5635
5642
|
autoComplete: "off",
|
|
@@ -5639,17 +5646,17 @@ function ManualClasses() {
|
|
|
5639
5646
|
placeholder: c("Enter classes separated by space"),
|
|
5640
5647
|
value: f,
|
|
5641
5648
|
onKeyDown: (I) => {
|
|
5642
|
-
I.key === "Enter" && f.trim() !== "" &&
|
|
5649
|
+
I.key === "Enter" && f.trim() !== "" && B();
|
|
5643
5650
|
},
|
|
5644
|
-
onChange: (I, { newValue:
|
|
5651
|
+
onChange: (I, { newValue: R }) => h(R),
|
|
5645
5652
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
5646
5653
|
}),
|
|
5647
5654
|
[f, c, o]
|
|
5648
|
-
),
|
|
5655
|
+
), y = (I) => {
|
|
5649
5656
|
debugger;
|
|
5650
|
-
const
|
|
5651
|
-
g(
|
|
5652
|
-
},
|
|
5657
|
+
const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5658
|
+
g(m, [I]), u(m, R, !0), r(""), l(-1);
|
|
5659
|
+
}, E = () => {
|
|
5653
5660
|
if (navigator.clipboard === void 0) {
|
|
5654
5661
|
toast.error(c("Clipboard not supported"));
|
|
5655
5662
|
return;
|
|
@@ -5661,11 +5668,11 @@ function ManualClasses() {
|
|
|
5661
5668
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
|
|
5662
5669
|
/* @__PURE__ */ jsx("span", { children: c("Classes") }),
|
|
5663
5670
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5664
|
-
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick:
|
|
5671
|
+
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: E, className: "cursor-pointer" }) }),
|
|
5665
5672
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
|
|
5666
5673
|
] })
|
|
5667
5674
|
] }),
|
|
5668
|
-
|
|
5675
|
+
x ? /* @__PURE__ */ jsxs(Popover, { children: [
|
|
5669
5676
|
/* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
|
|
5670
5677
|
/* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4" }),
|
|
5671
5678
|
/* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
|
|
@@ -5677,10 +5684,10 @@ function ManualClasses() {
|
|
|
5677
5684
|
/* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
|
|
5678
5685
|
Autosuggest,
|
|
5679
5686
|
{
|
|
5680
|
-
suggestions:
|
|
5681
|
-
onSuggestionsFetchRequested:
|
|
5687
|
+
suggestions: C,
|
|
5688
|
+
onSuggestionsFetchRequested: _,
|
|
5682
5689
|
onSuggestionsClearRequested: S,
|
|
5683
|
-
getSuggestionValue:
|
|
5690
|
+
getSuggestionValue: w,
|
|
5684
5691
|
renderSuggestion: L,
|
|
5685
5692
|
inputProps: v,
|
|
5686
5693
|
containerProps: {
|
|
@@ -5698,7 +5705,7 @@ function ManualClasses() {
|
|
|
5698
5705
|
{
|
|
5699
5706
|
variant: "outline",
|
|
5700
5707
|
className: "h-6 border-border",
|
|
5701
|
-
onClick:
|
|
5708
|
+
onClick: B,
|
|
5702
5709
|
disabled: f.trim() === "",
|
|
5703
5710
|
size: "sm",
|
|
5704
5711
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
@@ -5706,17 +5713,17 @@ function ManualClasses() {
|
|
|
5706
5713
|
)
|
|
5707
5714
|
] }),
|
|
5708
5715
|
/* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: A.map(
|
|
5709
|
-
(I,
|
|
5716
|
+
(I, R) => a === R ? /* @__PURE__ */ jsx(
|
|
5710
5717
|
"input",
|
|
5711
5718
|
{
|
|
5712
5719
|
ref: o,
|
|
5713
5720
|
value: n,
|
|
5714
|
-
onChange: (
|
|
5721
|
+
onChange: (P) => r(P.target.value),
|
|
5715
5722
|
onBlur: () => {
|
|
5716
|
-
|
|
5723
|
+
y(I);
|
|
5717
5724
|
},
|
|
5718
|
-
onKeyDown: (
|
|
5719
|
-
|
|
5725
|
+
onKeyDown: (P) => {
|
|
5726
|
+
P.key === "Enter" && y(I);
|
|
5720
5727
|
},
|
|
5721
5728
|
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"
|
|
5722
5729
|
},
|
|
@@ -5730,7 +5737,7 @@ function ManualClasses() {
|
|
|
5730
5737
|
n !== I && /* @__PURE__ */ jsx(
|
|
5731
5738
|
Cross2Icon,
|
|
5732
5739
|
{
|
|
5733
|
-
onClick: () => g(
|
|
5740
|
+
onClick: () => g(m, [I], !0),
|
|
5734
5741
|
className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
|
|
5735
5742
|
}
|
|
5736
5743
|
)
|
|
@@ -6076,10 +6083,10 @@ const COLOR_PROP = {
|
|
|
6076
6083
|
ringColor: "ring",
|
|
6077
6084
|
ringOffsetColor: "ring-offset"
|
|
6078
6085
|
}, ColorChoice = ({ property: o, onChange: n }) => {
|
|
6079
|
-
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", ""),
|
|
6086
|
+
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", ""), x = useCallback(
|
|
6080
6087
|
// eslint-disable-next-line no-shadow
|
|
6081
6088
|
(b) => {
|
|
6082
|
-
["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((
|
|
6089
|
+
["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((k) => ({ ...k, color: b, shade: k.shade ? k.shade : "500" })));
|
|
6083
6090
|
},
|
|
6084
6091
|
[c, p]
|
|
6085
6092
|
);
|
|
@@ -6098,18 +6105,18 @@ const COLOR_PROP = {
|
|
|
6098
6105
|
useEffect(() => {
|
|
6099
6106
|
p({ color: "", shade: "" });
|
|
6100
6107
|
}, [r]);
|
|
6101
|
-
const { match:
|
|
6108
|
+
const { match: h } = useTailwindClassList();
|
|
6102
6109
|
return useEffect(() => {
|
|
6103
|
-
const
|
|
6104
|
-
|
|
6105
|
-
}, [
|
|
6110
|
+
const k = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
|
|
6111
|
+
h(o, k) && n(k, o);
|
|
6112
|
+
}, [h, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
|
|
6106
6113
|
/* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
|
|
6107
6114
|
DropDown,
|
|
6108
6115
|
{
|
|
6109
6116
|
disabled: !l,
|
|
6110
6117
|
rounded: !0,
|
|
6111
6118
|
selected: g,
|
|
6112
|
-
onChange:
|
|
6119
|
+
onChange: x,
|
|
6113
6120
|
options: [
|
|
6114
6121
|
"current",
|
|
6115
6122
|
"transparent",
|
|
@@ -6142,7 +6149,7 @@ const COLOR_PROP = {
|
|
|
6142
6149
|
]
|
|
6143
6150
|
}
|
|
6144
6151
|
) }),
|
|
6145
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected:
|
|
6152
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: f, options: i }) })
|
|
6146
6153
|
] });
|
|
6147
6154
|
}, IconChoices = ({ property: o, onChange: n }) => {
|
|
6148
6155
|
const { getClasses: r } = useTailwindClassList(), a = r(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
|
|
@@ -6339,52 +6346,52 @@ const COLOR_PROP = {
|
|
|
6339
6346
|
},
|
|
6340
6347
|
a
|
|
6341
6348
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
6342
|
-
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [
|
|
6349
|
+
const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, x] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, h] = useState(!1), [b, k] = useState(""), [A, B] = useState(!1), [C, j] = useState(!1);
|
|
6343
6350
|
useEffect(() => {
|
|
6344
|
-
const { value: v, unit:
|
|
6345
|
-
if (
|
|
6346
|
-
l(v),
|
|
6351
|
+
const { value: v, unit: y } = getClassValueAndUnit(i);
|
|
6352
|
+
if (y === "") {
|
|
6353
|
+
l(v), x(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
|
|
6347
6354
|
return;
|
|
6348
6355
|
}
|
|
6349
|
-
|
|
6356
|
+
x(y), l(y === "class" || isEmpty(v) ? "" : v);
|
|
6350
6357
|
}, [i, p, u]);
|
|
6351
|
-
const
|
|
6358
|
+
const _ = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), S = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), w = useCallback(
|
|
6352
6359
|
(v = !1) => {
|
|
6353
|
-
const
|
|
6354
|
-
if (get(
|
|
6355
|
-
|
|
6360
|
+
const y = getUserInputValues(`${a}`, u);
|
|
6361
|
+
if (get(y, "error", !1)) {
|
|
6362
|
+
h(!0);
|
|
6356
6363
|
return;
|
|
6357
6364
|
}
|
|
6358
|
-
const
|
|
6359
|
-
if (
|
|
6360
|
-
|
|
6365
|
+
const E = get(y, "unit") !== "" ? get(y, "unit") : m;
|
|
6366
|
+
if (E === "auto" || E === "none") {
|
|
6367
|
+
_(`${d}${E}`);
|
|
6361
6368
|
return;
|
|
6362
6369
|
}
|
|
6363
|
-
if (get(
|
|
6370
|
+
if (get(y, "value") === "")
|
|
6364
6371
|
return;
|
|
6365
|
-
const I = `${get(
|
|
6366
|
-
v ? S(I) :
|
|
6372
|
+
const I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
|
|
6373
|
+
v ? S(I) : _(I);
|
|
6367
6374
|
},
|
|
6368
|
-
[
|
|
6375
|
+
[_, S, a, m, d, u]
|
|
6369
6376
|
), L = useCallback(
|
|
6370
6377
|
(v) => {
|
|
6371
|
-
const
|
|
6372
|
-
if (get(
|
|
6373
|
-
|
|
6378
|
+
const y = getUserInputValues(`${a}`, u);
|
|
6379
|
+
if (get(y, "error", !1)) {
|
|
6380
|
+
h(!0);
|
|
6374
6381
|
return;
|
|
6375
6382
|
}
|
|
6376
6383
|
if (v === "auto" || v === "none") {
|
|
6377
|
-
|
|
6384
|
+
_(`${d}${v}`);
|
|
6378
6385
|
return;
|
|
6379
6386
|
}
|
|
6380
|
-
if (get(
|
|
6387
|
+
if (get(y, "value") === "")
|
|
6381
6388
|
return;
|
|
6382
|
-
const
|
|
6383
|
-
|
|
6389
|
+
const E = get(y, "unit") !== "" ? get(y, "unit") : v, I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
|
|
6390
|
+
_(I);
|
|
6384
6391
|
},
|
|
6385
|
-
[
|
|
6392
|
+
[_, a, d, u]
|
|
6386
6393
|
);
|
|
6387
|
-
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children:
|
|
6394
|
+
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: [
|
|
6388
6395
|
/* @__PURE__ */ jsx(
|
|
6389
6396
|
"input",
|
|
6390
6397
|
{
|
|
@@ -6399,33 +6406,33 @@ const COLOR_PROP = {
|
|
|
6399
6406
|
] })
|
|
6400
6407
|
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${A ? "z-auto" : ""}`, children: [
|
|
6401
6408
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
6402
|
-
["none", "auto"].indexOf(
|
|
6409
|
+
["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
|
|
6403
6410
|
"input",
|
|
6404
6411
|
{
|
|
6405
|
-
readOnly:
|
|
6412
|
+
readOnly: m === "class",
|
|
6406
6413
|
onKeyPress: (v) => {
|
|
6407
|
-
v.key === "Enter" &&
|
|
6414
|
+
v.key === "Enter" && w();
|
|
6408
6415
|
},
|
|
6409
6416
|
onKeyDown: (v) => {
|
|
6410
6417
|
if (v.keyCode !== 38 && v.keyCode !== 40)
|
|
6411
6418
|
return;
|
|
6412
|
-
v.preventDefault(),
|
|
6413
|
-
const
|
|
6414
|
-
let
|
|
6415
|
-
v.keyCode === 38 && (
|
|
6416
|
-
const T = `${
|
|
6417
|
-
S(
|
|
6419
|
+
v.preventDefault(), j(!0);
|
|
6420
|
+
const y = parseInt$1(v.target.value);
|
|
6421
|
+
let E = isNaN$1(y) ? 0 : y;
|
|
6422
|
+
v.keyCode === 38 && (E += 1), v.keyCode === 40 && (E -= 1);
|
|
6423
|
+
const T = `${E}`, R = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6424
|
+
S(R);
|
|
6418
6425
|
},
|
|
6419
6426
|
onKeyUp: (v) => {
|
|
6420
|
-
|
|
6427
|
+
C && (v.preventDefault(), j(!1));
|
|
6421
6428
|
},
|
|
6422
|
-
onBlur: () =>
|
|
6429
|
+
onBlur: () => w(),
|
|
6423
6430
|
onChange: (v) => {
|
|
6424
|
-
|
|
6431
|
+
h(!1), l(v.target.value);
|
|
6425
6432
|
},
|
|
6426
6433
|
onClick: (v) => {
|
|
6427
|
-
var
|
|
6428
|
-
(
|
|
6434
|
+
var y;
|
|
6435
|
+
(y = v == null ? void 0 : v.target) == null || y.select(), r(!1);
|
|
6429
6436
|
},
|
|
6430
6437
|
value: A ? b : a,
|
|
6431
6438
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
@@ -6442,7 +6449,7 @@ const COLOR_PROP = {
|
|
|
6442
6449
|
onClick: () => r(!n),
|
|
6443
6450
|
className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
|
|
6444
6451
|
children: [
|
|
6445
|
-
/* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children:
|
|
6452
|
+
/* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: m }),
|
|
6446
6453
|
u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
|
|
6447
6454
|
]
|
|
6448
6455
|
}
|
|
@@ -6451,33 +6458,33 @@ const COLOR_PROP = {
|
|
|
6451
6458
|
UnitSelection,
|
|
6452
6459
|
{
|
|
6453
6460
|
units: u,
|
|
6454
|
-
current:
|
|
6461
|
+
current: m,
|
|
6455
6462
|
onSelect: (v) => {
|
|
6456
|
-
r(!1),
|
|
6463
|
+
r(!1), x(v), L(v);
|
|
6457
6464
|
}
|
|
6458
6465
|
}
|
|
6459
6466
|
) }) })
|
|
6460
6467
|
] })
|
|
6461
6468
|
] }),
|
|
6462
|
-
["none", "auto"].indexOf(
|
|
6469
|
+
["none", "auto"].indexOf(m) !== -1 || A ? null : /* @__PURE__ */ jsx(
|
|
6463
6470
|
DragStyleButton,
|
|
6464
6471
|
{
|
|
6465
|
-
onDragStart: () =>
|
|
6472
|
+
onDragStart: () => B(!0),
|
|
6466
6473
|
onDragEnd: (v) => {
|
|
6467
|
-
if (
|
|
6474
|
+
if (k(() => ""), B(!1), isEmpty(v))
|
|
6468
6475
|
return;
|
|
6469
|
-
const
|
|
6470
|
-
|
|
6476
|
+
const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6477
|
+
_(T);
|
|
6471
6478
|
},
|
|
6472
6479
|
onDrag: (v) => {
|
|
6473
6480
|
if (isEmpty(v))
|
|
6474
6481
|
return;
|
|
6475
|
-
|
|
6476
|
-
const
|
|
6482
|
+
k(v);
|
|
6483
|
+
const y = `${v}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
|
|
6477
6484
|
S(T);
|
|
6478
6485
|
},
|
|
6479
6486
|
currentValue: a,
|
|
6480
|
-
unit:
|
|
6487
|
+
unit: m,
|
|
6481
6488
|
negative: g,
|
|
6482
6489
|
cssProperty: p
|
|
6483
6490
|
}
|
|
@@ -6571,23 +6578,23 @@ const COLOR_PROP = {
|
|
|
6571
6578
|
"2xl": "1536px"
|
|
6572
6579
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
6573
6580
|
const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
6574
|
-
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(),
|
|
6575
|
-
(S,
|
|
6581
|
+
}, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), x = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), k = useCallback(
|
|
6582
|
+
(S, w = !0) => {
|
|
6576
6583
|
const L = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
|
|
6577
6584
|
(p || u !== "") && (L.mq = "xs");
|
|
6578
6585
|
const v = generateFullClsName(L);
|
|
6579
|
-
|
|
6586
|
+
x(h, [v], w);
|
|
6580
6587
|
},
|
|
6581
|
-
[
|
|
6588
|
+
[h, p, g, u, l, x]
|
|
6582
6589
|
), A = useCallback(() => {
|
|
6583
|
-
f(
|
|
6584
|
-
}, [
|
|
6590
|
+
f(h, [b], !0);
|
|
6591
|
+
}, [h, b, f]), B = useMemo(() => canChangeClass(m, g), [m, g]);
|
|
6585
6592
|
useEffect(() => {
|
|
6586
|
-
i(
|
|
6587
|
-
}, [
|
|
6588
|
-
const [, ,
|
|
6593
|
+
i(B, m);
|
|
6594
|
+
}, [B, i, m]);
|
|
6595
|
+
const [, , C] = useScreenSizeWidth(), j = useCallback(
|
|
6589
6596
|
(S) => {
|
|
6590
|
-
|
|
6597
|
+
C({
|
|
6591
6598
|
xs: 400,
|
|
6592
6599
|
sm: 640,
|
|
6593
6600
|
md: 800,
|
|
@@ -6596,29 +6603,29 @@ const COLOR_PROP = {
|
|
|
6596
6603
|
"2xl": 1920
|
|
6597
6604
|
}[S]);
|
|
6598
6605
|
},
|
|
6599
|
-
[
|
|
6600
|
-
),
|
|
6601
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange:
|
|
6602
|
-
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${
|
|
6606
|
+
[C]
|
|
6607
|
+
), _ = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
|
|
6608
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: m && _, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
6609
|
+
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !_ ? "text-foreground" : ""}`, children: n(a) }) }),
|
|
6603
6610
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
6604
6611
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
6605
6612
|
r === "arbitrary" ? /* @__PURE__ */ jsx(
|
|
6606
6613
|
AdvanceChoices,
|
|
6607
6614
|
{
|
|
6608
|
-
currentClass: get(
|
|
6615
|
+
currentClass: get(m, "cls", ""),
|
|
6609
6616
|
classPrefix: get(CLASS_PREFIXES, l, ""),
|
|
6610
6617
|
units: c || [],
|
|
6611
|
-
onChange:
|
|
6618
|
+
onChange: k,
|
|
6612
6619
|
negative: d,
|
|
6613
6620
|
cssProperty: l
|
|
6614
6621
|
}
|
|
6615
6622
|
) : null,
|
|
6616
|
-
r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange:
|
|
6617
|
-
r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange:
|
|
6618
|
-
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange:
|
|
6619
|
-
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange:
|
|
6623
|
+
r === "icons" && /* @__PURE__ */ jsx(IconChoices, { property: l, onChange: k }),
|
|
6624
|
+
r === "range" && /* @__PURE__ */ jsx(RangeChoices, { property: l, onChange: k }),
|
|
6625
|
+
r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: k }),
|
|
6626
|
+
r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: k })
|
|
6620
6627
|
] }),
|
|
6621
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children:
|
|
6628
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: _ ? /* @__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" }) }) : B && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
6622
6629
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
6623
6630
|
"button",
|
|
6624
6631
|
{
|
|
@@ -6630,19 +6637,19 @@ const COLOR_PROP = {
|
|
|
6630
6637
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
6631
6638
|
"Current style is set at ",
|
|
6632
6639
|
/* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
|
|
6633
|
-
getBreakpoint(get(
|
|
6634
|
-
p && !
|
|
6640
|
+
getBreakpoint(get(m, "mq")),
|
|
6641
|
+
p && !m.dark ? "(Light mode)" : ""
|
|
6635
6642
|
] }),
|
|
6636
6643
|
/* @__PURE__ */ jsx("br", {}),
|
|
6637
6644
|
/* @__PURE__ */ jsxs(
|
|
6638
6645
|
"button",
|
|
6639
6646
|
{
|
|
6640
6647
|
type: "button",
|
|
6641
|
-
onClick: () =>
|
|
6648
|
+
onClick: () => j(get(m, "mq")),
|
|
6642
6649
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
6643
6650
|
children: [
|
|
6644
6651
|
"Switch to ",
|
|
6645
|
-
get(
|
|
6652
|
+
get(m, "mq").toUpperCase()
|
|
6646
6653
|
]
|
|
6647
6654
|
}
|
|
6648
6655
|
)
|
|
@@ -6659,7 +6666,7 @@ const COLOR_PROP = {
|
|
|
6659
6666
|
units: i = basicUnits,
|
|
6660
6667
|
negative: c = !1
|
|
6661
6668
|
}) => {
|
|
6662
|
-
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(),
|
|
6669
|
+
const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((x) => map(g, "property").includes(x), [g]);
|
|
6663
6670
|
return /* @__PURE__ */ jsxs(
|
|
6664
6671
|
"div",
|
|
6665
6672
|
{
|
|
@@ -6668,7 +6675,7 @@ const COLOR_PROP = {
|
|
|
6668
6675
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
6669
6676
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
|
|
6670
6677
|
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
|
|
6671
|
-
n.map(({ label:
|
|
6678
|
+
n.map(({ label: x, key: f }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6672
6679
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6673
6680
|
"button",
|
|
6674
6681
|
{
|
|
@@ -6677,13 +6684,13 @@ const COLOR_PROP = {
|
|
|
6677
6684
|
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
6678
6685
|
children: [
|
|
6679
6686
|
React__default.createElement("div", {
|
|
6680
|
-
className:
|
|
6687
|
+
className: m(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
6681
6688
|
}),
|
|
6682
6689
|
React__default.createElement(get(EDITOR_ICONS, f, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
6683
6690
|
]
|
|
6684
6691
|
}
|
|
6685
6692
|
) }),
|
|
6686
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(
|
|
6693
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(x)) })
|
|
6687
6694
|
] }) }))
|
|
6688
6695
|
) })
|
|
6689
6696
|
] }),
|
|
@@ -6822,13 +6829,13 @@ function BlockStyling() {
|
|
|
6822
6829
|
cssProperty: ""
|
|
6823
6830
|
}), d = useThrottledCallback(
|
|
6824
6831
|
(u) => {
|
|
6825
|
-
const g = !get(i, "negative", !1),
|
|
6826
|
-
let
|
|
6827
|
-
|
|
6832
|
+
const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
|
|
6833
|
+
let x = parseFloat(i.dragStartValue);
|
|
6834
|
+
x = isNaN(x) ? 0 : x;
|
|
6828
6835
|
let f = MAPPER[i.dragUnit];
|
|
6829
|
-
(startsWith(
|
|
6830
|
-
let b = (i.dragStartY - u.pageY) / f +
|
|
6831
|
-
g && b < 0 && (b = 0),
|
|
6836
|
+
(startsWith(m, "scale") || m === "opacity") && (f = 10);
|
|
6837
|
+
let b = (i.dragStartY - u.pageY) / f + x;
|
|
6838
|
+
g && b < 0 && (b = 0), m === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
|
|
6832
6839
|
},
|
|
6833
6840
|
[i],
|
|
6834
6841
|
50
|
|
@@ -6864,41 +6871,45 @@ function BlockStyling() {
|
|
|
6864
6871
|
] })
|
|
6865
6872
|
] });
|
|
6866
6873
|
}
|
|
6867
|
-
const
|
|
6874
|
+
const CHAI_BUILDER_EVENTS = {
|
|
6875
|
+
OPEN_ADD_BLOCK: "OPEN_ADD_BLOCK",
|
|
6876
|
+
CLOSE_ADD_BLOCK: "CLOSE_ADD_BLOCK",
|
|
6877
|
+
SHOW_BLOCK_SETTINGS: "SHOW_BLOCK_SETTINGS"
|
|
6878
|
+
}, CoreBlock = ({
|
|
6868
6879
|
block: o,
|
|
6869
6880
|
disabled: n,
|
|
6870
6881
|
parentId: r,
|
|
6871
6882
|
position: a
|
|
6872
6883
|
}) => {
|
|
6873
|
-
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight:
|
|
6884
|
+
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), x = () => {
|
|
6874
6885
|
if (console.log("addBlockToPage", o), has(o, "blocks")) {
|
|
6875
6886
|
const b = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
|
|
6876
6887
|
u(syncBlocksWithDefaults(b), r || null, a);
|
|
6877
6888
|
} else
|
|
6878
6889
|
p(o, r || null, a);
|
|
6879
6890
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6880
|
-
}, f = useFeature("dnd"), { t:
|
|
6891
|
+
}, f = useFeature("dnd"), { t: h } = useTranslation();
|
|
6881
6892
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6882
6893
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6883
6894
|
"button",
|
|
6884
6895
|
{
|
|
6885
6896
|
disabled: n,
|
|
6886
|
-
onClick:
|
|
6897
|
+
onClick: x,
|
|
6887
6898
|
type: "button",
|
|
6888
6899
|
onDragStart: (b) => {
|
|
6889
6900
|
b.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), b.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
6890
|
-
g([]),
|
|
6901
|
+
g([]), m();
|
|
6891
6902
|
}, 200);
|
|
6892
6903
|
},
|
|
6893
6904
|
draggable: f ? "true" : "false",
|
|
6894
6905
|
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",
|
|
6895
6906
|
children: [
|
|
6896
6907
|
createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
6897
|
-
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(
|
|
6908
|
+
/* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(h(d || i)) })
|
|
6898
6909
|
]
|
|
6899
6910
|
}
|
|
6900
6911
|
) }),
|
|
6901
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
6912
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: h(d || i) }) })
|
|
6902
6913
|
] }) });
|
|
6903
6914
|
}, DefaultChaiBlocks = ({
|
|
6904
6915
|
parentId: o,
|
|
@@ -7086,22 +7097,22 @@ const CoreBlock = ({
|
|
|
7086
7097
|
}
|
|
7087
7098
|
}
|
|
7088
7099
|
}, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
|
|
7089
|
-
var
|
|
7100
|
+
var m, x, f, h, b, k, A, B;
|
|
7090
7101
|
if (r.type === "comment") return [];
|
|
7091
7102
|
console.log("node ===>", r);
|
|
7092
7103
|
let a = { _id: generateUUID() };
|
|
7093
7104
|
if (n && (a._parent = n.block._id), r.type === "text")
|
|
7094
7105
|
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", "") };
|
|
7095
7106
|
const l = get(r, "attributes", []), i = l.find(
|
|
7096
|
-
(
|
|
7107
|
+
(C) => C.key === "data-chai-richtext" || C.key === "chai-richtext"
|
|
7097
7108
|
), c = l.find(
|
|
7098
|
-
(
|
|
7109
|
+
(C) => C.key === "data-chai-lightbox" || C.key === "chai-lightbox"
|
|
7099
7110
|
), d = l.find(
|
|
7100
|
-
(
|
|
7111
|
+
(C) => C.key === "data-chai-dropdown" || C.key === "chai-dropdown"
|
|
7101
7112
|
), p = l.find(
|
|
7102
|
-
(
|
|
7113
|
+
(C) => C.key === "data-chai-dropdown-button" || C.key === "chai-dropdown-button"
|
|
7103
7114
|
), u = l.find(
|
|
7104
|
-
(
|
|
7115
|
+
(C) => C.key === "data-chai-dropdown-content" || C.key === "chai-dropdown-content"
|
|
7105
7116
|
);
|
|
7106
7117
|
if (a = {
|
|
7107
7118
|
...a,
|
|
@@ -7109,13 +7120,13 @@ const CoreBlock = ({
|
|
|
7109
7120
|
...getAttrs(r),
|
|
7110
7121
|
...getStyles(r)
|
|
7111
7122
|
}, r.attributes) {
|
|
7112
|
-
const
|
|
7113
|
-
|
|
7123
|
+
const C = r.attributes.find((j) => includes(NAME_ATTRIBUTES, j.key));
|
|
7124
|
+
C && (a._name = C.value);
|
|
7114
7125
|
}
|
|
7115
7126
|
if (i)
|
|
7116
7127
|
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];
|
|
7117
7128
|
if (c) {
|
|
7118
|
-
const
|
|
7129
|
+
const C = [
|
|
7119
7130
|
"data-chai-lightbox",
|
|
7120
7131
|
"chai-lightbox",
|
|
7121
7132
|
"data-vbtype",
|
|
@@ -7127,44 +7138,44 @@ const CoreBlock = ({
|
|
|
7127
7138
|
];
|
|
7128
7139
|
a = {
|
|
7129
7140
|
...a,
|
|
7130
|
-
href: ((
|
|
7131
|
-
hrefType: ((
|
|
7132
|
-
autoplay: ((f = l.find((
|
|
7133
|
-
maxWidth: ((b = (
|
|
7134
|
-
backdropColor: ((
|
|
7135
|
-
galleryName: ((A = l.find((
|
|
7136
|
-
}, forEach(
|
|
7137
|
-
has(a, `styles_attrs.${
|
|
7141
|
+
href: ((m = l.find((j) => j.key === "href")) == null ? void 0 : m.value) || "",
|
|
7142
|
+
hrefType: ((x = l.find((j) => j.key === "data-vbtype")) == null ? void 0 : x.value) || "video",
|
|
7143
|
+
autoplay: ((f = l.find((j) => j.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
|
|
7144
|
+
maxWidth: ((b = (h = l.find((j) => j.key === "data-maxwidth")) == null ? void 0 : h.value) == null ? void 0 : b.replace("px", "")) || "",
|
|
7145
|
+
backdropColor: ((k = l.find((j) => j.key === "data-overlay")) == null ? void 0 : k.value) || "",
|
|
7146
|
+
galleryName: ((A = l.find((j) => j.key === "data-gall")) == null ? void 0 : A.value) || ""
|
|
7147
|
+
}, forEach(C, (j) => {
|
|
7148
|
+
has(a, `styles_attrs.${j}`) && delete a.styles_attrs[j];
|
|
7138
7149
|
});
|
|
7139
7150
|
}
|
|
7140
7151
|
if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
|
|
7141
7152
|
delete a.styles_attrs;
|
|
7142
|
-
const
|
|
7143
|
-
a.content = getTextContent(
|
|
7144
|
-
const
|
|
7153
|
+
const C = filter(r.children || [], (_) => (_ == null ? void 0 : _.tagName) !== "span");
|
|
7154
|
+
a.content = getTextContent(C);
|
|
7155
|
+
const j = find(
|
|
7145
7156
|
r.children || [],
|
|
7146
|
-
(
|
|
7157
|
+
(_) => (_ == null ? void 0 : _.tagName) === "span" && some(_.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg")
|
|
7147
7158
|
);
|
|
7148
|
-
if (
|
|
7149
|
-
const
|
|
7150
|
-
if (
|
|
7151
|
-
a.icon = stringify([
|
|
7152
|
-
const { height: S, width:
|
|
7153
|
-
a.iconHeight = S, a.iconWidth =
|
|
7159
|
+
if (j) {
|
|
7160
|
+
const _ = find(j.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg");
|
|
7161
|
+
if (_) {
|
|
7162
|
+
a.icon = stringify([_]);
|
|
7163
|
+
const { height: S, width: w } = getSvgDimensions(_, "16px", "16px");
|
|
7164
|
+
a.iconHeight = S, a.iconWidth = w;
|
|
7154
7165
|
}
|
|
7155
7166
|
}
|
|
7156
7167
|
return [a];
|
|
7157
7168
|
}
|
|
7158
7169
|
if (a._type === "Input") {
|
|
7159
|
-
const
|
|
7160
|
-
|
|
7170
|
+
const C = a.inputType || "text";
|
|
7171
|
+
C === "checkbox" ? set(a, "_type", "Checkbox") : C === "radio" && set(a, "_type", "Radio");
|
|
7161
7172
|
} else if (r.tagName === "video" || r.tagName === "iframe") {
|
|
7162
|
-
const
|
|
7163
|
-
return hasVideoEmbed(
|
|
7173
|
+
const C = stringify([r]);
|
|
7174
|
+
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];
|
|
7164
7175
|
} else if (r.tagName === "svg") {
|
|
7165
|
-
const
|
|
7166
|
-
return a.styles = `${STYLES_KEY}, ${cn$1(`w-${S} h-${
|
|
7167
|
-
} else if (r.tagName == "option" && n && ((
|
|
7176
|
+
const C = find(r.attributes, { key: "height" }), j = find(r.attributes, { key: "width" }), _ = get(C, "value") ? `[${get(C, "value")}px]` : "24px", S = get(j, "value") ? `[${get(j, "value")}px]` : "24px", w = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
|
|
7177
|
+
return a.styles = `${STYLES_KEY}, ${cn$1(`w-${S} h-${_}`, w)}`.trim(), r.attributes = filter(r.attributes, (L) => !includes(["style", "width", "height", "class"], L.key)), a.icon = stringify([r]), [a];
|
|
7178
|
+
} else if (r.tagName == "option" && n && ((B = n.block) == null ? void 0 : B._type) === "Select")
|
|
7168
7179
|
return n.block.options.push({
|
|
7169
7180
|
label: getTextContent(r.children),
|
|
7170
7181
|
...getAttrs(r)
|
|
@@ -7237,29 +7248,29 @@ const CoreBlock = ({
|
|
|
7237
7248
|
error: c
|
|
7238
7249
|
}), g(!0);
|
|
7239
7250
|
else if (!l && Object.keys(a || {}).length > 0) {
|
|
7240
|
-
const
|
|
7241
|
-
const
|
|
7251
|
+
const x = Object.entries(a).map(([h, b]) => {
|
|
7252
|
+
const k = b, A = k.type || "partial", B = formatReadableName(A);
|
|
7242
7253
|
return {
|
|
7243
7254
|
type: "PartialBlock",
|
|
7244
7255
|
// Set the type to PartialBlock
|
|
7245
|
-
label: formatReadableName(
|
|
7246
|
-
description:
|
|
7256
|
+
label: formatReadableName(k.name || h),
|
|
7257
|
+
description: k.description || "",
|
|
7247
7258
|
icon: Globe,
|
|
7248
|
-
group:
|
|
7259
|
+
group: B,
|
|
7249
7260
|
// Use formatted type as group
|
|
7250
7261
|
category: "partial",
|
|
7251
|
-
partialBlockId:
|
|
7262
|
+
partialBlockId: h,
|
|
7252
7263
|
// Store the original ID as partialBlockId
|
|
7253
|
-
_name:
|
|
7264
|
+
_name: k.name
|
|
7254
7265
|
};
|
|
7255
|
-
}), f = uniq(map(
|
|
7266
|
+
}), f = uniq(map(x, "group"));
|
|
7256
7267
|
p({
|
|
7257
|
-
blocks:
|
|
7268
|
+
blocks: x,
|
|
7258
7269
|
groups: f,
|
|
7259
7270
|
isLoading: !1,
|
|
7260
7271
|
error: null
|
|
7261
7272
|
}), g(!0);
|
|
7262
|
-
} else l ? p((
|
|
7273
|
+
} else l ? p((x) => ({ ...x, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
|
|
7263
7274
|
blocks: [],
|
|
7264
7275
|
groups: [],
|
|
7265
7276
|
isLoading: !1,
|
|
@@ -7274,15 +7285,15 @@ const CoreBlock = ({
|
|
|
7274
7285
|
d.blocks,
|
|
7275
7286
|
c
|
|
7276
7287
|
]);
|
|
7277
|
-
const
|
|
7278
|
-
p((
|
|
7288
|
+
const m = () => {
|
|
7289
|
+
p((x) => ({ ...x, isLoading: !0, error: null })), g(!1), i();
|
|
7279
7290
|
};
|
|
7280
7291
|
return d.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : d.error || d.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
|
|
7281
7292
|
/* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
|
|
7282
7293
|
/* @__PURE__ */ jsx(
|
|
7283
7294
|
"button",
|
|
7284
7295
|
{
|
|
7285
|
-
onClick:
|
|
7296
|
+
onClick: m,
|
|
7286
7297
|
className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
|
|
7287
7298
|
children: "Refresh"
|
|
7288
7299
|
}
|
|
@@ -7299,43 +7310,43 @@ const CoreBlock = ({
|
|
|
7299
7310
|
);
|
|
7300
7311
|
}, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
7301
7312
|
var v;
|
|
7302
|
-
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom),
|
|
7313
|
+
const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (v = find(c, (y) => y._id === r)) == null ? void 0 : v._type, [x, f] = useState("all"), [h, b] = useState(null), k = useRef(null);
|
|
7303
7314
|
useEffect(() => {
|
|
7304
|
-
const
|
|
7305
|
-
var
|
|
7306
|
-
(
|
|
7315
|
+
const y = setTimeout(() => {
|
|
7316
|
+
var E;
|
|
7317
|
+
(E = u.current) == null || E.focus();
|
|
7307
7318
|
}, 0);
|
|
7308
|
-
return () => clearTimeout(
|
|
7319
|
+
return () => clearTimeout(y);
|
|
7309
7320
|
}, [g]), useEffect(() => {
|
|
7310
7321
|
d && (f("all"), b(null));
|
|
7311
|
-
}, [d]), useEffect(() => (
|
|
7312
|
-
f(
|
|
7322
|
+
}, [d]), useEffect(() => (k.current = debounce((y) => {
|
|
7323
|
+
f(y);
|
|
7313
7324
|
}, 500), () => {
|
|
7314
|
-
|
|
7325
|
+
k.current && k.current.cancel();
|
|
7315
7326
|
}), []);
|
|
7316
|
-
const A = useCallback((
|
|
7317
|
-
b(
|
|
7318
|
-
}, []),
|
|
7319
|
-
b(null),
|
|
7320
|
-
}, []),
|
|
7321
|
-
|
|
7322
|
-
}, []),
|
|
7327
|
+
const A = useCallback((y) => {
|
|
7328
|
+
b(y), k.current && k.current(y);
|
|
7329
|
+
}, []), B = useCallback(() => {
|
|
7330
|
+
b(null), k.current && k.current.cancel();
|
|
7331
|
+
}, []), C = useCallback((y) => {
|
|
7332
|
+
k.current && k.current.cancel(), f(y), b(null);
|
|
7333
|
+
}, []), j = useMemo(
|
|
7323
7334
|
() => d ? values(n).filter(
|
|
7324
|
-
(
|
|
7325
|
-
var
|
|
7326
|
-
return (((
|
|
7335
|
+
(y) => {
|
|
7336
|
+
var E, T;
|
|
7337
|
+
return (((E = y.label) == null ? void 0 : E.toLowerCase()) + " " + ((T = y.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
|
|
7327
7338
|
}
|
|
7328
7339
|
) : n,
|
|
7329
7340
|
[n, d]
|
|
7330
|
-
),
|
|
7341
|
+
), _ = useMemo(
|
|
7331
7342
|
() => d ? o.filter(
|
|
7332
|
-
(
|
|
7333
|
-
) : o.filter((
|
|
7334
|
-
[n,
|
|
7343
|
+
(y) => reject(filter(values(j), { group: y }), { hidden: !0 }).length > 0
|
|
7344
|
+
) : o.filter((y) => reject(filter(values(n), { group: y }), { hidden: !0 }).length > 0),
|
|
7345
|
+
[n, j, o, d]
|
|
7335
7346
|
), S = useMemo(
|
|
7336
|
-
() => sortBy(
|
|
7337
|
-
[
|
|
7338
|
-
),
|
|
7347
|
+
() => sortBy(_, (y) => CORE_GROUPS.indexOf(y) === -1 ? 99 : CORE_GROUPS.indexOf(y)),
|
|
7348
|
+
[_]
|
|
7349
|
+
), w = useMemo(() => x === "all" ? j : filter(values(j), { group: x }), [j, x]), L = useMemo(() => x === "all" ? S : [x], [S, x]);
|
|
7339
7350
|
return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
|
|
7340
7351
|
/* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
|
|
7341
7352
|
Input$1,
|
|
@@ -7345,7 +7356,7 @@ const CoreBlock = ({
|
|
|
7345
7356
|
placeholder: i("Search blocks..."),
|
|
7346
7357
|
value: d,
|
|
7347
7358
|
className: "-ml-2",
|
|
7348
|
-
onChange: (
|
|
7359
|
+
onChange: (y) => p(y.target.value)
|
|
7349
7360
|
}
|
|
7350
7361
|
) }),
|
|
7351
7362
|
/* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
|
|
@@ -7353,49 +7364,49 @@ const CoreBlock = ({
|
|
|
7353
7364
|
/* @__PURE__ */ jsx(
|
|
7354
7365
|
"button",
|
|
7355
7366
|
{
|
|
7356
|
-
onClick: () =>
|
|
7367
|
+
onClick: () => C("all"),
|
|
7357
7368
|
onMouseEnter: () => A("all"),
|
|
7358
|
-
onMouseLeave:
|
|
7359
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${
|
|
7369
|
+
onMouseLeave: B,
|
|
7370
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${x === "all" || h === "all" ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
|
|
7360
7371
|
children: i("All")
|
|
7361
7372
|
},
|
|
7362
7373
|
"sidebar-all"
|
|
7363
7374
|
),
|
|
7364
|
-
S.map((
|
|
7375
|
+
S.map((y) => /* @__PURE__ */ jsx(
|
|
7365
7376
|
"button",
|
|
7366
7377
|
{
|
|
7367
|
-
onClick: () =>
|
|
7368
|
-
onMouseEnter: () => A(
|
|
7369
|
-
onMouseLeave:
|
|
7370
|
-
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${
|
|
7371
|
-
children: capitalize(i(
|
|
7378
|
+
onClick: () => C(y),
|
|
7379
|
+
onMouseEnter: () => A(y),
|
|
7380
|
+
onMouseLeave: B,
|
|
7381
|
+
className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${x === y || h === y ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
|
|
7382
|
+
children: capitalize(i(y.toLowerCase()))
|
|
7372
7383
|
},
|
|
7373
|
-
`sidebar-${
|
|
7384
|
+
`sidebar-${y}`
|
|
7374
7385
|
))
|
|
7375
7386
|
] }) }) }),
|
|
7376
|
-
/* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children:
|
|
7387
|
+
/* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children: _.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: [
|
|
7377
7388
|
i("No blocks found matching"),
|
|
7378
7389
|
' "',
|
|
7379
7390
|
d,
|
|
7380
7391
|
'"'
|
|
7381
|
-
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((
|
|
7382
|
-
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(
|
|
7392
|
+
] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((y) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
|
|
7393
|
+
/* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(y.toLowerCase())) }),
|
|
7383
7394
|
/* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: React__default.Children.toArray(
|
|
7384
7395
|
reject(
|
|
7385
|
-
|
|
7396
|
+
x === "all" ? filter(values(w), { group: y }) : values(w),
|
|
7386
7397
|
{ hidden: !0 }
|
|
7387
|
-
).map((
|
|
7398
|
+
).map((E) => /* @__PURE__ */ jsx(
|
|
7388
7399
|
CoreBlock,
|
|
7389
7400
|
{
|
|
7390
7401
|
parentId: r,
|
|
7391
7402
|
position: a,
|
|
7392
|
-
block:
|
|
7393
|
-
disabled: !canAcceptChildBlock(
|
|
7403
|
+
block: E,
|
|
7404
|
+
disabled: !canAcceptChildBlock(m, E.type) || !canBeNestedInside(m, E.type)
|
|
7394
7405
|
},
|
|
7395
|
-
|
|
7406
|
+
E.type
|
|
7396
7407
|
))
|
|
7397
7408
|
) })
|
|
7398
|
-
] },
|
|
7409
|
+
] }, y)) }) }) })
|
|
7399
7410
|
] })
|
|
7400
7411
|
] });
|
|
7401
7412
|
}, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
|
|
@@ -7404,13 +7415,13 @@ const CoreBlock = ({
|
|
|
7404
7415
|
parentId: r = void 0,
|
|
7405
7416
|
position: a = -1
|
|
7406
7417
|
}) => {
|
|
7407
|
-
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(),
|
|
7418
|
+
const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(), m = Object.keys(g || {}).length > 0, { hasPermission: x } = usePermissions();
|
|
7408
7419
|
useEffect(() => {
|
|
7409
|
-
i === "partials" && !
|
|
7410
|
-
}, [i,
|
|
7411
|
-
const
|
|
7420
|
+
i === "partials" && !m && c("library");
|
|
7421
|
+
}, [i, m, c]);
|
|
7422
|
+
const f = useCallback(() => {
|
|
7412
7423
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7413
|
-
}, []);
|
|
7424
|
+
}, []), h = p && x(PERMISSIONS.IMPORT_HTML);
|
|
7414
7425
|
return /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
7415
7426
|
n ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
|
|
7416
7427
|
/* @__PURE__ */ jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: l("Add block") }),
|
|
@@ -7419,8 +7430,8 @@ const CoreBlock = ({
|
|
|
7419
7430
|
/* @__PURE__ */ jsxs(
|
|
7420
7431
|
Tabs,
|
|
7421
7432
|
{
|
|
7422
|
-
onValueChange: (
|
|
7423
|
-
d(""), c(
|
|
7433
|
+
onValueChange: (b) => {
|
|
7434
|
+
d(""), c(b);
|
|
7424
7435
|
},
|
|
7425
7436
|
value: i,
|
|
7426
7437
|
className: "flex h-full max-h-full flex-col overflow-hidden",
|
|
@@ -7428,15 +7439,15 @@ const CoreBlock = ({
|
|
|
7428
7439
|
/* @__PURE__ */ jsxs(TabsList, { className: "flex w-full items-center", children: [
|
|
7429
7440
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
|
|
7430
7441
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
7431
|
-
|
|
7432
|
-
|
|
7433
|
-
map(u, (
|
|
7442
|
+
m && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
|
|
7443
|
+
h ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
7444
|
+
map(u, (b) => /* @__PURE__ */ jsx(TabsTrigger, { value: b.key, children: React__default.createElement(b.tab) }))
|
|
7434
7445
|
] }),
|
|
7435
7446
|
/* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
|
|
7436
7447
|
/* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
map(u, (
|
|
7448
|
+
m && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
|
|
7449
|
+
h ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
|
|
7450
|
+
map(u, (b) => /* @__PURE__ */ jsx(TabsContent, { value: b.key, children: React__default.createElement(b.tabContent, { close: f, parentId: r, position: a }) }))
|
|
7440
7451
|
]
|
|
7441
7452
|
}
|
|
7442
7453
|
)
|
|
@@ -7493,9 +7504,9 @@ const BlockCard = ({
|
|
|
7493
7504
|
parentId: r = void 0,
|
|
7494
7505
|
position: a = -1
|
|
7495
7506
|
}) => {
|
|
7496
|
-
const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(),
|
|
7497
|
-
const
|
|
7498
|
-
return A._type === "Box" &&
|
|
7507
|
+
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")), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), h = (A) => {
|
|
7508
|
+
const B = has(A, "styles_attrs.data-page-section");
|
|
7509
|
+
return A._type === "Box" && B;
|
|
7499
7510
|
}, b = useCallback(
|
|
7500
7511
|
async (A) => {
|
|
7501
7512
|
if (A.stopPropagation(), has(o, "component")) {
|
|
@@ -7503,8 +7514,8 @@ const BlockCard = ({
|
|
|
7503
7514
|
return;
|
|
7504
7515
|
}
|
|
7505
7516
|
i(!0);
|
|
7506
|
-
const
|
|
7507
|
-
isEmpty(
|
|
7517
|
+
const B = await c(n, o);
|
|
7518
|
+
isEmpty(B) || p(syncBlocksWithDefaults(B), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7508
7519
|
},
|
|
7509
7520
|
[d, p, o, c, n, r, a]
|
|
7510
7521
|
);
|
|
@@ -7514,20 +7525,20 @@ const BlockCard = ({
|
|
|
7514
7525
|
{
|
|
7515
7526
|
onClick: l ? () => {
|
|
7516
7527
|
} : b,
|
|
7517
|
-
draggable:
|
|
7528
|
+
draggable: x ? "true" : "false",
|
|
7518
7529
|
onDragStart: async (A) => {
|
|
7519
|
-
const
|
|
7520
|
-
let
|
|
7521
|
-
if (
|
|
7522
|
-
const
|
|
7523
|
-
if (A.dataTransfer.setData("text/plain", JSON.stringify(
|
|
7524
|
-
const
|
|
7525
|
-
|
|
7526
|
-
A.dataTransfer.setDragImage(
|
|
7530
|
+
const B = await c(n, o);
|
|
7531
|
+
let C = r;
|
|
7532
|
+
if (h(first(B)) && (C = null), !isEmpty(B)) {
|
|
7533
|
+
const j = { blocks: B, uiLibrary: !0, parent: C };
|
|
7534
|
+
if (A.dataTransfer.setData("text/plain", JSON.stringify(j)), o.preview) {
|
|
7535
|
+
const _ = new Image();
|
|
7536
|
+
_.src = o.preview, _.onload = () => {
|
|
7537
|
+
A.dataTransfer.setDragImage(_, 0, 0);
|
|
7527
7538
|
};
|
|
7528
7539
|
} else
|
|
7529
7540
|
A.dataTransfer.setDragImage(new Image(), 0, 0);
|
|
7530
|
-
f(
|
|
7541
|
+
f(j), setTimeout(() => {
|
|
7531
7542
|
u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
7532
7543
|
}, 200);
|
|
7533
7544
|
}
|
|
@@ -7540,11 +7551,11 @@ const BlockCard = ({
|
|
|
7540
7551
|
/* @__PURE__ */ jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
|
|
7541
7552
|
/* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
|
|
7542
7553
|
] }),
|
|
7543
|
-
o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt:
|
|
7554
|
+
o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: m }) : /* @__PURE__ */ jsx("div", { className: "flex h-20 items-center justify-center rounded-md border border-border bg-gray-200", children: /* @__PURE__ */ jsx("p", { className: "max-w-xs text-center text-sm text-gray-700", children: m }) })
|
|
7544
7555
|
]
|
|
7545
7556
|
}
|
|
7546
7557
|
) }),
|
|
7547
|
-
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children:
|
|
7558
|
+
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: m }) })
|
|
7548
7559
|
] });
|
|
7549
7560
|
}, libraryBlocksAtom = atom$1(
|
|
7550
7561
|
{}
|
|
@@ -7559,9 +7570,9 @@ const BlockCard = ({
|
|
|
7559
7570
|
})();
|
|
7560
7571
|
}, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
|
|
7561
7572
|
}, UILibrarySection = ({ parentId: o, position: n }) => {
|
|
7562
|
-
const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((
|
|
7563
|
-
|
|
7564
|
-
|
|
7573
|
+
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, x] = useState("Hero"), f = get(g, m, []), h = useRef(null), { t: b } = useTranslation(), k = (C) => {
|
|
7574
|
+
h.current && (clearTimeout(h.current), h.current = null), h.current = setTimeout(() => {
|
|
7575
|
+
h.current && x(C);
|
|
7565
7576
|
}, 300);
|
|
7566
7577
|
};
|
|
7567
7578
|
if (u)
|
|
@@ -7569,7 +7580,7 @@ const BlockCard = ({
|
|
|
7569
7580
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
|
|
7570
7581
|
/* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
|
|
7571
7582
|
] });
|
|
7572
|
-
const A = filter(f, (
|
|
7583
|
+
const A = filter(f, (C, j) => j % 2 === 0), B = filter(f, (C, j) => j % 2 === 1);
|
|
7573
7584
|
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: [
|
|
7574
7585
|
/* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
|
|
7575
7586
|
/* @__PURE__ */ jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
|
|
@@ -7577,22 +7588,22 @@ const BlockCard = ({
|
|
|
7577
7588
|
/* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: b("Groups") }),
|
|
7578
7589
|
/* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
|
|
7579
7590
|
/* @__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(
|
|
7580
|
-
map(g, (
|
|
7591
|
+
map(g, (C, j) => /* @__PURE__ */ jsxs(
|
|
7581
7592
|
"div",
|
|
7582
7593
|
{
|
|
7583
|
-
onMouseEnter: () =>
|
|
7584
|
-
onMouseLeave: () => clearTimeout(
|
|
7585
|
-
onClick: () =>
|
|
7594
|
+
onMouseEnter: () => k(j),
|
|
7595
|
+
onMouseLeave: () => clearTimeout(h.current),
|
|
7596
|
+
onClick: () => x(j),
|
|
7586
7597
|
className: cn$1(
|
|
7587
7598
|
"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",
|
|
7588
|
-
|
|
7599
|
+
j === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
|
|
7589
7600
|
),
|
|
7590
7601
|
children: [
|
|
7591
|
-
/* @__PURE__ */ jsx("span", { children: capitalize(b(
|
|
7602
|
+
/* @__PURE__ */ jsx("span", { children: capitalize(b(j.toLowerCase())) }),
|
|
7592
7603
|
/* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
|
|
7593
7604
|
]
|
|
7594
7605
|
},
|
|
7595
|
-
|
|
7606
|
+
j
|
|
7596
7607
|
))
|
|
7597
7608
|
) })
|
|
7598
7609
|
] })
|
|
@@ -7600,15 +7611,15 @@ const BlockCard = ({
|
|
|
7600
7611
|
/* @__PURE__ */ jsxs(
|
|
7601
7612
|
ScrollArea,
|
|
7602
7613
|
{
|
|
7603
|
-
onMouseEnter: () =>
|
|
7614
|
+
onMouseEnter: () => h.current ? clearTimeout(h.current) : null,
|
|
7604
7615
|
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",
|
|
7605
7616
|
children: [
|
|
7606
7617
|
/* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
|
|
7607
7618
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
7608
|
-
A.map((
|
|
7619
|
+
A.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
|
|
7609
7620
|
) }),
|
|
7610
7621
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
|
|
7611
|
-
|
|
7622
|
+
B.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
|
|
7612
7623
|
) })
|
|
7613
7624
|
] }),
|
|
7614
7625
|
/* @__PURE__ */ jsx("br", {}),
|
|
@@ -7618,7 +7629,18 @@ const BlockCard = ({
|
|
|
7618
7629
|
}
|
|
7619
7630
|
)
|
|
7620
7631
|
] }) }) });
|
|
7621
|
-
}, UILibrariesPanel = ({ parentId: o, position: n }) => /* @__PURE__ */ jsx(UILibrarySection, { parentId: o, position: n }),
|
|
7632
|
+
}, UILibrariesPanel = ({ parentId: o, position: n }) => /* @__PURE__ */ jsx(UILibrarySection, { parentId: o, position: n }), PERMISSIONS = {
|
|
7633
|
+
ADD_BLOCK: "add_block",
|
|
7634
|
+
DELETE_BLOCK: "delete_block",
|
|
7635
|
+
EDIT_BLOCK: "edit_block",
|
|
7636
|
+
MOVE_BLOCK: "move_block",
|
|
7637
|
+
EDIT_THEME: "edit_theme",
|
|
7638
|
+
SAVE_PAGE: "save_page",
|
|
7639
|
+
EDIT_STYLES: "edit_styles",
|
|
7640
|
+
IMPORT_HTML: "import_html"
|
|
7641
|
+
};
|
|
7642
|
+
Object.values(PERMISSIONS);
|
|
7643
|
+
const PasteAtRootContextMenu = ({ parentContext: o, setParentContext: n }) => {
|
|
7622
7644
|
const { t: r } = useTranslation(), { canPaste: a, pasteBlocks: l } = usePasteBlocks();
|
|
7623
7645
|
return useEffect(() => {
|
|
7624
7646
|
a("root") || n(null);
|
|
@@ -7703,11 +7725,11 @@ const BlockCard = ({
|
|
|
7703
7725
|
);
|
|
7704
7726
|
}, RenameBlock = ({ node: o }) => {
|
|
7705
7727
|
const { t: n } = useTranslation();
|
|
7706
|
-
return
|
|
7728
|
+
return /* @__PURE__ */ jsxs(
|
|
7707
7729
|
DropdownMenuItem,
|
|
7708
7730
|
{
|
|
7709
7731
|
onClick: (r) => {
|
|
7710
|
-
r.stopPropagation(),
|
|
7732
|
+
r.stopPropagation(), o.edit(), o.deselect();
|
|
7711
7733
|
},
|
|
7712
7734
|
className: "flex items-center gap-x-4 text-xs",
|
|
7713
7735
|
children: [
|
|
@@ -7718,40 +7740,43 @@ const BlockCard = ({
|
|
|
7718
7740
|
}
|
|
7719
7741
|
);
|
|
7720
7742
|
}, BlockContextMenuContent = ({ node: o }) => {
|
|
7721
|
-
const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), i = useCallback(() => {
|
|
7743
|
+
const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), { hasPermission: i } = usePermissions(), c = useBuilderProp("blockMoreOptions", []), d = useCallback(() => {
|
|
7722
7744
|
a(r);
|
|
7723
7745
|
}, [r, a]);
|
|
7724
7746
|
return /* @__PURE__ */ jsxs(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: [
|
|
7725
|
-
/* @__PURE__ */ jsxs(
|
|
7726
|
-
|
|
7727
|
-
|
|
7728
|
-
|
|
7729
|
-
|
|
7730
|
-
|
|
7731
|
-
|
|
7732
|
-
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7747
|
+
i(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
7748
|
+
/* @__PURE__ */ jsxs(
|
|
7749
|
+
DropdownMenuItem,
|
|
7750
|
+
{
|
|
7751
|
+
disabled: !canAddChildBlock(l == null ? void 0 : l._type),
|
|
7752
|
+
className: "flex items-center gap-x-4 text-xs",
|
|
7753
|
+
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, l),
|
|
7754
|
+
children: [
|
|
7755
|
+
/* @__PURE__ */ jsx(PlusIcon$1, { size: "14" }),
|
|
7756
|
+
" ",
|
|
7757
|
+
n("Add block")
|
|
7758
|
+
]
|
|
7759
|
+
}
|
|
7760
|
+
),
|
|
7761
|
+
/* @__PURE__ */ jsxs(
|
|
7762
|
+
DropdownMenuItem,
|
|
7763
|
+
{
|
|
7764
|
+
disabled: !canDuplicateBlock(l == null ? void 0 : l._type),
|
|
7765
|
+
className: "flex items-center gap-x-4 text-xs",
|
|
7766
|
+
onClick: d,
|
|
7767
|
+
children: [
|
|
7768
|
+
/* @__PURE__ */ jsx(CardStackPlusIcon, {}),
|
|
7769
|
+
" ",
|
|
7770
|
+
n("Duplicate")
|
|
7771
|
+
]
|
|
7772
|
+
}
|
|
7773
|
+
)
|
|
7774
|
+
] }),
|
|
7751
7775
|
/* @__PURE__ */ jsx(RenameBlock, { node: o }),
|
|
7752
|
-
/* @__PURE__ */ jsx(CutBlocks, {}),
|
|
7753
|
-
/* @__PURE__ */ jsx(CopyPasteBlocks, {}),
|
|
7754
|
-
/* @__PURE__ */ jsx(RemoveBlocks, {})
|
|
7776
|
+
i(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(CutBlocks, {}),
|
|
7777
|
+
i(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(CopyPasteBlocks, {}),
|
|
7778
|
+
i(PERMISSIONS.DELETE_BLOCK) && /* @__PURE__ */ jsx(RemoveBlocks, {}),
|
|
7779
|
+
c.map((p, u) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("span", { children: "Loading..." }), children: React__default.createElement(p, { block: l }) }, `more-${u}`))
|
|
7755
7780
|
] });
|
|
7756
7781
|
}, BlockMoreOptions = ({ children: o, id: n, node: r }) => {
|
|
7757
7782
|
const [, a] = useSelectedBlockIds();
|
|
@@ -7836,52 +7861,53 @@ const selectParent = (o, n) => {
|
|
|
7836
7861
|
r.isInternal && n && r.close();
|
|
7837
7862
|
}, currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, dragHandle: r }) => {
|
|
7838
7863
|
var P;
|
|
7839
|
-
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
|
|
7840
|
-
let
|
|
7841
|
-
const
|
|
7842
|
-
N.stopPropagation(), !i.includes(
|
|
7864
|
+
const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom), { hasPermission: p } = usePermissions();
|
|
7865
|
+
let u = null;
|
|
7866
|
+
const g = o.children.length > 0, { highlightBlock: m, clearHighlight: x } = useBlockHighlight(), { id: f, data: h, isSelected: b, willReceiveDrop: k, isDragging: A, isEditing: B, handleClick: C } = o, j = (N) => {
|
|
7867
|
+
N.stopPropagation(), !i.includes(f) && o.toggle();
|
|
7843
7868
|
}, _ = (N) => {
|
|
7844
|
-
N.isInternal && (
|
|
7845
|
-
},
|
|
7846
|
-
N.isInternal &&
|
|
7847
|
-
}, [
|
|
7869
|
+
N.isInternal && (u = N.isOpen, N.isOpen && N.close());
|
|
7870
|
+
}, S = (N) => {
|
|
7871
|
+
N.isInternal && u !== null && (u ? N.open() : N.close(), u = null);
|
|
7872
|
+
}, [w, L] = useAtom$1(currentAddSelection), v = () => {
|
|
7848
7873
|
var N;
|
|
7849
|
-
|
|
7850
|
-
},
|
|
7851
|
-
|
|
7852
|
-
},
|
|
7853
|
-
|
|
7874
|
+
y(), o.parent.isSelected || L((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
|
|
7875
|
+
}, y = () => {
|
|
7876
|
+
L(null);
|
|
7877
|
+
}, E = (N) => {
|
|
7878
|
+
y(), N.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(), C(N);
|
|
7854
7879
|
};
|
|
7855
7880
|
useEffect(() => {
|
|
7856
7881
|
const N = setTimeout(() => {
|
|
7857
|
-
|
|
7882
|
+
k && !o.isOpen && !A && !i.includes(f) && o.toggle();
|
|
7858
7883
|
}, 500);
|
|
7859
7884
|
return () => clearTimeout(N);
|
|
7860
|
-
}, [
|
|
7861
|
-
const
|
|
7862
|
-
const N = Object.keys(
|
|
7863
|
-
for (let
|
|
7864
|
-
if (N[
|
|
7865
|
-
const
|
|
7866
|
-
|
|
7885
|
+
}, [k, o, A]);
|
|
7886
|
+
const T = useMemo(() => {
|
|
7887
|
+
const N = Object.keys(h), M = [];
|
|
7888
|
+
for (let D = 0; D < N.length; D++)
|
|
7889
|
+
if (N[D].endsWith("_attrs")) {
|
|
7890
|
+
const O = h[N[D]], $ = Object.keys(O).join("|");
|
|
7891
|
+
$.match(/x-data/) && M.push("data"), $.match(/x-on/) && M.push("event"), $.match(/x-show|x-if/) && M.push("show");
|
|
7867
7892
|
}
|
|
7868
|
-
return
|
|
7869
|
-
}, [
|
|
7870
|
-
const
|
|
7871
|
-
|
|
7872
|
-
const
|
|
7873
|
-
|
|
7874
|
-
},
|
|
7875
|
-
|
|
7876
|
-
const
|
|
7877
|
-
|
|
7893
|
+
return M;
|
|
7894
|
+
}, [h]), I = (N, M) => {
|
|
7895
|
+
const D = d.contentDocument || d.contentWindow.document, O = D.querySelector(`[data-block-id=${N}]`);
|
|
7896
|
+
O && O.setAttribute("data-drop", M);
|
|
7897
|
+
const $ = O.getBoundingClientRect(), H = d.getBoundingClientRect();
|
|
7898
|
+
$.top >= H.top && $.left >= H.left && $.bottom <= H.bottom && $.right <= H.right || (D.documentElement.scrollTop = O.offsetTop - H.top);
|
|
7899
|
+
}, R = (N) => {
|
|
7900
|
+
y();
|
|
7901
|
+
const M = get(o, "parent.id");
|
|
7902
|
+
M !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: M, position: N }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: N });
|
|
7878
7903
|
};
|
|
7879
|
-
return
|
|
7904
|
+
return f === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
|
|
7880
7905
|
/* @__PURE__ */ jsx("br", {}),
|
|
7881
|
-
/* @__PURE__ */ jsx(
|
|
7906
|
+
p(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
|
|
7882
7907
|
"div",
|
|
7883
7908
|
{
|
|
7884
|
-
|
|
7909
|
+
role: "button",
|
|
7910
|
+
onClick: () => R(-1),
|
|
7885
7911
|
className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
|
|
7886
7912
|
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: [
|
|
7887
7913
|
/* @__PURE__ */ jsx(PlusIcon$1, { className: "h-2 w-2 stroke-[3]" }),
|
|
@@ -7894,32 +7920,32 @@ const selectParent = (o, n) => {
|
|
|
7894
7920
|
] }) : /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
|
|
7895
7921
|
"div",
|
|
7896
7922
|
{
|
|
7897
|
-
onMouseEnter: () =>
|
|
7898
|
-
onMouseLeave: () =>
|
|
7899
|
-
onClick:
|
|
7923
|
+
onMouseEnter: () => m(f),
|
|
7924
|
+
onMouseLeave: () => x(),
|
|
7925
|
+
onClick: E,
|
|
7900
7926
|
style: n,
|
|
7901
|
-
"data-node-id":
|
|
7902
|
-
ref: i.includes(
|
|
7927
|
+
"data-node-id": f,
|
|
7928
|
+
ref: i.includes(f) ? null : r,
|
|
7903
7929
|
onDragStart: () => _(o),
|
|
7904
|
-
onDragEnd: () =>
|
|
7930
|
+
onDragEnd: () => S(o),
|
|
7905
7931
|
onDragOver: (N) => {
|
|
7906
|
-
N.preventDefault(),
|
|
7932
|
+
N.preventDefault(), I(f, "yes");
|
|
7907
7933
|
},
|
|
7908
7934
|
onDragLeave: (N) => {
|
|
7909
|
-
N.preventDefault(),
|
|
7935
|
+
N.preventDefault(), I(f, "no");
|
|
7910
7936
|
},
|
|
7911
7937
|
onDrop: (N) => {
|
|
7912
|
-
N.preventDefault(),
|
|
7938
|
+
N.preventDefault(), I(f, "no");
|
|
7913
7939
|
},
|
|
7914
7940
|
children: [
|
|
7915
|
-
(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(
|
|
7941
|
+
p(PERMISSIONS.ADD_BLOCK) && (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(
|
|
7916
7942
|
"div",
|
|
7917
7943
|
{
|
|
7918
7944
|
onClick: (N) => {
|
|
7919
|
-
N.stopPropagation(),
|
|
7945
|
+
N.stopPropagation(), R(o.childIndex);
|
|
7920
7946
|
},
|
|
7921
|
-
onMouseEnter:
|
|
7922
|
-
onMouseLeave:
|
|
7947
|
+
onMouseEnter: v,
|
|
7948
|
+
onMouseLeave: y,
|
|
7923
7949
|
className: "absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",
|
|
7924
7950
|
children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500", children: /* @__PURE__ */ jsx(PlusIcon$1, { className: "h-3 w-3 stroke-[4] text-white" }) })
|
|
7925
7951
|
}
|
|
@@ -7929,11 +7955,11 @@ const selectParent = (o, n) => {
|
|
|
7929
7955
|
{
|
|
7930
7956
|
className: cn$1(
|
|
7931
7957
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
(o == null ? void 0 : o.id) ===
|
|
7935
|
-
|
|
7936
|
-
i.includes(
|
|
7958
|
+
b ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
|
|
7959
|
+
k && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
|
|
7960
|
+
(o == null ? void 0 : o.id) === w ? "bg-purple-100" : "",
|
|
7961
|
+
A && "opacity-20",
|
|
7962
|
+
i.includes(f) ? "opacity-50" : ""
|
|
7937
7963
|
),
|
|
7938
7964
|
children: [
|
|
7939
7965
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -7941,12 +7967,12 @@ const selectParent = (o, n) => {
|
|
|
7941
7967
|
"div",
|
|
7942
7968
|
{
|
|
7943
7969
|
className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
|
|
7944
|
-
children:
|
|
7970
|
+
children: g && /* @__PURE__ */ jsx("button", { onClick: j, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${b ? "text-slate-200" : "text-slate-400"}` }) })
|
|
7945
7971
|
}
|
|
7946
7972
|
),
|
|
7947
7973
|
/* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
|
|
7948
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
7949
|
-
|
|
7974
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
|
|
7975
|
+
B ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
|
|
7950
7976
|
"div",
|
|
7951
7977
|
{
|
|
7952
7978
|
className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
|
|
@@ -7954,32 +7980,32 @@ const selectParent = (o, n) => {
|
|
|
7954
7980
|
N.stopPropagation(), o.edit(), o.deselect();
|
|
7955
7981
|
},
|
|
7956
7982
|
children: [
|
|
7957
|
-
/* @__PURE__ */ jsx("span", { children: (
|
|
7958
|
-
|
|
7959
|
-
|
|
7960
|
-
|
|
7983
|
+
/* @__PURE__ */ jsx("span", { children: (h == null ? void 0 : h._name) || (h == null ? void 0 : h._type.split("/").pop()) }),
|
|
7984
|
+
T.includes("data") && /* @__PURE__ */ jsx(FileJson, { className: "h-3 w-3 text-orange-600" }),
|
|
7985
|
+
T.includes("event") && /* @__PURE__ */ jsx(Zap, { className: "h-3 w-3 text-yellow-500" }),
|
|
7986
|
+
T.includes("show") && /* @__PURE__ */ jsx(EyeOff, { className: "h-3 w-3 text-orange-600" })
|
|
7961
7987
|
]
|
|
7962
7988
|
}
|
|
7963
7989
|
)
|
|
7964
7990
|
] })
|
|
7965
7991
|
] }),
|
|
7966
7992
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
7967
|
-
!i.includes(
|
|
7993
|
+
!i.includes(f) && a.map((N) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7968
7994
|
/* @__PURE__ */ jsx(
|
|
7969
7995
|
TooltipTrigger,
|
|
7970
7996
|
{
|
|
7971
7997
|
className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
|
|
7972
7998
|
asChild: !0,
|
|
7973
|
-
children: React__default.createElement(N.item, { blockId:
|
|
7999
|
+
children: React__default.createElement(N.item, { blockId: f })
|
|
7974
8000
|
}
|
|
7975
8001
|
),
|
|
7976
8002
|
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: N.tooltip })
|
|
7977
8003
|
] })),
|
|
7978
|
-
canAddChildBlock(
|
|
8004
|
+
canAddChildBlock(h == null ? void 0 : h._type) && !i.includes(f) && p(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7979
8005
|
/* @__PURE__ */ jsx(
|
|
7980
8006
|
TooltipTrigger,
|
|
7981
8007
|
{
|
|
7982
|
-
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id:
|
|
8008
|
+
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: f }),
|
|
7983
8009
|
className: "cursor-pointer rounded bg-transparent hover:text-black",
|
|
7984
8010
|
asChild: !0,
|
|
7985
8011
|
children: /* @__PURE__ */ jsx(PlusIcon$1, { size: "15" })
|
|
@@ -7992,7 +8018,7 @@ const selectParent = (o, n) => {
|
|
|
7992
8018
|
TooltipTrigger,
|
|
7993
8019
|
{
|
|
7994
8020
|
onClick: (N) => {
|
|
7995
|
-
N.stopPropagation(), c(
|
|
8021
|
+
N.stopPropagation(), c(f), o.isOpen && o.toggle();
|
|
7996
8022
|
},
|
|
7997
8023
|
className: "cursor-pointer rounded bg-transparent hover:text-black",
|
|
7998
8024
|
asChild: !0,
|
|
@@ -8001,7 +8027,7 @@ const selectParent = (o, n) => {
|
|
|
8001
8027
|
),
|
|
8002
8028
|
/* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999]", side: "left", children: l("Hide block") })
|
|
8003
8029
|
] }),
|
|
8004
|
-
/* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id:
|
|
8030
|
+
/* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: f, children: /* @__PURE__ */ jsx(MoreVertical, { size: "15" }) })
|
|
8005
8031
|
] })
|
|
8006
8032
|
]
|
|
8007
8033
|
}
|
|
@@ -8098,21 +8124,32 @@ const selectParent = (o, n) => {
|
|
|
8098
8124
|
break;
|
|
8099
8125
|
}
|
|
8100
8126
|
};
|
|
8101
|
-
|
|
8127
|
+
useEffect(() => {
|
|
8102
8128
|
const o = () => {
|
|
8103
8129
|
treeRef.current && setTreeRef(treeRef.current);
|
|
8104
8130
|
};
|
|
8105
8131
|
o();
|
|
8106
8132
|
const n = new MutationObserver(o);
|
|
8107
8133
|
return n.observe(document.body, { childList: !0, subtree: !0 }), () => n.disconnect();
|
|
8108
|
-
}, [setTreeRef])
|
|
8134
|
+
}, [setTreeRef]);
|
|
8135
|
+
const { hasPermission } = usePermissions();
|
|
8136
|
+
return isEmpty(treeData) ? /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx("div", { className: "mt-10 flex h-full w-full items-center justify-center p-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "mb-1.5 text-sm text-gray-400", children: [
|
|
8109
8137
|
t("This page is empty"),
|
|
8110
8138
|
/* @__PURE__ */ jsx("br", {}),
|
|
8111
8139
|
/* @__PURE__ */ jsx("br", {}),
|
|
8112
|
-
/* @__PURE__ */ jsxs(
|
|
8113
|
-
|
|
8114
|
-
|
|
8115
|
-
|
|
8140
|
+
hasPermission(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsxs(
|
|
8141
|
+
Button,
|
|
8142
|
+
{
|
|
8143
|
+
disabled: !hasPermission(PERMISSIONS.ADD_BLOCK),
|
|
8144
|
+
onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK),
|
|
8145
|
+
variant: "default",
|
|
8146
|
+
size: "sm",
|
|
8147
|
+
children: [
|
|
8148
|
+
"+ ",
|
|
8149
|
+
t("Add Block")
|
|
8150
|
+
]
|
|
8151
|
+
}
|
|
8152
|
+
)
|
|
8116
8153
|
] }) }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
8117
8154
|
/* @__PURE__ */ jsx("div", { className: cn$1("flex h-full select-none flex-col space-y-1"), onClick: () => clearSelection(), children: /* @__PURE__ */ jsxs(
|
|
8118
8155
|
"div",
|
|
@@ -8650,14 +8687,14 @@ function QuickPrompts({ onClick: o }) {
|
|
|
8650
8687
|
) }) });
|
|
8651
8688
|
}
|
|
8652
8689
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
8653
|
-
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(),
|
|
8690
|
+
const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null), x = useRef(null);
|
|
8654
8691
|
useEffect(() => {
|
|
8655
|
-
var
|
|
8656
|
-
(
|
|
8692
|
+
var h;
|
|
8693
|
+
(h = m.current) == null || h.focus();
|
|
8657
8694
|
}, []);
|
|
8658
|
-
const f = (
|
|
8659
|
-
const { usage: b } =
|
|
8660
|
-
!l && b && g(b),
|
|
8695
|
+
const f = (h) => {
|
|
8696
|
+
const { usage: b } = h || {};
|
|
8697
|
+
!l && b && g(b), x.current = setTimeout(() => g(void 0), 1e4), l || c("");
|
|
8661
8698
|
};
|
|
8662
8699
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
8663
8700
|
/* @__PURE__ */ jsxs(
|
|
@@ -8675,14 +8712,14 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8675
8712
|
/* @__PURE__ */ jsx(
|
|
8676
8713
|
Textarea,
|
|
8677
8714
|
{
|
|
8678
|
-
ref:
|
|
8715
|
+
ref: m,
|
|
8679
8716
|
value: i,
|
|
8680
|
-
onChange: (
|
|
8717
|
+
onChange: (h) => c(h.target.value),
|
|
8681
8718
|
placeholder: n("Ask AI to edit content"),
|
|
8682
8719
|
className: "w-full",
|
|
8683
8720
|
rows: 3,
|
|
8684
|
-
onKeyDown: (
|
|
8685
|
-
|
|
8721
|
+
onKeyDown: (h) => {
|
|
8722
|
+
h.key === "Enter" && (h.preventDefault(), x.current && clearTimeout(x.current), g(void 0), r("content", o, i, f));
|
|
8686
8723
|
}
|
|
8687
8724
|
}
|
|
8688
8725
|
),
|
|
@@ -8692,7 +8729,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8692
8729
|
{
|
|
8693
8730
|
disabled: i.trim().length < 5 || a,
|
|
8694
8731
|
onClick: () => {
|
|
8695
|
-
|
|
8732
|
+
x.current && clearTimeout(x.current), g(void 0), r("content", o, i, f);
|
|
8696
8733
|
},
|
|
8697
8734
|
variant: "default",
|
|
8698
8735
|
className: "w-fit",
|
|
@@ -8724,8 +8761,8 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8724
8761
|
/* @__PURE__ */ jsx(
|
|
8725
8762
|
QuickPrompts,
|
|
8726
8763
|
{
|
|
8727
|
-
onClick: (
|
|
8728
|
-
|
|
8764
|
+
onClick: (h) => {
|
|
8765
|
+
x.current && clearTimeout(x.current), g(void 0), r("content", o, h, f);
|
|
8729
8766
|
}
|
|
8730
8767
|
}
|
|
8731
8768
|
)
|
|
@@ -8735,13 +8772,13 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8735
8772
|
] }) }) : null
|
|
8736
8773
|
] });
|
|
8737
8774
|
}, AISetContext = () => {
|
|
8738
|
-
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),
|
|
8775
|
+
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);
|
|
8739
8776
|
useEffect(() => {
|
|
8740
8777
|
n && a(n);
|
|
8741
8778
|
}, [n]);
|
|
8742
|
-
const
|
|
8779
|
+
const x = async () => {
|
|
8743
8780
|
try {
|
|
8744
|
-
d(!0), u(null), await i(r), toast.success(o("Updated AI Context")),
|
|
8781
|
+
d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
|
|
8745
8782
|
} catch (f) {
|
|
8746
8783
|
u(f);
|
|
8747
8784
|
} finally {
|
|
@@ -8757,7 +8794,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8757
8794
|
type: "single",
|
|
8758
8795
|
collapsible: !0,
|
|
8759
8796
|
children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
|
|
8760
|
-
/* @__PURE__ */ jsx(AccordionTrigger, { ref:
|
|
8797
|
+
/* @__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") }) }) }),
|
|
8761
8798
|
/* @__PURE__ */ jsxs(AccordionContent, { children: [
|
|
8762
8799
|
/* @__PURE__ */ jsx(
|
|
8763
8800
|
Textarea,
|
|
@@ -8769,7 +8806,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8769
8806
|
className: "mt-1 w-full",
|
|
8770
8807
|
rows: 10,
|
|
8771
8808
|
onKeyDown: (f) => {
|
|
8772
|
-
f.key === "Enter" && (f.preventDefault(),
|
|
8809
|
+
f.key === "Enter" && (f.preventDefault(), x());
|
|
8773
8810
|
}
|
|
8774
8811
|
}
|
|
8775
8812
|
),
|
|
@@ -8781,7 +8818,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8781
8818
|
Button,
|
|
8782
8819
|
{
|
|
8783
8820
|
disabled: r.trim().length < 5,
|
|
8784
|
-
onClick: () =>
|
|
8821
|
+
onClick: () => x(),
|
|
8785
8822
|
variant: "default",
|
|
8786
8823
|
className: "w-fit",
|
|
8787
8824
|
size: "sm",
|
|
@@ -8810,7 +8847,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8810
8847
|
AlertDialogAction,
|
|
8811
8848
|
{
|
|
8812
8849
|
onClick: () => {
|
|
8813
|
-
a(""),
|
|
8850
|
+
a(""), x();
|
|
8814
8851
|
},
|
|
8815
8852
|
children: o("Yes, Delete")
|
|
8816
8853
|
}
|
|
@@ -8891,8 +8928,8 @@ function usePubSub(o, n) {
|
|
|
8891
8928
|
}, [o, n]);
|
|
8892
8929
|
}
|
|
8893
8930
|
const AiAssistant = () => {
|
|
8894
|
-
const o = useAiAssistant(), [n] = useRightPanel(), r = useBuilderProp("askAiCallBack", null), { t: a } = useTranslation();
|
|
8895
|
-
return r ? /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
8931
|
+
const o = useAiAssistant(), [n] = useRightPanel(), r = useBuilderProp("askAiCallBack", null), { t: a } = useTranslation(), { hasPermission: l } = usePermissions();
|
|
8932
|
+
return !r || !l(PERMISSIONS.EDIT_BLOCK) ? null : /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
|
|
8896
8933
|
/* @__PURE__ */ jsxs(Label, { htmlFor: "ai-assistant", className: "flex items-center gap-x-1 text-sm text-yellow-600", children: [
|
|
8897
8934
|
/* @__PURE__ */ jsx(SparklesIcon, { className: "w-4" }),
|
|
8898
8935
|
a("AI Assistant")
|
|
@@ -8902,13 +8939,13 @@ const AiAssistant = () => {
|
|
|
8902
8939
|
{
|
|
8903
8940
|
className: "scale-90",
|
|
8904
8941
|
checked: n === "ai",
|
|
8905
|
-
onCheckedChange: (
|
|
8906
|
-
o(
|
|
8942
|
+
onCheckedChange: (i) => {
|
|
8943
|
+
o(i);
|
|
8907
8944
|
},
|
|
8908
8945
|
id: "ai-assistant"
|
|
8909
8946
|
}
|
|
8910
8947
|
)
|
|
8911
|
-
] })
|
|
8948
|
+
] });
|
|
8912
8949
|
}, ClearCanvas = () => {
|
|
8913
8950
|
const { t: o } = useTranslation(), { setNewBlocks: n } = useBlocksStoreUndoableActions(), [, r] = useSelectedBlockIds(), [, a] = useSelectedStylingBlocks(), l = useCallback(() => {
|
|
8914
8951
|
n([]), r([]), a([]);
|
|
@@ -8967,54 +9004,54 @@ const AiAssistant = () => {
|
|
|
8967
9004
|
preloadedAttributes: n = [],
|
|
8968
9005
|
onAttributesChange: r
|
|
8969
9006
|
}) {
|
|
8970
|
-
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [
|
|
9007
|
+
const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, x] = useState(""), f = useRef(null), h = useRef(null), b = usePageExternalData();
|
|
8971
9008
|
useEffect(() => {
|
|
8972
9009
|
l(n);
|
|
8973
9010
|
}, [n]);
|
|
8974
|
-
const
|
|
9011
|
+
const k = () => {
|
|
8975
9012
|
if (i.startsWith("@")) {
|
|
8976
|
-
|
|
9013
|
+
x("Attribute keys cannot start with '@'");
|
|
8977
9014
|
return;
|
|
8978
9015
|
}
|
|
8979
9016
|
if (i) {
|
|
8980
9017
|
const S = [...a, { key: i, value: d }];
|
|
8981
|
-
r(S), l(a), c(""), p(""),
|
|
9018
|
+
r(S), l(a), c(""), p(""), x("");
|
|
8982
9019
|
}
|
|
8983
9020
|
}, A = (S) => {
|
|
8984
|
-
const
|
|
8985
|
-
r(
|
|
8986
|
-
},
|
|
9021
|
+
const w = a.filter((L, v) => v !== S);
|
|
9022
|
+
r(w), l(w);
|
|
9023
|
+
}, B = (S) => {
|
|
8987
9024
|
g(S), c(a[S].key), p(a[S].value);
|
|
8988
|
-
},
|
|
9025
|
+
}, C = () => {
|
|
8989
9026
|
if (i.startsWith("@")) {
|
|
8990
|
-
|
|
9027
|
+
x("Attribute keys cannot start with '@'");
|
|
8991
9028
|
return;
|
|
8992
9029
|
}
|
|
8993
9030
|
if (u !== null && i) {
|
|
8994
9031
|
const S = [...a];
|
|
8995
|
-
S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""),
|
|
9032
|
+
S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), x("");
|
|
8996
9033
|
}
|
|
8997
|
-
},
|
|
8998
|
-
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ?
|
|
8999
|
-
},
|
|
9000
|
-
const
|
|
9001
|
-
let I = "",
|
|
9002
|
-
const
|
|
9003
|
-
return
|
|
9004
|
-
text: I + T +
|
|
9034
|
+
}, j = (S) => {
|
|
9035
|
+
S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? C() : k());
|
|
9036
|
+
}, _ = useCallback((S) => {
|
|
9037
|
+
const w = (y) => /[.,!?;:]/.test(y), L = (y, E, T) => {
|
|
9038
|
+
let I = "", R = "";
|
|
9039
|
+
const P = E > 0 ? y[E - 1] : "", N = E < y.length ? y[E] : "";
|
|
9040
|
+
return E > 0 && (P === "." || !w(P) && P !== " ") && (I = " "), E < y.length && !w(N) && N !== " " && (R = " "), {
|
|
9041
|
+
text: I + T + R,
|
|
9005
9042
|
prefixLength: I.length,
|
|
9006
|
-
suffixLength:
|
|
9043
|
+
suffixLength: R.length
|
|
9007
9044
|
};
|
|
9008
|
-
}, v =
|
|
9045
|
+
}, v = h.current;
|
|
9009
9046
|
if (v) {
|
|
9010
|
-
const
|
|
9011
|
-
if (T >
|
|
9012
|
-
const M = `{{${S}}}`, { text:
|
|
9047
|
+
const y = v.selectionStart || 0, E = v.value || "", T = v.selectionEnd || y;
|
|
9048
|
+
if (T > y) {
|
|
9049
|
+
const M = `{{${S}}}`, { text: D } = L(E, y, M), O = E.slice(0, y) + D + E.slice(T);
|
|
9013
9050
|
p(O);
|
|
9014
9051
|
return;
|
|
9015
9052
|
}
|
|
9016
|
-
const
|
|
9017
|
-
p(
|
|
9053
|
+
const R = `{{${S}}}`, { text: P } = L(E, y, R), N = E.slice(0, y) + P + E.slice(y);
|
|
9054
|
+
p(N);
|
|
9018
9055
|
}
|
|
9019
9056
|
}, []);
|
|
9020
9057
|
return /* @__PURE__ */ jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
|
|
@@ -9022,7 +9059,7 @@ const AiAssistant = () => {
|
|
|
9022
9059
|
"form",
|
|
9023
9060
|
{
|
|
9024
9061
|
onSubmit: (S) => {
|
|
9025
|
-
S.preventDefault(), u !== null ?
|
|
9062
|
+
S.preventDefault(), u !== null ? C() : k();
|
|
9026
9063
|
},
|
|
9027
9064
|
className: "space-y-3",
|
|
9028
9065
|
children: [
|
|
@@ -9047,7 +9084,7 @@ const AiAssistant = () => {
|
|
|
9047
9084
|
/* @__PURE__ */ jsxs("div", { className: "w-full", children: [
|
|
9048
9085
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
9049
9086
|
/* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
|
|
9050
|
-
!isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect:
|
|
9087
|
+
!isEmpty(b) && /* @__PURE__ */ jsx(NestedPathSelector, { data: b, onSelect: _ })
|
|
9051
9088
|
] }),
|
|
9052
9089
|
/* @__PURE__ */ jsx(
|
|
9053
9090
|
Textarea,
|
|
@@ -9057,10 +9094,10 @@ const AiAssistant = () => {
|
|
|
9057
9094
|
spellCheck: "false",
|
|
9058
9095
|
id: "attrValue",
|
|
9059
9096
|
rows: 2,
|
|
9060
|
-
ref:
|
|
9097
|
+
ref: h,
|
|
9061
9098
|
value: d,
|
|
9062
9099
|
onChange: (S) => p(S.target.value),
|
|
9063
|
-
onKeyDown:
|
|
9100
|
+
onKeyDown: j,
|
|
9064
9101
|
placeholder: "Enter Value",
|
|
9065
9102
|
className: "text-xs font-normal leading-tight placeholder:text-slate-400"
|
|
9066
9103
|
}
|
|
@@ -9068,20 +9105,20 @@ const AiAssistant = () => {
|
|
|
9068
9105
|
] })
|
|
9069
9106
|
] }),
|
|
9070
9107
|
/* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: !i.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: u !== null ? "Save" : "Add" }) }),
|
|
9071
|
-
|
|
9108
|
+
m && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: m })
|
|
9072
9109
|
]
|
|
9073
9110
|
}
|
|
9074
9111
|
),
|
|
9075
|
-
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S,
|
|
9112
|
+
/* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, w) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
|
|
9076
9113
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
|
|
9077
9114
|
/* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
|
|
9078
9115
|
/* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: S.value.toString() })
|
|
9079
9116
|
] }),
|
|
9080
9117
|
/* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
|
|
9081
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () =>
|
|
9082
|
-
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(
|
|
9118
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(w), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
|
|
9119
|
+
/* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(w), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
|
|
9083
9120
|
] })
|
|
9084
|
-
] },
|
|
9121
|
+
] }, w)) })
|
|
9085
9122
|
] });
|
|
9086
9123
|
}), BlockAttributesEditor = React.memo(() => {
|
|
9087
9124
|
const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
|
|
@@ -9118,10 +9155,26 @@ function BlockAttributesToggle() {
|
|
|
9118
9155
|
] });
|
|
9119
9156
|
}
|
|
9120
9157
|
const SettingsPanel = () => {
|
|
9121
|
-
const o = useSelectedBlock(), { t: n } = useTranslation(), r = useBuilderProp("onError", noop);
|
|
9122
|
-
|
|
9158
|
+
const o = useSelectedBlock(), { t: n } = useTranslation(), r = useBuilderProp("onError", noop), { hasPermission: a } = usePermissions();
|
|
9159
|
+
let l = !a(PERMISSIONS.EDIT_BLOCK);
|
|
9160
|
+
const i = !a(PERMISSIONS.EDIT_STYLES), c = a("!" + PERMISSIONS.EDIT_BLOCK + "_" + (o == null ? void 0 : o._type));
|
|
9161
|
+
return l = l || c, isNull(o) ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 rounded-xl p-4 text-muted-foreground", children: [
|
|
9123
9162
|
/* @__PURE__ */ jsx(MixerHorizontalIcon, { className: "mx-auto text-3xl" }),
|
|
9124
9163
|
/* @__PURE__ */ jsx("h1", { children: n("Please select a block to edit settings or styles") })
|
|
9164
|
+
] }) }) : l && i ? /* @__PURE__ */ jsx("div", { className: "p-4 text-center", children: /* @__PURE__ */ jsxs("div", { className: "space-y-4 rounded-xl p-4 text-muted-foreground", children: [
|
|
9165
|
+
/* @__PURE__ */ jsx(MixerHorizontalIcon, { className: "mx-auto text-3xl" }),
|
|
9166
|
+
/* @__PURE__ */ jsx("h1", { children: n("You don't have permission to edit settings or styles") }),
|
|
9167
|
+
/* @__PURE__ */ jsx("p", { children: n("Please contact your administrator to get access") })
|
|
9168
|
+
] }) }) : i ? /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs("div", { className: "no-scrollbar h-full max-h-min w-full overflow-y-auto", children: [
|
|
9169
|
+
/* @__PURE__ */ jsx(BlockSettings, {}),
|
|
9170
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
9171
|
+
/* @__PURE__ */ jsx("br", {})
|
|
9172
|
+
] }) }) : l ? /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs("div", { className: "no-scrollbar h-full max-h-min w-full overflow-y-auto overflow-x-hidden", children: [
|
|
9173
|
+
/* @__PURE__ */ jsx(BlockStyling, {}),
|
|
9174
|
+
/* @__PURE__ */ jsx(BlockAttributesToggle, {}),
|
|
9175
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
9176
|
+
/* @__PURE__ */ jsx("br", {}),
|
|
9177
|
+
/* @__PURE__ */ jsx("br", {})
|
|
9125
9178
|
] }) }) : /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs(Tabs, { defaultValue: "settings", className: "flex flex-1 flex-col", children: [
|
|
9126
9179
|
/* @__PURE__ */ jsxs(TabsList, { className: "grid h-auto w-full grid-cols-2 p-1 py-1", children: [
|
|
9127
9180
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "settings", className: "text-xs", children: "Settings" }),
|
|
@@ -9275,11 +9328,11 @@ const RootLayout = () => {
|
|
|
9275
9328
|
usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
|
|
9276
9329
|
n(1);
|
|
9277
9330
|
});
|
|
9278
|
-
const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (
|
|
9279
|
-
|
|
9280
|
-
}, u = (
|
|
9281
|
-
n(o ===
|
|
9282
|
-
}, g = useSidebarMenuItems(), { t:
|
|
9331
|
+
const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (h) => {
|
|
9332
|
+
h.preventDefault();
|
|
9333
|
+
}, u = (h) => {
|
|
9334
|
+
n(o === h ? null : h);
|
|
9335
|
+
}, g = useSidebarMenuItems(), { t: m } = useTranslation(), x = [...g, ...c], f = useBuilderProp("htmlDir", "ltr");
|
|
9283
9336
|
return /* @__PURE__ */ jsx("div", { dir: f, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
|
|
9284
9337
|
/* @__PURE__ */ jsxs(
|
|
9285
9338
|
"div",
|
|
@@ -9290,21 +9343,21 @@ const RootLayout = () => {
|
|
|
9290
9343
|
/* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
|
|
9291
9344
|
/* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
|
|
9292
9345
|
/* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
|
|
9293
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children:
|
|
9346
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: x.map((h, b) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
9294
9347
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
9295
9348
|
Button,
|
|
9296
9349
|
{
|
|
9297
9350
|
variant: o === b ? "default" : "ghost",
|
|
9298
9351
|
className: "mb-2 rounded-lg p-2 transition-colors",
|
|
9299
9352
|
onClick: () => u(b),
|
|
9300
|
-
children: get(
|
|
9353
|
+
children: get(h, "icon", null)
|
|
9301
9354
|
},
|
|
9302
9355
|
b
|
|
9303
9356
|
) }),
|
|
9304
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: h
|
|
9357
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(h.label) }) })
|
|
9305
9358
|
] }, "button" + b)) }),
|
|
9306
9359
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
9307
|
-
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((
|
|
9360
|
+
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((h, b) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(h, {}) }, `sidebar-component-${b}`)) })
|
|
9308
9361
|
] }),
|
|
9309
9362
|
/* @__PURE__ */ jsx(
|
|
9310
9363
|
motion.div,
|
|
@@ -9317,14 +9370,14 @@ const RootLayout = () => {
|
|
|
9317
9370
|
/* @__PURE__ */ jsxs(
|
|
9318
9371
|
"div",
|
|
9319
9372
|
{
|
|
9320
|
-
className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(
|
|
9373
|
+
className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(x, `${o}.isInternal`, !1) ? "" : "w-64"}`,
|
|
9321
9374
|
children: [
|
|
9322
|
-
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(
|
|
9323
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9375
|
+
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(x, `${o}.icon`, null) }),
|
|
9376
|
+
/* @__PURE__ */ jsx("span", { children: m(x[o].label) })
|
|
9324
9377
|
]
|
|
9325
9378
|
}
|
|
9326
9379
|
),
|
|
9327
|
-
/* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(
|
|
9380
|
+
/* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(x, `${o}.component`, null), {}) }) })
|
|
9328
9381
|
] })
|
|
9329
9382
|
}
|
|
9330
9383
|
),
|
|
@@ -9343,11 +9396,11 @@ const RootLayout = () => {
|
|
|
9343
9396
|
/* @__PURE__ */ jsx("h2", { className: "-mt-1 flex items-center space-x-1 text-base font-bold", children: /* @__PURE__ */ jsx("div", { className: "flex grow items-center gap-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between gap-2", children: l === "ai" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
9344
9397
|
/* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
|
|
9345
9398
|
" ",
|
|
9346
|
-
|
|
9399
|
+
m("AI Assistant")
|
|
9347
9400
|
] }) }) : l === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
9348
9401
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
9349
9402
|
/* @__PURE__ */ jsx(Paintbrush, { className: "h-4 w-4 rtl:ml-2" }),
|
|
9350
|
-
|
|
9403
|
+
m("Theme Settings")
|
|
9351
9404
|
] }),
|
|
9352
9405
|
/* @__PURE__ */ jsx(
|
|
9353
9406
|
Button,
|
|
@@ -9462,6 +9515,7 @@ export {
|
|
|
9462
9515
|
DefaultChaiBlocks,
|
|
9463
9516
|
ImportHTML,
|
|
9464
9517
|
ListTree as Outline,
|
|
9518
|
+
PERMISSIONS,
|
|
9465
9519
|
Breakpoints$1 as ScreenSizes,
|
|
9466
9520
|
ThemeConfigPanel as ThemeOptions,
|
|
9467
9521
|
UILibrariesPanel as UILibraries,
|
|
@@ -9469,9 +9523,9 @@ export {
|
|
|
9469
9523
|
generateUUID as generateBlockId,
|
|
9470
9524
|
getBlocksFromHTML,
|
|
9471
9525
|
getClassValueAndUnit,
|
|
9472
|
-
|
|
9526
|
+
We as i18n,
|
|
9473
9527
|
cn$1 as mergeClasses,
|
|
9474
|
-
|
|
9528
|
+
Fe as registerChaiBlock,
|
|
9475
9529
|
useAddBlock,
|
|
9476
9530
|
useAddClassesToBlocks,
|
|
9477
9531
|
useAskAi,
|
|
@@ -9497,6 +9551,7 @@ export {
|
|
|
9497
9551
|
usePartailBlocksStore,
|
|
9498
9552
|
usePartialBlocksList,
|
|
9499
9553
|
usePasteBlocks,
|
|
9554
|
+
usePermissions,
|
|
9500
9555
|
usePreviewMode,
|
|
9501
9556
|
useRemoveBlocks,
|
|
9502
9557
|
useRemoveClassesFromBlocks,
|
|
@@ -9514,7 +9569,7 @@ export {
|
|
|
9514
9569
|
useStylingState,
|
|
9515
9570
|
useTheme,
|
|
9516
9571
|
useThemeOptions,
|
|
9517
|
-
|
|
9572
|
+
Ve as useTranslation,
|
|
9518
9573
|
useUILibraryBlocks,
|
|
9519
9574
|
useUndoManager,
|
|
9520
9575
|
useUpdateBlocksProps,
|