@chaibuilder/sdk 2.2.7 → 2.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/code-editor-Dkq7gsQH.cjs +1 -0
- package/dist/{code-editor-HKrlrH8b.js → code-editor-QVi542cK.js} +12 -11
- package/dist/core.cjs +5 -5
- package/dist/core.d.ts +3 -1
- package/dist/core.js +535 -401
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.js +65 -59
- package/package.json +1 -1
- package/dist/code-editor-B7r9YjDC.cjs +0 -1
package/dist/core.js
CHANGED
|
@@ -310,12 +310,12 @@ class PubSub {
|
|
|
310
310
|
}
|
|
311
311
|
}
|
|
312
312
|
const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: r }) => {
|
|
313
|
-
const { t: n } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), d = get(o, "_parent"), c = filter(a, (
|
|
314
|
-
if (
|
|
313
|
+
const { t: n } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), d = get(o, "_parent"), c = filter(a, (h) => d ? get(h, "_parent") === d : !get(h, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(c, { _id: i }), g = (h) => {
|
|
314
|
+
if (h === "CHILD")
|
|
315
315
|
pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
|
|
316
316
|
else {
|
|
317
317
|
const m = { _id: d || "", position: c == null ? void 0 : c.length };
|
|
318
|
-
|
|
318
|
+
h === "BEFORE" ? m.position = Math.max(u, 0) : h === "AFTER" && (m.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, m);
|
|
319
319
|
}
|
|
320
320
|
};
|
|
321
321
|
return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
@@ -349,23 +349,23 @@ function insertBlocksAtPosition(o, r, n, a) {
|
|
|
349
349
|
let i = [...o];
|
|
350
350
|
if (n) {
|
|
351
351
|
const u = o.find((g) => g._id === n);
|
|
352
|
-
if (u && u.content !== void 0 && u.content !== "" && !o.some((
|
|
352
|
+
if (u && u.content !== void 0 && u.content !== "" && !o.some((h) => h._parent === n)) {
|
|
353
353
|
const m = {
|
|
354
354
|
_id: generateUUID(),
|
|
355
355
|
_parent: n,
|
|
356
356
|
_type: "Text",
|
|
357
357
|
content: u.content
|
|
358
358
|
};
|
|
359
|
-
Object.keys(u).forEach((
|
|
360
|
-
|
|
361
|
-
}), l.unshift(m), i = i.map((
|
|
362
|
-
if (
|
|
363
|
-
const x = { ...
|
|
359
|
+
Object.keys(u).forEach((f) => {
|
|
360
|
+
f.startsWith("content-") && (m[f] = u[f]);
|
|
361
|
+
}), l.unshift(m), i = i.map((f) => {
|
|
362
|
+
if (f._id === n) {
|
|
363
|
+
const x = { ...f, content: "" };
|
|
364
364
|
return Object.keys(x).forEach((y) => {
|
|
365
365
|
y.startsWith("content-") && (x[y] = "");
|
|
366
366
|
}), x;
|
|
367
367
|
}
|
|
368
|
-
return
|
|
368
|
+
return f;
|
|
369
369
|
});
|
|
370
370
|
}
|
|
371
371
|
}
|
|
@@ -398,13 +398,13 @@ function moveNode(o, r, n, a) {
|
|
|
398
398
|
const l = findNodeById(o, r), i = findNodeById(o, n);
|
|
399
399
|
if (!l || !i) return !1;
|
|
400
400
|
i.children || (i.model.children = []);
|
|
401
|
-
let d = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((
|
|
401
|
+
let d = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((h) => h.model._id === r);
|
|
402
402
|
l.drop(), d = Math.max(d, 0);
|
|
403
403
|
const p = (((g = l == null ? void 0 : l.model) == null ? void 0 : g._parent) || "root") === n && d <= a ? a - 1 : a;
|
|
404
404
|
try {
|
|
405
405
|
i.addChildAtIndex(l, p);
|
|
406
|
-
} catch (
|
|
407
|
-
return console.error("Error adding child to parent:",
|
|
406
|
+
} catch (h) {
|
|
407
|
+
return console.error("Error adding child to parent:", h), !1;
|
|
408
408
|
}
|
|
409
409
|
return !0;
|
|
410
410
|
}
|
|
@@ -445,8 +445,8 @@ function handleNewParentTextBlock(o, r, n) {
|
|
|
445
445
|
const c = o.map((u) => {
|
|
446
446
|
if (u._id === n) {
|
|
447
447
|
const g = { ...u, content: "" };
|
|
448
|
-
return Object.keys(g).forEach((
|
|
449
|
-
|
|
448
|
+
return Object.keys(g).forEach((h) => {
|
|
449
|
+
h.startsWith("content-") && (g[h] = "");
|
|
450
450
|
}), g;
|
|
451
451
|
}
|
|
452
452
|
return u;
|
|
@@ -463,7 +463,7 @@ function moveBlocksWithChildren(o, r, n, a) {
|
|
|
463
463
|
const d = n || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
|
|
464
464
|
if (moveNode(p, r, d, a)) {
|
|
465
465
|
let u = flattenTree(p);
|
|
466
|
-
const g = u.find((
|
|
466
|
+
const g = u.find((h) => h._id === r);
|
|
467
467
|
return g && (g._parent = d === "root" ? null : d), u.shift(), n && (u = handleNewParentTextBlock(u, l, n)), u;
|
|
468
468
|
}
|
|
469
469
|
return i;
|
|
@@ -487,22 +487,22 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
|
|
|
487
487
|
}, removeNestedBlocks = (o, r) => {
|
|
488
488
|
let n = [...o], a = [];
|
|
489
489
|
r.forEach((c) => {
|
|
490
|
-
const p = n.find((
|
|
490
|
+
const p = n.find((h) => h._id === c);
|
|
491
491
|
if (!p || !p._parent) return;
|
|
492
|
-
const u = p._parent, g = n.filter((
|
|
492
|
+
const u = p._parent, g = n.filter((h) => h._parent === u);
|
|
493
493
|
if (g.length === 2) {
|
|
494
|
-
const
|
|
495
|
-
if (
|
|
496
|
-
const m = n.find((
|
|
497
|
-
m && "content" in m && (n = n.map((
|
|
498
|
-
if (
|
|
499
|
-
const x = { ...
|
|
500
|
-
return Object.keys(
|
|
501
|
-
y.startsWith("content-") && (x[y] =
|
|
494
|
+
const h = g.find((m) => m._id !== c);
|
|
495
|
+
if (h && h._type === "Text") {
|
|
496
|
+
const m = n.find((f) => f._id === u);
|
|
497
|
+
m && "content" in m && (n = n.map((f) => {
|
|
498
|
+
if (f._id === u) {
|
|
499
|
+
const x = { ...f, content: h.content };
|
|
500
|
+
return Object.keys(h).forEach((y) => {
|
|
501
|
+
y.startsWith("content-") && (x[y] = h[y]);
|
|
502
502
|
}), x;
|
|
503
503
|
}
|
|
504
|
-
return
|
|
505
|
-
}), a.push(
|
|
504
|
+
return f;
|
|
505
|
+
}), a.push(h._id));
|
|
506
506
|
}
|
|
507
507
|
}
|
|
508
508
|
});
|
|
@@ -824,12 +824,12 @@ const useUndoManager = () => {
|
|
|
824
824
|
const [o] = useBlocksStore(), [, r] = useSelectedBlockIds(), { addBlocks: n } = useBlocksStoreUndoableActions(), a = useCallback(
|
|
825
825
|
(i, d, c) => {
|
|
826
826
|
var m;
|
|
827
|
-
for (let
|
|
828
|
-
const { _id: x } = i[
|
|
829
|
-
i[
|
|
827
|
+
for (let f = 0; f < i.length; f++) {
|
|
828
|
+
const { _id: x } = i[f];
|
|
829
|
+
i[f]._id = generateUUID();
|
|
830
830
|
const y = filter(i, { _parent: x });
|
|
831
831
|
for (let b = 0; b < y.length; b++)
|
|
832
|
-
y[b]._parent = i[
|
|
832
|
+
y[b]._parent = i[f]._id;
|
|
833
833
|
}
|
|
834
834
|
const p = first(i);
|
|
835
835
|
let u, g;
|
|
@@ -850,8 +850,8 @@ const useUndoManager = () => {
|
|
|
850
850
|
...has(i, "_name") && { _name: i._name },
|
|
851
851
|
...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
|
|
852
852
|
};
|
|
853
|
-
let
|
|
854
|
-
return d && (
|
|
853
|
+
let h, m;
|
|
854
|
+
return d && (h = find(o, { _id: d }), g._parent = d, m = d), !canAcceptChildBlock(h == null ? void 0 : h._type, g._type) && h && (g._parent = h._parent, m = h._parent), n([g], m, c), r([g._id]), g;
|
|
855
855
|
},
|
|
856
856
|
[n, a, o, r]
|
|
857
857
|
), addPredefinedBlock: a };
|
|
@@ -2297,8 +2297,8 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2297
2297
|
return isEmpty(d) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...d });
|
|
2298
2298
|
})
|
|
2299
2299
|
), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
|
|
2300
|
-
const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), d = useUpdateMultipleBlocksProps(), [c] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u,
|
|
2301
|
-
const x = cloneDeep(
|
|
2300
|
+
const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), d = useUpdateMultipleBlocksProps(), [c] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, h = (m, f) => {
|
|
2301
|
+
const x = cloneDeep(f.find((y) => y._id === m));
|
|
2302
2302
|
for (const y in x) {
|
|
2303
2303
|
const b = x[y];
|
|
2304
2304
|
if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
|
|
@@ -2311,11 +2311,11 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2311
2311
|
};
|
|
2312
2312
|
return {
|
|
2313
2313
|
askAi: useCallback(
|
|
2314
|
-
async (m,
|
|
2314
|
+
async (m, f, x, y) => {
|
|
2315
2315
|
if (l) {
|
|
2316
2316
|
r(!0), a(null);
|
|
2317
2317
|
try {
|
|
2318
|
-
const b = p === u ? "" : p, v = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(
|
|
2318
|
+
const b = p === u ? "" : p, v = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, c)), p) : [h(f, c)], w = await l(m, addLangToPrompt(x, g, m), v, b), { blocks: A, error: E } = w;
|
|
2319
2319
|
if (E) {
|
|
2320
2320
|
a(E);
|
|
2321
2321
|
return;
|
|
@@ -2359,7 +2359,7 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2359
2359
|
},
|
|
2360
2360
|
[o]
|
|
2361
2361
|
);
|
|
2362
|
-
}, partialBlocksStoreAtom = atom({}), partialBlocksLoadingStateAtom = atom({}),
|
|
2362
|
+
}, partialBlocksStoreAtom = atom({}), partialBlocksLoadingStateAtom = atom({}), usePartialBlocksStore = () => {
|
|
2363
2363
|
const [o, r] = useAtom$1(partialBlocksStoreAtom), n = useCallback((l) => get(o, l, []), [o]), a = useCallback(() => r({}), [r]);
|
|
2364
2364
|
return { getPartailBlocks: n, reset: a };
|
|
2365
2365
|
}, useWatchPartailBlocks = () => {
|
|
@@ -2400,7 +2400,7 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2400
2400
|
c();
|
|
2401
2401
|
}, []), { data: l, isLoading: o, refetch: c, error: n };
|
|
2402
2402
|
}, useBuilderReset = () => {
|
|
2403
|
-
const { clear: o } = useUndoManager(), [, r] = useSelectedBlockIds(), { clearHighlight: n } = useBlockHighlight(), [, a] = useSelectedStylingBlocks(), [, l] = useAtom$1(aiAssistantActiveAtom), { reset: i } =
|
|
2403
|
+
const { clear: o } = useUndoManager(), [, r] = useSelectedBlockIds(), { clearHighlight: n } = useBlockHighlight(), [, a] = useSelectedStylingBlocks(), [, l] = useAtom$1(aiAssistantActiveAtom), { reset: i } = usePartialBlocksStore(), { setSaveState: d } = useSavePage();
|
|
2404
2404
|
return () => {
|
|
2405
2405
|
r([]), a([]), n(), o(), l(!1), i(), d("SAVED");
|
|
2406
2406
|
};
|
|
@@ -2412,14 +2412,44 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2412
2412
|
[r, n]
|
|
2413
2413
|
);
|
|
2414
2414
|
return [o, a];
|
|
2415
|
-
}, copiedBlockIdsAtom = atom([]),
|
|
2416
|
-
const [o, r] = useAtom$1(copiedBlockIdsAtom),
|
|
2417
|
-
|
|
2418
|
-
|
|
2415
|
+
}, copiedBlockIdsAtom = atom([]), useCopyBlocks = () => {
|
|
2416
|
+
const [o] = useBlocksStore(), [r, n] = useAtom$1(copiedBlockIdsAtom), a = useSetAtom$1(cutBlockIdsAtom), { getPartailBlocks: l } = usePartialBlocksStore(), i = useCallback(
|
|
2417
|
+
(c) => c.some((p) => getDuplicatedBlocks(o, p, null).some((g) => g._type === "PartialBlock" || g._type === "GlobalBlock")),
|
|
2418
|
+
[o]
|
|
2419
|
+
), d = useCallback(
|
|
2420
|
+
async (c, p = !1) => {
|
|
2421
|
+
try {
|
|
2422
|
+
n(c), a([]);
|
|
2423
|
+
const u = {
|
|
2424
|
+
_chai_copied_blocks: c.flatMap((g) => {
|
|
2425
|
+
const h = getDuplicatedBlocks(o, g, null);
|
|
2426
|
+
if (!p)
|
|
2427
|
+
return h;
|
|
2428
|
+
let m = [];
|
|
2429
|
+
for (const f of h)
|
|
2430
|
+
if (f._type === "PartialBlock" || f._type === "GlobalBlock") {
|
|
2431
|
+
const x = l(f.partialBlockId);
|
|
2432
|
+
set(x, "0._parent", f._parent), m = [...m, ...x];
|
|
2433
|
+
} else
|
|
2434
|
+
m.push(f);
|
|
2435
|
+
return m;
|
|
2436
|
+
})
|
|
2437
|
+
};
|
|
2438
|
+
if (!navigator.clipboard) {
|
|
2439
|
+
toast.error("Clipboard not available.");
|
|
2440
|
+
return;
|
|
2441
|
+
}
|
|
2442
|
+
toast.promise(navigator.clipboard.writeText(JSON.stringify(u)), {
|
|
2443
|
+
success: "Blocks copied successfully",
|
|
2444
|
+
error: "Failed to copy blocks to clipboard"
|
|
2445
|
+
});
|
|
2446
|
+
} catch (u) {
|
|
2447
|
+
toast.error("Failed to copy blocks to clipboard"), console.error("Failed to copy blocks to clipboard:", u);
|
|
2448
|
+
}
|
|
2419
2449
|
},
|
|
2420
|
-
[
|
|
2450
|
+
[n, a]
|
|
2421
2451
|
);
|
|
2422
|
-
return [
|
|
2452
|
+
return [r, d, i];
|
|
2423
2453
|
}, useCopyToClipboard = () => {
|
|
2424
2454
|
const [o, r] = useState(null), n = useCallback(async (a) => {
|
|
2425
2455
|
if (!(navigator != null && navigator.clipboard))
|
|
@@ -2445,8 +2475,8 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2445
2475
|
const g = filter(
|
|
2446
2476
|
o,
|
|
2447
2477
|
(m) => isString(l) ? m._parent === l : !m._parent
|
|
2448
|
-
).indexOf(c) + 1,
|
|
2449
|
-
n(
|
|
2478
|
+
).indexOf(c) + 1, h = getDuplicatedBlocks(o, d, l);
|
|
2479
|
+
n(h, l, g), i.push(get(h, "0._id", ""));
|
|
2450
2480
|
}), r(i);
|
|
2451
2481
|
},
|
|
2452
2482
|
[o, r]
|
|
@@ -2509,25 +2539,64 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2509
2539
|
[r, o]
|
|
2510
2540
|
);
|
|
2511
2541
|
}, usePasteBlocks = () => {
|
|
2512
|
-
const [o, r] = useCutBlockIds(),
|
|
2542
|
+
const [o, r] = useCutBlockIds(), n = useMoveCutBlocks(), { addPredefinedBlock: a } = useAddBlock(), l = useCanPaste();
|
|
2513
2543
|
return {
|
|
2514
2544
|
canPaste: useCallback(
|
|
2515
|
-
async (
|
|
2516
|
-
|
|
2545
|
+
async (d) => {
|
|
2546
|
+
if (o.length > 0)
|
|
2547
|
+
return l(o, d);
|
|
2548
|
+
try {
|
|
2549
|
+
const c = await navigator.clipboard.readText();
|
|
2550
|
+
if (c) {
|
|
2551
|
+
const p = JSON.parse(c);
|
|
2552
|
+
return has(p, "_chai_copied_blocks");
|
|
2553
|
+
}
|
|
2554
|
+
} catch {
|
|
2555
|
+
return !1;
|
|
2556
|
+
}
|
|
2557
|
+
return !1;
|
|
2558
|
+
},
|
|
2559
|
+
[l, o]
|
|
2517
2560
|
),
|
|
2518
2561
|
pasteBlocks: useCallback(
|
|
2519
|
-
async (
|
|
2520
|
-
const
|
|
2521
|
-
if (!
|
|
2522
|
-
|
|
2562
|
+
async (d) => {
|
|
2563
|
+
const c = Array.isArray(d) ? d[0] : d;
|
|
2564
|
+
if (!(navigator != null && navigator.permissions)) {
|
|
2565
|
+
toast.error("Cannot check clipboard permissions.");
|
|
2566
|
+
return;
|
|
2567
|
+
}
|
|
2568
|
+
try {
|
|
2569
|
+
if ((await navigator.permissions.query({ name: "clipboard-read" })).state === "denied") {
|
|
2570
|
+
toast.error("Clipboard paste permission denied. Please allow clipboard access.");
|
|
2571
|
+
return;
|
|
2572
|
+
}
|
|
2573
|
+
} catch {
|
|
2574
|
+
toast.error("Failed to check clipboard permissions. Please allow clipboard access.");
|
|
2523
2575
|
return;
|
|
2524
2576
|
}
|
|
2525
|
-
if (!isEmpty(
|
|
2526
|
-
|
|
2577
|
+
if (!isEmpty(o)) {
|
|
2578
|
+
n(o, d), r([]), await navigator.clipboard.writeText("");
|
|
2527
2579
|
return;
|
|
2528
2580
|
}
|
|
2581
|
+
toast.promise(
|
|
2582
|
+
async () => {
|
|
2583
|
+
const p = await navigator.clipboard.readText();
|
|
2584
|
+
if (p) {
|
|
2585
|
+
const u = JSON.parse(p);
|
|
2586
|
+
if (has(u, "_chai_copied_blocks"))
|
|
2587
|
+
a(u._chai_copied_blocks, c === "root" ? null : c);
|
|
2588
|
+
else
|
|
2589
|
+
throw new Error("Nothing to paste");
|
|
2590
|
+
} else
|
|
2591
|
+
throw new Error("Nothing to paste");
|
|
2592
|
+
},
|
|
2593
|
+
{
|
|
2594
|
+
success: () => "Blocks pasted successfully",
|
|
2595
|
+
error: () => "Nothing to paste"
|
|
2596
|
+
}
|
|
2597
|
+
);
|
|
2529
2598
|
},
|
|
2530
|
-
[o,
|
|
2599
|
+
[o, n, r]
|
|
2531
2600
|
)
|
|
2532
2601
|
};
|
|
2533
2602
|
}, previewModeAtom = atom(!1), usePreviewMode = () => {
|
|
@@ -2544,14 +2613,14 @@ const getBlockWithChildren = (o, r) => {
|
|
|
2544
2613
|
return map(i, (d) => {
|
|
2545
2614
|
const c = o(d), p = a;
|
|
2546
2615
|
let { classes: u, baseClasses: g } = getSplitChaiClasses(get(c, l.prop, `${STYLES_KEY},`));
|
|
2547
|
-
return each(p, (
|
|
2548
|
-
const m =
|
|
2549
|
-
u = u.replace(
|
|
2550
|
-
const x = first(
|
|
2551
|
-
includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(
|
|
2552
|
-
}), each(p, (
|
|
2553
|
-
const m =
|
|
2554
|
-
g = g.replace(
|
|
2616
|
+
return each(p, (h) => {
|
|
2617
|
+
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
|
|
2618
|
+
u = u.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
2619
|
+
const x = first(h.split(":"));
|
|
2620
|
+
includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(h.split(":").pop().trim());
|
|
2621
|
+
}), each(p, (h) => {
|
|
2622
|
+
const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
|
|
2623
|
+
g = g.replace(f, " ").replace(/\s+/g, " ").trim();
|
|
2555
2624
|
}), {
|
|
2556
2625
|
ids: [c._id],
|
|
2557
2626
|
props: {
|
|
@@ -2654,21 +2723,21 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2654
2723
|
return "VERTICAL";
|
|
2655
2724
|
}
|
|
2656
2725
|
}, isDisabledControl = (o, r, n) => !!(o && (n === "UP" || n === "LEFT") || r && (n === "DOWN" || n === "RIGHT")), useBlockController = (o, r) => {
|
|
2657
|
-
const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), d = get(o, "_parent"), c = filter(n, (x) => d ? get(x, "_parent") === d : !get(x, "_parent")), p = (c == null ? void 0 : c.length) <= 1, u = findIndex(c, { _id: i }), g = u <= 0,
|
|
2726
|
+
const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), d = get(o, "_parent"), c = filter(n, (x) => d ? get(x, "_parent") === d : !get(x, "_parent")), p = (c == null ? void 0 : c.length) <= 1, u = findIndex(c, { _id: i }), g = u <= 0, h = u + 1 === (c == null ? void 0 : c.length), m = getParentBlockOrientation(d, i, a), f = useCallback(
|
|
2658
2727
|
(x) => {
|
|
2659
|
-
isDisabledControl(g,
|
|
2728
|
+
isDisabledControl(g, h, x) || p || (x === "UP" || x === "LEFT" ? l([i], d || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], d || null, u + 2), r());
|
|
2660
2729
|
},
|
|
2661
|
-
[g,
|
|
2730
|
+
[g, h, p, u, i, d, r]
|
|
2662
2731
|
);
|
|
2663
2732
|
return useHotkeys(
|
|
2664
2733
|
"shift+up, shift+down, shift+left, shift+right",
|
|
2665
2734
|
({ key: x }) => {
|
|
2666
2735
|
var y;
|
|
2667
|
-
|
|
2736
|
+
f((y = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : y.toUpperCase());
|
|
2668
2737
|
},
|
|
2669
2738
|
{ document: a == null ? void 0 : a.contentDocument },
|
|
2670
|
-
[
|
|
2671
|
-
), { isOnlyChild: p, isFirstBlock: g, isLastBlock:
|
|
2739
|
+
[f]
|
|
2740
|
+
), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock: f, orientation: m };
|
|
2672
2741
|
}, BlockController = ({ block: o, updateFloatingBar: r }) => {
|
|
2673
2742
|
const { isOnlyChild: n, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: d } = useBlockController(
|
|
2674
2743
|
o,
|
|
@@ -2705,7 +2774,7 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2705
2774
|
}
|
|
2706
2775
|
);
|
|
2707
2776
|
}, BlockFloatingSelector = ({ selectedBlockElement: o, block: r }) => {
|
|
2708
|
-
const n = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, d] = useSelectedStylingBlocks(), { hasPermission: c } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: g, refs:
|
|
2777
|
+
const n = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, d] = useSelectedStylingBlocks(), { hasPermission: c } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: g, refs: h, update: m } = useFloating({
|
|
2709
2778
|
placement: "top-start",
|
|
2710
2779
|
middleware: [shift(), flip()],
|
|
2711
2780
|
elements: {
|
|
@@ -2713,13 +2782,13 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2713
2782
|
}
|
|
2714
2783
|
});
|
|
2715
2784
|
useResizeObserver(o, () => m(), o !== null), useResizeObserver(u == null ? void 0 : u.body, () => m(), (u == null ? void 0 : u.body) !== null);
|
|
2716
|
-
const
|
|
2785
|
+
const f = get(r, "_parent", null), x = isEmpty(get(r, "_name", "")) ? get(r, "_type", "") : get(r, "_name", "");
|
|
2717
2786
|
return !o || !r || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
2718
2787
|
"div",
|
|
2719
2788
|
{
|
|
2720
2789
|
role: "button",
|
|
2721
2790
|
tabIndex: 0,
|
|
2722
|
-
ref:
|
|
2791
|
+
ref: h.setFloating,
|
|
2723
2792
|
style: g,
|
|
2724
2793
|
onClick: (y) => {
|
|
2725
2794
|
y.stopPropagation(), y.preventDefault();
|
|
@@ -2730,12 +2799,12 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
|
|
|
2730
2799
|
onKeyDown: (y) => y.stopPropagation(),
|
|
2731
2800
|
className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
|
|
2732
2801
|
children: [
|
|
2733
|
-
|
|
2802
|
+
f && /* @__PURE__ */ jsx(
|
|
2734
2803
|
ArrowUpIcon,
|
|
2735
2804
|
{
|
|
2736
2805
|
className: "hover:scale-105",
|
|
2737
2806
|
onClick: () => {
|
|
2738
|
-
d([]), l([
|
|
2807
|
+
d([]), l([f]);
|
|
2739
2808
|
}
|
|
2740
2809
|
}
|
|
2741
2810
|
),
|
|
@@ -2878,21 +2947,21 @@ z(Frame, "defaultProps", {
|
|
|
2878
2947
|
initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
|
|
2879
2948
|
});
|
|
2880
2949
|
const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: r })), useKeyEventWatcher = (o) => {
|
|
2881
|
-
const [r, n] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: d, redo: c } = useUndoManager(), [, p] = useCutBlockIds(), [, u] =
|
|
2950
|
+
const [r, n] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: d, redo: c } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: g, pasteBlocks: h } = usePasteBlocks(), m = o ? { document: o } : {};
|
|
2882
2951
|
useHotkeys("ctrl+z,command+z", () => d(), {}, [d]), useHotkeys("ctrl+y,command+y", () => c(), {}, [c]), useHotkeys("ctrl+x,command+x", () => p(r), {}, [r, p]), useHotkeys("ctrl+c,command+c", () => u(r), {}, [r, u]), useHotkeys(
|
|
2883
2952
|
"ctrl+v,command+v",
|
|
2884
2953
|
() => {
|
|
2885
|
-
g(r[0]) &&
|
|
2954
|
+
g(r[0]) && h(r);
|
|
2886
2955
|
},
|
|
2887
2956
|
{ ...m, preventDefault: !0 },
|
|
2888
|
-
[r, g,
|
|
2957
|
+
[r, g, h]
|
|
2889
2958
|
), useHotkeys("esc", () => n([]), m, [n]), useHotkeys("ctrl+d,command+d", () => i(r), { ...m, preventDefault: !0 }, [
|
|
2890
2959
|
r,
|
|
2891
2960
|
i
|
|
2892
2961
|
]), useHotkeys(
|
|
2893
2962
|
"del, backspace",
|
|
2894
|
-
(
|
|
2895
|
-
|
|
2963
|
+
(f) => {
|
|
2964
|
+
f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(r);
|
|
2896
2965
|
},
|
|
2897
2966
|
m,
|
|
2898
2967
|
[r, l]
|
|
@@ -2969,7 +3038,7 @@ function removeDataDrop() {
|
|
|
2969
3038
|
const useDnd = () => {
|
|
2970
3039
|
const { document: o } = useFrame(), [r, n] = useAtom$1(draggingFlagAtom), { addCoreBlock: a } = useAddBlock(), [, l] = useHighlightBlockId(), [, i] = useSelectedBlockIds(), { moveBlocks: d } = useBlocksStoreUndoableActions(), [c, p] = useAtom$1(draggedBlockAtom), [, u] = useAtom$1(dropTargetBlockIdAtom);
|
|
2971
3040
|
if (!useFeature("dnd")) return {};
|
|
2972
|
-
const
|
|
3041
|
+
const h = () => {
|
|
2973
3042
|
removePlaceholder(), n(!1), p(null), u(null), possiblePositions = [];
|
|
2974
3043
|
};
|
|
2975
3044
|
return iframeDocument = o, {
|
|
@@ -2979,25 +3048,25 @@ const useDnd = () => {
|
|
|
2979
3048
|
},
|
|
2980
3049
|
onDrop: (m) => {
|
|
2981
3050
|
var E;
|
|
2982
|
-
const
|
|
3051
|
+
const f = dropTarget, y = getOrientation(f) === "vertical" ? m.clientY + ((E = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : E.scrollY) : m.clientX;
|
|
2983
3052
|
dropIndex = calculateDropIndex(y, possiblePositions);
|
|
2984
|
-
const b = c, v =
|
|
3053
|
+
const b = c, v = f.getAttribute("data-block-id"), w = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
|
|
2985
3054
|
if ((b == null ? void 0 : b._id) === v || !w) {
|
|
2986
|
-
|
|
3055
|
+
h();
|
|
2987
3056
|
return;
|
|
2988
3057
|
}
|
|
2989
3058
|
if (!has(b, "_id")) {
|
|
2990
|
-
a(b, v === "canvas" ? null : v, dropIndex), setTimeout(
|
|
3059
|
+
a(b, v === "canvas" ? null : v, dropIndex), setTimeout(h, 300);
|
|
2991
3060
|
return;
|
|
2992
3061
|
}
|
|
2993
|
-
let A =
|
|
2994
|
-
A === null && (A = m.target.parentElement.getAttribute("data-block-id")), d([b._id], A === "canvas" ? null : A, dropIndex),
|
|
3062
|
+
let A = f.getAttribute("data-block-id");
|
|
3063
|
+
A === null && (A = m.target.parentElement.getAttribute("data-block-id")), d([b._id], A === "canvas" ? null : A, dropIndex), h(), setTimeout(removePlaceholder, 300);
|
|
2995
3064
|
},
|
|
2996
3065
|
onDragEnter: (m) => {
|
|
2997
|
-
const
|
|
3066
|
+
const f = m, x = f.target;
|
|
2998
3067
|
dropTarget = x;
|
|
2999
3068
|
const y = x.getAttribute("data-block-id"), b = x.getAttribute("data-dnd-dragged") !== "yes";
|
|
3000
|
-
u(y),
|
|
3069
|
+
u(y), f.stopPropagation(), f.preventDefault(), possiblePositions = [], b && calculatePossiblePositions(x), n(!0), l(""), i([]);
|
|
3001
3070
|
},
|
|
3002
3071
|
onDragLeave: (m) => {
|
|
3003
3072
|
m.target.getAttribute("data-block-id") === "canvas" && (u(null), n(!1), removePlaceholder(), possiblePositions = []);
|
|
@@ -3022,16 +3091,16 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3022
3091
|
const g = u.getAttribute("data-block-type");
|
|
3023
3092
|
if (!g || !n.includes(g))
|
|
3024
3093
|
return;
|
|
3025
|
-
const
|
|
3026
|
-
if (!
|
|
3027
|
-
o.on("update", ({ editor:
|
|
3028
|
-
console.log(
|
|
3094
|
+
const h = u.getAttribute("data-block-id");
|
|
3095
|
+
if (!h) return;
|
|
3096
|
+
o.on("update", ({ editor: f }) => {
|
|
3097
|
+
console.log(f.getHTML());
|
|
3029
3098
|
}), o.on("blur", () => {
|
|
3030
3099
|
console.log("blur");
|
|
3031
|
-
const
|
|
3032
|
-
a([
|
|
3033
|
-
}), i(
|
|
3034
|
-
const m = c(
|
|
3100
|
+
const f = o.getHTML();
|
|
3101
|
+
a([h], { content: f }), r.style.display = "none", u.style.visibility = "visible";
|
|
3102
|
+
}), i(h);
|
|
3103
|
+
const m = c(h).content;
|
|
3035
3104
|
o.commands.setContent(m), r.style.display = "block", u.style.visibility = "hidden", r.style.position = "absolute", r.style.top = `${u.offsetTop}px`, r.style.left = `${u.offsetLeft}px`, r.style.width = `${u.offsetWidth}px`, r.style.height = `${u.offsetHeight}px`, r.classList.add(...u.classList);
|
|
3036
3105
|
},
|
|
3037
3106
|
[l, d, c, i, a, o, r]
|
|
@@ -3071,11 +3140,11 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3071
3140
|
setTimeout(() => {
|
|
3072
3141
|
if (!isEmpty(a))
|
|
3073
3142
|
return;
|
|
3074
|
-
const
|
|
3075
|
-
if (
|
|
3076
|
-
const x =
|
|
3143
|
+
const f = getElementByDataBlockId(r, first(n));
|
|
3144
|
+
if (f) {
|
|
3145
|
+
const x = f.getAttribute("data-style-prop");
|
|
3077
3146
|
if (x) {
|
|
3078
|
-
const y =
|
|
3147
|
+
const y = f.getAttribute("data-style-id"), b = f.getAttribute("data-block-parent");
|
|
3079
3148
|
l([{ id: y, prop: x, blockId: b }]);
|
|
3080
3149
|
}
|
|
3081
3150
|
}
|
|
@@ -3083,7 +3152,7 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3083
3152
|
}, [r, n, l, a]);
|
|
3084
3153
|
const d = useEditor({
|
|
3085
3154
|
extensions: [StarterKit]
|
|
3086
|
-
}), c = useRef(null), p = useHandleCanvasDblClick(d, c.current), u = useHandleCanvasClick(), g = useHandleMouseMove(),
|
|
3155
|
+
}), c = useRef(null), p = useHandleCanvasDblClick(d, c.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), h = useHandleMouseLeave(), m = useDnd();
|
|
3087
3156
|
return /* @__PURE__ */ jsx(
|
|
3088
3157
|
"div",
|
|
3089
3158
|
{
|
|
@@ -3092,7 +3161,7 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3092
3161
|
onClick: u,
|
|
3093
3162
|
onDoubleClick: p,
|
|
3094
3163
|
onMouseMove: g,
|
|
3095
|
-
onMouseLeave:
|
|
3164
|
+
onMouseLeave: h,
|
|
3096
3165
|
...omit(m, "isDragging"),
|
|
3097
3166
|
className: "relative h-full max-w-full p-px " + (m.isDragging ? "dragging" : ""),
|
|
3098
3167
|
children: o
|
|
@@ -3104,7 +3173,7 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3104
3173
|
}, HeadTags = () => {
|
|
3105
3174
|
const [o] = useTheme(), r = useThemeOptions(), [n] = useSelectedBlockIds(), [a] = useDarkMode(), [l] = useSelectedStylingBlocks(), [i] = useAtom$1(draggedBlockAtom), [d] = useAtom$1(dropTargetBlockIdAtom), { document: c, window: p } = useFrame(), [u] = useState(c == null ? void 0 : c.getElementById("highlighted-block")), [g] = useState(
|
|
3106
3175
|
c == null ? void 0 : c.getElementById("selected-block")
|
|
3107
|
-
), [
|
|
3176
|
+
), [h] = useState(
|
|
3108
3177
|
c == null ? void 0 : c.getElementById("selected-styling-block")
|
|
3109
3178
|
), [m] = useState(
|
|
3110
3179
|
c == null ? void 0 : c.getElementById("dragged-block")
|
|
@@ -3112,7 +3181,7 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3112
3181
|
useEffect(() => {
|
|
3113
3182
|
a ? c == null || c.documentElement.classList.add("dark") : c == null || c.documentElement.classList.remove("dark");
|
|
3114
3183
|
}, [a, c]);
|
|
3115
|
-
const
|
|
3184
|
+
const f = useRegisteredFonts();
|
|
3116
3185
|
useEffect(() => {
|
|
3117
3186
|
!p || !p.tailwind || (p.tailwind.config = {
|
|
3118
3187
|
darkMode: "class",
|
|
@@ -3156,10 +3225,10 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3156
3225
|
}, [i, m]), useEffect(() => {
|
|
3157
3226
|
u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
|
|
3158
3227
|
}, [u]), useEffect(() => {
|
|
3159
|
-
|
|
3228
|
+
h && (h.textContent = `${map(l, ({ id: v }) => `[data-style-id="${v}"]`).join(",")}{
|
|
3160
3229
|
outline: 1px solid orange !important; outline-offset: -1px;
|
|
3161
3230
|
}`);
|
|
3162
|
-
}, [l,
|
|
3231
|
+
}, [l, h]), useEffect(() => {
|
|
3163
3232
|
c.querySelector("#drop-target-block").innerHTML = d ? `[data-block-id="${d}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
|
|
3164
3233
|
}, [d, c]);
|
|
3165
3234
|
const x = useMemo(() => {
|
|
@@ -3167,8 +3236,8 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3167
3236
|
heading: get(o, "fontFamily.heading"),
|
|
3168
3237
|
body: get(o, "fontFamily.body")
|
|
3169
3238
|
};
|
|
3170
|
-
return
|
|
3171
|
-
}, [o == null ? void 0 : o.fontFamily,
|
|
3239
|
+
return f.filter((A) => A.family === v || A.family === w);
|
|
3240
|
+
}, [o == null ? void 0 : o.fontFamily, f]), y = useMemo(() => getThemeFontsLinkMarkup(filter(x, (v) => has(v, "url"))), [x]), b = useMemo(
|
|
3172
3241
|
() => getThemeCustomFontFace(filter(x, (v) => has(v, "src"))),
|
|
3173
3242
|
[x]
|
|
3174
3243
|
);
|
|
@@ -3212,9 +3281,9 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3212
3281
|
blockAtom: o,
|
|
3213
3282
|
children: r
|
|
3214
3283
|
}) => {
|
|
3215
|
-
const [n] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(n._type), [n._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), d = useBlockRuntimeProps(), c = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), { index:
|
|
3216
|
-
() => u ? applyBinding(applyLanguage(n, l, a), c, { index:
|
|
3217
|
-
[n, l, a, c, u,
|
|
3284
|
+
const [n] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(n._type), [n._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), d = useBlockRuntimeProps(), c = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), { index: h, key: m } = useContext(RepeaterContext), f = useMemo(
|
|
3285
|
+
() => u ? applyBinding(applyLanguage(n, l, a), c, { index: h, key: m }) : applyLanguage(n, l, a),
|
|
3286
|
+
[n, l, a, c, u, h, m]
|
|
3218
3287
|
), x = useMemo(() => getBlockTagAttributes(n), [n, getBlockTagAttributes]), y = useMemo(
|
|
3219
3288
|
() => d(n._id, getBlockRuntimeProps(n._type)),
|
|
3220
3289
|
[n._id, n._type, d, getBlockRuntimeProps]
|
|
@@ -3226,7 +3295,7 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3226
3295
|
},
|
|
3227
3296
|
inBuilder: !0,
|
|
3228
3297
|
lang: l || i,
|
|
3229
|
-
...
|
|
3298
|
+
...f,
|
|
3230
3299
|
...x,
|
|
3231
3300
|
...y,
|
|
3232
3301
|
...b
|
|
@@ -3236,7 +3305,7 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3236
3305
|
n._type,
|
|
3237
3306
|
l,
|
|
3238
3307
|
i,
|
|
3239
|
-
|
|
3308
|
+
f,
|
|
3240
3309
|
x,
|
|
3241
3310
|
y,
|
|
3242
3311
|
b
|
|
@@ -3247,16 +3316,16 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3247
3316
|
children: r({
|
|
3248
3317
|
_id: n._id,
|
|
3249
3318
|
_type: n._type,
|
|
3250
|
-
...isArray(
|
|
3251
|
-
repeaterItems: applyLimit(
|
|
3252
|
-
repeaterItemsBinding:
|
|
3319
|
+
...isArray(f.repeaterItems) ? {
|
|
3320
|
+
repeaterItems: applyLimit(f.repeaterItems, n),
|
|
3321
|
+
repeaterItemsBinding: f.repeaterItemsBinding
|
|
3253
3322
|
} : {},
|
|
3254
3323
|
...n.partialBlockId ? { partialBlockId: n.partialBlockId } : "",
|
|
3255
3324
|
...n.globalBlock ? { partialBlockId: n.globalBlock } : ""
|
|
3256
3325
|
})
|
|
3257
3326
|
}) });
|
|
3258
3327
|
}, PartialBlocksRenderer = ({ partialBlockId: o }) => {
|
|
3259
|
-
const { getPartailBlocks: r } =
|
|
3328
|
+
const { getPartailBlocks: r } = usePartialBlocksStore(), n = useMemo(() => r(o), [r, o]), a = useMemo(() => splitAtom(atom(n)), [n]);
|
|
3260
3329
|
return isEmpty(n) ? null : /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: n });
|
|
3261
3330
|
}, BlocksRenderer = ({
|
|
3262
3331
|
blocks: o,
|
|
@@ -3272,7 +3341,7 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3272
3341
|
);
|
|
3273
3342
|
return map(l, (d) => {
|
|
3274
3343
|
const c = a(d._id);
|
|
3275
|
-
return c ? /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: c, children: ({ _id: p, _type: u, partialBlockId: g, repeaterItems:
|
|
3344
|
+
return c ? /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: c, children: ({ _id: p, _type: u, partialBlockId: g, repeaterItems: h, repeaterItemsBinding: m }) => u === "Repeater" ? isArray(h) && h.map((f, x) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: x, key: m }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: d._id }) })) : u === "GlobalBlock" || u === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: g }) }) : i(p) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: d._id }) : null }, d._id) : null;
|
|
3276
3345
|
});
|
|
3277
3346
|
}, PageBlocksRenderer = () => {
|
|
3278
3347
|
const [o] = useBlocksStore();
|
|
@@ -3286,10 +3355,10 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3286
3355
|
if (c < r) {
|
|
3287
3356
|
const u = parseFloat((c / r).toFixed(2).toString());
|
|
3288
3357
|
let g = {};
|
|
3289
|
-
const
|
|
3358
|
+
const h = p * u, m = c * u;
|
|
3290
3359
|
p && (g = {
|
|
3291
3360
|
// Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
|
|
3292
|
-
height: 100 + (p -
|
|
3361
|
+
height: 100 + (p - h) / h * 100 + "%",
|
|
3293
3362
|
width: 100 + (c - m) / m * 100 + "%"
|
|
3294
3363
|
}), i({
|
|
3295
3364
|
position: "relative",
|
|
@@ -3307,7 +3376,7 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3307
3376
|
d();
|
|
3308
3377
|
}, [r, o, n, d]), l;
|
|
3309
3378
|
}, getElementByStyleId = (o, r) => o.querySelector(`[data-style-id="${r}"]`), StaticCanvas = () => {
|
|
3310
|
-
const [o] = useAtom$1(networkModeAtom), [r] = useCanvasDisplayWidth(), [, n] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), d = useRef(null), [c, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(c), [g,
|
|
3379
|
+
const [o] = useAtom$1(networkModeAtom), [r] = useCanvasDisplayWidth(), [, n] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), d = useRef(null), [c, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(c), [g, h] = useState([]), [, m] = useState([]), [, f] = useAtom$1(canvasIframeAtom), [x, y] = useSelectedStylingBlocks(), b = useBuilderProp("loading", !1), v = useBuilderProp("htmlDir", "ltr"), w = (_) => {
|
|
3311
3380
|
p((S) => ({ ...S, width: _ }));
|
|
3312
3381
|
};
|
|
3313
3382
|
useEffect(() => {
|
|
@@ -3323,7 +3392,7 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3323
3392
|
var _, S;
|
|
3324
3393
|
if (a != null && a._id && a.type !== "Multiple" && i.current) {
|
|
3325
3394
|
const B = getElementByDataBlockId(i.current.contentDocument, a._id);
|
|
3326
|
-
B && (A(B) || (S = (_ = i.current) == null ? void 0 : _.contentWindow) == null || S.scrollTo({ top: B.offsetTop, behavior: "smooth" }),
|
|
3395
|
+
B && (A(B) || (S = (_ = i.current) == null ? void 0 : _.contentWindow) == null || S.scrollTo({ top: B.offsetTop, behavior: "smooth" }), h([B]));
|
|
3327
3396
|
}
|
|
3328
3397
|
}, [a == null ? void 0 : a._id, a == null ? void 0 : a.type]), useEffect(() => {
|
|
3329
3398
|
if (!isEmpty(x) && i.current) {
|
|
@@ -3351,7 +3420,7 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3351
3420
|
children: /* @__PURE__ */ jsxs(
|
|
3352
3421
|
ChaiFrame,
|
|
3353
3422
|
{
|
|
3354
|
-
contentDidMount: () =>
|
|
3423
|
+
contentDidMount: () => f(i.current),
|
|
3355
3424
|
ref: i,
|
|
3356
3425
|
id: "canvas-iframe",
|
|
3357
3426
|
style: { ...u, ...isEmpty(u) ? { width: `${r}px` } : {} },
|
|
@@ -3389,7 +3458,7 @@ const useHandleCanvasDblClick = (o, r) => {
|
|
|
3389
3458
|
}, FallbackError = () => /* @__PURE__ */ jsx("div", { className: "h-full w-full rounded-md bg-red-200 p-4 text-red-500", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center", children: [
|
|
3390
3459
|
/* @__PURE__ */ jsx("p", { className: "font-semibold", children: "Oops! Something went wrong." }),
|
|
3391
3460
|
/* @__PURE__ */ jsx("p", { children: "Please try again." })
|
|
3392
|
-
] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-
|
|
3461
|
+
] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-QVi542cK.js")), CanvasArea = () => {
|
|
3393
3462
|
const [o] = useCodeEditor(), r = useBuilderProp("onError", noop);
|
|
3394
3463
|
return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2", children: [
|
|
3395
3464
|
/* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
|
|
@@ -3402,22 +3471,22 @@ function NestedPathSelector({ data: o, onSelect: r, dataType: n = "value" }) {
|
|
|
3402
3471
|
useEffect(() => {
|
|
3403
3472
|
a || d([]), p(o);
|
|
3404
3473
|
}, [a, o]);
|
|
3405
|
-
const u = (
|
|
3406
|
-
(
|
|
3474
|
+
const u = (f) => Array.isArray(f) ? "array" : typeof f == "object" && f !== null ? "object" : "value", g = React.useCallback(
|
|
3475
|
+
(f) => {
|
|
3407
3476
|
const x = (y) => n === "value" ? y === "value" || y === "object" : n === "array" ? y === "array" : y === n;
|
|
3408
|
-
|
|
3477
|
+
f.type === "object" ? (d((y) => [...y, f.key]), p(f.value)) : x(f.type) && (r([...i, f.key].join("."), n), l(!1));
|
|
3409
3478
|
},
|
|
3410
3479
|
[i, r, n]
|
|
3411
|
-
),
|
|
3480
|
+
), h = React.useCallback(() => {
|
|
3412
3481
|
if (i.length > 0) {
|
|
3413
|
-
const
|
|
3414
|
-
d(
|
|
3482
|
+
const f = i.slice(0, -1);
|
|
3483
|
+
d(f), p(f.reduce((x, y) => x[y], o));
|
|
3415
3484
|
}
|
|
3416
|
-
}, [i, o]), m = React.useMemo(() => Object.entries(c).map(([
|
|
3417
|
-
key:
|
|
3485
|
+
}, [i, o]), m = React.useMemo(() => Object.entries(c).map(([f, x]) => ({
|
|
3486
|
+
key: f,
|
|
3418
3487
|
value: x,
|
|
3419
3488
|
type: u(x)
|
|
3420
|
-
})).filter((
|
|
3489
|
+
})).filter((f) => n === "value" ? f.type === "value" || f.type === "object" : n === "array" ? f.type === "array" || f.type === "object" : n === "object" ? f.type === "object" : !0), [c, n]);
|
|
3421
3490
|
return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
|
|
3422
3491
|
/* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
3423
3492
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
@@ -3438,40 +3507,40 @@ function NestedPathSelector({ data: o, onSelect: r, dataType: n = "value" }) {
|
|
|
3438
3507
|
/* @__PURE__ */ jsxs(CommandList, { children: [
|
|
3439
3508
|
/* @__PURE__ */ jsx(CommandEmpty, { children: "No option found." }),
|
|
3440
3509
|
/* @__PURE__ */ jsxs(CommandGroup, { children: [
|
|
3441
|
-
i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect:
|
|
3510
|
+
i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: h, className: "flex items-center text-sm", children: [
|
|
3442
3511
|
/* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
|
|
3443
3512
|
"Back"
|
|
3444
3513
|
] }),
|
|
3445
|
-
m.map((
|
|
3514
|
+
m.map((f) => /* @__PURE__ */ jsxs(
|
|
3446
3515
|
CommandItem,
|
|
3447
3516
|
{
|
|
3448
|
-
value:
|
|
3517
|
+
value: f.key,
|
|
3449
3518
|
disabled: !1,
|
|
3450
|
-
onSelect: () => g(
|
|
3519
|
+
onSelect: () => g(f),
|
|
3451
3520
|
className: "flex items-center justify-between",
|
|
3452
3521
|
children: [
|
|
3453
3522
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-x-2", children: [
|
|
3454
|
-
startsWith(
|
|
3455
|
-
startsWith(
|
|
3523
|
+
startsWith(f.key, "#") ? /* @__PURE__ */ jsx(LoopIcon, {}) : null,
|
|
3524
|
+
startsWith(f.key, "#") ? "Repeater Data" : f.key
|
|
3456
3525
|
] }),
|
|
3457
3526
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
3458
|
-
n === "object" &&
|
|
3527
|
+
n === "object" && f.type === "object" && /* @__PURE__ */ jsx(
|
|
3459
3528
|
Button,
|
|
3460
3529
|
{
|
|
3461
3530
|
size: "sm",
|
|
3462
3531
|
variant: "ghost",
|
|
3463
3532
|
className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
|
|
3464
3533
|
onClick: (x) => {
|
|
3465
|
-
x.stopPropagation(), r([...i,
|
|
3534
|
+
x.stopPropagation(), r([...i, f.key].join("."), n), l(!1);
|
|
3466
3535
|
},
|
|
3467
3536
|
children: "Select"
|
|
3468
3537
|
}
|
|
3469
3538
|
),
|
|
3470
|
-
|
|
3539
|
+
f.type === "object" && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 opacity-50" }) })
|
|
3471
3540
|
] })
|
|
3472
3541
|
]
|
|
3473
3542
|
},
|
|
3474
|
-
|
|
3543
|
+
f.key
|
|
3475
3544
|
))
|
|
3476
3545
|
] })
|
|
3477
3546
|
] })
|
|
@@ -3490,16 +3559,16 @@ const JSONFormFieldTemplate = ({
|
|
|
3490
3559
|
required: p,
|
|
3491
3560
|
schema: u,
|
|
3492
3561
|
formData: g,
|
|
3493
|
-
onChange:
|
|
3562
|
+
onChange: h
|
|
3494
3563
|
}) => {
|
|
3495
|
-
const { selectedLang: m, fallbackLang:
|
|
3564
|
+
const { selectedLang: m, fallbackLang: f, languages: x } = useLanguages(), y = isEmpty(x) ? "" : isEmpty(m) ? f : m, b = get(LANGUAGES, y, y), v = usePageExternalData(), w = useSelectedBlock(), A = useRegisteredChaiBlocks(), E = get(A, [w == null ? void 0 : w._type, "i18nProps"], []) || [], [_, S] = useState(null), B = useSelectedBlockHierarchy(), N = useMemo(() => B.length === 1 ? "" : `#${get(
|
|
3496
3565
|
B.find((L) => L._type === "Repeater"),
|
|
3497
3566
|
"repeaterItems",
|
|
3498
3567
|
""
|
|
3499
3568
|
).replace(/\{\{(.*)\}\}/g, "$1")}`, [B]), C = useMemo(() => first(get(v, N.replace("#", ""), [])), [N, v]), k = useCallback(
|
|
3500
3569
|
(I, P) => {
|
|
3501
3570
|
if (I = isEmpty(N) ? I : I.replace(`${N}.`, "$index."), P === "array" || P === "object") {
|
|
3502
|
-
|
|
3571
|
+
h(`{{${I}}}`, {}, o);
|
|
3503
3572
|
return;
|
|
3504
3573
|
}
|
|
3505
3574
|
const L = (D) => /[.,!?;:]/.test(D), O = (D, M, H) => {
|
|
@@ -3528,21 +3597,21 @@ const JSONFormFieldTemplate = ({
|
|
|
3528
3597
|
let q = "";
|
|
3529
3598
|
G && G !== " " && !L(G) && (q = " "), D.chain().insertContent(Y + M + q).run();
|
|
3530
3599
|
}
|
|
3531
|
-
setTimeout(() =>
|
|
3600
|
+
setTimeout(() => h(D.getHTML(), {}, o), 100);
|
|
3532
3601
|
return;
|
|
3533
3602
|
}
|
|
3534
3603
|
} else {
|
|
3535
3604
|
const D = $, M = D.selectionStart || 0, H = D.value || "", F = D.selectionEnd || M;
|
|
3536
3605
|
if (F > M) {
|
|
3537
3606
|
const G = `{{${I}}}`, { text: Y } = O(H, M, G), q = H.slice(0, M) + Y + H.slice(F);
|
|
3538
|
-
|
|
3607
|
+
h(q, {}, o);
|
|
3539
3608
|
return;
|
|
3540
3609
|
}
|
|
3541
3610
|
const U = `{{${I}}}`, { text: V } = O(H, M, U), K = H.slice(0, M) + V + H.slice(M);
|
|
3542
|
-
|
|
3611
|
+
h(K, {}, o);
|
|
3543
3612
|
}
|
|
3544
3613
|
},
|
|
3545
|
-
[o,
|
|
3614
|
+
[o, h, g, w == null ? void 0 : w._id, N]
|
|
3546
3615
|
);
|
|
3547
3616
|
if (c)
|
|
3548
3617
|
return null;
|
|
@@ -3660,8 +3729,8 @@ const JSONFormFieldTemplate = ({
|
|
|
3660
3729
|
/* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: a("Paste SVG code to use as an icon") })
|
|
3661
3730
|
] });
|
|
3662
3731
|
}, DefaultMediaManager = ({ close: o, onSelect: r, mode: n = "image" }) => {
|
|
3663
|
-
const [a, l] = useState(""), [i, d] = useState(!1), [c, p] = useState(!1), [u, g] = useState(null),
|
|
3664
|
-
if (!
|
|
3732
|
+
const [a, l] = useState(""), [i, d] = useState(!1), [c, p] = useState(!1), [u, g] = useState(null), h = async (f) => {
|
|
3733
|
+
if (!f.trim()) {
|
|
3665
3734
|
p(!1), g("Please enter a URL");
|
|
3666
3735
|
return;
|
|
3667
3736
|
}
|
|
@@ -3685,8 +3754,8 @@ const JSONFormFieldTemplate = ({
|
|
|
3685
3754
|
{
|
|
3686
3755
|
placeholder: m(`Enter ${n} URL`),
|
|
3687
3756
|
value: a,
|
|
3688
|
-
onChange: (
|
|
3689
|
-
|
|
3757
|
+
onChange: (f) => l(f.target.value),
|
|
3758
|
+
onKeyUp: () => h(a)
|
|
3690
3759
|
}
|
|
3691
3760
|
),
|
|
3692
3761
|
/* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
|
|
@@ -3694,7 +3763,7 @@ const JSONFormFieldTemplate = ({
|
|
|
3694
3763
|
/* @__PURE__ */ jsx(
|
|
3695
3764
|
Button,
|
|
3696
3765
|
{
|
|
3697
|
-
onClick: () => r({ url: a, width: 600, height: 400, description: "This is image description" }),
|
|
3766
|
+
onClick: () => r({ id: "dam-id", url: a, width: 600, height: 400, description: "This is image description" }),
|
|
3698
3767
|
disabled: !c || i,
|
|
3699
3768
|
children: m("Insert")
|
|
3700
3769
|
}
|
|
@@ -3707,37 +3776,56 @@ const JSONFormFieldTemplate = ({
|
|
|
3707
3776
|
}, registerChaiMediaManager = (o) => {
|
|
3708
3777
|
MEDIA_MANAGER.component = o;
|
|
3709
3778
|
}, useMediaManagerComponent = () => useMemo(() => MEDIA_MANAGER.component, []), MediaManagerModal = ({
|
|
3710
|
-
|
|
3711
|
-
|
|
3712
|
-
|
|
3779
|
+
assetId: o,
|
|
3780
|
+
children: r,
|
|
3781
|
+
onSelect: n,
|
|
3782
|
+
mode: a = "image"
|
|
3713
3783
|
}) => {
|
|
3714
|
-
const [
|
|
3715
|
-
return /* @__PURE__ */ jsxs(Dialog, { open:
|
|
3716
|
-
/* @__PURE__ */ jsx(DialogTrigger, { asChild: !0, children:
|
|
3717
|
-
/* @__PURE__ */ jsx(DialogContent, { className: "flex max-h-[90vh] max-w-7xl border-border md:w-fit", children: /* @__PURE__ */ jsx("div", { className: "h-full w-full", children:
|
|
3718
|
-
|
|
3719
|
-
}, mode:
|
|
3784
|
+
const [l, i] = useState(!1), d = useMediaManagerComponent();
|
|
3785
|
+
return /* @__PURE__ */ jsxs(Dialog, { open: l, onOpenChange: (p) => i(p), children: [
|
|
3786
|
+
/* @__PURE__ */ jsx(DialogTrigger, { asChild: !0, children: r }),
|
|
3787
|
+
/* @__PURE__ */ jsx(DialogContent, { className: "flex max-h-[90vh] max-w-7xl border-border md:w-fit", children: /* @__PURE__ */ jsx("div", { className: "h-full w-full", children: d ? /* @__PURE__ */ jsx(d, { close: () => i(!1), onSelect: (...p) => {
|
|
3788
|
+
n.call(void 0, ...p), i(!1);
|
|
3789
|
+
}, mode: a, assetId: o }) : null }) })
|
|
3720
3790
|
] });
|
|
3721
3791
|
};
|
|
3722
3792
|
MediaManagerModal.displayName = "MediaManagerModal";
|
|
3723
3793
|
const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
3724
|
-
const { t: l } = useTranslation(), i = useSelectedBlock(), d = useUpdateBlocksProps(), c = (
|
|
3725
|
-
const
|
|
3726
|
-
if (
|
|
3727
|
-
r(
|
|
3728
|
-
const
|
|
3729
|
-
|
|
3730
|
-
|
|
3731
|
-
|
|
3732
|
-
|
|
3733
|
-
|
|
3794
|
+
const { t: l } = useTranslation(), i = useSelectedBlock(), d = useUpdateBlocksProps(), c = (g) => {
|
|
3795
|
+
const h = isArray(g) ? first(g) : g;
|
|
3796
|
+
if (h) {
|
|
3797
|
+
r(h == null ? void 0 : h.url);
|
|
3798
|
+
const m = h == null ? void 0 : h.width, f = h == null ? void 0 : h.height;
|
|
3799
|
+
if (i != null && i._id) {
|
|
3800
|
+
const x = {
|
|
3801
|
+
...m && { width: m },
|
|
3802
|
+
...f && { height: f },
|
|
3803
|
+
...h.description && { alt: h.description },
|
|
3804
|
+
...h.id && { assetId: h.id }
|
|
3805
|
+
};
|
|
3806
|
+
if (isEmpty(x)) return;
|
|
3807
|
+
d([i._id], x);
|
|
3808
|
+
}
|
|
3734
3809
|
}
|
|
3735
|
-
}
|
|
3810
|
+
}, p = useCallback(() => {
|
|
3811
|
+
r("https://placehold.co/400"), i != null && i._id && d([i._id], { assetId: "" });
|
|
3812
|
+
}, [r, i == null ? void 0 : i._id, d]), u = get(i, "assetId", "");
|
|
3736
3813
|
return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex items-center gap-x-3", children: [
|
|
3737
|
-
o ? /* @__PURE__ */
|
|
3814
|
+
o ? /* @__PURE__ */ jsxs("div", { className: "relative", children: [
|
|
3815
|
+
/* @__PURE__ */ jsx("img", { src: o, className: "h-20 w-20 overflow-hidden rounded-md border border-border object-cover", alt: "" }),
|
|
3816
|
+
/* @__PURE__ */ jsx(
|
|
3817
|
+
"button",
|
|
3818
|
+
{
|
|
3819
|
+
type: "button",
|
|
3820
|
+
onClick: p,
|
|
3821
|
+
className: "absolute -right-2 -top-2 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",
|
|
3822
|
+
children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
|
|
3823
|
+
}
|
|
3824
|
+
)
|
|
3825
|
+
] }) : /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: c, mode: "image", assetId: u, children: /* @__PURE__ */ jsx("div", { className: "h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]" }) }),
|
|
3738
3826
|
/* @__PURE__ */ jsxs("div", { className: "flex w-3/5 flex-col", children: [
|
|
3739
3827
|
/* @__PURE__ */ jsxs(Fragment, { children: [
|
|
3740
|
-
/* @__PURE__ */ jsx(MediaManagerModal, { onSelect: c, children: /* @__PURE__ */ jsx("small", { className: "h-6 cursor-pointer rounded-md bg-secondary px-2 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80", children: o || !isEmpty(o) ? l("Replace image") : l("Choose image") }) }),
|
|
3828
|
+
/* @__PURE__ */ jsx(MediaManagerModal, { onSelect: c, assetId: u, children: /* @__PURE__ */ jsx("small", { className: "h-6 cursor-pointer rounded-md bg-secondary px-2 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80", children: o || !isEmpty(o) ? l("Replace image") : l("Choose image") }) }),
|
|
3741
3829
|
/* @__PURE__ */ jsx("small", { className: "-pl-4 pt-2 text-center text-xs text-secondary-foreground", children: "OR" })
|
|
3742
3830
|
] }),
|
|
3743
3831
|
/* @__PURE__ */ jsx(
|
|
@@ -3751,8 +3839,8 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
|
3751
3839
|
className: "text-xs",
|
|
3752
3840
|
placeholder: l("Enter image URL"),
|
|
3753
3841
|
value: o,
|
|
3754
|
-
onBlur: ({ target: { value:
|
|
3755
|
-
onChange: (
|
|
3842
|
+
onBlur: ({ target: { value: g } }) => a(n, g),
|
|
3843
|
+
onChange: (g) => r(g.target.value)
|
|
3756
3844
|
}
|
|
3757
3845
|
)
|
|
3758
3846
|
] })
|
|
@@ -3763,7 +3851,7 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
|
3763
3851
|
onChange: n
|
|
3764
3852
|
}) => {
|
|
3765
3853
|
var N;
|
|
3766
|
-
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, d] = useState(!1), [c, p] = useState(!1), [u, g] = useState("page"), [
|
|
3854
|
+
const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, d] = useState(!1), [c, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [f, x] = useState([]), [y, b] = useState(-1), v = useRef(null), w = (N = r == null ? void 0 : r.find((C) => C.key === u)) == null ? void 0 : N.name;
|
|
3767
3855
|
useEffect(() => {
|
|
3768
3856
|
if (m(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
|
|
3769
3857
|
const C = split(o, ":"), k = get(C, 1, "page") || "page";
|
|
@@ -3790,14 +3878,14 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
|
3790
3878
|
}, _ = (C) => {
|
|
3791
3879
|
switch (C.key) {
|
|
3792
3880
|
case "ArrowDown":
|
|
3793
|
-
C.preventDefault(), b((k) => k <
|
|
3881
|
+
C.preventDefault(), b((k) => k < f.length - 1 ? k + 1 : k);
|
|
3794
3882
|
break;
|
|
3795
3883
|
case "ArrowUp":
|
|
3796
3884
|
C.preventDefault(), b((k) => k > 0 ? k - 1 : k);
|
|
3797
3885
|
break;
|
|
3798
3886
|
case "Enter":
|
|
3799
|
-
if (C.preventDefault(),
|
|
3800
|
-
y >= 0 && E(
|
|
3887
|
+
if (C.preventDefault(), f.length === 0) return;
|
|
3888
|
+
y >= 0 && E(f[y]);
|
|
3801
3889
|
break;
|
|
3802
3890
|
case "Escape":
|
|
3803
3891
|
C.preventDefault(), S();
|
|
@@ -3822,24 +3910,24 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
|
|
|
3822
3910
|
"input",
|
|
3823
3911
|
{
|
|
3824
3912
|
type: "text",
|
|
3825
|
-
value:
|
|
3913
|
+
value: h,
|
|
3826
3914
|
onChange: (C) => B(C.target.value),
|
|
3827
3915
|
onKeyDown: _,
|
|
3828
3916
|
placeholder: a(`Search ${w ?? ""}`),
|
|
3829
3917
|
className: "w-full rounded-md border border-gray-300 p-2 pr-16"
|
|
3830
3918
|
}
|
|
3831
3919
|
),
|
|
3832
|
-
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children:
|
|
3920
|
+
/* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
|
|
3833
3921
|
] }),
|
|
3834
|
-
(i || !isEmpty(
|
|
3922
|
+
(i || !isEmpty(f) || c && 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: [
|
|
3835
3923
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
|
|
3836
3924
|
/* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
|
|
3837
|
-
] }) : c && isEmpty(
|
|
3925
|
+
] }) : c && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
|
|
3838
3926
|
a("No results found for"),
|
|
3839
3927
|
' "',
|
|
3840
|
-
|
|
3928
|
+
h,
|
|
3841
3929
|
'"'
|
|
3842
|
-
] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(
|
|
3930
|
+
] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(f == null ? void 0 : f.slice(0, 20), (C, k) => /* @__PURE__ */ jsxs(
|
|
3843
3931
|
"li",
|
|
3844
3932
|
{
|
|
3845
3933
|
onClick: () => E(C),
|
|
@@ -4078,14 +4166,14 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4078
4166
|
const d = useRef(null), c = useRef(a || ""), p = usePageExternalData();
|
|
4079
4167
|
useEffect(() => {
|
|
4080
4168
|
if (o) {
|
|
4081
|
-
const
|
|
4082
|
-
return
|
|
4169
|
+
const h = document.createElement("style");
|
|
4170
|
+
return h.id = "rte-modal-styles", h.innerHTML = `
|
|
4083
4171
|
/* Ensure the NestedPathSelector popover appears above the dialog */
|
|
4084
4172
|
.rte-path-selector + [data-radix-popper-content-wrapper],
|
|
4085
4173
|
[data-radix-popper-content-wrapper] {
|
|
4086
4174
|
z-index: 9999 !important;
|
|
4087
4175
|
}
|
|
4088
|
-
`, document.head.appendChild(
|
|
4176
|
+
`, document.head.appendChild(h), () => {
|
|
4089
4177
|
const m = document.getElementById("rte-modal-styles");
|
|
4090
4178
|
m && m.remove();
|
|
4091
4179
|
};
|
|
@@ -4108,12 +4196,12 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4108
4196
|
Underline
|
|
4109
4197
|
],
|
|
4110
4198
|
content: a || "",
|
|
4111
|
-
onUpdate: ({ editor:
|
|
4112
|
-
const m =
|
|
4199
|
+
onUpdate: ({ editor: h }) => {
|
|
4200
|
+
const m = h.getHTML();
|
|
4113
4201
|
l(m);
|
|
4114
4202
|
},
|
|
4115
|
-
onBlur: ({ editor:
|
|
4116
|
-
const m =
|
|
4203
|
+
onBlur: ({ editor: h }) => {
|
|
4204
|
+
const m = h.getHTML();
|
|
4117
4205
|
i(n, m);
|
|
4118
4206
|
},
|
|
4119
4207
|
editorProps: {
|
|
@@ -4129,12 +4217,12 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4129
4217
|
}, [o, u]), useEffect(() => {
|
|
4130
4218
|
d.current && u && (d.current.__chaiRTE = u);
|
|
4131
4219
|
}, [u, o]);
|
|
4132
|
-
const g = (
|
|
4220
|
+
const g = (h) => {
|
|
4133
4221
|
if (!u) return;
|
|
4134
|
-
const m = `{{${
|
|
4222
|
+
const m = `{{${h}}}`;
|
|
4135
4223
|
u.commands.focus();
|
|
4136
|
-
const { from:
|
|
4137
|
-
if (
|
|
4224
|
+
const { from: f, to: x } = u.state.selection;
|
|
4225
|
+
if (f !== x)
|
|
4138
4226
|
u.chain().deleteSelection().insertContent(m).run();
|
|
4139
4227
|
else {
|
|
4140
4228
|
const { state: b } = u, v = b.selection.from, w = b.doc.textBetween(Math.max(0, v - 1), v), A = b.doc.textBetween(v, Math.min(v + 1, b.doc.content.size));
|
|
@@ -4144,7 +4232,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4144
4232
|
A && A !== " " && !/[.,!?;:]/.test(A) && (_ = " "), u.chain().insertContent(E + m + _).run();
|
|
4145
4233
|
}
|
|
4146
4234
|
};
|
|
4147
|
-
return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (
|
|
4235
|
+
return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (h) => !h && r(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
|
|
4148
4236
|
/* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center justify-between pr-8", children: [
|
|
4149
4237
|
/* @__PURE__ */ jsx("span", { children: "Rich Text Editor" }),
|
|
4150
4238
|
p && Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
@@ -4176,12 +4264,12 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4176
4264
|
Underline
|
|
4177
4265
|
],
|
|
4178
4266
|
content: n || "",
|
|
4179
|
-
onUpdate: ({ editor:
|
|
4180
|
-
const x =
|
|
4267
|
+
onUpdate: ({ editor: f }) => {
|
|
4268
|
+
const x = f.getHTML();
|
|
4181
4269
|
a(x), d || u(x);
|
|
4182
4270
|
},
|
|
4183
|
-
onBlur: ({ editor:
|
|
4184
|
-
const x =
|
|
4271
|
+
onBlur: ({ editor: f }) => {
|
|
4272
|
+
const x = f.getHTML();
|
|
4185
4273
|
l(o, x);
|
|
4186
4274
|
},
|
|
4187
4275
|
editorProps: {
|
|
@@ -4195,8 +4283,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4195
4283
|
}, [g]), useEffect(() => {
|
|
4196
4284
|
u(n || "");
|
|
4197
4285
|
}, [n]);
|
|
4198
|
-
const
|
|
4199
|
-
a(
|
|
4286
|
+
const h = (f) => {
|
|
4287
|
+
a(f);
|
|
4200
4288
|
}, m = () => {
|
|
4201
4289
|
c(!1), g && g.commands.setContent(p);
|
|
4202
4290
|
};
|
|
@@ -4212,7 +4300,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4212
4300
|
onClose: m,
|
|
4213
4301
|
id: o,
|
|
4214
4302
|
value: p,
|
|
4215
|
-
onChange:
|
|
4303
|
+
onChange: h,
|
|
4216
4304
|
onBlur: l
|
|
4217
4305
|
}
|
|
4218
4306
|
)
|
|
@@ -4228,7 +4316,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4228
4316
|
}, [a]), useEffect(() => {
|
|
4229
4317
|
u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && r({ ...o, currentSlide: get(u, "0._id") });
|
|
4230
4318
|
}, [o, u]);
|
|
4231
|
-
const
|
|
4319
|
+
const h = () => {
|
|
4232
4320
|
const x = findIndex(u, { _id: g });
|
|
4233
4321
|
if (x > -1) {
|
|
4234
4322
|
const y = (x + 1) % u.length, b = get(u, [y, "_id"]);
|
|
@@ -4242,7 +4330,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4242
4330
|
if (!b) return;
|
|
4243
4331
|
r({ ...o, currentSlide: b }), d([b]);
|
|
4244
4332
|
}
|
|
4245
|
-
},
|
|
4333
|
+
}, f = () => {
|
|
4246
4334
|
const x = i(
|
|
4247
4335
|
{ styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
|
|
4248
4336
|
p == null ? void 0 : p._id
|
|
@@ -4260,11 +4348,11 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4260
4348
|
"/",
|
|
4261
4349
|
u.length
|
|
4262
4350
|
] }) : "-" }),
|
|
4263
|
-
/* @__PURE__ */ jsx("button", { onClick:
|
|
4351
|
+
/* @__PURE__ */ jsx("button", { onClick: h, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
|
|
4264
4352
|
/* @__PURE__ */ jsxs(
|
|
4265
4353
|
"button",
|
|
4266
4354
|
{
|
|
4267
|
-
onClick:
|
|
4355
|
+
onClick: f,
|
|
4268
4356
|
className: "flex w-full items-center justify-center gap-x-1 rounded bg-gray-200 p-1.5 text-xs font-medium leading-tight hover:opacity-80",
|
|
4269
4357
|
children: [
|
|
4270
4358
|
/* @__PURE__ */ jsx(PlusCircle, { className: "h-3 w-3 stroke-[2]" }),
|
|
@@ -4338,7 +4426,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4338
4426
|
const n = get(o, "srcsets", []) || [], a = (d, c) => {
|
|
4339
4427
|
const p = d.target.name, u = d.target.value;
|
|
4340
4428
|
r({
|
|
4341
|
-
srcsets: map(n, (g,
|
|
4429
|
+
srcsets: map(n, (g, h) => h === c ? { ...g, [p]: u } : g)
|
|
4342
4430
|
});
|
|
4343
4431
|
}, l = () => {
|
|
4344
4432
|
r({ srcsets: [...n, {}] });
|
|
@@ -4421,8 +4509,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4421
4509
|
/* @__PURE__ */ jsx("span", { children: "Add" })
|
|
4422
4510
|
] }) }), JSONForm = memo(({ blockId: o, schema: r, uiSchema: n, formData: a, onChange: l }) => {
|
|
4423
4511
|
const { selectedLang: i } = useLanguages(), d = useBlockSettingComponents("widget"), c = useBlockSettingComponents("field"), p = useBlockSettingComponents("template"), u = useThrottledCallback(
|
|
4424
|
-
async ({ formData: g },
|
|
4425
|
-
l({ formData: g },
|
|
4512
|
+
async ({ formData: g }, h) => {
|
|
4513
|
+
l({ formData: g }, h);
|
|
4426
4514
|
},
|
|
4427
4515
|
[l, i],
|
|
4428
4516
|
400
|
|
@@ -4462,9 +4550,9 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4462
4550
|
uiSchema: n,
|
|
4463
4551
|
schema: r,
|
|
4464
4552
|
formData: a,
|
|
4465
|
-
onChange: ({ formData: g },
|
|
4466
|
-
if (!
|
|
4467
|
-
const m = take(
|
|
4553
|
+
onChange: ({ formData: g }, h) => {
|
|
4554
|
+
if (!h || o !== (g == null ? void 0 : g._id)) return;
|
|
4555
|
+
const m = take(h.split("."), 2).join(".").replace("root.", "");
|
|
4468
4556
|
u({ formData: g }, m);
|
|
4469
4557
|
}
|
|
4470
4558
|
},
|
|
@@ -4477,11 +4565,11 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
|
|
|
4477
4565
|
}), a;
|
|
4478
4566
|
};
|
|
4479
4567
|
function BlockSettings() {
|
|
4480
|
-
const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [d, c] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(),
|
|
4568
|
+
const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [d, c] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), f = ({ formData: _ }, S, B) => {
|
|
4481
4569
|
S && (d == null ? void 0 : d._id) === r._id && a([r._id], { [S]: get(_, S) }, B);
|
|
4482
4570
|
}, x = useCallback(
|
|
4483
4571
|
debounce(({ formData: _ }, S, B) => {
|
|
4484
|
-
|
|
4572
|
+
f({ formData: _ }, S, B), c(_);
|
|
4485
4573
|
}, 1500),
|
|
4486
4574
|
[r == null ? void 0 : r._id, o]
|
|
4487
4575
|
), y = ({ formData: _ }, S) => {
|
|
@@ -4718,7 +4806,7 @@ const BlockStylingProps = () => {
|
|
|
4718
4806
|
},
|
|
4719
4807
|
a
|
|
4720
4808
|
)) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
|
|
4721
|
-
const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: d, classPrefix: c, cssProperty: p, units: u, negative: g } = o, [
|
|
4809
|
+
const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: d, classPrefix: c, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [y, b] = useState(""), [v, w] = useState(!1), [A, E] = useState(!1);
|
|
4722
4810
|
useEffect(() => {
|
|
4723
4811
|
const { value: C, unit: k } = getClassValueAndUnit(i);
|
|
4724
4812
|
if (k === "") {
|
|
@@ -4734,7 +4822,7 @@ const BlockStylingProps = () => {
|
|
|
4734
4822
|
x(!0);
|
|
4735
4823
|
return;
|
|
4736
4824
|
}
|
|
4737
|
-
const j = get(k, "unit") !== "" ? get(k, "unit") :
|
|
4825
|
+
const j = get(k, "unit") !== "" ? get(k, "unit") : h;
|
|
4738
4826
|
if (j === "auto" || j === "none") {
|
|
4739
4827
|
_(`${c}${j}`);
|
|
4740
4828
|
return;
|
|
@@ -4744,7 +4832,7 @@ const BlockStylingProps = () => {
|
|
|
4744
4832
|
const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${c}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
|
|
4745
4833
|
C ? S(I) : _(I);
|
|
4746
4834
|
},
|
|
4747
|
-
[_, S, a,
|
|
4835
|
+
[_, S, a, h, c, u]
|
|
4748
4836
|
), N = useCallback(
|
|
4749
4837
|
(C) => {
|
|
4750
4838
|
const k = getUserInputValues(`${a}`, u);
|
|
@@ -4763,7 +4851,7 @@ const BlockStylingProps = () => {
|
|
|
4763
4851
|
},
|
|
4764
4852
|
[_, a, c, u]
|
|
4765
4853
|
);
|
|
4766
|
-
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children:
|
|
4854
|
+
return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: h === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
4767
4855
|
/* @__PURE__ */ jsx(
|
|
4768
4856
|
"input",
|
|
4769
4857
|
{
|
|
@@ -4778,10 +4866,10 @@ const BlockStylingProps = () => {
|
|
|
4778
4866
|
] })
|
|
4779
4867
|
] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${v ? "z-auto" : ""}`, children: [
|
|
4780
4868
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
|
|
4781
|
-
["none", "auto"].indexOf(
|
|
4869
|
+
["none", "auto"].indexOf(h) !== -1 ? null : /* @__PURE__ */ jsx(
|
|
4782
4870
|
"input",
|
|
4783
4871
|
{
|
|
4784
|
-
readOnly:
|
|
4872
|
+
readOnly: h === "class",
|
|
4785
4873
|
onKeyPress: (C) => {
|
|
4786
4874
|
C.key === "Enter" && B();
|
|
4787
4875
|
},
|
|
@@ -4792,7 +4880,7 @@ const BlockStylingProps = () => {
|
|
|
4792
4880
|
const k = parseInt$1(C.target.value);
|
|
4793
4881
|
let j = isNaN$1(k) ? 0 : k;
|
|
4794
4882
|
C.keyCode === 38 && (j += 1), C.keyCode === 40 && (j -= 1);
|
|
4795
|
-
const T = `${j}`, P = `${T.startsWith("-") ? "-" : ""}${c}[${T.replace("-", "")}${
|
|
4883
|
+
const T = `${j}`, P = `${T.startsWith("-") ? "-" : ""}${c}[${T.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
4796
4884
|
S(P);
|
|
4797
4885
|
},
|
|
4798
4886
|
onKeyUp: (C) => {
|
|
@@ -4809,7 +4897,7 @@ const BlockStylingProps = () => {
|
|
|
4809
4897
|
value: v ? y : a,
|
|
4810
4898
|
className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
|
|
4811
4899
|
" ",
|
|
4812
|
-
|
|
4900
|
+
f ? "border-red-500 text-red-500" : "border-foreground/20"
|
|
4813
4901
|
)
|
|
4814
4902
|
}
|
|
4815
4903
|
),
|
|
@@ -4821,7 +4909,7 @@ const BlockStylingProps = () => {
|
|
|
4821
4909
|
onClick: () => n(!r),
|
|
4822
4910
|
className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
|
|
4823
4911
|
children: [
|
|
4824
|
-
/* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children:
|
|
4912
|
+
/* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: h }),
|
|
4825
4913
|
u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
|
|
4826
4914
|
]
|
|
4827
4915
|
}
|
|
@@ -4830,7 +4918,7 @@ const BlockStylingProps = () => {
|
|
|
4830
4918
|
UnitSelection,
|
|
4831
4919
|
{
|
|
4832
4920
|
units: u,
|
|
4833
|
-
current:
|
|
4921
|
+
current: h,
|
|
4834
4922
|
onSelect: (C) => {
|
|
4835
4923
|
n(!1), m(C), N(C);
|
|
4836
4924
|
}
|
|
@@ -4838,25 +4926,25 @@ const BlockStylingProps = () => {
|
|
|
4838
4926
|
) })
|
|
4839
4927
|
] })
|
|
4840
4928
|
] }),
|
|
4841
|
-
["none", "auto"].indexOf(
|
|
4929
|
+
["none", "auto"].indexOf(h) !== -1 || v ? null : /* @__PURE__ */ jsx(
|
|
4842
4930
|
DragStyleButton,
|
|
4843
4931
|
{
|
|
4844
4932
|
onDragStart: () => w(!0),
|
|
4845
4933
|
onDragEnd: (C) => {
|
|
4846
4934
|
if (b(() => ""), w(!1), isEmpty(C))
|
|
4847
4935
|
return;
|
|
4848
|
-
const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${c}[${k.replace("-", "")}${
|
|
4936
|
+
const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${c}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
4849
4937
|
_(T);
|
|
4850
4938
|
},
|
|
4851
4939
|
onDrag: (C) => {
|
|
4852
4940
|
if (isEmpty(C))
|
|
4853
4941
|
return;
|
|
4854
4942
|
b(C);
|
|
4855
|
-
const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${c}[${k.replace("-", "")}${
|
|
4943
|
+
const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${c}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
|
|
4856
4944
|
S(T);
|
|
4857
4945
|
},
|
|
4858
4946
|
currentValue: a,
|
|
4859
|
-
unit:
|
|
4947
|
+
unit: h,
|
|
4860
4948
|
negative: g,
|
|
4861
4949
|
cssProperty: p
|
|
4862
4950
|
}
|
|
@@ -4916,7 +5004,7 @@ const COLOR_PROP = {
|
|
|
4916
5004
|
ringColor: "ring",
|
|
4917
5005
|
ringOffsetColor: "ring-offset"
|
|
4918
5006
|
}, ColorChoice = ({ property: o, onChange: r }) => {
|
|
4919
|
-
const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, d] = useState([]), [c, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""),
|
|
5007
|
+
const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, d] = useState([]), [c, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), h = get(u, "2", ""), m = useCallback(
|
|
4920
5008
|
// eslint-disable-next-line no-shadow
|
|
4921
5009
|
(y) => {
|
|
4922
5010
|
["current", "inherit", "transparent", "black", "white"].includes(y) ? (d([]), p({ color: y })) : (d(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: y, shade: b.shade ? b.shade : "500" })));
|
|
@@ -4928,7 +5016,7 @@ const COLOR_PROP = {
|
|
|
4928
5016
|
return d([]);
|
|
4929
5017
|
d(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
|
|
4930
5018
|
}, [g]);
|
|
4931
|
-
const
|
|
5019
|
+
const f = useCallback(
|
|
4932
5020
|
// eslint-disable-next-line no-shadow
|
|
4933
5021
|
(y) => {
|
|
4934
5022
|
p({ color: g, shade: y });
|
|
@@ -4982,7 +5070,7 @@ const COLOR_PROP = {
|
|
|
4982
5070
|
]
|
|
4983
5071
|
}
|
|
4984
5072
|
) }),
|
|
4985
|
-
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected:
|
|
5073
|
+
/* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange: f, options: i }) })
|
|
4986
5074
|
] });
|
|
4987
5075
|
}, EDITOR_ICONS = {
|
|
4988
5076
|
"not-italic": () => /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M9 3H11V5H9V11H11V13H5V11H7V5H5V3H9Z", fill: "white" }) }),
|
|
@@ -5316,7 +5404,7 @@ const COLOR_PROP = {
|
|
|
5316
5404
|
"2xl": "1536px"
|
|
5317
5405
|
}, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
|
|
5318
5406
|
const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
|
|
5319
|
-
}, units: d, negative: c = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(),
|
|
5407
|
+
}, units: d, negative: c = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), y = useMemo(() => get(h, "fullCls", ""), [h]), b = useCallback(
|
|
5320
5408
|
(S, B = !0) => {
|
|
5321
5409
|
const N = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
|
|
5322
5410
|
(p || u !== "") && (N.mq = "xs");
|
|
@@ -5325,11 +5413,11 @@ const COLOR_PROP = {
|
|
|
5325
5413
|
},
|
|
5326
5414
|
[x, p, g, u, l, m]
|
|
5327
5415
|
), v = useCallback(() => {
|
|
5328
|
-
|
|
5329
|
-
}, [x, y,
|
|
5416
|
+
f(x, [y], !0);
|
|
5417
|
+
}, [x, y, f]), w = useMemo(() => canChangeClass(h, g), [h, g]);
|
|
5330
5418
|
useEffect(() => {
|
|
5331
|
-
i(w,
|
|
5332
|
-
}, [w, i,
|
|
5419
|
+
i(w, h);
|
|
5420
|
+
}, [w, i, h]);
|
|
5333
5421
|
const [, , A] = useScreenSizeWidth(), E = useCallback(
|
|
5334
5422
|
(S) => {
|
|
5335
5423
|
A({
|
|
@@ -5342,15 +5430,15 @@ const COLOR_PROP = {
|
|
|
5342
5430
|
}[S]);
|
|
5343
5431
|
},
|
|
5344
5432
|
[A]
|
|
5345
|
-
), _ = get(
|
|
5346
|
-
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: w, canReset:
|
|
5347
|
-
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${
|
|
5433
|
+
), _ = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
|
|
5434
|
+
return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: w, canReset: h && _, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
|
|
5435
|
+
/* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !_ ? "text-foreground" : ""}`, children: r(a) }) }),
|
|
5348
5436
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
|
|
5349
5437
|
/* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
|
|
5350
5438
|
n === "arbitrary" ? /* @__PURE__ */ jsx(
|
|
5351
5439
|
AdvanceChoices,
|
|
5352
5440
|
{
|
|
5353
|
-
currentClass: get(
|
|
5441
|
+
currentClass: get(h, "cls", ""),
|
|
5354
5442
|
classPrefix: get(CLASS_PREFIXES, l, ""),
|
|
5355
5443
|
units: d || [],
|
|
5356
5444
|
onChange: b,
|
|
@@ -5363,7 +5451,7 @@ const COLOR_PROP = {
|
|
|
5363
5451
|
n === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
|
|
5364
5452
|
n === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
|
|
5365
5453
|
] }),
|
|
5366
|
-
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: _ ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : w &&
|
|
5454
|
+
/* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: _ ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : w && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
|
|
5367
5455
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
|
|
5368
5456
|
"button",
|
|
5369
5457
|
{
|
|
@@ -5375,19 +5463,19 @@ const COLOR_PROP = {
|
|
|
5375
5463
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxs("div", { children: [
|
|
5376
5464
|
"Current style is set at ",
|
|
5377
5465
|
/* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
|
|
5378
|
-
getBreakpoint(get(
|
|
5379
|
-
p && !
|
|
5466
|
+
getBreakpoint(get(h, "mq")),
|
|
5467
|
+
p && !h.dark ? "(Light mode)" : ""
|
|
5380
5468
|
] }),
|
|
5381
5469
|
/* @__PURE__ */ jsx("br", {}),
|
|
5382
5470
|
/* @__PURE__ */ jsxs(
|
|
5383
5471
|
"button",
|
|
5384
5472
|
{
|
|
5385
5473
|
type: "button",
|
|
5386
|
-
onClick: () => E(get(
|
|
5474
|
+
onClick: () => E(get(h, "mq")),
|
|
5387
5475
|
className: "block w-full cursor-default text-right font-semibold text-blue-500",
|
|
5388
5476
|
children: [
|
|
5389
5477
|
"Switch to ",
|
|
5390
|
-
get(
|
|
5478
|
+
get(h, "mq").toUpperCase()
|
|
5391
5479
|
]
|
|
5392
5480
|
}
|
|
5393
5481
|
)
|
|
@@ -5404,7 +5492,7 @@ const COLOR_PROP = {
|
|
|
5404
5492
|
units: i = basicUnits,
|
|
5405
5493
|
negative: d = !1
|
|
5406
5494
|
}) => {
|
|
5407
|
-
const { t: c } = useTranslation(), [p, u] = useState(r[0].key), g = useSelectedBlockCurrentClasses(),
|
|
5495
|
+
const { t: c } = useTranslation(), [p, u] = useState(r[0].key), g = useSelectedBlockCurrentClasses(), h = useCallback((m) => map(g, "property").includes(m), [g]);
|
|
5408
5496
|
return /* @__PURE__ */ jsxs(
|
|
5409
5497
|
"div",
|
|
5410
5498
|
{
|
|
@@ -5412,18 +5500,18 @@ const COLOR_PROP = {
|
|
|
5412
5500
|
children: [
|
|
5413
5501
|
/* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
|
|
5414
5502
|
o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: c(o) }),
|
|
5415
|
-
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: r.map(({ label: m, key:
|
|
5503
|
+
/* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: r.map(({ label: m, key: f }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
5416
5504
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
5417
5505
|
"button",
|
|
5418
5506
|
{
|
|
5419
5507
|
type: "button",
|
|
5420
|
-
onClick: () => u(
|
|
5421
|
-
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${
|
|
5508
|
+
onClick: () => u(f),
|
|
5509
|
+
className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
|
|
5422
5510
|
children: [
|
|
5423
5511
|
React__default.createElement("div", {
|
|
5424
|
-
className: f
|
|
5512
|
+
className: h(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
|
|
5425
5513
|
}),
|
|
5426
|
-
React__default.createElement(get(EDITOR_ICONS,
|
|
5514
|
+
React__default.createElement(get(EDITOR_ICONS, f, BoxIcon), { className: "text-inherit w-3 h-3" })
|
|
5427
5515
|
]
|
|
5428
5516
|
}
|
|
5429
5517
|
) }),
|
|
@@ -5583,7 +5671,7 @@ const COLOR_PROP = {
|
|
|
5583
5671
|
canvas: r = !1,
|
|
5584
5672
|
tooltip: n = !0
|
|
5585
5673
|
}) => {
|
|
5586
|
-
const [a, , l] = useScreenSizeWidth(), [i, d] = useCanvasDisplayWidth(), [c, p] = useSelectedBreakpoints(), u = c, g = p, { t:
|
|
5674
|
+
const [a, , l] = useScreenSizeWidth(), [i, d] = useCanvasDisplayWidth(), [c, p] = useSelectedBreakpoints(), u = c, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (b) => {
|
|
5587
5675
|
u.includes(b) ? u.length > 2 && g(u.filter((v) => v !== b)) : g((v) => [...v, b]);
|
|
5588
5676
|
}, x = (b) => {
|
|
5589
5677
|
r || l(b), d(b);
|
|
@@ -5616,15 +5704,15 @@ const COLOR_PROP = {
|
|
|
5616
5704
|
/* @__PURE__ */ jsxs(DropdownMenu, { children: [
|
|
5617
5705
|
/* @__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" }) }) }),
|
|
5618
5706
|
/* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
|
|
5619
|
-
/* @__PURE__ */ jsx(DropdownMenuLabel, { children:
|
|
5707
|
+
/* @__PURE__ */ jsx(DropdownMenuLabel, { children: h("Screen sizes") }),
|
|
5620
5708
|
/* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
|
|
5621
5709
|
map(m, (b) => /* @__PURE__ */ jsx(
|
|
5622
5710
|
DropdownMenuCheckboxItem,
|
|
5623
5711
|
{
|
|
5624
5712
|
disabled: b.breakpoint === "xs",
|
|
5625
|
-
onCheckedChange: () =>
|
|
5713
|
+
onCheckedChange: () => f(toUpper(b.breakpoint)),
|
|
5626
5714
|
checked: includes(u, toUpper(b.breakpoint)),
|
|
5627
|
-
children:
|
|
5715
|
+
children: h(b.title)
|
|
5628
5716
|
},
|
|
5629
5717
|
b.breakpoint
|
|
5630
5718
|
))
|
|
@@ -5706,9 +5794,9 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5706
5794
|
var m;
|
|
5707
5795
|
(m = c.current) == null || m.focus();
|
|
5708
5796
|
}, []);
|
|
5709
|
-
const
|
|
5710
|
-
const { usage:
|
|
5711
|
-
!l &&
|
|
5797
|
+
const h = (m) => {
|
|
5798
|
+
const { usage: f } = m || {};
|
|
5799
|
+
!l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || d("");
|
|
5712
5800
|
};
|
|
5713
5801
|
return /* @__PURE__ */ jsxs("div", { className: "", children: [
|
|
5714
5802
|
/* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: r("Ask AI") }),
|
|
@@ -5722,7 +5810,7 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5722
5810
|
className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
|
|
5723
5811
|
rows: 4,
|
|
5724
5812
|
onKeyDown: (m) => {
|
|
5725
|
-
m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), g(void 0), n("styles", o, i,
|
|
5813
|
+
m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), g(void 0), n("styles", o, i, h));
|
|
5726
5814
|
}
|
|
5727
5815
|
}
|
|
5728
5816
|
),
|
|
@@ -5732,7 +5820,7 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5732
5820
|
{
|
|
5733
5821
|
disabled: i.trim().length < 5 || a,
|
|
5734
5822
|
onClick: () => {
|
|
5735
|
-
p.current && clearTimeout(p.current), g(void 0), n("styles", o, i,
|
|
5823
|
+
p.current && clearTimeout(p.current), g(void 0), n("styles", o, i, h);
|
|
5736
5824
|
},
|
|
5737
5825
|
variant: "default",
|
|
5738
5826
|
className: "w-fit",
|
|
@@ -5764,9 +5852,9 @@ const AskAIStyles = ({ blockId: o }) => {
|
|
|
5764
5852
|
};
|
|
5765
5853
|
function ManualClasses() {
|
|
5766
5854
|
var T;
|
|
5767
|
-
const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: d } = useTranslation(), [c] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [
|
|
5768
|
-
const I =
|
|
5769
|
-
u(
|
|
5855
|
+
const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: d } = useTranslation(), [c] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), y = (T = first(c)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), v = b.split(" ").filter((I) => !isEmpty(I)), w = () => {
|
|
5856
|
+
const I = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5857
|
+
u(h, I, !0), x("");
|
|
5770
5858
|
}, [A, E] = useState([]), _ = ({ value: I }) => {
|
|
5771
5859
|
const P = I.trim().toLowerCase(), L = P.match(/.+:/g);
|
|
5772
5860
|
let O = [];
|
|
@@ -5789,18 +5877,18 @@ function ManualClasses() {
|
|
|
5789
5877
|
autoCapitalize: "off",
|
|
5790
5878
|
spellCheck: !1,
|
|
5791
5879
|
placeholder: d("Enter classes separated by space"),
|
|
5792
|
-
value:
|
|
5880
|
+
value: f,
|
|
5793
5881
|
onKeyDown: (I) => {
|
|
5794
|
-
I.key === "Enter" &&
|
|
5882
|
+
I.key === "Enter" && f.trim() !== "" && w();
|
|
5795
5883
|
},
|
|
5796
5884
|
onChange: (I, { newValue: P }) => x(P),
|
|
5797
5885
|
className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
|
|
5798
5886
|
}),
|
|
5799
|
-
[
|
|
5887
|
+
[f, d, o]
|
|
5800
5888
|
), k = (I) => {
|
|
5801
5889
|
debugger;
|
|
5802
5890
|
const P = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
|
|
5803
|
-
g(
|
|
5891
|
+
g(h, [I]), u(h, P, !0), n(""), l(-1);
|
|
5804
5892
|
}, j = () => {
|
|
5805
5893
|
if (navigator.clipboard === void 0) {
|
|
5806
5894
|
toast.error(d("Clipboard not supported"));
|
|
@@ -5851,7 +5939,7 @@ function ManualClasses() {
|
|
|
5851
5939
|
variant: "outline",
|
|
5852
5940
|
className: "h-6 border-border",
|
|
5853
5941
|
onClick: w,
|
|
5854
|
-
disabled:
|
|
5942
|
+
disabled: f.trim() === "",
|
|
5855
5943
|
size: "sm",
|
|
5856
5944
|
children: /* @__PURE__ */ jsx(PlusIcon, {})
|
|
5857
5945
|
}
|
|
@@ -5882,7 +5970,7 @@ function ManualClasses() {
|
|
|
5882
5970
|
r !== I && /* @__PURE__ */ jsx(
|
|
5883
5971
|
Cross2Icon,
|
|
5884
5972
|
{
|
|
5885
|
-
onClick: () => g(
|
|
5973
|
+
onClick: () => g(h, [I], !0),
|
|
5886
5974
|
className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
|
|
5887
5975
|
}
|
|
5888
5976
|
)
|
|
@@ -6002,13 +6090,13 @@ function BlockStyling() {
|
|
|
6002
6090
|
cssProperty: ""
|
|
6003
6091
|
}), c = useThrottledCallback(
|
|
6004
6092
|
(u) => {
|
|
6005
|
-
const g = !get(i, "negative", !1),
|
|
6093
|
+
const g = !get(i, "negative", !1), h = get(i, "cssProperty", "");
|
|
6006
6094
|
let m = parseFloat(i.dragStartValue);
|
|
6007
6095
|
m = isNaN(m) ? 0 : m;
|
|
6008
|
-
let
|
|
6009
|
-
(startsWith(
|
|
6010
|
-
let y = (i.dragStartY - u.pageY) /
|
|
6011
|
-
g && y < 0 && (y = 0),
|
|
6096
|
+
let f = MAPPER[i.dragUnit];
|
|
6097
|
+
(startsWith(h, "scale") || h === "opacity") && (f = 10);
|
|
6098
|
+
let y = (i.dragStartY - u.pageY) / f + m;
|
|
6099
|
+
g && y < 0 && (y = 0), h === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
|
|
6012
6100
|
},
|
|
6013
6101
|
[i],
|
|
6014
6102
|
50
|
|
@@ -6049,14 +6137,14 @@ const CoreBlock = ({
|
|
|
6049
6137
|
parentId: n,
|
|
6050
6138
|
position: a
|
|
6051
6139
|
}) => {
|
|
6052
|
-
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: d, label: c } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight:
|
|
6140
|
+
const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: d, label: c } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
|
|
6053
6141
|
if (console.log("addBlockToPage", o), has(o, "blocks")) {
|
|
6054
6142
|
const y = isFunction(o.blocks) ? o.blocks() : o.blocks;
|
|
6055
6143
|
u(syncBlocksWithDefaults(y), n || null, a);
|
|
6056
6144
|
} else
|
|
6057
6145
|
p(o, n || null, a);
|
|
6058
6146
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6059
|
-
},
|
|
6147
|
+
}, f = useFeature("dnd"), { t: x } = useTranslation();
|
|
6060
6148
|
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
6061
6149
|
/* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
|
|
6062
6150
|
"button",
|
|
@@ -6066,10 +6154,10 @@ const CoreBlock = ({
|
|
|
6066
6154
|
type: "button",
|
|
6067
6155
|
onDragStart: (y) => {
|
|
6068
6156
|
y.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), y.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
|
|
6069
|
-
g([]),
|
|
6157
|
+
g([]), h();
|
|
6070
6158
|
}, 200);
|
|
6071
6159
|
},
|
|
6072
|
-
draggable:
|
|
6160
|
+
draggable: f ? "true" : "false",
|
|
6073
6161
|
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",
|
|
6074
6162
|
children: [
|
|
6075
6163
|
createElement(d || BoxIcon, { className: "w-4 h-4 mx-auto" }),
|
|
@@ -6265,7 +6353,7 @@ const CoreBlock = ({
|
|
|
6265
6353
|
}
|
|
6266
6354
|
}
|
|
6267
6355
|
}, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
|
|
6268
|
-
var
|
|
6356
|
+
var h, m, f, x, y, b, v, w;
|
|
6269
6357
|
if (n.type === "comment") return [];
|
|
6270
6358
|
console.log("node ===>", n);
|
|
6271
6359
|
let a = { _id: generateUUID() };
|
|
@@ -6306,9 +6394,9 @@ const CoreBlock = ({
|
|
|
6306
6394
|
];
|
|
6307
6395
|
a = {
|
|
6308
6396
|
...a,
|
|
6309
|
-
href: ((
|
|
6397
|
+
href: ((h = l.find((E) => E.key === "href")) == null ? void 0 : h.value) || "",
|
|
6310
6398
|
hrefType: ((m = l.find((E) => E.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
|
|
6311
|
-
autoplay: ((
|
|
6399
|
+
autoplay: ((f = l.find((E) => E.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
|
|
6312
6400
|
maxWidth: ((y = (x = l.find((E) => E.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : y.replace("px", "")) || "",
|
|
6313
6401
|
backdropColor: ((b = l.find((E) => E.key === "data-overlay")) == null ? void 0 : b.value) || "",
|
|
6314
6402
|
galleryName: ((v = l.find((E) => E.key === "data-gall")) == null ? void 0 : v.value) || ""
|
|
@@ -6447,7 +6535,7 @@ const BlockCard = ({
|
|
|
6447
6535
|
parentId: n = void 0,
|
|
6448
6536
|
position: a = -1
|
|
6449
6537
|
}) => {
|
|
6450
|
-
const [l, i] = useState(!1), d = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: c, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(),
|
|
6538
|
+
const [l, i] = useState(!1), d = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: c, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), y = (w) => {
|
|
6451
6539
|
const A = has(w, "styles_attrs.data-page-section");
|
|
6452
6540
|
return w._type === "Box" && A;
|
|
6453
6541
|
}, b = useCallback(
|
|
@@ -6468,7 +6556,7 @@ const BlockCard = ({
|
|
|
6468
6556
|
{
|
|
6469
6557
|
onClick: l ? () => {
|
|
6470
6558
|
} : b,
|
|
6471
|
-
draggable:
|
|
6559
|
+
draggable: f ? "true" : "false",
|
|
6472
6560
|
onDragStart: async (w) => {
|
|
6473
6561
|
const A = await d(r, o);
|
|
6474
6562
|
let E = n;
|
|
@@ -6494,35 +6582,35 @@ const BlockCard = ({
|
|
|
6494
6582
|
/* @__PURE__ */ jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
|
|
6495
6583
|
/* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
|
|
6496
6584
|
] }),
|
|
6497
|
-
o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt:
|
|
6498
|
-
/* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children:
|
|
6585
|
+
o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: h }) : /* @__PURE__ */ jsxs("div", { className: "flex h-fit w-full flex-col items-center justify-center gap-1 rounded-md border border-border p-6 py-10 text-center", children: [
|
|
6586
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children: h }),
|
|
6499
6587
|
m && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-600", children: m })
|
|
6500
6588
|
] })
|
|
6501
6589
|
]
|
|
6502
6590
|
}
|
|
6503
6591
|
) }),
|
|
6504
6592
|
/* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsxs("div", { className: "max-w-xs", children: [
|
|
6505
|
-
/* @__PURE__ */ jsx("p", { className: "font-medium", children:
|
|
6593
|
+
/* @__PURE__ */ jsx("p", { className: "font-medium", children: h }),
|
|
6506
6594
|
m && o.preview && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-primary-foreground", children: m })
|
|
6507
6595
|
] }) })
|
|
6508
6596
|
] });
|
|
6509
6597
|
}, UILibrarySection = ({ parentId: o, position: r }) => {
|
|
6510
|
-
const [n, a] = useSelectedLibrary(), l = useBuilderProp("uiLibraries", []), i = l.find((k) => k.id === n) || first(l), { data: d, isLoading: c, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [
|
|
6598
|
+
const [n, a] = useSelectedLibrary(), l = useBuilderProp("uiLibraries", []), i = l.find((k) => k.id === n) || first(l), { data: d, isLoading: c, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]), f = useRef(null);
|
|
6511
6599
|
useEffect(() => {
|
|
6512
|
-
d && d.length > 0 && (
|
|
6600
|
+
d && d.length > 0 && (f.current = new Fuse(d, {
|
|
6513
6601
|
keys: ["name", "label", "description", "group"],
|
|
6514
6602
|
threshold: 0.4,
|
|
6515
6603
|
ignoreLocation: !0
|
|
6516
6604
|
}));
|
|
6517
6605
|
}, [d]), useEffect(() => {
|
|
6518
|
-
if (!u.trim() || !
|
|
6606
|
+
if (!u.trim() || !f.current) {
|
|
6519
6607
|
m([]);
|
|
6520
6608
|
return;
|
|
6521
6609
|
}
|
|
6522
|
-
const k =
|
|
6610
|
+
const k = f.current.search(u).map((j) => j.item);
|
|
6523
6611
|
m(k);
|
|
6524
6612
|
}, [u]);
|
|
6525
|
-
const x = u.trim() && !isEmpty(
|
|
6613
|
+
const x = u.trim() && !isEmpty(h) ? h : d, y = groupBy(x, "group"), [b, v] = useState(null);
|
|
6526
6614
|
useEffect(() => {
|
|
6527
6615
|
if (isEmpty(keys(y))) {
|
|
6528
6616
|
v(null);
|
|
@@ -6677,10 +6765,10 @@ const BlockCard = ({
|
|
|
6677
6765
|
// Store the original ID as partialBlockId
|
|
6678
6766
|
_name: b.name
|
|
6679
6767
|
};
|
|
6680
|
-
}),
|
|
6768
|
+
}), f = uniq(map(m, "group"));
|
|
6681
6769
|
p({
|
|
6682
6770
|
blocks: m,
|
|
6683
|
-
groups:
|
|
6771
|
+
groups: f,
|
|
6684
6772
|
isLoading: !1,
|
|
6685
6773
|
error: null
|
|
6686
6774
|
}), g(!0);
|
|
@@ -6699,7 +6787,7 @@ const BlockCard = ({
|
|
|
6699
6787
|
c.blocks,
|
|
6700
6788
|
d
|
|
6701
6789
|
]);
|
|
6702
|
-
const
|
|
6790
|
+
const h = () => {
|
|
6703
6791
|
p((m) => ({ ...m, isLoading: !0, error: null })), g(!1), i();
|
|
6704
6792
|
};
|
|
6705
6793
|
return c.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : c.error || c.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
|
|
@@ -6707,7 +6795,7 @@ const BlockCard = ({
|
|
|
6707
6795
|
/* @__PURE__ */ jsx(
|
|
6708
6796
|
"button",
|
|
6709
6797
|
{
|
|
6710
|
-
onClick:
|
|
6798
|
+
onClick: h,
|
|
6711
6799
|
className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
|
|
6712
6800
|
children: "Refresh"
|
|
6713
6801
|
}
|
|
@@ -6726,7 +6814,7 @@ const BlockCard = ({
|
|
|
6726
6814
|
has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...r });
|
|
6727
6815
|
}, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: r, parentId: n, position: a, gridCols: l = "grid-cols-4" }) => {
|
|
6728
6816
|
var C;
|
|
6729
|
-
const { t: i } = useTranslation(), [d] = useBlocksStore(), [c, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom),
|
|
6817
|
+
const { t: i } = useTranslation(), [d] = useBlocksStore(), [c, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (C = find(d, (k) => k._id === n)) == null ? void 0 : C._type, [m, f] = useState("all"), [x, y] = useState(null), b = useRef(null);
|
|
6730
6818
|
useEffect(() => {
|
|
6731
6819
|
const k = setTimeout(() => {
|
|
6732
6820
|
var j;
|
|
@@ -6734,9 +6822,9 @@ const BlockCard = ({
|
|
|
6734
6822
|
}, 0);
|
|
6735
6823
|
return () => clearTimeout(k);
|
|
6736
6824
|
}, [g]), useEffect(() => {
|
|
6737
|
-
c && (
|
|
6825
|
+
c && (f("all"), y(null));
|
|
6738
6826
|
}, [c]), useEffect(() => (b.current = debounce((k) => {
|
|
6739
|
-
|
|
6827
|
+
f(k);
|
|
6740
6828
|
}, 500), () => {
|
|
6741
6829
|
b.current && b.current.cancel();
|
|
6742
6830
|
}), []);
|
|
@@ -6745,7 +6833,7 @@ const BlockCard = ({
|
|
|
6745
6833
|
}, []), w = useCallback(() => {
|
|
6746
6834
|
y(null), b.current && b.current.cancel();
|
|
6747
6835
|
}, []), A = useCallback((k) => {
|
|
6748
|
-
b.current && b.current.cancel(),
|
|
6836
|
+
b.current && b.current.cancel(), f(k), y(null);
|
|
6749
6837
|
}, []), E = useMemo(
|
|
6750
6838
|
() => c ? values(r).filter(
|
|
6751
6839
|
(k) => {
|
|
@@ -6816,7 +6904,7 @@ const BlockCard = ({
|
|
|
6816
6904
|
parentId: n,
|
|
6817
6905
|
position: a,
|
|
6818
6906
|
block: j,
|
|
6819
|
-
disabled: !canAcceptChildBlock(
|
|
6907
|
+
disabled: !canAcceptChildBlock(h, j.type) || !canBeNestedInside(h, j.type)
|
|
6820
6908
|
},
|
|
6821
6909
|
j.type
|
|
6822
6910
|
)) })
|
|
@@ -6829,13 +6917,13 @@ const BlockCard = ({
|
|
|
6829
6917
|
parentId: n = void 0,
|
|
6830
6918
|
position: a = -1
|
|
6831
6919
|
}) => {
|
|
6832
|
-
const { t: l } = useTranslation(), [i, d] = useAtom$1(addBlockTabAtom), [, c] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(), g = Object.keys(u || {}).length > 0, { hasPermission:
|
|
6920
|
+
const { t: l } = useTranslation(), [i, d] = useAtom$1(addBlockTabAtom), [, c] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(), g = Object.keys(u || {}).length > 0, { hasPermission: h } = usePermissions();
|
|
6833
6921
|
useEffect(() => {
|
|
6834
6922
|
i === "partials" && !g && d("library");
|
|
6835
6923
|
}, [i, g, d]);
|
|
6836
6924
|
const m = useCallback(() => {
|
|
6837
6925
|
pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
|
|
6838
|
-
}, []),
|
|
6926
|
+
}, []), f = useChaiAddBlockTabs(), x = p && h(PERMISSIONS.IMPORT_HTML), b = useBuilderProp("uiLibraries", []).length > 0;
|
|
6839
6927
|
return useEffect(() => {
|
|
6840
6928
|
i === "library" && !b && d("core");
|
|
6841
6929
|
}, [i, b, d]), /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
|
|
@@ -6857,13 +6945,13 @@ const BlockCard = ({
|
|
|
6857
6945
|
/* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
|
|
6858
6946
|
g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
|
|
6859
6947
|
x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
|
|
6860
|
-
map(
|
|
6948
|
+
map(f, (v) => /* @__PURE__ */ jsx(TabsTrigger, { value: v.id, children: React__default.createElement(v.tab) }, `tab-add-block-${v.id}`))
|
|
6861
6949
|
] }),
|
|
6862
6950
|
/* @__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: n, position: a }) }) }) }),
|
|
6863
6951
|
b && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: n, position: a }) }),
|
|
6864
6952
|
g && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: n, position: a }) }) }) }),
|
|
6865
6953
|
x ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: n, position: a }) }) : null,
|
|
6866
|
-
map(
|
|
6954
|
+
map(f, (v) => /* @__PURE__ */ jsx(TabsContent, { value: v.id, children: React__default.createElement(v.tabContent, { close: m, parentId: n, position: a }) }, `panel-add-block-${v.id}`))
|
|
6867
6955
|
]
|
|
6868
6956
|
}
|
|
6869
6957
|
)
|
|
@@ -6982,28 +7070,45 @@ const registerChaiSaveToLibrary = (o) => {
|
|
|
6982
7070
|
" ",
|
|
6983
7071
|
o("Unlink from library")
|
|
6984
7072
|
] });
|
|
6985
|
-
}, CopyPasteBlocks = () => {
|
|
6986
|
-
const [o] = useBlocksStore(), [r] = useSelectedBlockIds(), { pasteBlocks: n } = usePasteBlocks(), [, a] =
|
|
6987
|
-
const
|
|
6988
|
-
const
|
|
7073
|
+
}, CANNOT_COPY_BLOCKS = !navigator.clipboard, CopyPasteBlocks = () => {
|
|
7074
|
+
const [o] = useBlocksStore(), [r] = useSelectedBlockIds(), { pasteBlocks: n } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), d = useSelectedBlock(), c = useCallback(() => {
|
|
7075
|
+
const p = r.map((u) => {
|
|
7076
|
+
const g = o.find((h) => h._id === u);
|
|
6989
7077
|
return {
|
|
6990
|
-
id:
|
|
6991
|
-
data:
|
|
7078
|
+
id: u,
|
|
7079
|
+
data: g
|
|
6992
7080
|
};
|
|
6993
7081
|
});
|
|
6994
|
-
|
|
6995
|
-
|
|
7082
|
+
l(p.map((u) => u.id)) ? toast.warning("Partial blocks detected. Clone partial blocks?", {
|
|
7083
|
+
cancel: {
|
|
7084
|
+
label: i("No"),
|
|
7085
|
+
onClick: () => {
|
|
7086
|
+
a(p.map((u) => u.id)), toast.dismiss();
|
|
7087
|
+
}
|
|
7088
|
+
},
|
|
7089
|
+
action: {
|
|
7090
|
+
label: i("Yes"),
|
|
7091
|
+
onClick: () => {
|
|
7092
|
+
a(
|
|
7093
|
+
p.map((u) => u.id),
|
|
7094
|
+
!0
|
|
7095
|
+
), toast.dismiss();
|
|
7096
|
+
}
|
|
7097
|
+
},
|
|
7098
|
+
position: "top-center"
|
|
7099
|
+
}) : a(p.map((u) => u.id));
|
|
7100
|
+
}, [r, o, a, l]);
|
|
6996
7101
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
6997
|
-
/* @__PURE__ */ jsxs(
|
|
7102
|
+
!CANNOT_COPY_BLOCKS && /* @__PURE__ */ jsxs(
|
|
6998
7103
|
DropdownMenuItem,
|
|
6999
7104
|
{
|
|
7000
|
-
disabled: !canDuplicateBlock(
|
|
7001
|
-
onClick:
|
|
7105
|
+
disabled: !canDuplicateBlock(d == null ? void 0 : d._type),
|
|
7106
|
+
onClick: c,
|
|
7002
7107
|
className: "flex items-center gap-x-4 text-xs",
|
|
7003
7108
|
children: [
|
|
7004
7109
|
/* @__PURE__ */ jsx(CopyIcon, {}),
|
|
7005
7110
|
" ",
|
|
7006
|
-
|
|
7111
|
+
i("Copy")
|
|
7007
7112
|
]
|
|
7008
7113
|
}
|
|
7009
7114
|
),
|
|
@@ -7017,7 +7122,7 @@ const registerChaiSaveToLibrary = (o) => {
|
|
|
7017
7122
|
children: [
|
|
7018
7123
|
/* @__PURE__ */ jsx(CardStackIcon, {}),
|
|
7019
7124
|
" ",
|
|
7020
|
-
|
|
7125
|
+
i("Paste")
|
|
7021
7126
|
]
|
|
7022
7127
|
}
|
|
7023
7128
|
)
|
|
@@ -7153,7 +7258,7 @@ const Input = ({ node: o }) => {
|
|
|
7153
7258
|
var P;
|
|
7154
7259
|
const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom), { hasPermission: c } = usePermissions();
|
|
7155
7260
|
let p = null;
|
|
7156
|
-
const u = o.children.length > 0, { highlightBlock: g, clearHighlight:
|
|
7261
|
+
const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: f, isSelected: x, willReceiveDrop: y, isDragging: b, isEditing: v, handleClick: w } = o, A = (L) => {
|
|
7157
7262
|
L.stopPropagation(), !l.includes(m) && o.toggle();
|
|
7158
7263
|
}, E = (L) => {
|
|
7159
7264
|
L.isInternal && (p = L.isOpen, L.isOpen && L.close());
|
|
@@ -7201,12 +7306,12 @@ const Input = ({ node: o }) => {
|
|
|
7201
7306
|
),
|
|
7202
7307
|
/* @__PURE__ */ jsx("br", {})
|
|
7203
7308
|
] });
|
|
7204
|
-
const I = useMemo(() => has(
|
|
7309
|
+
const I = useMemo(() => has(f, "_libBlockId") && !isEmpty(f._libBlockId) && (c(PERMISSIONS.CREATE_LIBRARY_BLOCK) || c(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [f, c]);
|
|
7205
7310
|
return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
|
|
7206
7311
|
"div",
|
|
7207
7312
|
{
|
|
7208
7313
|
onMouseEnter: () => g(m),
|
|
7209
|
-
onMouseLeave: () =>
|
|
7314
|
+
onMouseLeave: () => h(),
|
|
7210
7315
|
onClick: k,
|
|
7211
7316
|
style: r,
|
|
7212
7317
|
"data-node-id": m,
|
|
@@ -7241,7 +7346,7 @@ const Input = ({ node: o }) => {
|
|
|
7241
7346
|
className: cn(
|
|
7242
7347
|
"group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
|
|
7243
7348
|
x ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
|
|
7244
|
-
y && canAcceptChildBlock(
|
|
7349
|
+
y && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
|
|
7245
7350
|
(o == null ? void 0 : o.id) === S ? "bg-primary/10" : "",
|
|
7246
7351
|
b && "opacity-20",
|
|
7247
7352
|
l.includes(m) ? "opacity-50" : "",
|
|
@@ -7265,7 +7370,7 @@ const Input = ({ node: o }) => {
|
|
|
7265
7370
|
I && x && "text-primary/80"
|
|
7266
7371
|
),
|
|
7267
7372
|
children: [
|
|
7268
|
-
/* @__PURE__ */ jsx(TypeIcon, { type:
|
|
7373
|
+
/* @__PURE__ */ jsx(TypeIcon, { type: f == null ? void 0 : f._type }),
|
|
7269
7374
|
v ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
|
|
7270
7375
|
"div",
|
|
7271
7376
|
{
|
|
@@ -7273,7 +7378,7 @@ const Input = ({ node: o }) => {
|
|
|
7273
7378
|
onDoubleClick: (L) => {
|
|
7274
7379
|
L.stopPropagation(), o.edit(), o.deselect();
|
|
7275
7380
|
},
|
|
7276
|
-
children: /* @__PURE__ */ jsx("span", { children: (
|
|
7381
|
+
children: /* @__PURE__ */ jsx("span", { children: (f == null ? void 0 : f._name) || (f == null ? void 0 : f._type.split("/").pop()) })
|
|
7277
7382
|
}
|
|
7278
7383
|
)
|
|
7279
7384
|
]
|
|
@@ -7281,7 +7386,7 @@ const Input = ({ node: o }) => {
|
|
|
7281
7386
|
)
|
|
7282
7387
|
] }),
|
|
7283
7388
|
/* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
|
|
7284
|
-
canAddChildBlock(
|
|
7389
|
+
canAddChildBlock(f == null ? void 0 : f._type) && !l.includes(m) && c(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
7285
7390
|
/* @__PURE__ */ jsx(
|
|
7286
7391
|
TooltipTrigger,
|
|
7287
7392
|
{
|
|
@@ -7315,7 +7420,35 @@ const Input = ({ node: o }) => {
|
|
|
7315
7420
|
]
|
|
7316
7421
|
}
|
|
7317
7422
|
) });
|
|
7318
|
-
}),
|
|
7423
|
+
}), PasteAtRootContextMenu = ({ parentContext: o, setParentContext: r }) => {
|
|
7424
|
+
const { t: n } = useTranslation(), { canPaste: a, pasteBlocks: l } = usePasteBlocks();
|
|
7425
|
+
return useEffect(() => {
|
|
7426
|
+
a("root") || r(null);
|
|
7427
|
+
}, [a("root")]), !o || !a("root") ? null : /* @__PURE__ */ jsx("div", { className: "absolute inset-0", children: /* @__PURE__ */ jsxs(DropdownMenu, { open: !0, onOpenChange: () => r(null), children: [
|
|
7428
|
+
/* @__PURE__ */ jsx(DropdownMenuTrigger, { className: "hidden" }),
|
|
7429
|
+
/* @__PURE__ */ jsx(
|
|
7430
|
+
DropdownMenuContent,
|
|
7431
|
+
{
|
|
7432
|
+
className: "absolute w-28 p-1 text-xs",
|
|
7433
|
+
style: { top: o.y, left: o.x },
|
|
7434
|
+
children: /* @__PURE__ */ jsxs(
|
|
7435
|
+
DropdownMenuItem,
|
|
7436
|
+
{
|
|
7437
|
+
className: "flex items-center gap-x-4 text-xs",
|
|
7438
|
+
onClick: () => {
|
|
7439
|
+
l("root"), r(null);
|
|
7440
|
+
},
|
|
7441
|
+
children: [
|
|
7442
|
+
/* @__PURE__ */ jsx(CardStackIcon, {}),
|
|
7443
|
+
" ",
|
|
7444
|
+
n("Paste")
|
|
7445
|
+
]
|
|
7446
|
+
}
|
|
7447
|
+
)
|
|
7448
|
+
}
|
|
7449
|
+
)
|
|
7450
|
+
] }) });
|
|
7451
|
+
}, useCanMove = () => {
|
|
7319
7452
|
const [o] = useBlocksStore();
|
|
7320
7453
|
return (r, n) => {
|
|
7321
7454
|
var i;
|
|
@@ -7415,7 +7548,7 @@ const Input = ({ node: o }) => {
|
|
|
7415
7548
|
/* @__PURE__ */ jsx("div", { className: cn$1("flex h-full select-none flex-col space-y-1"), onClick: () => clearSelection(), children: /* @__PURE__ */ jsxs(
|
|
7416
7549
|
"div",
|
|
7417
7550
|
{
|
|
7418
|
-
id: "outline-view",
|
|
7551
|
+
id: "outline-view ",
|
|
7419
7552
|
className: "no-scrollbar h-full overflow-y-auto text-sm",
|
|
7420
7553
|
onKeyDown: (o) => {
|
|
7421
7554
|
treeRef.current.isEditing || handleKeyDown(o);
|
|
@@ -7486,7 +7619,8 @@ const Input = ({ node: o }) => {
|
|
|
7486
7619
|
]
|
|
7487
7620
|
}
|
|
7488
7621
|
) }),
|
|
7489
|
-
/* @__PURE__ */ jsx(SaveToLibraryModal, {})
|
|
7622
|
+
/* @__PURE__ */ jsx(SaveToLibraryModal, {}),
|
|
7623
|
+
/* @__PURE__ */ jsx(PasteAtRootContextMenu, { parentContext, setParentContext })
|
|
7490
7624
|
] });
|
|
7491
7625
|
}, BorderRadiusInput = ({ value: o, onChange: r, disabled: n }) => {
|
|
7492
7626
|
const a = debounce((l) => r(l), 200);
|
|
@@ -7543,7 +7677,7 @@ const Input = ({ node: o }) => {
|
|
|
7543
7677
|
)
|
|
7544
7678
|
] });
|
|
7545
7679
|
}, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
|
|
7546
|
-
const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: d } = usePermissions(), [c, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(),
|
|
7680
|
+
const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: d } = usePermissions(), [c, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), h = (v) => {
|
|
7547
7681
|
a(v);
|
|
7548
7682
|
}, m = () => {
|
|
7549
7683
|
const v = l.find((w) => Object.keys(w)[0] === n);
|
|
@@ -7552,7 +7686,7 @@ const Input = ({ node: o }) => {
|
|
|
7552
7686
|
w && typeof w == "object" && "fontFamily" in w && "borderRadius" in w && "colors" in w ? p(w) : console.error("Invalid preset structure:", w);
|
|
7553
7687
|
} else
|
|
7554
7688
|
console.error("Preset not found:", n);
|
|
7555
|
-
},
|
|
7689
|
+
}, f = useDebouncedCallback(
|
|
7556
7690
|
(v, w) => {
|
|
7557
7691
|
p(() => ({
|
|
7558
7692
|
...c,
|
|
@@ -7610,7 +7744,7 @@ const Input = ({ node: o }) => {
|
|
|
7610
7744
|
"select",
|
|
7611
7745
|
{
|
|
7612
7746
|
value: n,
|
|
7613
|
-
onChange: (v) =>
|
|
7747
|
+
onChange: (v) => h(v.target.value),
|
|
7614
7748
|
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",
|
|
7615
7749
|
children: [
|
|
7616
7750
|
/* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
|
|
@@ -7636,7 +7770,7 @@ const Input = ({ node: o }) => {
|
|
|
7636
7770
|
{
|
|
7637
7771
|
label: v,
|
|
7638
7772
|
value: c.fontFamily[v.replace(/font-/g, "")] || w[Object.keys(w)[0]],
|
|
7639
|
-
onChange: (A) =>
|
|
7773
|
+
onChange: (A) => f(v, A)
|
|
7640
7774
|
},
|
|
7641
7775
|
v
|
|
7642
7776
|
)) }),
|
|
@@ -8119,12 +8253,12 @@ function QuickPrompts({ onClick: o }) {
|
|
|
8119
8253
|
) }) });
|
|
8120
8254
|
}
|
|
8121
8255
|
const AIUserPrompt = ({ blockId: o }) => {
|
|
8122
|
-
const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, d] = useState(""), [c, p] = useState(!0), [u, g] = useState(),
|
|
8256
|
+
const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, d] = useState(""), [c, p] = useState(!0), [u, g] = useState(), h = useRef(null), m = useRef(null);
|
|
8123
8257
|
useEffect(() => {
|
|
8124
8258
|
var x;
|
|
8125
|
-
(x =
|
|
8259
|
+
(x = h.current) == null || x.focus();
|
|
8126
8260
|
}, []);
|
|
8127
|
-
const
|
|
8261
|
+
const f = (x) => {
|
|
8128
8262
|
const { usage: y } = x || {};
|
|
8129
8263
|
!l && y && g(y), m.current = setTimeout(() => g(void 0), 1e4), l || d("");
|
|
8130
8264
|
};
|
|
@@ -8144,14 +8278,14 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8144
8278
|
/* @__PURE__ */ jsx(
|
|
8145
8279
|
Textarea,
|
|
8146
8280
|
{
|
|
8147
|
-
ref:
|
|
8281
|
+
ref: h,
|
|
8148
8282
|
value: i,
|
|
8149
8283
|
onChange: (x) => d(x.target.value),
|
|
8150
8284
|
placeholder: r("Ask AI to edit content"),
|
|
8151
8285
|
className: "w-full",
|
|
8152
8286
|
rows: 3,
|
|
8153
8287
|
onKeyDown: (x) => {
|
|
8154
|
-
x.key === "Enter" && (x.preventDefault(), m.current && clearTimeout(m.current), g(void 0), n("content", o, i,
|
|
8288
|
+
x.key === "Enter" && (x.preventDefault(), m.current && clearTimeout(m.current), g(void 0), n("content", o, i, f));
|
|
8155
8289
|
}
|
|
8156
8290
|
}
|
|
8157
8291
|
),
|
|
@@ -8161,7 +8295,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8161
8295
|
{
|
|
8162
8296
|
disabled: i.trim().length < 5 || a,
|
|
8163
8297
|
onClick: () => {
|
|
8164
|
-
m.current && clearTimeout(m.current), g(void 0), n("content", o, i,
|
|
8298
|
+
m.current && clearTimeout(m.current), g(void 0), n("content", o, i, f);
|
|
8165
8299
|
},
|
|
8166
8300
|
variant: "default",
|
|
8167
8301
|
className: "w-fit",
|
|
@@ -8194,7 +8328,7 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8194
8328
|
QuickPrompts,
|
|
8195
8329
|
{
|
|
8196
8330
|
onClick: (x) => {
|
|
8197
|
-
m.current && clearTimeout(m.current), g(void 0), n("content", o, x,
|
|
8331
|
+
m.current && clearTimeout(m.current), g(void 0), n("content", o, x, f);
|
|
8198
8332
|
}
|
|
8199
8333
|
}
|
|
8200
8334
|
)
|
|
@@ -8204,15 +8338,15 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8204
8338
|
] }) }) : null
|
|
8205
8339
|
] });
|
|
8206
8340
|
}, AISetContext = () => {
|
|
8207
|
-
const { t: o } = useTranslation(), r = useBuilderProp("aiContext", ""), [n, a] = useState(r), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [d, c] = useState(!1), [p, u] = useState(null), [, g] = useState(!1),
|
|
8341
|
+
const { t: o } = useTranslation(), r = useBuilderProp("aiContext", ""), [n, a] = useState(r), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [d, c] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), h = useRef(null);
|
|
8208
8342
|
useEffect(() => {
|
|
8209
8343
|
r && a(r);
|
|
8210
8344
|
}, [r]);
|
|
8211
8345
|
const m = async () => {
|
|
8212
8346
|
try {
|
|
8213
|
-
c(!0), u(null), await i(n), toast.success(o("Updated AI Context")),
|
|
8214
|
-
} catch (
|
|
8215
|
-
u(
|
|
8347
|
+
c(!0), u(null), await i(n), toast.success(o("Updated AI Context")), h.current.click();
|
|
8348
|
+
} catch (f) {
|
|
8349
|
+
u(f);
|
|
8216
8350
|
} finally {
|
|
8217
8351
|
c(!1);
|
|
8218
8352
|
}
|
|
@@ -8220,25 +8354,25 @@ const AIUserPrompt = ({ blockId: o }) => {
|
|
|
8220
8354
|
return /* @__PURE__ */ jsx(
|
|
8221
8355
|
Accordion,
|
|
8222
8356
|
{
|
|
8223
|
-
onValueChange: (
|
|
8224
|
-
g(
|
|
8357
|
+
onValueChange: (f) => {
|
|
8358
|
+
g(f !== "");
|
|
8225
8359
|
},
|
|
8226
8360
|
type: "single",
|
|
8227
8361
|
collapsible: !0,
|
|
8228
8362
|
children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
|
|
8229
|
-
/* @__PURE__ */ jsx(AccordionTrigger, { ref:
|
|
8363
|
+
/* @__PURE__ */ jsx(AccordionTrigger, { ref: h, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
|
|
8230
8364
|
/* @__PURE__ */ jsxs(AccordionContent, { children: [
|
|
8231
8365
|
/* @__PURE__ */ jsx(
|
|
8232
8366
|
Textarea,
|
|
8233
8367
|
{
|
|
8234
8368
|
ref: l,
|
|
8235
8369
|
value: n,
|
|
8236
|
-
onChange: (
|
|
8370
|
+
onChange: (f) => a(f.target.value),
|
|
8237
8371
|
placeholder: o("Tell about this page eg this page is about"),
|
|
8238
8372
|
className: "mt-1 w-full",
|
|
8239
8373
|
rows: 10,
|
|
8240
|
-
onKeyDown: (
|
|
8241
|
-
|
|
8374
|
+
onKeyDown: (f) => {
|
|
8375
|
+
f.key === "Enter" && (f.preventDefault(), m());
|
|
8242
8376
|
}
|
|
8243
8377
|
}
|
|
8244
8378
|
),
|
|
@@ -8340,7 +8474,7 @@ function AIChatPanel() {
|
|
|
8340
8474
|
}, [o]), useEffect(() => {
|
|
8341
8475
|
g.current && (g.current.style.height = "auto", g.current.style.height = `${Math.min(g.current.scrollHeight, 120)}px`);
|
|
8342
8476
|
}, [n]);
|
|
8343
|
-
const
|
|
8477
|
+
const h = async () => {
|
|
8344
8478
|
if (!n.trim() && !d) return;
|
|
8345
8479
|
const b = {
|
|
8346
8480
|
id: Date.now().toString(),
|
|
@@ -8358,8 +8492,8 @@ function AIChatPanel() {
|
|
|
8358
8492
|
r((w) => [...w, v]), i(!1), c(null);
|
|
8359
8493
|
}, 1500);
|
|
8360
8494
|
}, m = (b) => {
|
|
8361
|
-
b.key === "Enter" && !b.shiftKey && (b.preventDefault(),
|
|
8362
|
-
},
|
|
8495
|
+
b.key === "Enter" && !b.shiftKey && (b.preventDefault(), h());
|
|
8496
|
+
}, f = (b) => {
|
|
8363
8497
|
var w;
|
|
8364
8498
|
const v = (w = b.target.files) == null ? void 0 : w[0];
|
|
8365
8499
|
if (v) {
|
|
@@ -8436,7 +8570,7 @@ function AIChatPanel() {
|
|
|
8436
8570
|
className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
|
|
8437
8571
|
}
|
|
8438
8572
|
),
|
|
8439
|
-
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange:
|
|
8573
|
+
/* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: f, accept: "image/*", className: "hidden" }),
|
|
8440
8574
|
/* @__PURE__ */ jsx(
|
|
8441
8575
|
Button,
|
|
8442
8576
|
{
|
|
@@ -8453,7 +8587,7 @@ function AIChatPanel() {
|
|
|
8453
8587
|
{
|
|
8454
8588
|
size: "sm",
|
|
8455
8589
|
className: "h-10 px-3",
|
|
8456
|
-
onClick:
|
|
8590
|
+
onClick: h,
|
|
8457
8591
|
disabled: l || !n.trim() && !d,
|
|
8458
8592
|
children: [
|
|
8459
8593
|
/* @__PURE__ */ jsx(Send, { className: "mr-1 h-4 w-4" }),
|
|
@@ -8568,7 +8702,7 @@ const AddBlocksDialog = () => {
|
|
|
8568
8702
|
preloadedAttributes: r = [],
|
|
8569
8703
|
onAttributesChange: n
|
|
8570
8704
|
}) {
|
|
8571
|
-
const [a, l] = useState([]), [i, d] = useState(""), [c, p] = useState(""), [u, g] = useState(null), [
|
|
8705
|
+
const [a, l] = useState([]), [i, d] = useState(""), [c, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), f = useRef(null), x = useRef(null), y = usePageExternalData();
|
|
8572
8706
|
useEffect(() => {
|
|
8573
8707
|
l(r);
|
|
8574
8708
|
}, [r]);
|
|
@@ -8637,7 +8771,7 @@ const AddBlocksDialog = () => {
|
|
|
8637
8771
|
autoCorrect: "off",
|
|
8638
8772
|
spellCheck: "false",
|
|
8639
8773
|
id: "attrKey",
|
|
8640
|
-
ref:
|
|
8774
|
+
ref: f,
|
|
8641
8775
|
value: i,
|
|
8642
8776
|
onChange: (S) => d(S.target.value),
|
|
8643
8777
|
placeholder: "Enter Key",
|
|
@@ -8669,7 +8803,7 @@ const AddBlocksDialog = () => {
|
|
|
8669
8803
|
] })
|
|
8670
8804
|
] }),
|
|
8671
8805
|
/* @__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" }) }),
|
|
8672
|
-
|
|
8806
|
+
h && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: h })
|
|
8673
8807
|
]
|
|
8674
8808
|
}
|
|
8675
8809
|
),
|
|
@@ -8802,9 +8936,9 @@ const RootLayout = () => {
|
|
|
8802
8936
|
});
|
|
8803
8937
|
const p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), g = (S) => {
|
|
8804
8938
|
S.preventDefault();
|
|
8805
|
-
},
|
|
8939
|
+
}, h = (S) => {
|
|
8806
8940
|
n(r === S ? null : S);
|
|
8807
|
-
}, m = useSidebarMenuItems(), { t:
|
|
8941
|
+
}, m = useSidebarMenuItems(), { t: f } = useTranslation(), x = useMemo(() => [...m, ...p], [m, p]), y = useBuilderProp("htmlDir", "ltr"), b = find(x, { id: r }) ?? first(x), v = get(b, "width", DEFAULT_PANEL_WIDTH);
|
|
8808
8942
|
useEffect(() => {
|
|
8809
8943
|
if (r !== null) {
|
|
8810
8944
|
const S = find(x, { id: r });
|
|
@@ -8825,9 +8959,9 @@ const RootLayout = () => {
|
|
|
8825
8959
|
}, [r, x]);
|
|
8826
8960
|
const _ = useCallback(
|
|
8827
8961
|
(S) => {
|
|
8828
|
-
|
|
8962
|
+
h(S);
|
|
8829
8963
|
},
|
|
8830
|
-
[
|
|
8964
|
+
[h]
|
|
8831
8965
|
);
|
|
8832
8966
|
return /* @__PURE__ */ jsx("div", { dir: y, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
|
|
8833
8967
|
/* @__PURE__ */ jsxs(
|
|
@@ -8846,7 +8980,7 @@ const RootLayout = () => {
|
|
|
8846
8980
|
isActive: r === S.id,
|
|
8847
8981
|
show: () => _(S.id)
|
|
8848
8982
|
}) }),
|
|
8849
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
8983
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(S.label) }) })
|
|
8850
8984
|
] }, "button-top-" + B)) }),
|
|
8851
8985
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
|
|
8852
8986
|
/* @__PURE__ */ jsx("div", { className: "flex flex-col", children: u == null ? void 0 : u.map((S, B) => /* @__PURE__ */ jsxs(Tooltip, { children: [
|
|
@@ -8856,7 +8990,7 @@ const RootLayout = () => {
|
|
|
8856
8990
|
isActive: r === S.id,
|
|
8857
8991
|
show: () => _(S.id)
|
|
8858
8992
|
}) }),
|
|
8859
|
-
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children:
|
|
8993
|
+
/* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(S.label) }) })
|
|
8860
8994
|
] }, "button-bottom-" + B)) })
|
|
8861
8995
|
] }),
|
|
8862
8996
|
/* @__PURE__ */ jsx(
|
|
@@ -8872,7 +9006,7 @@ const RootLayout = () => {
|
|
|
8872
9006
|
"div",
|
|
8873
9007
|
{
|
|
8874
9008
|
className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(b, "isInternal", !1) ? "" : "w-64"}`,
|
|
8875
|
-
children: /* @__PURE__ */ jsx("span", { children:
|
|
9009
|
+
children: /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
|
|
8876
9010
|
}
|
|
8877
9011
|
),
|
|
8878
9012
|
/* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {}) }) })
|
|
@@ -8895,11 +9029,11 @@ const RootLayout = () => {
|
|
|
8895
9029
|
/* @__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: d === "ai" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
|
|
8896
9030
|
/* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
|
|
8897
9031
|
" ",
|
|
8898
|
-
|
|
9032
|
+
f("AI Assistant")
|
|
8899
9033
|
] }) }) : d === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
|
|
8900
9034
|
/* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
|
|
8901
9035
|
/* @__PURE__ */ jsx(Paintbrush, { className: "h-4 w-4 rtl:ml-2" }),
|
|
8902
|
-
|
|
9036
|
+
f("Theme Settings")
|
|
8903
9037
|
] }),
|
|
8904
9038
|
/* @__PURE__ */ jsx(
|
|
8905
9039
|
Button,
|
|
@@ -8919,7 +9053,7 @@ const RootLayout = () => {
|
|
|
8919
9053
|
r !== null && get(b, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => A(), children: /* @__PURE__ */ jsxs(SheetContent, { side: "left", className: "p-0 sm:max-w-full", style: { width: `${v}px` }, children: [
|
|
8920
9054
|
/* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border p-4 pb-2", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
|
|
8921
9055
|
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
|
|
8922
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9056
|
+
/* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
|
|
8923
9057
|
] }) }),
|
|
8924
9058
|
/* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
|
|
8925
9059
|
close: E
|
|
@@ -8929,7 +9063,7 @@ const RootLayout = () => {
|
|
|
8929
9063
|
r !== null && get(b, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => A(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "p-0", style: { maxWidth: `${v}px` }, children: [
|
|
8930
9064
|
/* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border p-4 pb-2", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
|
|
8931
9065
|
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
|
|
8932
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9066
|
+
/* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
|
|
8933
9067
|
] }) }),
|
|
8934
9068
|
/* @__PURE__ */ jsx("div", { className: "max-h-[70vh] overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
|
|
8935
9069
|
close: E
|
|
@@ -8955,7 +9089,7 @@ const RootLayout = () => {
|
|
|
8955
9089
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b border-border p-4 py-2", children: [
|
|
8956
9090
|
/* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-lg font-bold", children: [
|
|
8957
9091
|
/* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
|
|
8958
|
-
/* @__PURE__ */ jsx("span", { children:
|
|
9092
|
+
/* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
|
|
8959
9093
|
] }),
|
|
8960
9094
|
/* @__PURE__ */ jsx(Button, { onClick: () => A(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
|
|
8961
9095
|
] }),
|
|
@@ -9062,17 +9196,17 @@ const FEATURE_TOGGLES = {
|
|
|
9062
9196
|
for (const i of r.p)
|
|
9063
9197
|
l.add(i);
|
|
9064
9198
|
return l;
|
|
9065
|
-
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), d = {}, c = (m, ...
|
|
9199
|
+
}, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), d = {}, c = (m, ...f) => m.read(...f), p = (m, ...f) => m.write(...f), u = (m, f) => {
|
|
9066
9200
|
var x;
|
|
9067
|
-
return (x = m.unstable_onInit) == null ? void 0 : x.call(m,
|
|
9068
|
-
}, g = (m,
|
|
9201
|
+
return (x = m.unstable_onInit) == null ? void 0 : x.call(m, f);
|
|
9202
|
+
}, g = (m, f) => {
|
|
9069
9203
|
var x;
|
|
9070
|
-
return (x = m.onMount) == null ? void 0 : x.call(m,
|
|
9071
|
-
}, ...
|
|
9072
|
-
const m =
|
|
9204
|
+
return (x = m.onMount) == null ? void 0 : x.call(m, f);
|
|
9205
|
+
}, ...h) => {
|
|
9206
|
+
const m = h[0] || ((B) => {
|
|
9073
9207
|
let N = o.get(B);
|
|
9074
9208
|
return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(B, N), u == null || u(B, S)), N;
|
|
9075
|
-
}),
|
|
9209
|
+
}), f = h[1] || (() => {
|
|
9076
9210
|
let B, N;
|
|
9077
9211
|
const C = (k) => {
|
|
9078
9212
|
try {
|
|
@@ -9091,7 +9225,7 @@ const FEATURE_TOGGLES = {
|
|
|
9091
9225
|
} while (a.size || i.size || l.size);
|
|
9092
9226
|
if (B)
|
|
9093
9227
|
throw N;
|
|
9094
|
-
}), x =
|
|
9228
|
+
}), x = h[2] || (() => {
|
|
9095
9229
|
const B = [], N = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
|
|
9096
9230
|
for (; k.length; ) {
|
|
9097
9231
|
const j = k[k.length - 1], T = m(j);
|
|
@@ -9117,7 +9251,7 @@ const FEATURE_TOGGLES = {
|
|
|
9117
9251
|
}
|
|
9118
9252
|
P && (y(T), w(T)), n.delete(T);
|
|
9119
9253
|
}
|
|
9120
|
-
}), y =
|
|
9254
|
+
}), y = h[3] || ((B) => {
|
|
9121
9255
|
var N, C;
|
|
9122
9256
|
const k = m(B);
|
|
9123
9257
|
if (isAtomStateInitialized(k) && (r.has(B) && n.get(B) !== k.n || Array.from(k.d).every(
|
|
@@ -9131,7 +9265,7 @@ const FEATURE_TOGGLES = {
|
|
|
9131
9265
|
k.d.clear();
|
|
9132
9266
|
let j = !0;
|
|
9133
9267
|
const T = () => {
|
|
9134
|
-
r.has(B) && (w(B), x(),
|
|
9268
|
+
r.has(B) && (w(B), x(), f());
|
|
9135
9269
|
}, I = (R) => {
|
|
9136
9270
|
var D;
|
|
9137
9271
|
if (isSelfAtom(B, R)) {
|
|
@@ -9161,7 +9295,7 @@ const FEATURE_TOGGLES = {
|
|
|
9161
9295
|
try {
|
|
9162
9296
|
return v(B, ...R);
|
|
9163
9297
|
} finally {
|
|
9164
|
-
x(),
|
|
9298
|
+
x(), f();
|
|
9165
9299
|
}
|
|
9166
9300
|
}), L;
|
|
9167
9301
|
}
|
|
@@ -9177,7 +9311,7 @@ const FEATURE_TOGGLES = {
|
|
|
9177
9311
|
} finally {
|
|
9178
9312
|
j = !1, $ !== k.n && n.get(B) === $ && (n.set(B, k.n), a.add(B), (C = d.c) == null || C.call(d, B));
|
|
9179
9313
|
}
|
|
9180
|
-
}), b =
|
|
9314
|
+
}), b = h[4] || ((B) => {
|
|
9181
9315
|
const N = [B];
|
|
9182
9316
|
for (; N.length; ) {
|
|
9183
9317
|
const C = N.pop(), k = m(C);
|
|
@@ -9186,7 +9320,7 @@ const FEATURE_TOGGLES = {
|
|
|
9186
9320
|
n.set(j, T.n), N.push(j);
|
|
9187
9321
|
}
|
|
9188
9322
|
}
|
|
9189
|
-
}), v =
|
|
9323
|
+
}), v = h[5] || ((B, ...N) => {
|
|
9190
9324
|
let C = !0;
|
|
9191
9325
|
const k = (T) => returnAtomValue(y(T)), j = (T, ...I) => {
|
|
9192
9326
|
var P;
|
|
@@ -9201,7 +9335,7 @@ const FEATURE_TOGGLES = {
|
|
|
9201
9335
|
} else
|
|
9202
9336
|
return v(T, ...I);
|
|
9203
9337
|
} finally {
|
|
9204
|
-
C || (x(),
|
|
9338
|
+
C || (x(), f());
|
|
9205
9339
|
}
|
|
9206
9340
|
};
|
|
9207
9341
|
try {
|
|
@@ -9209,7 +9343,7 @@ const FEATURE_TOGGLES = {
|
|
|
9209
9343
|
} finally {
|
|
9210
9344
|
C = !1;
|
|
9211
9345
|
}
|
|
9212
|
-
}), w =
|
|
9346
|
+
}), w = h[6] || ((B) => {
|
|
9213
9347
|
var N;
|
|
9214
9348
|
const C = m(B), k = r.get(B);
|
|
9215
9349
|
if (k && !isPendingPromise(C.v)) {
|
|
@@ -9225,7 +9359,7 @@ const FEATURE_TOGGLES = {
|
|
|
9225
9359
|
T == null || T.t.delete(B);
|
|
9226
9360
|
}
|
|
9227
9361
|
}
|
|
9228
|
-
}), A =
|
|
9362
|
+
}), A = h[7] || ((B) => {
|
|
9229
9363
|
var N;
|
|
9230
9364
|
const C = m(B);
|
|
9231
9365
|
let k = r.get(B);
|
|
@@ -9244,7 +9378,7 @@ const FEATURE_TOGGLES = {
|
|
|
9244
9378
|
try {
|
|
9245
9379
|
return v(B, ...P);
|
|
9246
9380
|
} finally {
|
|
9247
|
-
T || (x(),
|
|
9381
|
+
T || (x(), f());
|
|
9248
9382
|
}
|
|
9249
9383
|
};
|
|
9250
9384
|
try {
|
|
@@ -9265,7 +9399,7 @@ const FEATURE_TOGGLES = {
|
|
|
9265
9399
|
}
|
|
9266
9400
|
}
|
|
9267
9401
|
return k;
|
|
9268
|
-
}), E =
|
|
9402
|
+
}), E = h[8] || ((B) => {
|
|
9269
9403
|
var N;
|
|
9270
9404
|
const C = m(B);
|
|
9271
9405
|
let k = r.get(B);
|
|
@@ -9297,7 +9431,7 @@ const FEATURE_TOGGLES = {
|
|
|
9297
9431
|
g,
|
|
9298
9432
|
// building-block functions
|
|
9299
9433
|
m,
|
|
9300
|
-
|
|
9434
|
+
f,
|
|
9301
9435
|
x,
|
|
9302
9436
|
y,
|
|
9303
9437
|
b,
|
|
@@ -9311,13 +9445,13 @@ const FEATURE_TOGGLES = {
|
|
|
9311
9445
|
try {
|
|
9312
9446
|
return v(B, ...N);
|
|
9313
9447
|
} finally {
|
|
9314
|
-
x(),
|
|
9448
|
+
x(), f();
|
|
9315
9449
|
}
|
|
9316
9450
|
},
|
|
9317
9451
|
sub: (B, N) => {
|
|
9318
9452
|
const k = A(B).l;
|
|
9319
|
-
return k.add(N),
|
|
9320
|
-
k.delete(N), E(B),
|
|
9453
|
+
return k.add(N), f(), () => {
|
|
9454
|
+
k.delete(N), E(B), f();
|
|
9321
9455
|
};
|
|
9322
9456
|
}
|
|
9323
9457
|
};
|
|
@@ -9483,7 +9617,7 @@ export {
|
|
|
9483
9617
|
useCanvasDisplayWidth,
|
|
9484
9618
|
useCanvasZoom,
|
|
9485
9619
|
useCodeEditor,
|
|
9486
|
-
useCopyBlockIds,
|
|
9620
|
+
useCopyBlocks as useCopyBlockIds,
|
|
9487
9621
|
useCopyToClipboard,
|
|
9488
9622
|
useCurrentPage,
|
|
9489
9623
|
useCutBlockIds,
|
|
@@ -9494,7 +9628,7 @@ export {
|
|
|
9494
9628
|
useLanguages,
|
|
9495
9629
|
useLibraryBlocks,
|
|
9496
9630
|
useMediaManagerComponent,
|
|
9497
|
-
usePartailBlocksStore,
|
|
9631
|
+
usePartialBlocksStore as usePartailBlocksStore,
|
|
9498
9632
|
usePartialBlocksList,
|
|
9499
9633
|
usePasteBlocks,
|
|
9500
9634
|
usePermissions,
|